2 * Copyright (C) 1994, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.3 1994-08-18 12:40:58 adam
8 * Some development of dictionary. Not finished at all!
10 * Revision 1.2 1994/08/17 13:32:20 adam
11 * Use cache in dict - not in bfile.
13 * Revision 1.1 1994/08/16 16:26:49 adam
24 Dict dict_open (const char *name, int cache, int rw)
30 dict = xmalloc (sizeof(*dict));
32 dict->dbf = dict_bf_open (name, DICT_PAGESIZE, cache, rw);
39 if (dict_bf_readp (dict->dbf, 0, &head_buf) <= 0)
42 { /* create header with information (page 0) */
43 dict_bf_newp (dict->dbf, 0, &head_buf);
44 dh = (struct Dict_head *) head_buf;
45 strcpy(dh->magic_str, DICT_MAGIC);
46 dh->free_list = dh->last = 1;
47 dh->page_size = DICT_PAGESIZE;
48 memcpy (&dict->head, dh, sizeof(*dh));
51 { /* no header present, i.e. no dictionary at all */
52 dict->head.free_list = dict->head.last = 0;
53 dict->head.page_size = DICT_PAGESIZE;
56 else /* header was there, check magic and page size */
58 dh = (struct Dict_head *) head_buf;
59 if (!strcmp (dh->magic_str, DICT_MAGIC))
61 dict_bf_close (dict->dbf);
65 if (dh->page_size != DICT_PAGESIZE)
67 dict_bf_close (dict->dbf);
71 memcpy (&dict->head, dh, sizeof(*dh));
76 int dict_strcmp (const Dict_char *s1, const Dict_char *s2)
78 return strcmp (s1, s2);
81 int dict_strlen (const Dict_char *s)