Parse command line arguments. 
  163                                                           {
  164   int arg_count;  
  165 
  166   void get_hex_range (
char *instring, 
unsigned *start, 
unsigned *end);
 
  167 
  168   int strncmp (const char *s1, const char *s2, size_t n);
  169 
  170 
  171   arg_count = 1;
  172 
  173   while (arg_count < argc) {
  174      
  175      if (strncmp (argv [arg_count], "-all", 4) == 0) {
  176         params->starting_codept = 0x0001;
  183      }
  184      
  185      else if (strncmp (argv [arg_count], "-c", 2) == 0) {
  186         arg_count++;
  187         if (arg_count < argc) {
  188            sscanf (argv [arg_count], "%X", ¶ms->starting_codept);
  189         }
  190      }
  191      
  192      else if (strncmp (argv [arg_count], "-j1", 3) == 0) {
  193         arg_count++;
  194         if (arg_count < argc) {
  196                           ¶ms->cho_start, ¶ms->cho_end);
  197            
  198
  199
  202            }
  206            }
  207            
  208
  209
  210
  213            }
  217            }
  218         }
  219      }
  220      
  221      else if (strncmp (argv [arg_count], "-j2", 3) == 0) {
  222         arg_count++;
  223         if (arg_count < argc) {
  225                           ¶ms->jung_start, ¶ms->jung_end);
  226            
  227
  228
  231            }
  235            }
  236            
  237
  238
  239
  242            }
  246            }
  247         }
  248      }
  249      
  250      else if (strncmp (argv [arg_count], "-j3", 3) == 0) {
  251         arg_count++;
  252         if (arg_count < argc) {
  254                           ¶ms->jong_start, ¶ms->jong_end);
  255            
  256
  257
  260            }
  264            }
  265            
  266
  267
  268
  271            }
  275            }
  276         }
  277      }
  278      
  279      else if (strncmp (argv [arg_count], "-i", 2) == 0) {
  280         arg_count++;
  281         if (arg_count < argc) {
  282            params->infp = fopen (argv [arg_count], "r");
  283            if (params->infp == NULL) {
  284               fprintf (stderr, "\n*** ERROR: Cannot open %s for input.\n\n",
  285                        argv [arg_count]);
  286               exit (EXIT_FAILURE);
  287            }
  288         }
  289      }
  290      
  291      else if (strncmp (argv [arg_count], "-o", 2) == 0) {
  292         arg_count++;
  293         if (arg_count < argc) {
  294            params->outfp = fopen (argv [arg_count], "w");
  295            if (params->outfp == NULL) {
  296               fprintf (stderr, "\n*** ERROR: Cannot open %s for output.\n\n",
  297                        argv [arg_count]);
  298               exit (EXIT_FAILURE);
  299            }
  300         }
  301      }
  302      
  303      else if (strncmp (argv [arg_count], "-h",     2) == 0 ||
  304               strncmp (argv [arg_count], "--help", 6) == 0) {
  305         printf ("\nunigen-hangul [options]\n\n");
  306         printf ("     Generates Hangul syllables from an input Unifont .hex file encoded\n");
  307         printf ("     in Johab 6/3/1 format.  By default, the output is the Unicode Hangul\n");
  308         printf ("     Syllables range, U+AC00..U+D7A3.  Options allow the user to specify\n");
  309         printf ("     a starting code point for the output Unifont .hex file, and ranges\n");
  310         printf ("     in hexadecimal of the starting and ending Hangul Jamo code points:\n\n");
  311 
  312         printf ("          * 1100-115E Initial consonants (choseong)\n");
  313         printf ("          * 1161-11A7 Medial vowels (jungseong)\n");
  314         printf ("          * 11A8-11FF Final consonants (jongseong).\n\n");
  315 
  316         printf ("     A single code point or 0 to omit can be specified instead of a range.\n\n");
  317 
  318         printf ("   Option    Parameters    Function\n");
  319         printf ("   ------    ----------    --------\n");
  320         printf ("   -h, --help              Print this message and exit.\n\n");
  321         printf ("   -all                    Generate all Hangul syllables, using all modern and\n");
  322         printf ("                           ancient Hangul in the Unicode range U+1100..U+11FF,\n");
  323         printf ("                           U+A960..U+A97C, and U+D7B0..U+D7FB.\n");
  324         printf ("                           WARNING: this will generate over 1,600,000 syllables\n");
  325         printf ("                           in a 115 megabyte Unifont .hex format file.  The\n");
  326         printf ("                           default is to only output modern Hangul syllables.\n\n");
  327         printf ("   -c        code_point    Starting code point in hexadecimal for output file.\n\n");
  328         printf ("   -j1       start-end     Choseong (jamo 1) start-end range in hexadecimal.\n\n");
  329         printf ("   -j2       start-end     Jungseong (jamo 2) start-end range in hexadecimal.\n\n");
  330         printf ("   -j3       start-end     Jongseong (jamo 3) start-end range in hexadecimal.\n\n");
  331         printf ("   -i        input_file    Unifont hangul-base.hex formatted input file.\n\n");
  332         printf ("   -o        output_file   Unifont .hex format output file.\n\n");
  333         printf ("      Example:\n\n");
  334         printf ("         unigen-hangul -c 1 -j3 11AB-11AB -i hangul-base.hex -o nieun-only.hex\n\n");
  335         printf ("      Generates Hangul syllables using all modern choseong and jungseong,\n");
  336         printf ("      and only the jongseong nieun (Unicode code point U+11AB).  The output\n");
  337         printf ("      Unifont .hex file will contain code points starting at 1.  Instead of\n");
  338         printf ("      specifying \"-j3 11AB-11AB\", simply using \"-j3 11AB\" will also suffice.\n\n");
  339 
  340         exit (EXIT_SUCCESS);
  341      }
  342 
  343      arg_count++;
  344   }
  345 
  346   return;
  347}
#define CHO_UNICODE_START
Modern Hangul choseong start.
#define JONG_EXTB_UNICODE_END
Hangul Extended-B jongseong end.
#define JONG_UNICODE_START
Modern Hangul jongseong start.
#define CHO_EXTA_UNICODE_END
Hangul Extended-A choseong end.
#define JUNG_UNICODE_START
Modern Hangul jungseong start.
#define JUNG_EXTB_UNICODE_END
Hangul Extended-B jungseong end.
void get_hex_range(char *instring, unsigned *start, unsigned *end)
Scan a hexadecimal range from a character string.