1*48498Sbostic /* 2*48498Sbostic * Copyright (c) 1983 Regents of the University of California. 3*48498Sbostic * All rights reserved. The Berkeley software License Agreement 4*48498Sbostic * specifies the terms and conditions for redistribution. 5*48498Sbostic * 6*48498Sbostic * @(#)ndbm.h 5.3 (Berkeley) 5/29/90 7*48498Sbostic */ 8*48498Sbostic 9*48498Sbostic /* 10*48498Sbostic * Hashed key data base library. 11*48498Sbostic */ 12*48498Sbostic #define PBLKSIZ 1024 13*48498Sbostic #define DBLKSIZ 4096 14*48498Sbostic 15*48498Sbostic typedef struct { 16*48498Sbostic int dbm_dirf; /* open directory file */ 17*48498Sbostic int dbm_pagf; /* open page file */ 18*48498Sbostic int dbm_flags; /* flags, see below */ 19*48498Sbostic long dbm_maxbno; /* last ``bit'' in dir file */ 20*48498Sbostic long dbm_bitno; /* current bit number */ 21*48498Sbostic long dbm_hmask; /* hash mask */ 22*48498Sbostic long dbm_blkptr; /* current block for dbm_nextkey */ 23*48498Sbostic int dbm_keyptr; /* current key for dbm_nextkey */ 24*48498Sbostic long dbm_blkno; /* current page to read/write */ 25*48498Sbostic long dbm_pagbno; /* current page in pagbuf */ 26*48498Sbostic char dbm_pagbuf[PBLKSIZ]; /* page file block buffer */ 27*48498Sbostic long dbm_dirbno; /* current block in dirbuf */ 28*48498Sbostic char dbm_dirbuf[DBLKSIZ]; /* directory file block buffer */ 29*48498Sbostic } DBM; 30*48498Sbostic 31*48498Sbostic #define _DBM_RDONLY 0x1 /* data base open read-only */ 32*48498Sbostic #define _DBM_IOERR 0x2 /* data base I/O error */ 33*48498Sbostic 34*48498Sbostic #define dbm_rdonly(db) ((db)->dbm_flags & _DBM_RDONLY) 35*48498Sbostic 36*48498Sbostic #define dbm_error(db) ((db)->dbm_flags & _DBM_IOERR) 37*48498Sbostic /* use this one at your own risk! */ 38*48498Sbostic #define dbm_clearerr(db) ((db)->dbm_flags &= ~_DBM_IOERR) 39*48498Sbostic 40*48498Sbostic /* for flock(2) and fstat(2) */ 41*48498Sbostic #define dbm_dirfno(db) ((db)->dbm_dirf) 42*48498Sbostic #define dbm_pagfno(db) ((db)->dbm_pagf) 43*48498Sbostic 44*48498Sbostic typedef struct { 45*48498Sbostic char *dptr; 46*48498Sbostic int dsize; 47*48498Sbostic } datum; 48*48498Sbostic 49*48498Sbostic /* 50*48498Sbostic * flags to dbm_store() 51*48498Sbostic */ 52*48498Sbostic #define DBM_INSERT 0 53*48498Sbostic #define DBM_REPLACE 1 54*48498Sbostic 55*48498Sbostic #if __STDC__ || c_plusplus 56*48498Sbostic extern DBM *dbm_open(const char *, int, int); 57*48498Sbostic extern void dbm_close(DBM *); 58*48498Sbostic extern datum dbm_fetch(DBM *, datum); 59*48498Sbostic extern datum dbm_firstkey(DBM *); 60*48498Sbostic extern datum dbm_nextkey(DBM *); 61*48498Sbostic extern long dbm_forder(DBM *, datum); 62*48498Sbostic extern int dbm_delete(DBM *, datum); 63*48498Sbostic extern int dbm_store(DBM *, datum, datum, int); 64*48498Sbostic #else 65*48498Sbostic extern DBM *dbm_open(); 66*48498Sbostic extern void dbm_close(); 67*48498Sbostic extern datum dbm_fetch(); 68*48498Sbostic extern datum dbm_firstkey(); 69*48498Sbostic extern datum dbm_nextkey(); 70*48498Sbostic extern long dbm_forder(); 71*48498Sbostic extern int dbm_delete(); 72*48498Sbostic extern int dbm_store(); 73*48498Sbostic #endif 74