xdbm.h revision 90926
133965Sjdp/*
233965Sjdp * Copyright (c) 1995 - 2001 Kungliga Tekniska H�gskolan
333965Sjdp * (Royal Institute of Technology, Stockholm, Sweden).
433965Sjdp * All rights reserved.
533965Sjdp *
633965Sjdp * Redistribution and use in source and binary forms, with or without
733965Sjdp * modification, are permitted provided that the following conditions
833965Sjdp * are met:
933965Sjdp *
1033965Sjdp * 1. Redistributions of source code must retain the above copyright
1133965Sjdp *    notice, this list of conditions and the following disclaimer.
1233965Sjdp *
1333965Sjdp * 2. Redistributions in binary form must reproduce the above copyright
1433965Sjdp *    notice, this list of conditions and the following disclaimer in the
1533965Sjdp *    documentation and/or other materials provided with the distribution.
1633965Sjdp *
1733965Sjdp * 3. Neither the name of the Institute nor the names of its contributors
1833965Sjdp *    may be used to endorse or promote products derived from this software
1933965Sjdp *    without specific prior written permission.
2033965Sjdp *
2133965Sjdp * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
2233965Sjdp * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2333965Sjdp * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2433965Sjdp * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
2533965Sjdp * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2633965Sjdp * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2733965Sjdp * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2833965Sjdp * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2933965Sjdp * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3033965Sjdp * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3133965Sjdp * SUCH DAMAGE.
3233965Sjdp */
3333965Sjdp
3433965Sjdp/* $Id: xdbm.h,v 1.14 2001/09/03 05:03:00 assar Exp $ */
3533965Sjdp
3633965Sjdp/* Generic *dbm include file */
3733965Sjdp
3833965Sjdp#ifndef __XDBM_H__
3933965Sjdp#define __XDBM_H__
4033965Sjdp
4133965Sjdp#if HAVE_DB_NDBM
4233965Sjdp#define DB_DBM_HSEARCH 1
4333965Sjdp#include <db.h>
4433965Sjdp#elif HAVE_NDBM
4533965Sjdp#if defined(HAVE_GDBM_NDBM_H)
4633965Sjdp#include <gdbm/ndbm.h>
4733965Sjdp#elif defined(HAVE_NDBM_H)
4833965Sjdp#include <ndbm.h>
4933965Sjdp#elif defined(HAVE_DBM_H)
5033965Sjdp#include <dbm.h>
5133965Sjdp#endif
5233965Sjdp#endif /* HAVE_NDBM */
5333965Sjdp
5433965Sjdp#if 0
5533965Sjdp/* Macros to convert ndbm names to dbm names.
5633965Sjdp * Note that dbm_nextkey() cannot be simply converted using a macro, since
5733965Sjdp * it is invoked giving the database, and nextkey() needs the previous key.
5833965Sjdp *
5933965Sjdp * Instead, all routines call "dbm_next" instead.
6033965Sjdp */
6133965Sjdp
6233965Sjdp#if !defined(NDBM) && !defined(HAVE_DB_H)
6333965Sjdptypedef char DBM;
6433965Sjdp
6533965Sjdp#define dbm_open(file, flags, mode) ((dbminit(file) == 0)?"":((char *)0))
6633965Sjdp#define dbm_fetch(db, key) fetch(key)
6733965Sjdp#define dbm_store(db, key, content, flag) store(key, content)
6833965Sjdp#define dbm_delete(db, key) delete(key)
6933965Sjdp#define dbm_firstkey(db) firstkey()
7033965Sjdp#define dbm_next(db,key) nextkey(key)
7133965Sjdp#define dbm_close(db) dbmclose()
7233965Sjdp#else
7333965Sjdp#define dbm_next(db,key) dbm_nextkey(db)
7433965Sjdp#endif
7533965Sjdp#endif
7633965Sjdp
7733965Sjdp#endif /* __XDBM_H__ */
7833965Sjdp