1 /* $Id: lookup.c,v 1.13 2005-01-15 19:38:23 adam Exp $
2 Copyright (C) 1995-2005
5 This file is part of the Zebra server.
7 Zebra is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with Zebra; see the file LICENSE.zebra. If not, write to the
19 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
32 static char *dict_look (Dict dict, const Dict_char *str, Dict_ptr ptr)
40 dict_bf_readp (dict->dbf, ptr, &p);
43 indxp = (short*) ((char*) p+DICT_bsize(p)-sizeof(short));
49 /* string (Dict_char *) DICT_EOS terminated */
50 /* unsigned char length of information */
51 /* char * information */
52 info = (char*)p + indxp[-mid];
53 cmp = dict_strcmp((Dict_char*) info, str);
55 return info+(dict_strlen ((Dict_char*) info)+1)
64 /* Dict_char sub char */
65 /* unsigned char length of information */
66 /* char * information */
67 info = (char*)p - indxp[-mid];
68 memcpy (&dc, info+sizeof(Dict_ptr), sizeof(Dict_char));
72 memcpy (&subptr, info, sizeof(Dict_ptr));
73 if (*++str == DICT_EOS)
75 if (info[sizeof(Dict_ptr)+sizeof(Dict_char)])
76 return info+sizeof(Dict_ptr)+sizeof(Dict_char);
84 dict_bf_readp (dict->dbf, ptr, &p);
87 indxp = (short*) ((char*) p+DICT_bsize(p)-sizeof(short));
100 char *dict_lookup (Dict dict, const char *p)
102 if (!dict->head.root)
104 return dict_look (dict, (const Dict_char *) p, dict->head.root);