2 * Copyright (C) 1994-1999, Index Data
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.9 1999-02-02 14:50:25 adam
8 * Updated WIN32 code specific sections. Changed header.
10 * Revision 1.8 1998/03/05 08:17:24 adam
11 * Added a few comments - no code changed.
13 * Revision 1.7 1996/02/02 13:43:51 adam
14 * The public functions simply use char instead of Dict_char to represent
15 * search strings. Dict_char is used internally only.
17 * Revision 1.6 1995/12/11 09:04:50 adam
18 * Bug fix: the lookup/scan/lookgrep didn't handle empty dictionary.
20 * Revision 1.5 1995/09/04 09:09:15 adam
21 * String arg in lookup is const.
23 * Revision 1.4 1994/10/05 12:16:51 adam
24 * Pagesize is a resource now.
26 * Revision 1.3 1994/09/26 10:17:25 adam
29 * Revision 1.2 1994/09/16 15:39:14 adam
30 * Initial code of lookup - not tested yet.
32 * Revision 1.1 1994/08/16 16:26:48 adam
44 static char *dict_look (Dict dict, const Dict_char *str)
53 dict_bf_readp (dict->dbf, ptr, &p);
56 indxp = (short*) ((char*) p+DICT_pagesize(dict)-sizeof(short));
62 /* string (Dict_char *) DICT_EOS terminated */
63 /* unsigned char length of information */
64 /* char * information */
65 info = (char*)p + indxp[-mid];
66 cmp = dict_strcmp((Dict_char*) info, str);
68 return info+(dict_strlen ((Dict_char*) info)+1)
77 /* Dict_char sub char */
78 /* unsigned char length of information */
79 /* char * information */
80 info = (char*)p - indxp[-mid];
81 memcpy (&dc, info+sizeof(Dict_ptr), sizeof(Dict_char));
85 memcpy (&subptr, info, sizeof(Dict_ptr));
86 if (*++str == DICT_EOS)
88 if (info[sizeof(Dict_ptr)+sizeof(Dict_char)])
89 return info+sizeof(Dict_ptr)+sizeof(Dict_char);
97 dict_bf_readp (dict->dbf, ptr, &p);
100 indxp = (short*) ((char*) p+DICT_pagesize(dict)
114 char *dict_lookup (Dict dict, const char *p)
116 if (dict->head.last <= 1)
118 return dict_look (dict, (const Dict_char *) p);