aboutsummaryrefslogtreecommitdiff
path: root/compat
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2016-07-09 08:40:04 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2016-07-09 08:47:16 +0300
commit479a469033903a76b9c073806037dd66176f3da0 (patch)
tree2841b611288f9343868e6ded82909b096a62e121 /compat
parent2efd8358711ab3ea6c0ecaab75d195837b4b3e37 (diff)
downloadgdbm-479a469033903a76b9c073806037dd66176f3da0.tar.gz
gdbm-479a469033903a76b9c073806037dd66176f3da0.tar.bz2
Per-database error state.
Last error code is stored in the database file structure as well as in the global gdbm_errno. Special functions are provided for retrieving and clearing the last error state. * src/gdbmdefs.h (gdbm_file_info): New member: last_error * src/gdbm.h.in (gdbm_last_errno, gdbm_set_errno) (gdbm_clear_error): New protos. * src/gdbmerrno.c (gdbm_last_errno, gdbm_set_errno) (gdbm_clear_error): New functions * NEWS: Update. * compat/dbminit.c: Use gdbm_set_errno to set error state. * compat/dbmopen.c: Likewise. * src/bucket.c: Likewise. * src/findkey.c: Likewise. * src/gdbm_load.c: Likewise. * src/gdbmcount.c: Likewise. * src/gdbmdelete.c: Likewise. * src/gdbmdump.c: Likewise. * src/gdbmexists.c: Likewise. * src/gdbmexp.c: Likewise. * src/gdbmfetch.c: Likewise. * src/gdbmimp.c: Likewise. * src/gdbmload.c: Likewise. * src/gdbmopen.c: Likewise. * src/gdbmreorg.c: Likewise. * src/gdbmseq.c: Likewise. * src/gdbmsetopt.c: Likewise. * src/gdbmstore.c: Likewise. * src/gdbmsync.c: Likewise. * src/mmap.c: Likewise.
Diffstat (limited to 'compat')
-rw-r--r--compat/dbminit.c2
-rw-r--r--compat/dbmopen.c24
2 files changed, 13 insertions, 13 deletions
diff --git a/compat/dbminit.c b/compat/dbminit.c
index 94ddc22..f5c5a65 100644
--- a/compat/dbminit.c
+++ b/compat/dbminit.c
@@ -48,7 +48,7 @@ dbminit (char *file)
/* Did we successfully open the file? */
if (_gdbm_file == NULL)
{
- gdbm_errno = GDBM_FILE_OPEN_ERROR;
+ gdbm_set_errno (NULL, GDBM_FILE_OPEN_ERROR, 1);
return -1;
}
}
diff --git a/compat/dbmopen.c b/compat/dbmopen.c
index 7a5127e..f8df3e3 100644
--- a/compat/dbmopen.c
+++ b/compat/dbmopen.c
@@ -71,7 +71,7 @@ ndbm_open_dir_file0 (const char *file_name, int pagfd, int mode)
if (fstat (pagfd, &pagst))
{
- gdbm_errno = GDBM_FILE_OPEN_ERROR; /* FIXME: special code? */
+ gdbm_set_errno (NULL, GDBM_FILE_OPEN_ERROR, 1); /* FIXME: special code? */
return -1;
}
@@ -89,14 +89,14 @@ ndbm_open_dir_file0 (const char *file_name, int pagfd, int mode)
return pagfd;
else
{
- gdbm_errno = GDBM_FILE_OPEN_ERROR;
+ gdbm_set_errno (NULL, GDBM_FILE_OPEN_ERROR, 1);
return -1;
}
}
}
else
{
- gdbm_errno = GDBM_FILE_OPEN_ERROR;
+ gdbm_set_errno (NULL, GDBM_FILE_OPEN_ERROR, 1);
return -1;
}
}
@@ -104,7 +104,7 @@ ndbm_open_dir_file0 (const char *file_name, int pagfd, int mode)
/* ok */;
else if (st.st_size != DEF_DIR_SIZE)
{
- gdbm_errno = GDBM_BAD_MAGIC_NUMBER;
+ gdbm_set_errno (NULL, GDBM_BAD_MAGIC_NUMBER, 1);
return -1;
}
else
@@ -112,13 +112,13 @@ ndbm_open_dir_file0 (const char *file_name, int pagfd, int mode)
fd = open (file_name, flags);
if (fd == -1)
{
- gdbm_errno = GDBM_FILE_OPEN_ERROR;
+ gdbm_set_errno (NULL, GDBM_FILE_OPEN_ERROR, 1);
return fd;
}
if (read (fd, dirbuf, sizeof (dirbuf)) != sizeof (dirbuf))
{
- gdbm_errno = GDBM_FILE_OPEN_ERROR;
+ gdbm_set_errno (NULL, GDBM_FILE_OPEN_ERROR, 1);
close (fd);
return -1;
}
@@ -135,7 +135,7 @@ ndbm_open_dir_file0 (const char *file_name, int pagfd, int mode)
return fd;
}
close (fd);
- gdbm_errno = GDBM_BAD_MAGIC_NUMBER;
+ gdbm_set_errno (NULL, GDBM_BAD_MAGIC_NUMBER, 1);
return -1;
}
}
@@ -151,7 +151,7 @@ ndbm_open_dir_file0 (const char *file_name, int pagfd, int mode)
if (write (fd, dirbuf, sizeof (dirbuf)) != sizeof (dirbuf))
{
- gdbm_errno = GDBM_FILE_WRITE_ERROR;
+ gdbm_set_errno (NULL, GDBM_FILE_WRITE_ERROR, 1);
close (fd);
fd = -1;
}
@@ -168,7 +168,7 @@ ndbm_open_dir_file (const char *base, int pagfd, int mode)
if (!file_name)
{
- gdbm_errno = GDBM_MALLOC_ERROR;
+ gdbm_set_errno (NULL, GDBM_MALLOC_ERROR, 1);
return -1;
}
fd = ndbm_open_dir_file0 (strcat (strcpy (file_name, base), DIRSUF),
@@ -212,7 +212,7 @@ dbm_open (char *file, int flags, int mode)
pag_file = (char *) malloc (strlen (file) + 5);
if (!pag_file)
{
- gdbm_errno = GDBM_MALLOC_ERROR; /* For the hell of it. */
+ gdbm_set_errno (NULL, GDBM_MALLOC_ERROR, 1); /* For the hell of it. */
return NULL;
}
@@ -250,7 +250,7 @@ dbm_open (char *file, int flags, int mode)
if (!dbm)
{
free (pag_file);
- gdbm_errno = GDBM_MALLOC_ERROR; /* For the hell of it. */
+ gdbm_set_errno (NULL, GDBM_MALLOC_ERROR, 1); /* For the hell of it. */
return NULL;
}
@@ -259,7 +259,7 @@ dbm_open (char *file, int flags, int mode)
/* Did we successfully open the file? */
if (dbm->file == NULL)
{
- gdbm_errno = GDBM_FILE_OPEN_ERROR;
+ gdbm_set_errno (dbm, GDBM_FILE_OPEN_ERROR, 1);
free (dbm);
dbm = NULL;
}

Return to:

Send suggestions and report system problems to the System administrator.