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