2 * Copyright (C) 1994, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.7 1994-09-19 16:34:26 adam
8 * Depend rule change. Minor changes in dicttest.c
10 * Revision 1.6 1994/09/16 15:39:12 adam
11 * Initial code of lookup - not tested yet.
13 * Revision 1.5 1994/09/06 13:05:14 adam
14 * Further development of insertion. Some special cases are
15 * not properly handled yet! assert(0) are put here. The
16 * binary search in each page definitely reduce usr CPU.
18 * Revision 1.4 1994/09/01 17:49:37 adam
19 * Removed stupid line. Work on insertion in dictionary. Not finished yet.
21 * Revision 1.3 1994/09/01 17:44:06 adam
22 * depend include change.
24 * Revision 1.2 1994/08/18 12:40:54 adam
25 * Some development of dictionary. Not finished at all!
27 * Revision 1.1 1994/08/16 16:26:47 adam
42 int main (int argc, char **argv)
44 const char *name = NULL;
45 const char *inputfile = NULL;
46 const char *base = NULL;
51 int no_of_iterations = 0;
52 int no_of_new = 0, no_of_same = 0, no_of_change = 0;
53 int no_of_hits = 0, no_of_misses = 0;
60 fprintf (stderr, "usage:\n"
61 " %s [-u] [-s n] [-v n] [-i f] [-w] [-c n] base file\n",
65 while ((ret = options ("us:v:i:wc:", argv, argc, &arg)) != -2)
75 log (LOG_FATAL, "too many files specified\n");
99 log_init (atoi(arg), prog, NULL);
103 log (LOG_FATAL, "unknown option");
109 log (LOG_FATAL, "no base and/or dictionary specified");
112 common_resource = res_open (base);
113 if (!common_resource)
115 log (LOG_FATAL, "cannot open resource `%s'", base);
118 dict = dict_open (name, cache, rw);
121 log (LOG_FATAL, "dict_open fail of `%s'", name);
130 memset (infobytes, 0, 120);
132 if (!(ipf = fopen(inputfile, "r")))
134 log (LOG_FATAL|LOG_ERRNO, "cannot open %s", inputfile);
138 while (fgets (ipf_buf, 1023, ipf))
140 char *ipf_ptr = ipf_buf;
141 sprintf (infobytes, "%d", line);
142 for (;*ipf_ptr && *ipf_ptr != '\n';ipf_ptr++)
144 if (isalpha(*ipf_ptr) || *ipf_ptr == '_')
147 while (ipf_ptr[i] && (isalnum(ipf_ptr[i]) ||
154 switch(dict_insert (dict, ipf_ptr,
155 infosize, infobytes))
163 log (LOG_LOG, "%s change\n", ipf_ptr);
167 log (LOG_LOG, "%s duplicate\n", ipf_ptr);
176 cp = dict_lookup (dict, ipf_ptr);
192 log (LOG_LOG, "Insertions.... %d", no_of_iterations);
193 log (LOG_LOG, "No of new..... %d", no_of_new);
194 log (LOG_LOG, "No of change.. %d", no_of_change);
195 log (LOG_LOG, "No of same.... %d", no_of_same);
199 log (LOG_LOG, "Lookups....... %d", no_of_iterations);
200 log (LOG_LOG, "No of hits.... %d", no_of_hits);
201 log (LOG_LOG, "No of misses.. %d", no_of_misses);
204 res_close (common_resource);