root/src/casl2rev.c

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

DEFINITIONS

This source file includes following definitions.
  1. main

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

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