xref: /csrg-svn/old/libndbm/ndbm.h (revision 48499)
1*48499Sbostic /*-
2*48499Sbostic  * Copyright (c) 1983 The Regents of the University of California.
3*48499Sbostic  * All rights reserved.
4*48499Sbostic  *
5*48499Sbostic  * %sccs.include.proprietary.c%
6*48499Sbostic  *
7*48499Sbostic  *	@(#)ndbm.h	5.2 (Berkeley) 04/22/91
8*48499Sbostic  */
9*48499Sbostic 
1048498Sbostic /*
11*48499Sbostic  * Derived from:
1248498Sbostic  *
1348498Sbostic  *	@(#)ndbm.h	5.3 (Berkeley) 5/29/90
1448498Sbostic  */
1548498Sbostic 
1648498Sbostic /*
1748498Sbostic  * Hashed key data base library.
1848498Sbostic  */
1948498Sbostic #define PBLKSIZ 1024
2048498Sbostic #define DBLKSIZ 4096
2148498Sbostic 
2248498Sbostic typedef struct {
2348498Sbostic 	int	dbm_dirf;		/* open directory file */
2448498Sbostic 	int	dbm_pagf;		/* open page file */
2548498Sbostic 	int	dbm_flags;		/* flags, see below */
2648498Sbostic 	long	dbm_maxbno;		/* last ``bit'' in dir file */
2748498Sbostic 	long	dbm_bitno;		/* current bit number */
2848498Sbostic 	long	dbm_hmask;		/* hash mask */
2948498Sbostic 	long	dbm_blkptr;		/* current block for dbm_nextkey */
3048498Sbostic 	int	dbm_keyptr;		/* current key for dbm_nextkey */
3148498Sbostic 	long	dbm_blkno;		/* current page to read/write */
3248498Sbostic 	long	dbm_pagbno;		/* current page in pagbuf */
3348498Sbostic 	char	dbm_pagbuf[PBLKSIZ];	/* page file block buffer */
3448498Sbostic 	long	dbm_dirbno;		/* current block in dirbuf */
3548498Sbostic 	char	dbm_dirbuf[DBLKSIZ];	/* directory file block buffer */
3648498Sbostic } DBM;
3748498Sbostic 
3848498Sbostic #define _DBM_RDONLY	0x1	/* data base open read-only */
3948498Sbostic #define _DBM_IOERR	0x2	/* data base I/O error */
4048498Sbostic 
4148498Sbostic #define dbm_rdonly(db)	((db)->dbm_flags & _DBM_RDONLY)
4248498Sbostic 
4348498Sbostic #define dbm_error(db)	((db)->dbm_flags & _DBM_IOERR)
4448498Sbostic 	/* use this one at your own risk! */
4548498Sbostic #define dbm_clearerr(db)	((db)->dbm_flags &= ~_DBM_IOERR)
4648498Sbostic 
4748498Sbostic /* for flock(2) and fstat(2) */
4848498Sbostic #define dbm_dirfno(db)	((db)->dbm_dirf)
4948498Sbostic #define dbm_pagfno(db)	((db)->dbm_pagf)
5048498Sbostic 
5148498Sbostic typedef struct {
5248498Sbostic 	char	*dptr;
5348498Sbostic 	int	dsize;
5448498Sbostic } datum;
5548498Sbostic 
5648498Sbostic /*
5748498Sbostic  * flags to dbm_store()
5848498Sbostic  */
5948498Sbostic #define DBM_INSERT	0
6048498Sbostic #define DBM_REPLACE	1
6148498Sbostic 
6248498Sbostic #if __STDC__ || c_plusplus
6348498Sbostic extern DBM *dbm_open(const char *, int, int);
6448498Sbostic extern void dbm_close(DBM *);
6548498Sbostic extern datum dbm_fetch(DBM *, datum);
6648498Sbostic extern datum dbm_firstkey(DBM *);
6748498Sbostic extern datum dbm_nextkey(DBM *);
6848498Sbostic extern long dbm_forder(DBM *, datum);
6948498Sbostic extern int dbm_delete(DBM *, datum);
7048498Sbostic extern int dbm_store(DBM *, datum, datum, int);
7148498Sbostic #else
7248498Sbostic extern DBM *dbm_open();
7348498Sbostic extern void dbm_close();
7448498Sbostic extern datum dbm_fetch();
7548498Sbostic extern datum dbm_firstkey();
7648498Sbostic extern datum dbm_nextkey();
7748498Sbostic extern long dbm_forder();
7848498Sbostic extern int dbm_delete();
7948498Sbostic extern int dbm_store();
8048498Sbostic #endif
81