From a5088330ed9d2e672152b81720f3f35ad15a3bce Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Mon, 1 Aug 2011 11:22:50 +0000 Subject: Use GDBM_FILE instead of gdbm_file_info *. --- compat/dbmopen.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'compat/dbmopen.c') diff --git a/compat/dbmopen.c b/compat/dbmopen.c index 257da77..309d08f 100644 --- a/compat/dbmopen.c +++ b/compat/dbmopen.c @@ -42,15 +42,15 @@ 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); @@ -68,23 +68,28 @@ dbm_open (char *file, int flags, int mode) /* 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) { -- cgit v1.2.1