2 * Copyright (C) 1994, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.5 1994-09-06 13:05:14 adam
8 * Further development of insertion. Some special cases are
9 * not properly handled yet! assert(0) are put here. The
10 * binary search in each page definitely reduce usr CPU.
12 * Revision 1.4 1994/09/01 17:49:37 adam
13 * Removed stupid line. Work on insertion in dictionary. Not finished yet.
15 * Revision 1.3 1994/09/01 17:44:06 adam
16 * depend include change.
18 * Revision 1.2 1994/08/18 12:40:54 adam
19 * Some development of dictionary. Not finished at all!
21 * Revision 1.1 1994/08/16 16:26:47 adam
36 int main (int argc, char **argv)
38 const char *name = NULL;
39 const char *inputfile = NULL;
40 const char *base = NULL;
45 int no_of_insertions = 0;
46 int no_of_new = 0, no_of_same = 0, no_of_change = 0;
52 fprintf (stderr, "usage:\n"
53 " %s [-s n] [-v n] [-i f] [-w] [-c n] base file\n",
57 while ((ret = options ("s:v:i:wc:", argv, argc, &arg)) != -2)
67 log (LOG_FATAL, "too many files specified\n");
90 log_init (atoi(arg), prog, NULL);
94 log (LOG_FATAL, "unknown option");
100 log (LOG_FATAL, "no base and/or dictionary specified");
103 common_resource = res_open (base);
104 if (!common_resource)
106 log (LOG_FATAL, "cannot open resource `%s'", base);
109 dict = dict_open (name, cache, rw);
112 log (LOG_FATAL, "dict_open fail of `%s'", name);
121 memset (infobytes, 0, 120);
123 if (!(ipf = fopen(inputfile, "r")))
125 log (LOG_FATAL|LOG_ERRNO, "cannot open %s", inputfile);
129 while (fgets (ipf_buf, 255, ipf))
131 char *ipf_ptr = ipf_buf;
132 sprintf (infobytes, "%d", line);
133 for (;*ipf_ptr && *ipf_ptr != '\n';ipf_ptr++)
135 if (isalpha(*ipf_ptr) || *ipf_ptr == '_')
138 while (ipf_ptr[i] && (isalnum(ipf_ptr[i]) ||
144 switch(dict_insert (dict, ipf_ptr, infosize, infobytes))
157 printf ("%s\n", ipf_ptr);
167 log (LOG_LOG, "Insertions.... %d", no_of_insertions);
168 log (LOG_LOG, "No of new..... %d", no_of_new);
169 log (LOG_LOG, "No of change.. %d", no_of_change);
170 log (LOG_LOG, "No of same.... %d", no_of_same);
172 res_close (common_resource);