2 * Copyright (C) 1994-1999, Index Data
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.10 1999-05-15 14:36:37 adam
8 * Updated dictionary. Implemented "compression" of dictionary.
10 * Revision 1.9 1999/02/02 14:50:25 adam
11 * Updated WIN32 code specific sections. Changed header.
13 * Revision 1.8 1998/03/05 08:17:24 adam
14 * Added a few comments - no code changed.
16 * Revision 1.7 1996/02/02 13:43:51 adam
17 * The public functions simply use char instead of Dict_char to represent
18 * search strings. Dict_char is used internally only.
20 * Revision 1.6 1995/12/11 09:04:50 adam
21 * Bug fix: the lookup/scan/lookgrep didn't handle empty dictionary.
23 * Revision 1.5 1995/09/04 09:09:15 adam
24 * String arg in lookup is const.
26 * Revision 1.4 1994/10/05 12:16:51 adam
27 * Pagesize is a resource now.
29 * Revision 1.3 1994/09/26 10:17:25 adam
32 * Revision 1.2 1994/09/16 15:39:14 adam
33 * Initial code of lookup - not tested yet.
35 * Revision 1.1 1994/08/16 16:26:48 adam
47 static char *dict_look (Dict dict, const Dict_char *str, Dict_ptr ptr)
55 dict_bf_readp (dict->dbf, ptr, &p);
58 indxp = (short*) ((char*) p+DICT_bsize(p)-sizeof(short));
64 /* string (Dict_char *) DICT_EOS terminated */
65 /* unsigned char length of information */
66 /* char * information */
67 info = (char*)p + indxp[-mid];
68 cmp = dict_strcmp((Dict_char*) info, str);
70 return info+(dict_strlen ((Dict_char*) info)+1)
79 /* Dict_char sub char */
80 /* unsigned char length of information */
81 /* char * information */
82 info = (char*)p - indxp[-mid];
83 memcpy (&dc, info+sizeof(Dict_ptr), sizeof(Dict_char));
87 memcpy (&subptr, info, sizeof(Dict_ptr));
88 if (*++str == DICT_EOS)
90 if (info[sizeof(Dict_ptr)+sizeof(Dict_char)])
91 return info+sizeof(Dict_ptr)+sizeof(Dict_char);
99 dict_bf_readp (dict->dbf, ptr, &p);
101 hi = DICT_nodir(p)-1;
102 indxp = (short*) ((char*) p+DICT_bsize(p)-sizeof(short));
115 char *dict_lookup (Dict dict, const char *p)
117 if (!dict->head.root)
119 return dict_look (dict, (const Dict_char *) p, dict->head.root);