Added dict.
[idzebra-moved-to-github.git] / include / dict.h
1 /*
2  * Copyright (C) 1994, Index Data I/S 
3  * All rights reserved.
4  * Sebastian Hammer, Adam Dickmeiss
5  *
6  * $Log: dict.h,v $
7  * Revision 1.1  1994-08-16 16:26:53  adam
8  * Added dict.
9  *
10  */
11
12 #ifndef DICT_H
13 #define DICT_H
14
15 #include <bfile.h>
16
17 typedef unsigned Dict_ptr;
18 typedef char Dict_char;
19
20 struct Dict_head {
21     char magic_str[8];
22     int page_size;
23     Dict_ptr free_list, last;
24 };
25
26 typedef struct Dict_struct {
27     BFile bf;
28     struct Dict_head head;
29 } *Dict;
30
31 #define DICT_MAGIC "dict00"
32
33 typedef int Dict_info;
34
35 #define DICT_PAGESIZE 8192
36     
37 Dict dict_open (const char *name, int cache, int rw);
38 int dict_close (Dict dict);
39 int dict_insert (Dict dict, const Dict_char *p, void *userinfo);
40 int dict_lookup (Dict dict, Dict_char *p);
41 int dict_strcmp (const Dict_char *s1, const Dict_char *s2);
42 int dict_strlen (const Dict_char *s);
43
44 #define DICT_EOS        0
45 #define DICT_type(x)    0[(Dict_ptr*) x]
46 #define DICT_backptr(x) 1[(Dict_ptr*) x]
47 #define DICT_nextptr(x) 2[(Dict_ptr*) x]
48 #define DICT_nodir(x)   0[(short*)((char*)(x)+3*sizeof(Dict_ptr))]
49 #define DICT_size(x)    1[(short*)((char*)(x)+3*sizeof(Dict_ptr))]
50 #define DICT_info(x)    ((char*)(x)+3*sizeof(Dict_ptr)+2*sizeof(short))
51
52 #define DICT_to_str(x)  sizeof(Dict_info)+sizeof(Dict_ptr)
53
54
55 /*
56    type            type of page
57    backptr         pointer to parent
58    nextptr         pointer to next page (if any)
59    nodir           no of words
60    size            size of strings,info,ptr entries
61
62    dir[0..nodir-1]
63    ptr,info,string
64  */
65
66    
67 #endif