The main function. 
   42                              {
   43   int      i;          
   44   int      arg_count;  
   45   unsigned codept;
   46   unsigned max_codept;
   48   int      initial, medial, final;         
   49   unsigned char  syllable[32];        
   50 
   51   FILE *infp  = stdin;   
   52   FILE *outfp = stdout;  
   53 
   54   
   56 
   57   
   59 
   60   
   62 
   63   
   65                         unsigned char hangul_base[][32],
   66                         unsigned char *syllable);
   67 
   68 
   69   
   70
   71
   72   arg_count = 1;
   73 
   74   while (arg_count < argc) {
   75      
   76      if (strncmp (argv [arg_count], "-i", 2) == 0) {
   77         arg_count++;
   78         if (arg_count < argc) {
   79            infp = fopen (argv [arg_count], "r");
   80            if (infp == NULL) {
   81               fprintf (stderr, "\n*** ERROR: Cannot open %s for input.\n\n",
   82                        argv [arg_count]);
   83               exit (EXIT_FAILURE);
   84            }
   85         }
   86      }
   87      
   88      else if (strncmp (argv [arg_count], "-o", 2) == 0) {
   89         arg_count++;
   90         if (arg_count < argc) {
   91            outfp = fopen (argv [arg_count], "w");
   92            if (outfp == NULL) {
   93               fprintf (stderr, "\n*** ERROR: Cannot open %s for output.\n\n",
   94                        argv [arg_count]);
   95               exit (EXIT_FAILURE);
   96            }
   97         }
   98      }
   99      
  100      else if (strncmp (argv [arg_count], "-h",     2) == 0 ||
  101               strncmp (argv [arg_count], "--help", 6) == 0) {
  103         exit (EXIT_SUCCESS);
  104      }
  105 
  106      arg_count++;
  107   }
  108 
  109 
  110   
  111
  112
  113
  114   for (codept = 0; codept < 
MAX_GLYPHS; codept++) {
 
  115      for (i = 0; i < 32; i++) hangul_base[codept][i] = 0;
  116   }
  117 
  118   
  119
  120
  121
  122
  123
  125   if (max_codept > 0x8FF) {
  126      fprintf (stderr, "\nWARNING: Hangul glyph range exceeds PUA space.\n\n");
  127   }
  128 
  129   
  130
  131
  132
  133
  134   for (codept = 0xAC00; codept < 0xAC00 + 19 * 21 * 28; codept++) {
  136 
  138 
  139      fprintf (outfp, "%04X:", codept);
  140 
  141      for (i = 0; i < 32; i++) {
  142         fprintf (outfp, "%02X", syllable[i]);
  143      }
  144      fputc ('\n', outfp);
  145   }
  146 
  147   exit (EXIT_SUCCESS);
  148}
unsigned hangul_read_base8(FILE *infp, unsigned char base[][32])
Read hangul-base.hex file into a unsigned char array.
void hangul_decompose(unsigned codept, int *initial, int *medial, int *final)
Decompose a Hangul Syllables code point into three letters.
void hangul_syllable(int choseong, int jungseong, int jongseong, unsigned char hangul_base[][32], unsigned char *syllable)
Given letters in a Hangul syllable, return a glyph.
#define MAX_GLYPHS
An OpenType font has at most 65536 glyphs.
void print_help()
Print a help message.