xref: /minix3/include/ndbm.h (revision 2fe8fb192fe7e8720e3e7a77f928da545e872a6a)
14fcd3413SBen Gras /*	$NetBSD: ndbm.h,v 1.15 2010/02/03 15:34:40 roy Exp $	*/
24fcd3413SBen Gras 
34fcd3413SBen Gras /*-
44fcd3413SBen Gras  * Copyright (c) 1990, 1993
54fcd3413SBen Gras  *	The Regents of the University of California.  All rights reserved.
64fcd3413SBen Gras  *
74fcd3413SBen Gras  * This code is derived from software contributed to Berkeley by
84fcd3413SBen Gras  * Margo Seltzer.
94fcd3413SBen Gras  *
104fcd3413SBen Gras  * Redistribution and use in source and binary forms, with or without
114fcd3413SBen Gras  * modification, are permitted provided that the following conditions
124fcd3413SBen Gras  * are met:
134fcd3413SBen Gras  * 1. Redistributions of source code must retain the above copyright
144fcd3413SBen Gras  *    notice, this list of conditions and the following disclaimer.
154fcd3413SBen Gras  * 2. Redistributions in binary form must reproduce the above copyright
164fcd3413SBen Gras  *    notice, this list of conditions and the following disclaimer in the
174fcd3413SBen Gras  *    documentation and/or other materials provided with the distribution.
184fcd3413SBen Gras  * 3. Neither the name of the University nor the names of its contributors
194fcd3413SBen Gras  *    may be used to endorse or promote products derived from this software
204fcd3413SBen Gras  *    without specific prior written permission.
214fcd3413SBen Gras  *
224fcd3413SBen Gras  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
234fcd3413SBen Gras  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
244fcd3413SBen Gras  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
254fcd3413SBen Gras  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
264fcd3413SBen Gras  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
274fcd3413SBen Gras  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
284fcd3413SBen Gras  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
294fcd3413SBen Gras  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
304fcd3413SBen Gras  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
314fcd3413SBen Gras  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
324fcd3413SBen Gras  * SUCH DAMAGE.
334fcd3413SBen Gras  *
344fcd3413SBen Gras  *	@(#)ndbm.h	8.1 (Berkeley) 6/2/93
354fcd3413SBen Gras  */
364fcd3413SBen Gras 
374fcd3413SBen Gras #ifndef _NDBM_H_
384fcd3413SBen Gras #define	_NDBM_H_
394fcd3413SBen Gras 
404fcd3413SBen Gras #include <sys/cdefs.h>
414fcd3413SBen Gras #include <sys/featuretest.h>
424fcd3413SBen Gras #include <stdint.h>
434fcd3413SBen Gras #include <db.h>
444fcd3413SBen Gras 
454fcd3413SBen Gras #if defined(_NETBSD_SOURCE)
464fcd3413SBen Gras /* Map dbm interface onto db(3). */
474fcd3413SBen Gras #define DBM_RDONLY	O_RDONLY
484fcd3413SBen Gras #endif
494fcd3413SBen Gras 
504fcd3413SBen Gras /* Flags to dbm_store(). */
514fcd3413SBen Gras #define DBM_INSERT      0
524fcd3413SBen Gras #define DBM_REPLACE     1
534fcd3413SBen Gras 
54*2fe8fb19SBen Gras #if defined(_NETBSD_SOURCE)
554fcd3413SBen Gras /*
564fcd3413SBen Gras  * The db(3) support for ndbm(3) always appends this suffix to the
574fcd3413SBen Gras  * file name to avoid overwriting the user's original database.
584fcd3413SBen Gras  */
594fcd3413SBen Gras #define	DBM_SUFFIX	".db"
604fcd3413SBen Gras #endif
614fcd3413SBen Gras 
624fcd3413SBen Gras typedef struct {
634fcd3413SBen Gras 	void	*dptr;
644fcd3413SBen Gras 	size_t	 dsize;		/* XPG4.2 */
654fcd3413SBen Gras } datum;
664fcd3413SBen Gras 
674fcd3413SBen Gras typedef DB DBM;
68*2fe8fb19SBen Gras #if defined(_NETBSD_SOURCE)
694fcd3413SBen Gras #define	dbm_pagfno(a)	DBM_PAGFNO_NOT_AVAILABLE
704fcd3413SBen Gras #endif
714fcd3413SBen Gras 
72*2fe8fb19SBen Gras __BEGIN_DECLS
734fcd3413SBen Gras void	 dbm_close(DBM *);
744fcd3413SBen Gras DBM	*dbm_open(const char *, int, mode_t);
754fcd3413SBen Gras int	 dbm_error(DBM *);
764fcd3413SBen Gras int	 dbm_clearerr(DBM *);
77*2fe8fb19SBen Gras #if defined(_NETBSD_SOURCE)
784fcd3413SBen Gras int	 dbm_dirfno(DBM *);
794fcd3413SBen Gras #endif
80*2fe8fb19SBen Gras #ifndef __LIBC12_SOURCE__
814fcd3413SBen Gras int	 dbm_delete(DBM *, datum)		__RENAME(__dbm_delete13);
824fcd3413SBen Gras datum	 dbm_fetch(DBM *, datum)		__RENAME(__dbm_fetch13);
834fcd3413SBen Gras datum	 dbm_firstkey(DBM *)			__RENAME(__dbm_firstkey13);
844fcd3413SBen Gras datum	 dbm_nextkey(DBM *)			__RENAME(__dbm_nextkey13);
854fcd3413SBen Gras int	 dbm_store(DBM *, datum, datum, int)	__RENAME(__dbm_store13);
864fcd3413SBen Gras #endif
87*2fe8fb19SBen Gras __END_DECLS
884fcd3413SBen Gras 
894fcd3413SBen Gras #endif /* !_NDBM_H_ */
90