home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 31 / CDASC_31_1996_juillet_aout.iso / vrac / lsdoor09.zip / LSTREE.H < prev    next >
C/C++ Source or Header  |  1995-08-30  |  2KB  |  77 lines

  1. // BTree.h
  2.  
  3. #ifndef __BTREE_HEADOR_FILE__
  4. #define __BTREE_HEADOR_FILE__
  5.  
  6. #define BTREE_OK           0
  7. #define BTREE_ERROR        1
  8. #define BTREE_END          2
  9. #define BTREE_LOCK         3
  10.  
  11. #define MAX_KEY            120   // Maximum size of an index key
  12. #define NUM_BUFS        6 // x IXBLOCK = Total cache memory
  13. #define MAX_LEVELS      8
  14. #define IXBLOCK        (1024 - 10)  // To change block size, change 1024...
  15.  
  16. typedef long POS;
  17.  
  18.  
  19. struct Block
  20. {
  21.   POS pos;
  22.   POS next;
  23.   int end;
  24.   uchar entries[IXBLOCK];         // the actual data
  25. };
  26.  
  27. struct Index
  28. {
  29.   int handle;                     // file handle
  30.  
  31.   int level;
  32.   uchar trunk_changed;
  33.  
  34.   Block trunk;
  35.   POS empty;
  36.   char dupe;                      // Dupe keys allowed (True or false)
  37.   int levels;
  38.  
  39.   POS cblock[MAX_LEVELS];
  40.   int coffset[MAX_LEVELS];
  41. };
  42.  
  43. struct Entry
  44. {
  45.   POS lower;
  46.   POS data;                       // Place the data's file position here
  47.   unsigned char key[MAX_KEY];     // Place the null-terminated keyword here
  48. };
  49.  
  50.  
  51. int open_index( char *filename, Index *ix );
  52. int create_index( char *filename, Index *ix, int dupe=1 );
  53.  
  54. int add_key( Index *, Entry * );
  55. int delete_key( Index *, Entry * );
  56.  
  57. int first_key( Index *, Entry * );
  58. int last_key( Index *, Entry * );
  59.  
  60. int next_key( Index *, Entry * );
  61. int prev_key( Index *, Entry * );
  62.  
  63. int find_key( Index *, Entry * );
  64. int locate_key( Index *, Entry * );
  65. int match_key( Index *, Entry * );
  66.  
  67. int cache_flush( Index * );
  68. int close_index( Index * );
  69.  
  70. #endif
  71.  
  72. // End of BTree.H
  73.  
  74.  
  75.  
  76.  
  77.