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