Category : C Source Code
Archive   : C-TOOLBX.ZIP
Filename : BTREE.H

 
Output of file : BTREE.H contained in archive : C-TOOLBX.ZIP
/* btree.h - data structures and constants for BTREE modue */
#define EOIX (-2) /* return value for end-of-index */
#define IX_FAIL (-1) /* return value for failed operation */
#define IX_OK 0 /* return value for success */

typedef long RECPOS ; /* file pos. of index block/data rec. */
#define NULLREC (-1L) /* special value for RECPOS */

#define MAXKEY 100 /* maximum length of a key */

typedef struct /* entry format in index */
{ RECPOS rptr ; /* points to lower level */
char key[MAXKEY] ; /* start of key value */
/* actual data type unknown */
} ENTRY ;

#define IXB_SIZE 1024 /* no. bytes in a block ( on disk ) */
/* IXB_SIZE = IXB_SIZE - sizeof(int)*2 - sizeof(long) */
#define IXB_SPACE 1016 /* no. bytes of entry space in block */

typedef struct /* index block format */
{ RECPOS brec ; /* index file location of block */
/* or location of next free block */
int bend ; /* first unused location in block */
int lvl ; /* records level no. (-1 = free) */
char entries[IXB_SPACE] ; /* space for entries */
} BLOCK ;

#define MAX_LEVELS 4 /* four index levels permitted */

typedef struct /* disk file index descriptor */
{ int nl ; /* number of index levels */
RECPOS rb ; /* location of root block in file */
RECPOS ff ; /* location of first free block */
ENTRY dume ; /* dummy entry */
} IX_DISK ;

typedef struct /* in-memory index descriptor */
{ int ixfile ; /* descriptor of open index file */
struct
{ RECPOS cblock ; /* current block number */
int coffset ; /* current offset within block */
} pos[MAX_LEVELS] ;
int (*pcomp) () ; /* address of compare function */
int (*psize) () ; /* address of entry size */
BLOCK cache[MAX_LEVELS] ; /* cache for current blocks */
IX_DISK dx ; /* disk resident stuff */
} IX_DESC ;





  3 Responses to “Category : C Source Code
Archive   : C-TOOLBX.ZIP
Filename : BTREE.H

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/