xdbm.h revision 57416
1189251Ssam/*
2189251Ssam * Copyright (c) 1995 - 2000 Kungliga Tekniska H�gskolan
3214734Srpaulo * (Royal Institute of Technology, Stockholm, Sweden).
4189251Ssam * All rights reserved.
5189251Ssam *
6189251Ssam * Redistribution and use in source and binary forms, with or without
7189251Ssam * modification, are permitted provided that the following conditions
8189251Ssam * are met:
9189251Ssam *
10189251Ssam * 1. Redistributions of source code must retain the above copyright
11189251Ssam *    notice, this list of conditions and the following disclaimer.
12189251Ssam *
13189251Ssam * 2. Redistributions in binary form must reproduce the above copyright
14189251Ssam *    notice, this list of conditions and the following disclaimer in the
15189251Ssam *    documentation and/or other materials provided with the distribution.
16189251Ssam *
17189251Ssam * 3. Neither the name of the Institute nor the names of its contributors
18189251Ssam *    may be used to endorse or promote products derived from this software
19214734Srpaulo *    without specific prior written permission.
20189251Ssam *
21189251Ssam * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
22189251Ssam * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23189251Ssam * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24189251Ssam * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
25189251Ssam * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26189251Ssam * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27189251Ssam * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28189251Ssam * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29189251Ssam * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30189251Ssam * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31189251Ssam * SUCH DAMAGE.
32189251Ssam */
33189251Ssam
34189251Ssam/* $Id: xdbm.h,v 1.8 2000/02/06 05:03:27 assar Exp $ */
35189251Ssam
36189251Ssam/* Generic *dbm include file */
37189251Ssam
38189251Ssam#ifndef __XDBM_H__
39189251Ssam#define __XDBM_H__
40189251Ssam
41189251Ssam#if defined(HAVE_DB_H)
42189251Ssam#define DB_DBM_HSEARCH 1
43189251Ssam#include <db.h>
44189251Ssam#endif
45189251Ssam
46189251Ssam#if defined(HAVE_NDBM_H)
47189251Ssam#include <ndbm.h>
48189251Ssam#elif defined(HAVE_DBM_H)
49189251Ssam#include <dbm.h>
50189251Ssam#elif defined(HAVE_RPCSVC_DBM_H)
51189251Ssam#include <rpcsvc/dbm.h>
52189251Ssam#endif
53189251Ssam
54189251Ssam/* Macros to convert ndbm names to dbm names.
55189251Ssam * Note that dbm_nextkey() cannot be simply converted using a macro, since
56189251Ssam * it is invoked giving the database, and nextkey() needs the previous key.
57189251Ssam *
58189251Ssam * Instead, all routines call "dbm_next" instead.
59189251Ssam */
60189251Ssam
61189251Ssam#ifndef NDBM
62189251Ssamtypedef char DBM;
63189251Ssam
64189251Ssam#define dbm_open(file, flags, mode) ((dbminit(file) == 0)?"":((char *)0))
65189251Ssam#define dbm_fetch(db, key) fetch(key)
66189251Ssam#define dbm_store(db, key, content, flag) store(key, content)
67189251Ssam#define dbm_delete(db, key) delete(key)
68189251Ssam#define dbm_firstkey(db) firstkey()
69189251Ssam#define dbm_next(db,key) nextkey(key)
70189251Ssam#define dbm_close(db) dbmclose()
71214734Srpaulo#else
72214734Srpaulo#define dbm_next(db,key) dbm_nextkey(db)
73214734Srpaulo#endif
74214734Srpaulo
75214734Srpaulo#endif /* __XDBM_H__ */
76214734Srpaulo