return (bytes);
}
-extern char *
+extern const char *
get_gdbm_version (void)
{
return (gdbm_version);
error_external_return ();
}
+#ifdef GDBM_VERSION_MAJOR
+# if GDBM_VERSION_MAJOR > 1
+# define GDBM_NEED_NOLOCK 1
+# elif GDBM_VERSION_MAJOR == 1 && GDBM_VERSION_MINOR >= 13
+# define GDBM_NEED_NOLOCK 1
+# endif
+#endif
+
extern gdbm_args *
do_gdbm_open (char * name, int block_size, int read_write, int mode)
{
gdbm_args *args = (gdbm_args *) malloc (sizeof (gdbm_args));
if (!args) return (args);
+#ifdef GDBM_NEED_NOLOCK
+ read_write |= GDBM_NOLOCK;
+#endif
+
args->key.dsize = 0;
args->key.dptr = NULL;
args->key_allocation = 0;
args->content.dsize = 0;
args->content.dptr = NULL;
args->content_allocation = 0;
- args->gdbm_errno = 0;
- args->sys_errno = 0;
+ args->errno_gdbm = 0;
+ args->errno_sys = 0;
args->dbf = gdbm_open (name, block_size, read_write, mode, &fatal_error);
if (args->dbf == NULL)
{
- args->gdbm_errno = gdbm_errno;
- args->sys_errno = errno;
+ args->errno_gdbm = gdbm_errno;
+ args->errno_sys = errno;
}
return (args);
}
int ret = gdbm_store (args->dbf, args->key, args->content, flag);
if (ret == -1)
{
- args->gdbm_errno = gdbm_errno;
- args->sys_errno = errno;
+ args->errno_gdbm = gdbm_errno;
+ args->errno_sys = errno;
}
return (ret);
}
int ret = gdbm_reorganize (args->dbf);
if (ret)
{
- args->gdbm_errno = gdbm_errno;
- args->sys_errno = errno;
+ args->errno_gdbm = gdbm_errno;
+ args->errno_sys = errno;
}
return (ret);
}
int ret = gdbm_setopt (args->dbf, option, &value, sizeof (int));
if (ret)
{
- args->gdbm_errno = gdbm_errno;
- args->sys_errno = errno;
+ args->errno_gdbm = gdbm_errno;
+ args->errno_sys = errno;
}
return (ret);
}
typedef struct gdbm_args {
GDBM_FILE dbf;
- gdbm_error gdbm_errno;
- int sys_errno;
+ gdbm_error errno_gdbm;
+ int errno_sys;
datum key, content;
int key_allocation, content_allocation;
} gdbm_args;
extern int do_gdbm_reorganize (gdbm_args * args);
extern void do_gdbm_sync (gdbm_args * args);
extern int do_gdbm_setopt (gdbm_args * args, int option, int value);
-extern char * get_gdbm_version (void);
+extern const char * get_gdbm_version (void);
(typedef gdbm_args
(struct
(dbf GDBM_FILE)
- (gdbm_errno int)
- (sys_errno int)
+ (errno_gdbm int)
+ (errno_sys int)
(key datum)
(content datum)))
(extern int do_gdbm_nextkey (args (* gdbm_args)))
(extern int do_gdbm_reorganize (args (* gdbm_args)))
(extern void do_gdbm_sync (args (* gdbm_args)))
-(extern (* char) gdbm_strerror (errnum int))
-(extern (* char) strerror (errnum int))
+(extern (* (const char)) gdbm_strerror (errnum int))
+(extern (* (const char)) strerror (errnum int))
(extern int do_gdbm_setopt (args (* gdbm_args)) (option int) (value int))
-(extern (* char) get_gdbm_version)
+(extern (* (const char)) get_gdbm_version)
(enum (GDBM_NO_ERROR)
(GDBM_MALLOC_ERROR)
(define (gdbm-error gdbf msg)
(let ((args (gdbf-args gdbf)))
(error (string-append msg " failed:")
- (gdbm-strerror (C-> args "gdbm_args gdbm_errno"))
- (strerror (C-> args "gdbm_args sys_errno")))))
+ (gdbm-strerror (C-> args "gdbm_args errno_gdbm"))
+ (strerror (C-> args "gdbm_args errno_sys")))))
(define (gdbf-args-put-key! args key)
(let ((bytes (->bytes key)))