2 * Copyright (C) 1994, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.1 1994-08-16 16:26:49 adam
19 Dict dict_open (const char *name, int cache, int rw)
25 dict = xmalloc (sizeof(*dict));
28 dict->bf = bf_open_w (name, DICT_PAGESIZE, cache);
30 dict->bf = bf_open (name, DICT_PAGESIZE, cache);
37 if (bf_read (dict->bf, 0, &head_buf) <= 0)
40 { /* create header with information (page 0) */
41 bf_newp (dict->bf, 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))
63 if (dh->page_size != DICT_PAGESIZE)
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)