1/* gdbm.h  -  The include file for dbm users.  */
2
3/*  This file is part of GDBM, the GNU data base manager, by Philip A. Nelson.
4    Copyright (C) 1990, 1991, 1993  Free Software Foundation, Inc.
5
6    GDBM is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2, or (at your option)
9    any later version.
10
11    GDBM is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with GDBM; see the file COPYING.  If not, write to
18    the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
19
20    You may contact the author by:
21       e-mail:  phil@cs.wwu.edu
22      us-mail:  Philip A. Nelson
23                Computer Science Department
24                Western Washington University
25                Bellingham, WA 98226
26
27*************************************************************************/
28
29/* Protection for multiple includes. */
30#ifndef _GDBM_H_
31#define _GDBM_H_
32
33/* Parameters to gdbm_open for READERS, WRITERS, and WRITERS who
34   can create the database. */
35#define  GDBM_READER  0		/* A reader. */
36#define  GDBM_WRITER  1		/* A writer. */
37#define  GDBM_WRCREAT 2		/* A writer.  Create the db if needed. */
38#define  GDBM_NEWDB   3		/* A writer.  Always create a new db. */
39#define  GDBM_FAST    0x10	/* Write fast! => No fsyncs.  OBSOLETE. */
40#define  GDBM_SYNC    0x20	/* Sync operations to the disk. */
41#define  GDBM_NOLOCK  0x40	/* Don't do file locking operations. */
42
43/* Parameters to gdbm_store for simple insertion or replacement in the
44   case that the key is already in the database. */
45#define  GDBM_INSERT  0		/* Never replace old data with new. */
46#define  GDBM_REPLACE 1		/* Always replace old data with new. */
47
48/* Parameters to gdbm_setopt, specifing the type of operation to perform. */
49#define  GDBM_CACHESIZE 1       /* Set the cache size. */
50#define  GDBM_FASTMODE  2       /* Toggle fast mode.  OBSOLETE. */
51#define  GDBM_SYNCMODE	3	/* Turn on or off sync operations. */
52#define  GDBM_CENTFREE  4	/* Keep all free blocks in the header. */
53#define  GDBM_COALESCEBLKS 5	/* Attempt to coalesce free blocks. */
54
55/* The data and key structure.  This structure is defined for compatibility. */
56typedef struct {
57	char *dptr;
58	int   dsize;
59      } datum;
60
61
62/* The file information header. This is good enough for most applications. */
63typedef struct {int dummy[10];} *GDBM_FILE;
64
65/* Determine if the C(++) compiler requires complete function prototype  */
66#ifndef __P
67#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
68#define __P(x) x
69#else
70#define __P(x) ()
71#endif
72#endif
73
74/* External variable, the gdbm build release string. */
75extern char *gdbm_version;
76
77
78/* GDBM C++ support */
79#if defined(__cplusplus) || defined(c_plusplus)
80extern "C" {
81#endif
82
83/* These are the routines! */
84
85extern GDBM_FILE gdbm_open __P((char *, int, int, int, void (*)()));
86extern void gdbm_close __P((GDBM_FILE));
87extern int gdbm_store __P((GDBM_FILE, datum, datum, int));
88extern datum gdbm_fetch __P((GDBM_FILE, datum));
89extern int gdbm_delete __P((GDBM_FILE, datum));
90extern datum gdbm_firstkey __P((GDBM_FILE));
91extern datum gdbm_nextkey __P((GDBM_FILE, datum));
92extern int gdbm_reorganize __P((GDBM_FILE));
93extern void gdbm_sync __P((GDBM_FILE));
94extern int gdbm_exists __P((GDBM_FILE, datum));
95extern int gdbm_setopt __P((GDBM_FILE, int, int *, int));
96extern int gdbm_fdesc __P((GDBM_FILE));
97
98#if defined(__cplusplus) || defined(c_plusplus)
99}
100#endif
101
102#define	GDBM_NO_ERROR		0
103#define	GDBM_MALLOC_ERROR	1
104#define	GDBM_BLOCK_SIZE_ERROR	2
105#define	GDBM_FILE_OPEN_ERROR	3
106#define	GDBM_FILE_WRITE_ERROR	4
107#define	GDBM_FILE_SEEK_ERROR	5
108#define	GDBM_FILE_READ_ERROR	6
109#define	GDBM_BAD_MAGIC_NUMBER	7
110#define	GDBM_EMPTY_DATABASE	8
111#define	GDBM_CANT_BE_READER	9
112#define	GDBM_CANT_BE_WRITER	10
113#define	GDBM_READER_CANT_DELETE	11
114#define	GDBM_READER_CANT_STORE	12
115#define	GDBM_READER_CANT_REORGANIZE	13
116#define	GDBM_UNKNOWN_UPDATE	14
117#define	GDBM_ITEM_NOT_FOUND	15
118#define	GDBM_REORGANIZE_FAILED	16
119#define	GDBM_CANNOT_REPLACE	17
120#define	GDBM_ILLEGAL_DATA	18
121#define	GDBM_OPT_ALREADY_SET	19
122#define	GDBM_OPT_ILLEGAL	20
123typedef int gdbm_error;		/* For compatibilities sake. */
124extern gdbm_error gdbm_errno;
125
126/* extra prototypes */
127
128/* GDBM C++ support */
129#if defined(__cplusplus) || defined(c_plusplus)
130extern "C" {
131#endif
132
133extern char *gdbm_strerror __P((gdbm_error));
134
135#if defined(__cplusplus) || defined(c_plusplus)
136}
137#endif
138
139#endif
140