1 /* This file is part of the Zebra server.
2 Copyright (C) 1994-2011 Index Data
4 Zebra is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
9 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 static char *dict_look(Dict dict, const Dict_char *str, Dict_ptr ptr)
37 dict_bf_readp(dict->dbf, ptr, &p);
40 indxp = (short*) ((char*) p+DICT_bsize(p)-sizeof(short));
46 /* string (Dict_char *) DICT_EOS terminated */
47 /* unsigned char length of information */
48 /* char * information */
49 info = (char*)p + indxp[-mid];
50 cmp = dict_strcmp((Dict_char*) info, str);
52 return info+(dict_strlen ((Dict_char*) info)+1)
61 /* Dict_char sub char */
62 /* unsigned char length of information */
63 /* char * information */
64 info = (char*)p - indxp[-mid];
65 memcpy(&dc, info+sizeof(Dict_ptr), sizeof(Dict_char));
69 memcpy(&subptr, info, sizeof(Dict_ptr));
70 if (*++str == DICT_EOS)
72 if (info[sizeof(Dict_ptr)+sizeof(Dict_char)])
73 return info+sizeof(Dict_ptr)+sizeof(Dict_char);
81 dict_bf_readp(dict->dbf, ptr, &p);
84 indxp = (short*) ((char*) p+DICT_bsize(p)-sizeof(short));
97 char *dict_lookup(Dict dict, const char *p)
100 if (!dict->head.root)
102 return dict_look(dict, (const Dict_char *) p, dict->head.root);
107 * c-file-style: "Stroustrup"
108 * indent-tabs-mode: nil
110 * vim: shiftwidth=4 tabstop=8 expandtab