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