root/src/casl2rev.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. main

   1 #include "package.h"
   2 #include "disassemble.h"
   3 #include "load.h"
   4 
   5 /**
   6  * @brief casl2revコマンドのオプション
   7  */
   8 static struct option longopts[] = {
   9     {"version", no_argument, NULL, 'v' },
  10     {"help", no_argument, NULL, 'h'},
  11     {0, 0, 0, 0},
  12 };
  13 
  14 /**
  15  * @brief casl2revコマンドのメイン
  16  *
  17  * @return 正常終了時は0、異常終了時は1
  18  *
  19  * @param argc コマンドライン引数の数
  20  * @param *argv[] コマンドライン引数の配列
  21  */
  22 int main(int argc, char *argv[])
  23 {
  24     int opt = 0;
  25     int stat = 0;
  26     const char *version = PACKAGE_VERSION;
  27     const char *cmdversion = "disassemble of YACASL2 version %s\n";
  28     const char *usage = "Usage: %s [-vh] FILE\n";
  29 
  30     /* エラーの定義 */
  31     cerr_init();
  32     addcerrlist_load();
  33 
  34     /* オプションの処理 */
  35     while((opt = getopt_long(argc, argv, "vh", longopts, NULL)) != -1) {
  36         switch(opt) {
  37         case 'v':
  38             fprintf(stdout, cmdversion, version);
  39             goto casl2revfin;
  40         case 'h':
  41             fprintf(stdout, usage, argv[0]);
  42             goto casl2revfin;
  43         case '?':
  44             fprintf(stderr, usage, argv[0]);
  45             setcerr(212, "");    /* invalid option */
  46             goto casl2revfin;
  47         }
  48     }
  49     if(argv[optind] == NULL) {
  50         setcerr(211, "");    /* object file not specified */
  51         fprintf(stderr, "disassemble error - %d: %s\n", cerr->num, cerr->msg);
  52         goto casl2revfin;
  53     }
  54     disassemble_file(argv[optind]);                /* プログラム実行 */
  55 casl2revfin:
  56     if(cerr->num > 0) {
  57         stat = 1;
  58     }
  59     freecerr();                 /* エラーの解放 */
  60     return stat;
  61 }

/* [<][>][^][v][top][bottom][index][help] */