Not functional yet
[idzebra-moved-to-github.git] / include / isam.h
1 /*
2  * Copyright (C) 1994, Index Data I/S 
3  * All rights reserved.
4  * Sebastian Hammer, Adam Dickmeiss
5  *
6  * $Log: isam.h,v $
7  * Revision 1.1  1994-09-12 08:02:07  quinn
8  * Not functional yet
9  *
10  */
11
12 #ifndef ISAM_H
13 #define ISAM_H
14
15 #include <bfile.h>
16 #include <isam.h>
17
18 #define IS_MAX_BLOCKTYPES 4
19
20 typedef unsigned int SYSNO; /* should be somewhere else */
21 typedef unsigned int ISAM_P;
22
23 /*
24  * Description of a blocktype (part of an isam file)
25  */
26 typedef struct isam_blocktype
27 {
28     BFile bf;                    /* blocked file */
29     int blocksize;
30     int max_keys_block;          /* max num of keys per block */
31     int nice_keys_block;         /* nice number of keys per block */
32     int max_keys;                /* max number of keys per table */
33 } isam_blocktype;
34
35 /*
36  * Handle to an open isam complex.
37  */
38 typedef struct isam_struct
39 {
40     isam_blocktype types[IS_MAX_BLOCKTYPES]; /* block_types used in this file */
41     int num_types;                /* number of block types used */
42     int writeflag;
43     int keysize;                  /* size of the keys (records) used */
44     int (*cmp)(const void *k1, const void *k2); /* compare function */
45 } isam_struct, *ISAM;
46
47 typedef struct ispt_struct
48 {
49     ISAM is;                       /* which file do we belong to? */
50     int ptr;                       /* current key offset */
51
52     struct ispt_struct *next;      /* freelist */
53 } ispt_struct, *ISPT; 
54
55 #define IS_TYPE(x) ((x) & 3))      /* type part of position */
56 #define IS_BLOCK(x) ((x >> 2))     /* block # part of position */
57
58 /*
59  * Public Prototypes.
60  *******************************************************************
61  */
62
63 /*
64  * Open isam file.
65  */
66 ISAM is_open(const char *name, int writeflag);
67
68 /*
69  * Close isam file.
70  */
71 int is_close(ISAM is);
72
73 /*
74  * Locate a table of keys in an isam file. The ISPT is an individual
75  * position marker for that table.
76  */
77 ISPT is_position(ISAM is, ISAM_P pos);
78
79 /*
80  * Release ISPT.
81  */
82 void is_pt_free(ISPT ip);
83
84 /*
85  * Read a key from a table.
86  */
87 int is_readkey(ISPT ip, void *buf);
88
89 #endif