main.c
changeset 0 7f37716d4f1e
child 5 c87681fff7d3
equal deleted inserted replaced
-1:000000000000 0:7f37716d4f1e
       
     1 #include <stdio.h>
       
     2 
       
     3 #include "dictre.h"
       
     4 
       
     5 extern int nwords;
       
     6 extern int ndefs;
       
     7 
       
     8 int main(int argn, char **argv)
       
     9 {
       
    10     char tmpname[500];
       
    11     FILE *i, *d;
       
    12 
       
    13     if (argn < 4)
       
    14     {
       
    15         fprintf(stderr, "usage: %s <dict_basename> "
       
    16                 "<dict_basename_out> <filter>\n",
       
    17                 argv[0]);
       
    18         return 1;
       
    19     }
       
    20     strcpy(tmpname, argv[1]);
       
    21     strcat(tmpname, ".index");
       
    22     i = fopen(tmpname, "r");
       
    23     if(i == NULL)
       
    24     {
       
    25         fprintf(stderr, "File: %s ", tmpname);
       
    26         perror("- cannot open file.");
       
    27         exit(-1);
       
    28     }
       
    29 
       
    30     strcpy(tmpname, argv[1]);
       
    31     strcat(tmpname, ".dict");
       
    32     d = fopen(tmpname, "r");
       
    33     if(d == NULL)
       
    34     {
       
    35         fprintf(stderr, "File: %s ", tmpname);
       
    36         perror("- cannot open file.");
       
    37         exit(-1);
       
    38     }
       
    39 
       
    40     load_init();
       
    41 
       
    42     load_dictionary(i, d);
       
    43 
       
    44     fclose(i);
       
    45     fclose(d);
       
    46 
       
    47     sort_words();
       
    48 
       
    49     if (0)
       
    50         print_words();
       
    51 
       
    52     filter_all(argv[3]);
       
    53 
       
    54     write_dictionary(argv[2]);
       
    55 
       
    56     return 0;
       
    57 }