# Copyright (C) 1994, Index Data I/S
# All rights reserved.
# Sebastian Hammer, Adam Dickmeiss
-# $Id: Makefile,v 1.1 1994-08-16 16:26:46 adam Exp $
+# $Id: Makefile,v 1.2 1994-08-17 13:32:18 adam Exp $
SHELL=/bin/sh
INCLUDE=-I../include
CFLAGS=-g -Wall
DEFS=$(INCLUDE)
LIB=../lib/dict.a
-PO = open.o close.o insert.o lookup.o
+PO = dopen.o dclose.o drdwr.o open.o close.o insert.o lookup.o
CPP=cc -E
all: $(LIB)
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: close.c,v $
- * Revision 1.1 1994-08-16 16:26:47 adam
+ * Revision 1.2 1994-08-17 13:32:19 adam
+ * Use cache in dict - not in bfile.
+ *
+ * Revision 1.1 1994/08/16 16:26:47 adam
* Added dict.
*
*/
{
assert (dict);
- bf_close (dict->bf);
+ dict_bf_close (dict->dbf);
free (dict);
return 0;
}
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: insert.c,v $
- * Revision 1.1 1994-08-16 16:26:48 adam
+ * Revision 1.2 1994-08-17 13:32:19 adam
+ * Use cache in dict - not in bfile.
+ *
+ * Revision 1.1 1994/08/16 16:26:48 adam
* Added dict.
*
*/
{
dict->head.free_list++;
dict->head.last = dict->head.free_list;
- bf_newp (dict->bf, ptr, &p);
+ dict_bf_newp (dict->dbf, ptr, &p);
}
else
{
- bf_readp (dict->bf, dict->head.free_list, &p);
+ dict_bf_readp (dict->dbf, dict->head.free_list, &p);
dict->head.free_list = DICT_nextptr(p);
if (dict->head.free_list == 0)
dict->head.free_list = dict->head.last;
if (memcmp (info+sizeof(Dict_ptr), userinfo, sizeof(userinfo)))
{
memcpy (info+sizeof(Dict_ptr), userinfo, sizeof(userinfo));
- bf_touch (dict->bf, ptr);
+ dict_bf_touch (dict->dbf, ptr);
}
return 0;
}
{
subptr = new_page (dict, ptr, &pp);
memcpy (info, &subptr, sizeof(subptr));
- bf_touch (dict->bf, ptr);
+ dict_bf_touch (dict->dbf, ptr);
}
return dict_ins (dict, str+1, ptr, pp, userinfo);
}
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: open.c,v $
- * Revision 1.1 1994-08-16 16:26:49 adam
+ * Revision 1.2 1994-08-17 13:32:20 adam
+ * Use cache in dict - not in bfile.
+ *
+ * Revision 1.1 1994/08/16 16:26:49 adam
* Added dict.
*
*/
dict = xmalloc (sizeof(*dict));
- if (rw)
- dict->bf = bf_open_w (name, DICT_PAGESIZE, cache);
- else
- dict->bf = bf_open (name, DICT_PAGESIZE, cache);
+ dict->dbf = dict_bf_open (name, DICT_PAGESIZE, cache, rw);
- if(!dict->bf)
+ if(!dict->dbf)
{
free (dict);
return NULL;
}
- if (bf_read (dict->bf, 0, &head_buf) <= 0)
+ if (dict_bf_readp (dict->dbf, 0, &head_buf) <= 0)
{
if (rw)
{ /* create header with information (page 0) */
- bf_newp (dict->bf, 0, &head_buf);
+ dict_bf_newp (dict->dbf, 0, &head_buf);
dh = (struct Dict_head *) head_buf;
strcpy(dh->magic_str, DICT_MAGIC);
dh->free_list = dh->last = 1;
dh = (struct Dict_head *) head_buf;
if (!strcmp (dh->magic_str, DICT_MAGIC))
{
- bf_close (dict->bf);
+ dict_bf_close (dict->dbf);
free (dict);
return NULL;
}
if (dh->page_size != DICT_PAGESIZE)
{
- bf_close (dict->bf);
+ dict_bf_close (dict->dbf);
free (dict);
return NULL;
}
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: bfile.h,v $
- * Revision 1.1 1994-08-16 16:16:02 adam
+ * Revision 1.2 1994-08-17 13:32:33 adam
+ * Use cache in dict - not in bfile.
+ *
+ * Revision 1.1 1994/08/16 16:16:02 adam
* bfile header created.
*
*/
#ifndef BFILE_H
#define BFILE_H
-struct BFile_block
-{
- struct BFile_block *h_next, **h_prev;
- struct BFile_block *lru_next, *lru_prev;
- void *data;
- int dirty;
- int no;
-};
+#include <util.h>
typedef struct BFile_struct
{
int fd;
int block_size;
- int cache;
- struct BFile_block *all_blocks;
- struct BFile_block *free_list;
- struct BFile_block **hash_array;
-
- struct BFile_block *lru_back, *lru_front;
- int hash_size;
- void *all_data;
-
- int hits;
- int misses;
} *BFile;
int bf_close (BFile);
-BFile bf_open (const char *name, int block_size, int cache);
-BFile bf_open_w (const char *name, int block_size, int cache);
+BFile bf_open (const char *name, int block_size, int rw);
int bf_read (BFile bf, int no, void *buf);
int bf_write (BFile bf, int no, const void *buf);
-int bf_readp (BFile bf, int no, void **bufp);
-int bf_newp (BFile bf, int no, void **bufp);
-int bf_touch (BFile bf, int no);
-void bf_flush_blocks (BFile bf, int no_to_flush);
-
-void *xmalloc_f (size_t size);
-#define xmalloc(x) xmalloc_f(x)
-
-extern char *prog;
-
#endif
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: dict.h,v $
- * Revision 1.1 1994-08-16 16:26:53 adam
+ * Revision 1.2 1994-08-17 13:32:33 adam
+ * Use cache in dict - not in bfile.
+ *
+ * Revision 1.1 1994/08/16 16:26:53 adam
* Added dict.
*
*/
Dict_ptr free_list, last;
};
-typedef struct Dict_struct {
+struct Dict_file_block
+{
+ struct Dict_file_block *h_next, **h_prev;
+ struct Dict_file_block *lru_next, *lru_prev;
+ void *data;
+ int dirty;
+ int no;
+};
+
+typedef struct Dict_file_struct
+{
+ int cache;
BFile bf;
+
+ struct Dict_file_block *all_blocks;
+ struct Dict_file_block *free_list;
+ struct Dict_file_block **hash_array;
+
+ struct Dict_file_block *lru_back, *lru_front;
+ int hash_size;
+ void *all_data;
+
+ int hits;
+ int misses;
+} *Dict_BFile;
+
+typedef struct Dict_struct {
+ Dict_BFile dbf;
struct Dict_head head;
} *Dict;
+int dict_bf_readp (Dict_BFile bf, int no, void **bufp);
+int dict_bf_newp (Dict_BFile bf, int no, void **bufp);
+int dict_bf_touch (Dict_BFile bf, int no);
+void dict_bf_flush_blocks (Dict_BFile bf, int no_to_flush);
+Dict_BFile dict_bf_open (const char *name, int block_size, int cache, int rw);
+int dict_bf_close (Dict_BFile dbf);
#define DICT_MAGIC "dict00"
typedef int Dict_info;
#define DICT_to_str(x) sizeof(Dict_info)+sizeof(Dict_ptr)
-
/*
type type of page
backptr pointer to parent