sdbm.h revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* sdbm - ndbm work-alike hashed database library
* based on Per-Ake Larson's Dynamic Hashing algorithms. BIT 18 (1978).
* author: oz@nexus.yorku.ca
* status: public domain.
*/
#define DBLKSIZ 4096
#define PBLKSIZ 1024
/* for a single insertion */
#ifdef VMS
#define DIRFEXT ".sdbm_dir"
#else
#define DIRFEXT ".dir"
#endif
#define PAGFEXT ".pag"
typedef struct {
int dirf; /* directory file descriptor */
int pagf; /* page file descriptor */
long maxbno; /* size of dirfile in bits */
long curbit; /* current bit number */
long hmask; /* current hash mask */
long blkptr; /* current block for nextkey */
int keyptr; /* current key for nextkey */
long pagbno; /* current page in pagbuf */
long dirbno; /* current block in dirbuf */
} DBM;
/*
* utility macros
*/
typedef struct {
char *dptr;
int dsize;
} datum;
#ifdef DOINIT
= {0, 0}
#endif
;
#define proto(p) p
#else
#define proto(p) ()
#endif
/*
* flags to sdbm_store
*/
#define DBM_INSERT 0
#define DBM_REPLACE 1
/*
* ndbm interface
*/
/*
* other
*/
#ifndef SDBM_ONLY
#define dbm_close sdbm_close
#define dbm_fetch sdbm_fetch
#define dbm_store sdbm_store
#define dbm_delete sdbm_delete
#define dbm_firstkey sdbm_firstkey
#define dbm_nextkey sdbm_nextkey
#define dbm_error sdbm_error
#define dbm_clearerr sdbm_clearerr
#endif
/* Most of the following is stolen from perl.h. We don't include
not everything else.
*/
#ifndef H_PERL /* Include guard */
#include "embed.h" /* Follow all the global renamings. */
/*
* The following contortions are brought to you on behalf of all the
* standards, semi-standards, de facto standards, not-so-de-facto standards
* of the world, as well as all the other botches anyone ever thought of.
* The basic theory is that if we work hard enough here, the rest of the
* code can be a lot prettier. Well, so much for theory. Sorry, Henry...
*/
#include <errno.h>
#ifdef HAS_SOCKET
# ifdef I_NET_ERRNO
# endif
#endif
# define STANDARD_C 1
#endif
#include <stdio.h>
#include <ctype.h>
#include <setjmp.h>
#if defined(I_UNISTD)
#include <unistd.h>
#endif
#ifdef VMS
# include <file.h>
# include <unixio.h>
#endif
#ifdef I_SYS_PARAM
# ifdef PARAM_NEEDS_TYPES
# endif
# endif
#endif
# endif
#endif
#ifndef SEEK_SET
# ifdef L_SET
# else
# define SEEK_SET 0 /* Wild guess. */
# endif
#endif
/* Use all the "standard" definitions? */
#if defined(STANDARD_C) && defined(I_STDLIB)
# include <stdlib.h>
#endif /* STANDARD_C */
/* This comes after <stdlib.h> so we don't try to change the standard
* library prototypes; we'll use our own instead. */
#if defined(MYMALLOC) && !defined(PERL_POLLUTE_MALLOC)
# define malloc Perl_malloc
# define calloc Perl_calloc
# define realloc Perl_realloc
# define free Perl_mfree
#endif /* MYMALLOC */
#ifdef I_STRING
# ifndef __ultrix__
# include <string.h>
# endif
#else
# include <strings.h>
#endif
#ifdef I_MEMORY
#include <memory.h>
#endif
#ifdef __cplusplus
#define HAS_MEMCPY
#endif
#ifdef HAS_MEMCPY
# ifndef memcpy
# endif
# endif
#else
# ifndef memcpy
# ifdef HAS_BCOPY
# else
# endif
# endif
#endif /* HAS_MEMCPY */
#ifdef HAS_MEMSET
# ifndef memset
# endif
# endif
#else
# ifndef memzero
# ifdef HAS_BZERO
# else
# endif
# endif
#endif /* HAS_MEMSET */
#endif
#if defined(HAS_MEMCMP) && defined(HAS_SANE_MEMCMP)
# ifndef memcmp
# endif
# endif
# ifdef BUGGY_MSC
# endif
#else
# ifndef memcmp
/* maybe we should have included the full embedding header... */
# ifdef NO_EMBED
# else
# define memcmp Perl_my_memcmp
# endif
#ifndef __cplusplus
#endif
# endif
#endif /* HAS_MEMCMP */
#ifndef HAS_BCMP
# ifndef bcmp
# endif
#endif /* !HAS_BCMP */
#ifdef HAS_MEMCMP
#else
#endif
#ifdef I_NETINET_IN
# ifdef VMS
# include <in.h>
# else
# endif
#endif
#endif /* Include guard */