aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog45
-rw-r--r--compat/dbmclose.c2
-rw-r--r--compat/dbmdelete.c2
-rw-r--r--compat/dbmdirfno.c2
-rw-r--r--compat/dbmfetch.c2
-rw-r--r--compat/dbmopen.c21
-rw-r--r--compat/dbmpagfno.c2
-rw-r--r--compat/dbmrdonly.c2
-rw-r--r--compat/dbmseq.c4
-rw-r--r--compat/dbmstore.c2
-rw-r--r--src/bucket.c8
-rw-r--r--src/extern.h2
-rw-r--r--src/falloc.c20
-rw-r--r--src/findkey.c4
-rw-r--r--src/flatfile.c5
-rw-r--r--src/gdbmclose.c2
-rw-r--r--src/gdbmdelete.c3
-rw-r--r--src/gdbmexists.c3
-rw-r--r--src/gdbmfdesc.c2
-rw-r--r--src/gdbmfetch.c3
-rw-r--r--src/gdbmreorg.c5
-rw-r--r--src/gdbmseq.c9
-rw-r--r--src/gdbmsetopt.c3
-rw-r--r--src/gdbmstore.c3
-rw-r--r--src/gdbmsync.c3
-rw-r--r--src/global.c3
-rw-r--r--src/lock.c7
-rw-r--r--src/mmap.c19
-rw-r--r--src/testgdbm.c7
-rw-r--r--src/update.c8
30 files changed, 120 insertions, 83 deletions
diff --git a/ChangeLog b/ChangeLog
index 6e73b14..b1b789f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,51 @@
+2011-08-01 Sergey Poznyakoff <gray@gnu.org.ua>
+
+ * Makefile.am (ACLOCAL_AMFLAGS): New variable.
+ * configure.ac: Use AM_INIT_AUTOMAKE with arguments.
+
+ * src/gdbm.proto (GDBM_FILE): Change typedef.
+ * src/gdbmdefs.h: Include gdbm.h
+ (datum): Remove duplicate declaration.
+ (gdbm_file_info): Change to struct gdbm_file_info
+
+ * src/proto.h: Use GDBM_FILE instead of gdbm_file_info *.
+ Remove duplicate declarations.
+
+ * src/gdbmopen.c: Use GDBM_FILE instead of gdbm_file_info *.
+ (gdbm_open): Fix signature to match global declaration.
+
+ * compat/dbmclose.c: Use GDBM_FILE instead of gdbm_file_info *.
+ * compat/dbmdirfno.c: Likewise.
+ * compat/dbmfetch.c: Likewise.
+ * compat/dbmopen.c: Likewise.
+ * compat/dbmpagfno.c: Likewise.
+ * compat/dbmrdonly.c: Likewise.
+ * compat/dbmseq.c: Likewise.
+ * compat/dbmstore.c: Likewise.
+ * src/bucket.c: Likewise.
+ * src/extern.h: Likewise.
+ * src/falloc.c: Likewise.
+ * src/findkey.c: Likewise.
+ * src/flatfile.c: Likewise.
+ * src/gdbmclose.c: Likewise.
+ * src/gdbmdelete.c: Likewise.
+ * src/gdbmexists.c: Likewise.
+ * src/gdbmfdesc.c: Likewise.
+ * src/gdbmfetch.c: Likewise.
+ * src/gdbmreorg.c: Likewise.
+ * src/gdbmseq.c: Likewise.
+ * src/gdbmsetopt.c: Likewise.
+ * src/gdbmstore.c: Likewise.
+ * src/gdbmsync.c: Likewise.
+ * src/global.c: Likewise.
+ * src/lock.c: Likewise.
+ * src/mmap.c: Likewise.
+ * src/testgdbm.c: Likewise.
+ * src/update.c: Likewise.
+
2009-01-03 Sergey Poznyakoff <gray@gnu.org.ua>
* configure.ac: Update bug-reporting address.
* doc/gdbm.texinfo: Likewise.
* INSTALL, doc/version.texi: Remove automatically generated files.
diff --git a/compat/dbmclose.c b/compat/dbmclose.c
index 30626cc..c0c3f61 100644
--- a/compat/dbmclose.c
+++ b/compat/dbmclose.c
@@ -23,10 +23,10 @@
#include "gdbmdefs.h"
/* Close the DBF file. */
void
-dbm_close (gdbm_file_info *dbf)
+dbm_close (GDBM_FILE dbf)
{
gdbm_close (dbf);
}
diff --git a/compat/dbmdelete.c b/compat/dbmdelete.c
index f5b5d6b..c24d053 100644
--- a/compat/dbmdelete.c
+++ b/compat/dbmdelete.c
@@ -25,10 +25,10 @@
#include "extern.h"
/* Remove the KEYed item and the KEY from the database DBF. */
int
-dbm_delete (gdbm_file_info *dbf, datum key)
+dbm_delete (GDBM_FILE dbf, datum key)
{
return gdbm_delete (dbf,key);
}
diff --git a/compat/dbmdirfno.c b/compat/dbmdirfno.c
index ae22cc2..79d9c24 100644
--- a/compat/dbmdirfno.c
+++ b/compat/dbmdirfno.c
@@ -24,10 +24,10 @@
/* Return the file number of the DBF file. NDBM original wanted the .dir
file number. Since we have only one file number, we return it. */
int
-dbm_dirfno (gdbm_file_info *dbf)
+dbm_dirfno (GDBM_FILE dbf)
{
return (dbf->desc);
}
diff --git a/compat/dbmfetch.c b/compat/dbmfetch.c
index bb650a4..54784c4 100644
--- a/compat/dbmfetch.c
+++ b/compat/dbmfetch.c
@@ -26,13 +26,13 @@
/* NDBM Look up a given KEY and return the information associated with that
KEY. The pointer in the structure that is returned is a pointer to
dynamically allocated memory block. */
datum
-dbm_fetch (gdbm_file_info *dbf, datum key)
+dbm_fetch (GDBM_FILE dbf, datum key)
{
datum ret_val; /* The return value. */
/* Free previous dynamic memory, do actual call, and save pointer to new
memory. */
ret_val = gdbm_fetch (dbf, key);
diff --git a/compat/dbmopen.c b/compat/dbmopen.c
index 257da77..309d08f 100644
--- a/compat/dbmopen.c
+++ b/compat/dbmopen.c
@@ -39,21 +39,21 @@
FLAGS == O_RDONLY, it will be a GDBM_READER, if FLAGS == O_RDWR|O_CREAT,
it will be a GDBM_WRCREAT (creater and writer) and if the FLAGS == O_RDWR,
it will be a GDBM_WRITER and if FLAGS contain O_TRUNC then it will be
a GDBM_NEWDB. All other values of FLAGS in the flags are
ignored. */
-gdbm_file_info *
+GDBM_FILE
dbm_open (char *file, int flags, int mode)
{
char* pag_file; /* Used to construct "file.pag". */
char* dir_file; /* Used to construct "file.dir". */
struct stat dir_stat; /* Stat information for "file.dir". */
- gdbm_file_info *temp_dbf; /* Temporary file pointer storage. */
-
-
+ GDBM_FILE temp_dbf; /* Temporary file pointer storage. */
+ int open_flags;
+
/* Prepare the correct names of "file.pag" and "file.dir". */
pag_file = (char *) malloc (strlen (file)+5);
dir_file = (char *) malloc (strlen (file)+5);
if ((pag_file == NULL) || (dir_file == NULL))
{
gdbm_errno = GDBM_MALLOC_ERROR; /* For the hell of it. */
@@ -65,29 +65,34 @@ dbm_open (char *file, int flags, int mode)
strcpy (dir_file, file);
strcat (dir_file, ".dir");
/* Call the actual routine, saving the pointer to the file information. */
flags &= O_RDONLY | O_RDWR | O_CREAT | O_TRUNC;
+
if (flags == O_RDONLY)
{
- temp_dbf = gdbm_open (pag_file, 0, GDBM_READER, 0, NULL);
+ open_flags = GDBM_READER;
+ mode = 0;
}
else if (flags == (O_RDWR | O_CREAT))
{
- temp_dbf = gdbm_open (pag_file, 0, GDBM_WRCREAT, mode, NULL);
+ open_flags = GDBM_WRCREAT;
}
else if ( (flags & O_TRUNC) == O_TRUNC)
{
- temp_dbf = gdbm_open (pag_file, 0, GDBM_NEWDB, mode, NULL);
+ open_flags = GDBM_NEWDB;
}
else
{
- temp_dbf = gdbm_open (pag_file, 0, GDBM_WRITER, 0, NULL);
+ open_flags = GDBM_WRITER;
+ mode = 0;
}
+ temp_dbf = gdbm_open (pag_file, 0, open_flags | GDBM_NOLOCK, mode, NULL);
+
/* Did we successfully open the file? */
if (temp_dbf == NULL)
{
gdbm_errno = GDBM_FILE_OPEN_ERROR;
goto done;
}
diff --git a/compat/dbmpagfno.c b/compat/dbmpagfno.c
index ae9d8cb..8532c03 100644
--- a/compat/dbmpagfno.c
+++ b/compat/dbmpagfno.c
@@ -24,10 +24,10 @@
/* Return the file number of the DBF file. NDBM original wanted the .pag
file number. Since we have only one file number, we return it. */
int
-dbm_pagfno (gdbm_file_info *dbf)
+dbm_pagfno (GDBM_FILE dbf)
{
return (dbf->desc);
}
diff --git a/compat/dbmrdonly.c b/compat/dbmrdonly.c
index 14d89c7..33e3274 100644
--- a/compat/dbmrdonly.c
+++ b/compat/dbmrdonly.c
@@ -23,10 +23,10 @@
#include "gdbmdefs.h"
/* not much of a routine, but should be a function for compatibility. */
int
-dbm_rdonly(gdbm_file_info *dbf)
+dbm_rdonly(GDBM_FILE dbf)
{
return (dbf->read_write == GDBM_READER);
}
diff --git a/compat/dbmseq.c b/compat/dbmseq.c
index d702241..7e1bed5 100644
--- a/compat/dbmseq.c
+++ b/compat/dbmseq.c
@@ -27,13 +27,13 @@
/* NDBM Start the visit of all keys in the database. This produces
something in hash order, not in any sorted order. DBF is the dbm file
information pointer. */
datum
-dbm_firstkey (gdbm_file_info *dbf)
+dbm_firstkey (GDBM_FILE dbf)
{
datum ret_val;
/* Free previous dynamic memory, do actual call, and save pointer to new
memory. */
ret_val = gdbm_firstkey (dbf);
@@ -46,13 +46,13 @@ dbm_firstkey (gdbm_file_info *dbf)
/* NDBM Continue visiting all keys. The next key in the sequence is returned.
DBF is the file information pointer. */
datum
-dbm_nextkey (gdbm_file_info *dbf)
+dbm_nextkey (GDBM_FILE dbf)
{
datum ret_val;
/* Make sure we have a valid key. */
if (_gdbm_memory.dptr == NULL)
return _gdbm_memory;
diff --git a/compat/dbmstore.c b/compat/dbmstore.c
index ac102ea..9d904ff 100644
--- a/compat/dbmstore.c
+++ b/compat/dbmstore.c
@@ -26,10 +26,10 @@
/* NDBM add a new element to the database. CONTENT is keyed by KEY.
The file on disk is updated to reflect the structure of the new
database before returning from this procedure. */
int
-dbm_store (gdbm_file_info *dbf, datum key, datum content, int flags)
+dbm_store (GDBM_FILE dbf, datum key, datum content, int flags)
{
return gdbm_store (dbf, key, content, flags);
}
diff --git a/src/bucket.c b/src/bucket.c
index 2374d07..65a5405 100644
--- a/src/bucket.c
+++ b/src/bucket.c
@@ -22,13 +22,13 @@
#include "gdbmdefs.h"
/* Initializing a new hash buckets sets all bucket entries to -1 hash value. */
void
-_gdbm_new_bucket (gdbm_file_info *dbf, hash_bucket *bucket, int bits)
+_gdbm_new_bucket (GDBM_FILE dbf, hash_bucket *bucket, int bits)
{
int index;
/* Initialize the avail block. */
bucket->av_count = 0;
@@ -47,13 +47,13 @@ _gdbm_new_bucket (gdbm_file_info *dbf, hash_bucket *bucket, int bits)
location DIR_INDEX. The bucket cache is first checked to see if it
is already in memory. If not, a bucket may be tossed to read the new
bucket. In any case, the requested bucket is make the "current" bucket
and dbf->bucket points to the correct bucket. */
void
-_gdbm_get_bucket (gdbm_file_info *dbf, int dir_index)
+_gdbm_get_bucket (GDBM_FILE dbf, int dir_index)
{
off_t bucket_adr; /* The address of the correct hash bucket. */
int num_bytes; /* The number of bytes read. */
off_t file_pos; /* The return address for lseek. */
int index; /* Loop index. */
@@ -107,13 +107,13 @@ _gdbm_get_bucket (gdbm_file_info *dbf, int dir_index)
/* Split the current bucket. This includes moving all items in the bucket to
a new bucket. This doesn't require any disk reads because all hash values
are stored in the buckets. Splitting the current bucket may require
doubling the size of the hash directory. */
void
-_gdbm_split_bucket (gdbm_file_info *dbf, int next_insert)
+_gdbm_split_bucket (GDBM_FILE dbf, int next_insert)
{
hash_bucket *bucket[2]; /* Pointers to the new buckets. */
int new_bits; /* The number of bits for the new buckets. */
int cache_0; /* Location in the cache for the buckets. */
int cache_1;
@@ -298,13 +298,13 @@ _gdbm_split_bucket (gdbm_file_info *dbf, int next_insert)
/* The only place where a bucket is written. CA_ENTRY is the
cache entry containing the bucket to be written. */
void
-_gdbm_write_bucket (gdbm_file_info *dbf, cache_elem *ca_entry)
+_gdbm_write_bucket (GDBM_FILE dbf, cache_elem *ca_entry)
{
int num_bytes; /* The return value for write. */
off_t file_pos; /* The return value for lseek. */
file_pos = __lseek (dbf, ca_entry->ca_adr, L_SET);
if (file_pos != ca_entry->ca_adr)
diff --git a/src/extern.h b/src/extern.h
index 86029f1..43f180d 100644
--- a/src/extern.h
+++ b/src/extern.h
@@ -15,11 +15,11 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
/* The global variables used for the "original" interface. */
-extern gdbm_file_info *_gdbm_file;
+extern GDBM_FILE _gdbm_file;
/* Memory for return data for the "original" interface. */
extern datum _gdbm_memory;
extern char *_gdbm_fetch_val;
diff --git a/src/falloc.c b/src/falloc.c
index e18f597..27b7ba0 100644
--- a/src/falloc.c
+++ b/src/falloc.c
@@ -24,16 +24,16 @@
/* The forward definitions for this file. See the functions for
the definition of the function. */
static avail_elem get_elem (int, avail_elem [], int *);
-static avail_elem get_block (int, gdbm_file_info *);
-static void push_avail_block (gdbm_file_info *);
-static void pop_avail_block (gdbm_file_info *);
-static void adjust_bucket_avail (gdbm_file_info *);
+static avail_elem get_block (int, GDBM_FILE);
+static void push_avail_block (GDBM_FILE);
+static void pop_avail_block (GDBM_FILE);
+static void adjust_bucket_avail (GDBM_FILE);
/* Allocate space in the file DBF for a block NUM_BYTES in length. Return
the file address of the start of the block.
Each hash bucket has a fixed size avail table. We first check this
avail table to satisfy the request for space. In most cases we can
@@ -46,13 +46,13 @@ static void adjust_bucket_avail (gdbm_file_info *);
"guarantees" that an allocation does not cross a block boundary unless
the size is larger than a single block. The avail structure is
changed by this routine if a change is needed. If an error occurs,
the value of 0 will be returned. */
off_t
-_gdbm_alloc (gdbm_file_info *dbf, int num_bytes)
+_gdbm_alloc (GDBM_FILE dbf, int num_bytes)
{
off_t file_adr; /* The address of the block. */
avail_elem av_el; /* For temporary use. */
/* The current bucket is the first place to look for space. */
av_el = get_elem (num_bytes, dbf->bucket->bucket_avail,
@@ -94,13 +94,13 @@ _gdbm_alloc (gdbm_file_info *dbf, int num_bytes)
/* Free space of size NUM_BYTES in the file DBF at file address FILE_ADR. Make
it avaliable for reuse through _gdbm_alloc. This routine changes the
avail structure. */
void
-_gdbm_free (gdbm_file_info *dbf, off_t file_adr, int num_bytes)
+_gdbm_free (GDBM_FILE dbf, off_t file_adr, int num_bytes)
{
avail_elem temp;
/* Is it too small to worry about? */
if (num_bytes <= IGNORE_SIZE)
return;
@@ -153,13 +153,13 @@ _gdbm_free (gdbm_file_info *dbf, off_t file_adr, int num_bytes)
/* Gets the avail block at the top of the stack and loads it into the
active avail block. It does a "free" for itself! This can (and is)
now called even when the avail block is not empty, so we must be
smart about things. */
static void
-pop_avail_block (gdbm_file_info *dbf)
+pop_avail_block (GDBM_FILE dbf)
{
int num_bytes; /* For use with the read system call. */
off_t file_pos; /* For use with the lseek system call. */
avail_elem new_el;
avail_block *new_blk;
int index;
@@ -228,13 +228,13 @@ pop_avail_block (gdbm_file_info *dbf)
}
/* Splits the header avail block and pushes half onto the avail stack. */
static void
-push_avail_block (gdbm_file_info *dbf)
+push_avail_block (GDBM_FILE dbf)
{
int num_bytes;
int av_size;
off_t av_adr;
int index;
off_t file_pos;
@@ -409,13 +409,13 @@ _gdbm_put_av_elem (avail_elem new_el, avail_elem av_table[], int *av_count,
one block size is in a single block.) Enough blocks are allocated to
make sure the number of bytes allocated in the blocks is larger than SIZE.
DBF contains the file header that needs updating. This routine does
no I/O. */
static avail_elem
-get_block (int size, gdbm_file_info *dbf)
+get_block (int size, GDBM_FILE dbf)
{
avail_elem val;
/* Need at least one block. */
val.av_adr = dbf->header->next_block;
val.av_size = dbf->header->block_size;
@@ -435,13 +435,13 @@ get_block (int size, gdbm_file_info *dbf)
}
/* When the header already needs writing, we can make sure the current
bucket has its avail block as close to 1/3 full as possible. */
static void
-adjust_bucket_avail (gdbm_file_info *dbf)
+adjust_bucket_avail (GDBM_FILE dbf)
{
int third = BUCKET_AVAIL / 3;
avail_elem av_el;
/* Can we add more entries to the bucket? */
if (dbf->bucket->av_count < third)
diff --git a/src/findkey.c b/src/findkey.c
index e1ca476..56a2c9d 100644
--- a/src/findkey.c
+++ b/src/findkey.c
@@ -24,13 +24,13 @@
/* Read the data found in bucket entry ELEM_LOC in file DBF and
return a pointer to it. Also, cache the read value. */
char *
-_gdbm_read_entry (gdbm_file_info *dbf, int elem_loc)
+_gdbm_read_entry (GDBM_FILE dbf, int elem_loc)
{
int num_bytes; /* For seeking and reading. */
int key_size;
int data_size;
off_t file_pos;
data_cache_elem *data_ca;
@@ -72,13 +72,13 @@ _gdbm_read_entry (gdbm_file_info *dbf, int elem_loc)
/* Find the KEY in the file and get ready to read the associated data. The
return value is the location in the current hash bucket of the KEY's
entry. If it is found, a pointer to the data and the key are returned
in DPTR. If it is not found, the value -1 is returned. Since find
key computes the hash value of key, that value */
int
-_gdbm_findkey (gdbm_file_info *dbf, datum key, char **dptr, int *new_hash_val)
+_gdbm_findkey (GDBM_FILE dbf, datum key, char **dptr, int *new_hash_val)
{
int bucket_hash_val; /* The hash value from the bucket. */
char *file_key; /* The complete key as stored in the file. */
int elem_loc; /* The location in the bucket. */
int home_loc; /* The home location in the bucket. */
int key_size; /* Size of the key on the file. */
diff --git a/src/flatfile.c b/src/flatfile.c
index 4d182d8..4589864 100644
--- a/src/flatfile.c
+++ b/src/flatfile.c
@@ -20,19 +20,18 @@
#ifndef _GDBMEXPORT_
/* Include system configuration before all else. */
#include "autoconf.h"
#include "gdbmdefs.h"
-#include "gdbmerrno.h"
#include "extern.h"
extern const char * gdbm_version;
int
-gdbm_export (gdbm_file_info *dbf, const char *exportfile, int flags, int mode)
+gdbm_export (GDBM_FILE dbf, const char *exportfile, int flags, int mode)
#else
int
gdbm_export (GDBM_FILE dbf, const char *exportfile, int flags, int mode)
#endif
{
int nfd, size;
@@ -114,13 +113,13 @@ write_fail:
return -1;
}
#ifndef _GDBMEXPORT_
int
-gdbm_import (gdbm_file_info *dbf, const char *importfile, int flag)
+gdbm_import (GDBM_FILE dbf, const char *importfile, int flag)
{
int ifd, seenbang, seennewline, rsize, size, kbufsize, dbufsize, rret;
char c, *kbuffer, *dbuffer;
datum key, data;
int count = 0;
diff --git a/src/gdbmclose.c b/src/gdbmclose.c
index c9ddf0f..24b92d0 100644
--- a/src/gdbmclose.c
+++ b/src/gdbmclose.c
@@ -24,13 +24,13 @@
/* Close the dbm file and free all memory associated with the file DBF.
Before freeing members of DBF, check and make sure that they were
allocated. */
void
-gdbm_close (gdbm_file_info *dbf)
+gdbm_close (GDBM_FILE dbf)
{
int index; /* For freeing the bucket cache. */
/* Make sure the database is all on disk. */
if (dbf->read_write != GDBM_READER)
__fsync (dbf);
diff --git a/src/gdbmdelete.c b/src/gdbmdelete.c
index 0227334..2226c2d 100644
--- a/src/gdbmdelete.c
+++ b/src/gdbmdelete.c
@@ -18,20 +18,19 @@
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
/* Include system configuration before all else. */
#include "autoconf.h"
#include "gdbmdefs.h"
-#include "gdbmerrno.h"
/* Remove the KEYed item and the KEY from the database DBF. The file on disk
is updated to reflect the structure of the new database before returning
from this procedure. */
int
-gdbm_delete (gdbm_file_info *dbf, datum key)
+gdbm_delete (GDBM_FILE dbf, datum key)
{
int elem_loc; /* The location in the current hash bucket. */
int last_loc; /* Last location emptied by the delete. */
int home; /* Home position of an item. */
bucket_element elem; /* The element to be deleted. */
char *find_data; /* Return pointer from findkey. */
diff --git a/src/gdbmexists.c b/src/gdbmexists.c
index 74da121..b1fb4cf 100644
--- a/src/gdbmexists.c
+++ b/src/gdbmexists.c
@@ -18,19 +18,18 @@
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
/* Include system configuration before all else. */
#include "autoconf.h"
#include "gdbmdefs.h"
-#include "gdbmerrno.h"
/* This is nothing more than a wrapper around _gdbm_findkey(). The
point? It doesn't alloate any memory. */
int
-gdbm_exists (gdbm_file_info *dbf, datum key)
+gdbm_exists (GDBM_FILE dbf, datum key)
{
char *find_data; /* Dummy */
int hash_val; /* Dummy */
return (_gdbm_findkey (dbf, key, &find_data, &hash_val) >= 0);
}
diff --git a/src/gdbmfdesc.c b/src/gdbmfdesc.c
index 67e8b89..152b5b2 100644
--- a/src/gdbmfdesc.c
+++ b/src/gdbmfdesc.c
@@ -22,10 +22,10 @@
#include "gdbmdefs.h"
/* Return the file number of the DBF file. */
int
-gdbm_fdesc(gdbm_file_info *dbf)
+gdbm_fdesc(GDBM_FILE dbf)
{
return (dbf->desc);
}
diff --git a/src/gdbmfetch.c b/src/gdbmfetch.c
index 3cd868e..a3749ae 100644
--- a/src/gdbmfetch.c
+++ b/src/gdbmfetch.c
@@ -18,20 +18,19 @@
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
/* Include system configuration before all else. */
#include "autoconf.h"
#include "gdbmdefs.h"
-#include "gdbmerrno.h"
/* Look up a given KEY and return the information associated with that KEY.
The pointer in the structure that is returned is a pointer to dynamically
allocated memory block. */
datum
-gdbm_fetch (gdbm_file_info *dbf, datum key)
+gdbm_fetch (GDBM_FILE dbf, datum key)
{
datum return_val; /* The return value. */
int elem_loc; /* The location in the bucket. */
char *find_data; /* Returned from find_key. */
int hash_val; /* Returned from find_key. */
diff --git a/src/gdbmreorg.c b/src/gdbmreorg.c
index fccffff..797d75a 100644
--- a/src/gdbmreorg.c
+++ b/src/gdbmreorg.c
@@ -18,13 +18,12 @@
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
/* Include system configuration before all else. */
#include "autoconf.h"
#include "gdbmdefs.h"
-#include "gdbmerrno.h"
#include "extern.h"
#if !HAVE_RENAME
/* Rename takes OLD_NAME and renames it as NEW_NAME. If it can not rename
the file a non-zero value is returned. OLD_NAME is guaranteed to
@@ -55,15 +54,15 @@ _gdbm_rename (char *old_name, char *new_name)
is then renamed to the same name as the old file and DBF is updated to
contain all the correct information about the new file. If an error
is detected, the return value is negative. The value zero is returned
after a successful reorganization. */
int
-gdbm_reorganize (gdbm_file_info *dbf)
+gdbm_reorganize (GDBM_FILE dbf)
{
- gdbm_file_info *new_dbf; /* The new file. */
+ GDBM_FILE new_dbf; /* The new file. */
char *new_name; /* A temporary name. */
int len; /* Used in new_name construction. */
datum key, nextkey, data; /* For the sequential sweep. */
struct stat fileinfo; /* Information about the file. */
int index; /* Use in moving the bucket cache. */
diff --git a/src/gdbmseq.c b/src/gdbmseq.c
index 2fe7b3c..59c05cd 100644
--- a/src/gdbmseq.c
+++ b/src/gdbmseq.c
@@ -18,24 +18,23 @@
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
/* Include system configuration before all else. */
#include "autoconf.h"
#include "gdbmdefs.h"
-#include "gdbmerrno.h"
/* Special extern for this file. */
-extern char *_gdbm_read_entry (gdbm_file_info *, int);
+extern char *_gdbm_read_entry (GDBM_FILE , int);
/* Find and read the next entry in the hash structure for DBF starting
at ELEM_LOC of the current bucket and using RETURN_VAL as the place to
put the data that is found. */
static void
-get_next_key (gdbm_file_info *dbf, int elem_loc, datum *return_val)
+get_next_key (GDBM_FILE dbf, int elem_loc, datum *return_val)
{
int found; /* Have we found the next key. */
char *find_data; /* Data pointer returned by find_key. */
/* Find the next key. */
found = FALSE;
@@ -77,13 +76,13 @@ get_next_key (gdbm_file_info *dbf, int elem_loc, datum *return_val)
/* Start the visit of all keys in the database. This produces something in
hash order, not in any sorted order. */
datum
-gdbm_firstkey (gdbm_file_info *dbf)
+gdbm_firstkey (GDBM_FILE dbf)
{
datum return_val; /* To return the first key. */
/* Set the default return value for not finding a first entry. */
return_val.dptr = NULL;
@@ -100,13 +99,13 @@ gdbm_firstkey (gdbm_file_info *dbf)
}
/* Continue visiting all keys. The next key following KEY is returned. */
datum
-gdbm_nextkey (gdbm_file_info *dbf, datum key)
+gdbm_nextkey (GDBM_FILE dbf, datum key)
{
datum return_val; /* The return value. */
int elem_loc; /* The location in the bucket. */
char *find_data; /* Data pointer returned by _gdbm_findkey. */
int hash_val; /* Returned by _gdbm_findkey. */
diff --git a/src/gdbmsetopt.c b/src/gdbmsetopt.c
index 7280163..5c7fbbd 100644
--- a/src/gdbmsetopt.c
+++ b/src/gdbmsetopt.c
@@ -18,19 +18,18 @@
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
/* Include system configuration before all else. */
#include "autoconf.h"
#include "gdbmdefs.h"
-#include "gdbmerrno.h"
/* operate on an already open descriptor. */
/* ARGSUSED */
int
-gdbm_setopt(gdbm_file_info *dbf, int optflag, int *optval, int optlen)
+gdbm_setopt(GDBM_FILE dbf, int optflag, int *optval, int optlen)
{
switch(optflag)
{
case GDBM_CACHESIZE:
/* Optval will point to the new size of the cache. */
if (dbf->bucket_cache != NULL)
diff --git a/src/gdbmstore.c b/src/gdbmstore.c
index cc2bee7..26874fe 100644
--- a/src/gdbmstore.c
+++ b/src/gdbmstore.c
@@ -18,13 +18,12 @@
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
/* Include system configuration before all else. */
#include "autoconf.h"
#include "gdbmdefs.h"
-#include "gdbmerrno.h"
/* Add a new element to the database. CONTENT is keyed by KEY. The
file on disk is updated to reflect the structure of the new database
before returning from this procedure. The FLAGS define the action to
take when the KEY is already in the database. The value GDBM_REPLACE
@@ -34,13 +33,13 @@
the item was not stored in the data base because the caller was not an
official writer. A return value of 0 means that the item was not stored
because the argument FLAGS was GDBM_INSERT and the KEY was already in
the database. */
int
-gdbm_store (gdbm_file_info *dbf, datum key, datum content, int flags)
+gdbm_store (GDBM_FILE dbf, datum key, datum content, int flags)
{
int new_hash_val; /* The new hash value. */
int elem_loc; /* The location in hash bucket. */
off_t file_adr; /* The address of new space in the file. */
off_t file_pos; /* The position after a lseek. */
int num_bytes; /* Used for error detection. */
diff --git a/src/gdbmsync.c b/src/gdbmsync.c
index 74e8c25..9b7c326 100644
--- a/src/gdbmsync.c
+++ b/src/gdbmsync.c
@@ -18,18 +18,17 @@
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
/* Include system configuration before all else. */
#include "autoconf.h"
#include "gdbmdefs.h"
-#include "gdbmerrno.h"
/* Make sure the database is all on disk. */
void
-gdbm_sync (gdbm_file_info *dbf)
+gdbm_sync (GDBM_FILE dbf)
{
/* Initialize the gdbm_errno variable. */
gdbm_errno = GDBM_NO_ERROR;
/* Do the sync on the file. */
diff --git a/src/global.c b/src/global.c
index e53db3f..b5e4279 100644
--- a/src/global.c
+++ b/src/global.c
@@ -19,17 +19,16 @@
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
/* Include system configuration before all else. */
#include "autoconf.h"
#include "gdbmdefs.h"
-#include "gdbmerrno.h"
/* The global variables used for the "original" interface. */
-gdbm_file_info *_gdbm_file = NULL;
+GDBM_FILE _gdbm_file = NULL;
/* Memory