1 #ifndef INN_DBZ_H 2 #define INN_DBZ_H 1 3 4 /* Need the definition of HASH. */ 5 #include "inn/libinn.h" 6 #include "inn/portable-macros.h" 7 8 BEGIN_DECLS 9 10 /* This is the number of bytes of the md5 to actually store in 11 * the .pag file. This number directly effects the collision 12 * rate and memory usage. You can probably set this number as 13 * low as 5 w/o problems and some sites may want to set it as 14 * high as 8. Anything higher than that is probably not useful. 15 * Note at the internal hash size isn't the only factor that 16 * effects collision rate. The table index is used as an implicit 17 * part of the hash value stored also. 18 */ 19 #ifdef DO_TAGGED_HASH 20 #define DBZMAXKEY 255 21 #define DBZ_INTERNAL_HASH_SIZE 4 22 #else 23 #define DBZ_INTERNAL_HASH_SIZE 6 24 #endif 25 26 typedef enum {DBZSTORE_OK, DBZSTORE_EXISTS, DBZSTORE_ERROR} DBZSTORE_RESULT; 27 typedef enum {INCORE_NO, INCORE_MEM, INCORE_MMAP} dbz_incore_val; 28 29 typedef struct { 30 /* Whether to write to the filesystem in addition to updating the incore 31 copy. This will replace a single large write to disk when dbzsync is 32 called. */ 33 bool writethrough; 34 /* Whether to do hash lookups from disk, memory or a mmap'ed file */ 35 dbz_incore_val pag_incore; 36 dbz_incore_val exists_incore; 37 /* Whether dbzstore should update the database async or sync. This 38 is only applicable if you're not mmaping the database */ 39 bool nonblock; 40 } dbzoptions; 41 42 #if !defined(lint) && (defined(__SUNPRO_C) || defined(_nec_ews)) 43 #pragma pack(1) 44 #endif /* nor lint, nor __SUNPRO_C, nor sgi, nor _nec_ews */ 45 /* Leave the __attribute__ ((__packed__)) on there because removing it 46 * might change the layout of the data structure on disk on some platform, 47 * thus invalidating old history files. 48 * It is fairly unlikely that this is a problem, though. 49 */ 50 typedef struct { 51 char hash[DBZ_INTERNAL_HASH_SIZE]; 52 } __attribute__ ((__packed__)) erec; 53 #if !defined(lint) && (defined(__SUNPRO_C) || defined(_nec_ews)) 54 #pragma pack() 55 #endif /* nor lint, nor__SUNPRO_C, nor _nec_ews */ 56 57 /* standard dbm functions */ 58 extern bool dbzinit(const char *name); 59 extern bool dbzclose(void); 60 61 /* new stuff for dbz */ 62 extern bool dbzfresh(const char *name, off_t size); 63 extern bool dbzagain(const char *name, const char *oldname); 64 extern bool dbzexists(const HASH key); 65 extern bool dbzfetch(const HASH key, off_t *value); 66 extern DBZSTORE_RESULT dbzstore(const HASH key, off_t data); 67 extern bool dbzsync(void); 68 extern long dbzsize(off_t contents); 69 extern void dbzsetoptions(const dbzoptions options); 70 extern void dbzgetoptions(dbzoptions *options); 71 72 #ifdef DBZTEST 73 extern int timediffms(struct timeval start, struct timeval end); 74 extern void RemoveDBZ(char *filename); 75 #endif /* DBZTEST */ 76 77 END_DECLS 78 79 #endif /* INN_DBZ_H */ 80