main.c
author viric@mandarina
Sat, 11 Aug 2007 16:12:27 +0200
changeset 4 b2dfe3374454
parent 0 7f37716d4f1e
child 5 c87681fff7d3
permissions -rw-r--r--
Fixed filtered %, and msg on sort.

#include <stdio.h>

#include "dictre.h"

extern int nwords;
extern int ndefs;

int main(int argn, char **argv)
{
    char tmpname[500];
    FILE *i, *d;

    if (argn < 4)
    {
        fprintf(stderr, "usage: %s <dict_basename> "
                "<dict_basename_out> <filter>\n",
                argv[0]);
        return 1;
    }
    strcpy(tmpname, argv[1]);
    strcat(tmpname, ".index");
    i = fopen(tmpname, "r");
    if(i == NULL)
    {
        fprintf(stderr, "File: %s ", tmpname);
        perror("- cannot open file.");
        exit(-1);
    }

    strcpy(tmpname, argv[1]);
    strcat(tmpname, ".dict");
    d = fopen(tmpname, "r");
    if(d == NULL)
    {
        fprintf(stderr, "File: %s ", tmpname);
        perror("- cannot open file.");
        exit(-1);
    }

    load_init();

    load_dictionary(i, d);

    fclose(i);
    fclose(d);

    sort_words();

    if (0)
        print_words();

    filter_all(argv[3]);

    write_dictionary(argv[2]);

    return 0;
}