2 * Copyright (C) 1994, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.6 1994-09-16 15:39:12 adam
8 * Initial code of lookup - not tested yet.
10 * Revision 1.5 1994/09/06 13:05:14 adam
11 * Further development of insertion. Some special cases are
12 * not properly handled yet! assert(0) are put here. The
13 * binary search in each page definitely reduce usr CPU.
15 * Revision 1.4 1994/09/01 17:49:37 adam
16 * Removed stupid line. Work on insertion in dictionary. Not finished yet.
18 * Revision 1.3 1994/09/01 17:44:06 adam
19 * depend include change.
21 * Revision 1.2 1994/08/18 12:40:54 adam
22 * Some development of dictionary. Not finished at all!
24 * Revision 1.1 1994/08/16 16:26:47 adam
39 int main (int argc, char **argv)
41 const char *name = NULL;
42 const char *inputfile = NULL;
43 const char *base = NULL;
48 int no_of_insertions = 0;
49 int no_of_new = 0, no_of_same = 0, no_of_change = 0;
56 fprintf (stderr, "usage:\n"
57 " %s [-u] [-s n] [-v n] [-i f] [-w] [-c n] base file\n",
61 while ((ret = options ("us:v:i:wc:", argv, argc, &arg)) != -2)
71 log (LOG_FATAL, "too many files specified\n");
98 log_init (atoi(arg), prog, NULL);
102 log (LOG_FATAL, "unknown option");
108 log (LOG_FATAL, "no base and/or dictionary specified");
111 common_resource = res_open (base);
112 if (!common_resource)
114 log (LOG_FATAL, "cannot open resource `%s'", base);
117 dict = dict_open (name, cache, rw);
120 log (LOG_FATAL, "dict_open fail of `%s'", name);
129 memset (infobytes, 0, 120);
131 if (!(ipf = fopen(inputfile, "r")))
133 log (LOG_FATAL|LOG_ERRNO, "cannot open %s", inputfile);
137 while (fgets (ipf_buf, 1023, ipf))
139 char *ipf_ptr = ipf_buf;
140 sprintf (infobytes, "%d", line);
141 for (;*ipf_ptr && *ipf_ptr != '\n';ipf_ptr++)
143 if (isalpha(*ipf_ptr) || *ipf_ptr == '_')
146 while (ipf_ptr[i] && (isalnum(ipf_ptr[i]) ||
151 switch(dict_insert (dict, ipf_ptr, infosize, infobytes))
159 log (LOG_LOG, "%s change\n", ipf_ptr);
163 log (LOG_LOG, "%s duplicate\n", ipf_ptr);
175 log (LOG_LOG, "Insertions.... %d", no_of_insertions);
176 log (LOG_LOG, "No of new..... %d", no_of_new);
177 log (LOG_LOG, "No of change.. %d", no_of_change);
178 log (LOG_LOG, "No of same.... %d", no_of_same);
180 res_close (common_resource);