xref: /openbsd-src/gnu/usr.bin/binutils/include/gdbm.h (revision 2159047f7a97bd07d66507696a8b038f6aef0509)
1*2159047fSniklas /* GNU DBM - DataBase Manager include file
2*2159047fSniklas    Copyright 1989, 1991  Free Software Foundation, Inc.
3*2159047fSniklas    Written by Philip A. Nelson.
4*2159047fSniklas 
5*2159047fSniklas This program is free software; you can redistribute it and/or modify
6*2159047fSniklas it under the terms of the GNU General Public License as published by
7*2159047fSniklas the Free Software Foundation; either version 2 of the License, or
8*2159047fSniklas (at your option) any later version.
9*2159047fSniklas 
10*2159047fSniklas This program is distributed in the hope that it will be useful,
11*2159047fSniklas but WITHOUT ANY WARRANTY; without even the implied warranty of
12*2159047fSniklas MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13*2159047fSniklas GNU General Public License for more details.
14*2159047fSniklas 
15*2159047fSniklas You should have received a copy of the GNU General Public License
16*2159047fSniklas along with this program; if not, write to the Free Software
17*2159047fSniklas Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
18*2159047fSniklas 
19*2159047fSniklas /* You may contact the author by:
20*2159047fSniklas        e-mail:  phil@wwu.edu
21*2159047fSniklas       us-mail:  Philip A. Nelson
22*2159047fSniklas                 Computer Science Department
23*2159047fSniklas                 Western Washington University
24*2159047fSniklas                 Bellingham, WA 98226
25*2159047fSniklas         phone:  (206) 676-3035
26*2159047fSniklas 
27*2159047fSniklas *************************************************************************/
28*2159047fSniklas 
29*2159047fSniklas /* Parameters to gdbm_open for READERS, WRITERS, and WRITERS who
30*2159047fSniklas    can create the database. */
31*2159047fSniklas #define  GDBM_READER  0
32*2159047fSniklas #define  GDBM_WRITER  1
33*2159047fSniklas #define  GDBM_WRCREAT 2
34*2159047fSniklas #define  GDBM_NEWDB   3
35*2159047fSniklas 
36*2159047fSniklas /* Parameters to gdbm_store for simple insertion or replacement. */
37*2159047fSniklas #define  GDBM_INSERT  0
38*2159047fSniklas #define  GDBM_REPLACE 1
39*2159047fSniklas 
40*2159047fSniklas 
41*2159047fSniklas /* The data and key structure.  This structure is defined for compatibility. */
42*2159047fSniklas typedef struct {
43*2159047fSniklas 	char *dptr;
44*2159047fSniklas 	int   dsize;
45*2159047fSniklas       } datum;
46*2159047fSniklas 
47*2159047fSniklas 
48*2159047fSniklas /* The file information header. This is good enough for most applications. */
49*2159047fSniklas typedef struct {int dummy[10];} *GDBM_FILE;
50*2159047fSniklas 
51*2159047fSniklas 
52*2159047fSniklas /* These are the routines! */
53*2159047fSniklas 
54*2159047fSniklas extern GDBM_FILE gdbm_open ();
55*2159047fSniklas 
56*2159047fSniklas extern void	 gdbm_close ();
57*2159047fSniklas 
58*2159047fSniklas extern datum	 gdbm_fetch ();
59*2159047fSniklas 
60*2159047fSniklas extern int	 gdbm_store ();
61*2159047fSniklas 
62*2159047fSniklas extern int	 gdbm_delete ();
63*2159047fSniklas 
64*2159047fSniklas extern datum	 gdbm_firstkey ();
65*2159047fSniklas 
66*2159047fSniklas extern datum	 gdbm_nextkey ();
67*2159047fSniklas 
68*2159047fSniklas extern int	 gdbm_reorganize ();
69*2159047fSniklas 
70*2159047fSniklas 
71*2159047fSniklas /* gdbm sends back the following error codes in the variable gdbm_errno. */
72*2159047fSniklas typedef enum {	NO_ERROR,
73*2159047fSniklas 		MALLOC_ERROR,
74*2159047fSniklas 		BLOCK_SIZE_ERROR,
75*2159047fSniklas 		FILE_OPEN_ERROR,
76*2159047fSniklas 		FILE_WRITE_ERROR,
77*2159047fSniklas 		FILE_SEEK_ERROR,
78*2159047fSniklas 		FILE_READ_ERROR,
79*2159047fSniklas 		BAD_MAGIC_NUMBER,
80*2159047fSniklas 		EMPTY_DATABASE,
81*2159047fSniklas 		CANT_BE_READER,
82*2159047fSniklas 	        CANT_BE_WRITER,
83*2159047fSniklas 		READER_CANT_RECOVER,
84*2159047fSniklas 		READER_CANT_DELETE,
85*2159047fSniklas 		READER_CANT_STORE,
86*2159047fSniklas 		READER_CANT_REORGANIZE,
87*2159047fSniklas 		UNKNOWN_UPDATE,
88*2159047fSniklas 		ITEM_NOT_FOUND,
89*2159047fSniklas 		REORGANIZE_FAILED,
90*2159047fSniklas 		CANNOT_REPLACE}
91*2159047fSniklas 	gdbm_error;
92