xref: /netbsd-src/include/ndbm.h (revision 98eb889579a5572baa8ffa4149f58180870bc0ce)
1*98eb8895Sroy /*	$NetBSD: ndbm.h,v 1.15 2010/02/03 15:34:40 roy Exp $	*/
24d2cbfceScgd 
361f28255Scgd /*-
470a04c5aScgd  * Copyright (c) 1990, 1993
570a04c5aScgd  *	The Regents of the University of California.  All rights reserved.
661f28255Scgd  *
761f28255Scgd  * This code is derived from software contributed to Berkeley by
861f28255Scgd  * Margo Seltzer.
961f28255Scgd  *
1061f28255Scgd  * Redistribution and use in source and binary forms, with or without
1161f28255Scgd  * modification, are permitted provided that the following conditions
1261f28255Scgd  * are met:
1361f28255Scgd  * 1. Redistributions of source code must retain the above copyright
1461f28255Scgd  *    notice, this list of conditions and the following disclaimer.
1561f28255Scgd  * 2. Redistributions in binary form must reproduce the above copyright
1661f28255Scgd  *    notice, this list of conditions and the following disclaimer in the
1761f28255Scgd  *    documentation and/or other materials provided with the distribution.
18039cc956Sagc  * 3. Neither the name of the University nor the names of its contributors
1961f28255Scgd  *    may be used to endorse or promote products derived from this software
2061f28255Scgd  *    without specific prior written permission.
2161f28255Scgd  *
2261f28255Scgd  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2361f28255Scgd  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2461f28255Scgd  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2561f28255Scgd  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2661f28255Scgd  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2761f28255Scgd  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2861f28255Scgd  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2961f28255Scgd  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3061f28255Scgd  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3161f28255Scgd  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3261f28255Scgd  * SUCH DAMAGE.
3361f28255Scgd  *
344d2cbfceScgd  *	@(#)ndbm.h	8.1 (Berkeley) 6/2/93
3561f28255Scgd  */
3661f28255Scgd 
3761f28255Scgd #ifndef _NDBM_H_
3861f28255Scgd #define	_NDBM_H_
3961f28255Scgd 
40813b1610Sad #include <sys/cdefs.h>
4162bbd8eeSkleink #include <sys/featuretest.h>
42*98eb8895Sroy #include <stdint.h>
4361f28255Scgd #include <db.h>
4461f28255Scgd 
454be7a2dcSbjh21 #if defined(_NETBSD_SOURCE)
4661f28255Scgd /* Map dbm interface onto db(3). */
4761f28255Scgd #define DBM_RDONLY	O_RDONLY
4862bbd8eeSkleink #endif
4961f28255Scgd 
5061f28255Scgd /* Flags to dbm_store(). */
5161f28255Scgd #define DBM_INSERT      0
5261f28255Scgd #define DBM_REPLACE     1
5361f28255Scgd 
544be7a2dcSbjh21 #if defined(_NETBSD_SOURCE)
5561f28255Scgd /*
5661f28255Scgd  * The db(3) support for ndbm(3) always appends this suffix to the
5761f28255Scgd  * file name to avoid overwriting the user's original database.
5861f28255Scgd  */
5961f28255Scgd #define	DBM_SUFFIX	".db"
6062bbd8eeSkleink #endif
6161f28255Scgd 
6261f28255Scgd typedef struct {
6362bbd8eeSkleink 	void	*dptr;
64dbfbef89Skleink 	size_t	 dsize;		/* XPG4.2 */
6561f28255Scgd } datum;
6661f28255Scgd 
6761f28255Scgd typedef DB DBM;
684be7a2dcSbjh21 #if defined(_NETBSD_SOURCE)
69e75cc16eSproven #define	dbm_pagfno(a)	DBM_PAGFNO_NOT_AVAILABLE
7062bbd8eeSkleink #endif
7161f28255Scgd 
7261f28255Scgd __BEGIN_DECLS
73cd7b32a9Skleink void	 dbm_close(DBM *);
74cd7b32a9Skleink DBM	*dbm_open(const char *, int, mode_t);
75cd7b32a9Skleink int	 dbm_error(DBM *);
76cd7b32a9Skleink int	 dbm_clearerr(DBM *);
774be7a2dcSbjh21 #if defined(_NETBSD_SOURCE)
78cd7b32a9Skleink int	 dbm_dirfno(DBM *);
7962bbd8eeSkleink #endif
8066412e72Schristos #ifndef __LIBC12_SOURCE__
81dbfbef89Skleink int	 dbm_delete(DBM *, datum)		__RENAME(__dbm_delete13);
82dbfbef89Skleink datum	 dbm_fetch(DBM *, datum)		__RENAME(__dbm_fetch13);
83dbfbef89Skleink datum	 dbm_firstkey(DBM *)			__RENAME(__dbm_firstkey13);
84dbfbef89Skleink datum	 dbm_nextkey(DBM *)			__RENAME(__dbm_nextkey13);
85dbfbef89Skleink int	 dbm_store(DBM *, datum, datum, int)	__RENAME(__dbm_store13);
86dbfbef89Skleink #endif
8761f28255Scgd __END_DECLS
8861f28255Scgd 
8961f28255Scgd #endif /* !_NDBM_H_ */
90