2 * Copyright (C) 1994, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.7 1996-02-02 13:43:51 adam
8 * The public functions simply use char instead of Dict_char to represent
9 * search strings. Dict_char is used internally only.
11 * Revision 1.6 1995/12/11 09:04:50 adam
12 * Bug fix: the lookup/scan/lookgrep didn't handle empty dictionary.
14 * Revision 1.5 1995/09/04 09:09:15 adam
15 * String arg in lookup is const.
17 * Revision 1.4 1994/10/05 12:16:51 adam
18 * Pagesize is a resource now.
20 * Revision 1.3 1994/09/26 10:17:25 adam
23 * Revision 1.2 1994/09/16 15:39:14 adam
24 * Initial code of lookup - not tested yet.
26 * Revision 1.1 1994/08/16 16:26:48 adam
38 static char *dict_look (Dict dict, const Dict_char *str)
47 dict_bf_readp (dict->dbf, ptr, &p);
50 indxp = (short*) ((char*) p+DICT_pagesize(dict)-sizeof(short));
56 /* string (Dict_char *) DICT_EOS terminated */
57 /* unsigned char length of information */
58 /* char * information */
59 info = (char*)p + indxp[-mid];
60 cmp = dict_strcmp((Dict_char*) info, str);
62 return info+(dict_strlen ((Dict_char*) info)+1)
71 /* Dict_char sub char */
72 /* unsigned char length of information */
73 /* char * information */
74 info = (char*)p - indxp[-mid];
75 memcpy (&dc, info+sizeof(Dict_ptr), sizeof(Dict_char));
79 memcpy (&subptr, info, sizeof(Dict_ptr));
80 if (*++str == DICT_EOS)
82 if (info[sizeof(Dict_ptr)+sizeof(Dict_char)])
83 return info+sizeof(Dict_ptr)+sizeof(Dict_char);
91 dict_bf_readp (dict->dbf, ptr, &p);
94 indxp = (short*) ((char*) p+DICT_pagesize(dict)
108 char *dict_lookup (Dict dict, const char *p)
110 if (dict->head.last <= 1)
112 return dict_look (dict, (const Dict_char *) p);