2 * Copyright (C) 1994, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.2 1994-08-17 13:32:20 adam
8 * Use cache in dict - not in bfile.
10 * Revision 1.1 1994/08/16 16:26:49 adam
22 Dict dict_open (const char *name, int cache, int rw)
28 dict = xmalloc (sizeof(*dict));
30 dict->dbf = dict_bf_open (name, DICT_PAGESIZE, cache, rw);
37 if (dict_bf_readp (dict->dbf, 0, &head_buf) <= 0)
40 { /* create header with information (page 0) */
41 dict_bf_newp (dict->dbf, 0, &head_buf);
42 dh = (struct Dict_head *) head_buf;
43 strcpy(dh->magic_str, DICT_MAGIC);
44 dh->free_list = dh->last = 1;
45 dh->page_size = DICT_PAGESIZE;
46 memcpy (&dict->head, dh, sizeof(*dh));
49 { /* no header present, i.e. no dictionary at all */
50 dict->head.free_list = dict->head.last = 0;
51 dict->head.page_size = DICT_PAGESIZE;
54 else /* header was there, check magic and page size */
56 dh = (struct Dict_head *) head_buf;
57 if (!strcmp (dh->magic_str, DICT_MAGIC))
59 dict_bf_close (dict->dbf);
63 if (dh->page_size != DICT_PAGESIZE)
65 dict_bf_close (dict->dbf);
69 memcpy (&dict->head, dh, sizeof(*dh));
74 int dict_strcmp (const Dict_char *s1, const Dict_char *s2)
76 return strcmp (s1, s2);
79 int dict_strlen (const Dict_char *s)