xref: /netbsd-src/usr.sbin/ypserv/common/ypdb.h (revision cea4b7cdfd41c75330a62e1d31727a6ffccb2dc7)
1*cea4b7cdSlukem /*	$NetBSD: ypdb.h,v 1.5 2008/02/29 03:00:47 lukem Exp $	*/
260aa689cSthorpej 
360aa689cSthorpej /*
460aa689cSthorpej  * Copyright (c) 1990, 1993
560aa689cSthorpej  *	The Regents of the University of California.  All rights reserved.
660aa689cSthorpej  * All rights reserved.
760aa689cSthorpej  *
860aa689cSthorpej  * This code is derived from software contributed to Berkeley by
960aa689cSthorpej  * Margo Seltzer.
1060aa689cSthorpej  *
1160aa689cSthorpej  * This code is derived from ndbm module of BSD4.4 db (hash) by
1260aa689cSthorpej  * Mats O Jansson
1360aa689cSthorpej  *
1460aa689cSthorpej  * Redistribution and use in source and binary forms, with or without
1560aa689cSthorpej  * modification, are permitted provided that the following conditions
1660aa689cSthorpej  * are met:
1760aa689cSthorpej  * 1. Redistributions of source code must retain the above copyright
1860aa689cSthorpej  *    notice, this list of conditions and the following disclaimer.
1960aa689cSthorpej  * 2. Redistributions in binary form must reproduce the above copyright
2060aa689cSthorpej  *    notice, this list of conditions and the following disclaimer in the
2160aa689cSthorpej  *    documentation and/or other materials provided with the distribution.
22326b2259Sagc  * 3. Neither the name of the University nor the names of its contributors
2360aa689cSthorpej  *    may be used to endorse or promote products derived from this software
2460aa689cSthorpej  *    without specific prior written permission.
2560aa689cSthorpej  *
2660aa689cSthorpej  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
2760aa689cSthorpej  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
2860aa689cSthorpej  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2960aa689cSthorpej  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
3060aa689cSthorpej  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3160aa689cSthorpej  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3260aa689cSthorpej  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3360aa689cSthorpej  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3460aa689cSthorpej  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3560aa689cSthorpej  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3660aa689cSthorpej  * SUCH DAMAGE.
3760aa689cSthorpej  */
3860aa689cSthorpej 
3960aa689cSthorpej #ifndef _YPDB_H_
4060aa689cSthorpej #define _YPDB_H_
4160aa689cSthorpej 
4260aa689cSthorpej #ifndef _DB_H_
4360aa689cSthorpej #include <db.h>
4460aa689cSthorpej #endif
4560aa689cSthorpej 
4660aa689cSthorpej #define YPDB_SUFFIX	".db"
4760aa689cSthorpej 
4860aa689cSthorpej /* Flags to ypdb_store(). */
4960aa689cSthorpej #define YPDB_INSERT      0
5060aa689cSthorpej #define YPDB_REPLACE     1
5160aa689cSthorpej 
5260aa689cSthorpej #ifndef DATUM
5360aa689cSthorpej typedef struct {
5460aa689cSthorpej 	char	*dptr;
5560aa689cSthorpej 	int	dsize;
5660aa689cSthorpej } datum;
5760aa689cSthorpej #define DATUM
5860aa689cSthorpej #endif
5960aa689cSthorpej 
6060aa689cSthorpej typedef DB DBM;
6160aa689cSthorpej 
6260aa689cSthorpej __BEGIN_DECLS
635c90fa67Swiz void	ypdb_close(DBM *);
645c90fa67Swiz int	ypdb_delete(DBM *, datum);
655c90fa67Swiz datum	ypdb_fetch(DBM *, datum);
665c90fa67Swiz datum	ypdb_firstkey(DBM *);
675c90fa67Swiz datum	ypdb_nextkey(DBM *);
685c90fa67Swiz datum	ypdb_setkey(DBM *, datum);
69*cea4b7cdSlukem DBM     *ypdb_open(const char *);
70*cea4b7cdSlukem DBM     *ypdb_mktemp(char *);
715c90fa67Swiz int	ypdb_store(DBM *, datum, datum, int);
7260aa689cSthorpej __END_DECLS
7360aa689cSthorpej 
7460aa689cSthorpej #endif /* !_YPDB_H_ */
75