1 /* 2 * Please do not edit this file. 3 * It was generated using rpcgen. 4 */ 5 6 #ifndef _DB_INDEX_H_RPCGEN 7 #define _DB_INDEX_H_RPCGEN 8 9 #include <rpc/rpc.h> 10 #ifndef _DB_INDEX_H 11 #define _DB_INDEX_H 12 13 /* db_index is a hash table with separate overflow buckets. */ 14 15 #include "db_item.h" 16 #include "db_index_entry.h" 17 #include "db_table.h" 18 #include "db_scheme.h" 19 20 #include "nisdb_rw.h" 21 22 class db_index { 23 long table_size; 24 db_index_entry_p *tab; 25 int count; 26 bool_t case_insens; 27 STRUCTRWLOCK(index); 28 29 /* Grow the current hashtable upto the next size. 30 The contents of the existing hashtable is copied to the new one and 31 relocated according to its hashvalue relative to the new size. 32 Old table is deleted after the relocation. */ 33 void grow(); 34 35 /* Clear the chains created in db_index_entrys */ 36 /* void clear_results();*/ 37 public: 38 39 /* Constructor: creates empty index. */ 40 db_index(); 41 42 /* Constructor: creates index by loading it from the specified file. 43 If loading fails, creates empty index. */ 44 db_index( char *); 45 46 /* Destructor: deletes index, including all associated db_index_entry. */ 47 ~db_index(); 48 49 /* Empty table (deletes index, including all associated db_index_entry) */ 50 void reset(); 51 52 /* Initialize index according to the specification of the key descriptor. 53 Currently, only affects case_insens flag of index. */ 54 void init( db_key_desc * ); 55 56 /* Moves an index from an xdr index */ 57 db_status move_xdr_db_index(db_index *orig); 58 59 /* Dumps this index to named file. */ 60 int dump( char *); 61 62 63 /* Look up given index value in hashtable. 64 Return pointer to db_index_entries that match the given value, linked 65 via the 'next_result' pointer. Return in 'how_many_found' the size 66 of this list. Return NULL if not found. */ 67 db_index_entry *lookup(item *, long *, db_table *, bool_t); 68 69 /* Remove the entry with the given index value and location 'recnum'. 70 If successful, return DB_SUCCESS; otherwise DB_NOTUNIQUE if index_value 71 is null; DB_NOTFOUND if entry is not found. 72 If successful, decrement count of number of entries in hash table. */ 73 db_status remove( item*, entryp ); 74 75 /* Add a new index entry with the given index value and location 'recnum'. 76 Return DB_NOTUNIQUE, if entry with identical index_value and recnum 77 already exists. If entry is added, return DB_SUCCESS. 78 Increment count of number of entries in index table and grow table 79 if table is more than half full. 80 Note that a copy of index_value is made for new entry. */ 81 db_status add( item*, entryp ); 82 83 /* Return in 'tsize' the table_size, and 'tcount' the number of entries 84 in the table. */ 85 void stats( long* tsize, long* tcount); 86 87 88 /* Print all entries in the table. */ 89 void print(); 90 91 /* Locking methods */ 92 93 int acqexcl(void) { 94 return (WLOCK(index)); 95 } 96 97 int relexcl(void) { 98 return (WULOCK(index)); 99 } 100 101 int acqnonexcl(void) { 102 return (RLOCK(index)); 103 } 104 105 int relnonexcl(void) { 106 return (RULOCK(index)); 107 } 108 }; 109 #ifdef __cplusplus 110 extern "C" bool_t xdr_db_index(XDR *, db_index *); 111 #elif __STDC__ 112 extern bool_t xdr_db_index(XDR *, db_index *); 113 #endif 114 typedef class db_index * db_index_p; 115 #endif /* _DB_INDEX_H */ 116 117 #endif /* !_DB_INDEX_H_RPCGEN */ 118