*** empty log message ***
[idzebra-moved-to-github.git] / bfile / cfile.c
index 3a69a58..fb8a96e 100644 (file)
@@ -4,7 +4,17 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: cfile.c,v $
- * Revision 1.3  1995-12-01 11:37:22  adam
+ * Revision 1.6  1995-12-11 09:03:53  adam
+ * New function: cf_unlink.
+ * New member of commit file head: state (0) deleted, (1) hash file.
+ *
+ * Revision 1.5  1995/12/08  16:21:14  adam
+ * Work on commit/update.
+ *
+ * Revision 1.4  1995/12/01  16:24:28  adam
+ * Commit files use separate meta file area.
+ *
+ * Revision 1.3  1995/12/01  11:37:22  adam
  * Cached/commit files implemented as meta-files.
  *
  * Revision 1.2  1995/11/30  17:00:49  adam
@@ -58,8 +68,8 @@ static int read_head (CFile cf)
 }
 
 
-CFile cf_open (MFile mf, const char *fname, int block_size, int wflag,
-               int *firstp)
+CFile cf_open (MFile mf, MFile_area area, const char *fname,
+               int block_size, int wflag, int *firstp)
 {
     char path[256];
     int i;
@@ -68,20 +78,23 @@ CFile cf_open (MFile mf, const char *fname, int block_size, int wflag,
    
     cf->rmf = mf; 
     sprintf (path, "%s.b", fname);
-    if (!(cf->block_mf = mf_open (0, path, block_size, wflag)))
+    if (!(cf->block_mf = mf_open (area, path, block_size, wflag)))
     {
         logf (LOG_FATAL|LOG_ERRNO, "Failed to open %s", path);
         exit (1);
     }
     sprintf (path, "%s.h", fname);
-    if (!(cf->hash_mf = mf_open (0, path, HASH_BSIZE, wflag)))
+    if (!(cf->hash_mf = mf_open (area, path, HASH_BSIZE, wflag)))
     {
         logf (LOG_FATAL|LOG_ERRNO, "Failed to open %s", path);
         exit (1);
     }
-    if (!mf_read (cf->hash_mf, 0, 0, sizeof(cf->head), &cf->head))
+    assert (firstp);
+    if (!mf_read (cf->hash_mf, 0, 0, sizeof(cf->head), &cf->head) ||
+        !cf->head.state)
     {
         *firstp = 1;
+        cf->head.state = 1;
         cf->head.block_size = block_size;
         cf->head.hash_size = 401;
         hash_bytes = cf->head.hash_size * sizeof(int);
@@ -111,7 +124,7 @@ CFile cf_open (MFile mf, const char *fname, int block_size, int wflag,
         cf->parray[i] = NULL;
     cf->bucket_lru_front = cf->bucket_lru_back = NULL;
     cf->bucket_in_memory = 0;
-    cf->max_bucket_in_memory = 200;
+    cf->max_bucket_in_memory = 400;
     cf->dirty = 0;
     cf->iobuf = xmalloc (cf->head.block_size);
     memset (cf->iobuf, 0, cf->head.block_size);