Towards GPL
[idzebra-moved-to-github.git] / include / isam.h
index d9a4d15..0e4488a 100644 (file)
@@ -1,27 +1,43 @@
-/*
- * Copyright (C) 1994, Index Data I/S 
- * All rights reserved.
- * Sebastian Hammer, Adam Dickmeiss
- *
- * $Log: isam.h,v $
- * Revision 1.2  1994-09-14 13:10:35  quinn
- * Small changes
- *
- * Revision 1.1  1994/09/12  08:02:07  quinn
- * Not functional yet
- *
- */
+/* $Id: isam.h,v 1.15 2002-08-02 19:26:55 adam Exp $
+   Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
+   Index Data Aps
+
+This file is part of the Zebra server.
+
+Zebra is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Zebra; see the file LICENSE.zebra.  If not, write to the
+Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA.
+*/
+
+
 
 #ifndef ISAM_H
 #define ISAM_H
 
+#include <res.h>
 #include <bfile.h>
-#include <isam.h>
 
-#define IS_MAX_BLOCKTYPES 4
+#include "../isam/memory.h"
+#include "../isam/physical.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 
-typedef unsigned int SYSNO; /* should be somewhere else */
-typedef unsigned int ISAM_P;
+#define IS_MAX_BLOCKTYPES 4
+#define IS_MAX_RECORD 512
+#define IS_DEF_REPACK_PERCENT "30" /* how much relative change before repack */
 
 /*
  * Description of a blocktype (part of an isam file)
@@ -32,9 +48,13 @@ typedef struct isam_blocktype
     int blocksize;
     int first_block;             /* position of first data block */
     int max_keys_block;          /* max num of keys per block */
+    int max_keys_block0;         /* max num of keys in first block */
     int nice_keys_block;         /* nice number of keys per block */
     int max_keys;                /* max number of keys per table */
-    int freelist;                /* fist free block */
+    int freelist;                /* first free block */
+    int top;                     /* first unused block */
+    int index;                   /* placeholder. Always 0. */
+    char *dbuf;                  /* buffer for use in I/O operations */
 } isam_blocktype;
 
 /*
@@ -46,19 +66,20 @@ typedef struct isam_struct
     int num_types;                /* number of block types used */
     int writeflag;
     int keysize;                  /* size of the keys (records) used */
+    int repack;                   /* how many percent to grow before repack */
     int (*cmp)(const void *k1, const void *k2); /* compare function */
-} isam_struct, *ISAM;
+} isam_struct;
 
 typedef struct ispt_struct
 {
-    ISAM is;                       /* which file do we belong to? */
-    int ptr;                       /* current key offset */
-
+    struct is_mtable tab;
     struct ispt_struct *next;      /* freelist */
 } ispt_struct, *ISPT; 
 
-#define IS_TYPE(x) ((x) & 3))      /* type part of position */
-#define IS_BLOCK(x) ((x >> 2))     /* block # part of position */
+#define is_type(x) ((x) & 3)      /* type part of position */
+#define is_block(x) ((x) >> 2)     /* block # part of position */
+
+#define is_keysize(is) ((is)->keysize)
 
 /*
  * Public Prototypes.
@@ -68,7 +89,9 @@ typedef struct ispt_struct
 /*
  * Open isam file.
  */
-ISAM is_open(const char *name, int writeflag);
+ISAM is_open(BFiles bfs, const char *name,
+            int (*cmp)(const void *p1, const void *p2),
+            int writeflag, int keysize, Res res);
 
 /*
  * Close isam file.
@@ -91,4 +114,16 @@ void is_pt_free(ISPT ip);
  */
 int is_readkey(ISPT ip, void *buf);
 
+int is_writekey(ISPT ip, const void *buf);
+
+int is_numkeys(ISPT ip);
+
+void is_rewind(ISPT ip);
+
+ISAM_P is_merge(ISAM is, ISAM_P pos, int num, char *data);
+
+#ifdef __cplusplus
+}
+#endif
+
 #endif