1 /* ndbm.h  -  The include file for ndbm users.  */
2 
3 /*  This file is part of GDBM, the GNU data base manager, by Philip A. Nelson.
4     Copyright (C) 1990-2021 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. If not, see <http://www.gnu.org/licenses/>.
18 
19     You may contact the author by:
20        e-mail:  phil@cs.wwu.edu
21       us-mail:  Philip A. Nelson
22                 Computer Science Department
23                 Western Washington University
24                 Bellingham, WA 98226
25 
26 *************************************************************************/
27 
28 #include <gdbm.h>
29 
30 /* Parameters to dbm_store for simple insertion or replacement. */
31 #define DBM_INSERT  GDBM_INSERT
32 #define DBM_REPLACE GDBM_REPLACE
33 
34 /* The file information header.  */
35 typedef struct
36 {
37   GDBM_FILE file;         /* Actual gdbm file (held in the .pag file */
38   int dirfd;              /* Descriptor of the .dir file */
39   datum _dbm_memory;      /* Keeps the last returned key */
40   char *_dbm_fetch_val;   /* Keeps the dptr of the last fetched datum */
41   gdbm_error _dbm_errno;  /* Error code from the last failed call */
42 } DBM;
43 
44 /* Used internally by the library */
45 #define __gdbm_error_to_ndbm(dbm)				\
46   do								\
47     {								\
48       if (gdbm_errno && gdbm_errno != GDBM_ITEM_NOT_FOUND)	\
49 	(dbm)->_dbm_errno = gdbm_errno;				\
50     }								\
51   while (0)
52 
53 /* These are the routines */
54 
55 extern DBM 	*dbm_open (char *file, int flags, int mode);
56 extern void	 dbm_close (DBM *dbf);
57 extern datum	 dbm_fetch (DBM *dbf, datum key);
58 extern int	 dbm_store (DBM *dbf, datum key, datum content, int flags);
59 extern int	 dbm_delete (DBM *dbf, datum key);
60 extern datum	 dbm_firstkey (DBM *dbf);
61 extern datum	 dbm_nextkey (DBM *dbf);
62 extern int       dbm_error (DBM *dbf);
63 extern void      dbm_clearerr (DBM *dbf);
64 extern int	 dbm_dirfno (DBM *dbf);
65 extern int	 dbm_pagfno (DBM *dbf);
66 extern int	 dbm_rdonly (DBM *dbf);
67