*** /net/muncher/home2/dovich/gnu/gdbm-1.5/gdbmreorg.c Thu Feb 28 19:58:30 1991 --- gdbmreorg.c Sat Sep 28 00:00:11 1991 *************** *** 149,154 **** --- 149,155 ---- /* Move the new file to old name. */ + #ifndef atarist /* on the atari you cannot rename before closing */ if (rename (new_name, dbf->name) != 0) { gdbm_errno = GDBM_REORGANIZE_FAILED; *************** *** 155,164 **** --- 156,183 ---- gdbm_close (new_dbf); return -1; } + #endif /* Fix up DBF to have the correct information for the new file. */ UNLOCK_FILE(dbf); close (dbf->desc); + #ifdef atarist + close(new_dbf->desc); + if (rename (new_name, dbf->name) != 0) + { + gdbm_errno = GDBM_REORGANIZE_FAILED; + gdbm_close (new_dbf); + return -1; + } + if((new_dbf->desc = open(dbf->name, O_RDWR)) < 0) + { + gdbm_errno = GDBM_REORGANIZE_FAILED; + gdbm_close (new_dbf); + return -1; + } + lseek(new_dbf->desc, 0L, SEEK_END); + #endif + free (dbf->header); free (dbf->dir); for (index = 0; index < CACHE_SIZE; index++) *** /net/muncher/home2/dovich/gnu/gdbm-1.5/systems.h Thu Feb 28 19:58:34 1991 --- systems.h Sat Sep 28 00:12:08 1991 *************** *** 82,97 **** /* Get string definitions. */ #include #define _HAVE_STRING - #endif /* Sys V does not have a truncate call, how primitive. */ #define TRUNCATE(dbf) close( open (dbf->name, O_RDWR|O_TRUNC, mode)); /* End of System V changes and defines. */ /**************************************************/ /* Alloca is builtin in gcc. Use the builtin alloca if compiled with gcc. */ #ifdef __GNUC__ --- 82,142 ---- /* Get string definitions. */ #include #define _HAVE_STRING /* Sys V does not have a truncate call, how primitive. */ #define TRUNCATE(dbf) close( open (dbf->name, O_RDWR|O_TRUNC, mode)); + #endif + /* End of System V changes and defines. */ /**************************************************/ + /* AtariST-gcc changes and defines. */ + /**************************************************/ + + #ifdef atarist + + /* File seeking needs L_SET defined .*/ + #include + #include + #define L_SET SEEK_SET + + /* Some files need fcntl.h for locking. pretend with successes always*/ + #define UNLOCK_FILE(dbf) (0) + #define READLOCK_FILE(dbf) { lock_val = 0; } + #define WRITELOCK_FILE(dbf) { lock_val = 0; } + + /* Send bcmp to the right place. */ + #include + + /* atariST does not have fsync. Things are always sync'ed so pretend */ + #define fsync(f) (0) + + /* Get string definitions. */ + #include + #define _HAVE_STRING + + /* atariST does not have a truncate call, how primitive. */ + /* for this application, (truncate to zero length) the following will suffice */ + #define TRUNCATE(dbf) \ + { \ + (void)close(dbf->desc); \ + (void)remove(dbf->name); \ + dbf->desc = open (dbf->name, O_RDWR|O_CREAT, mode); \ + if(dbf->desc < 0) \ + { \ + free(dbf->name); \ + free(dbf); \ + gdbm_errno = GDBM_FILE_OPEN_ERROR; \ + return NULL; \ + } \ + } + #endif + + /* End of AtariST-gcc changes and defines. */ + /**************************************************/ /* Alloca is builtin in gcc. Use the builtin alloca if compiled with gcc. */ #ifdef __GNUC__ *************** *** 113,119 **** --- 158,166 ---- #endif /* Malloc definition. */ + #if !__STDC__ extern char *malloc(); + #endif /* String definitions. */ #ifndef _HAVE_STRING *** /net/muncher/home2/dovich/gnu/gdbm-1.5/testgdbm.c Thu Feb 28 19:58:36 1991 --- testgdbm.c Fri Sep 27 23:28:53 1991 *************** *** 188,198 **** data_data.dptr = data_line; if (reader) ! gdbm_file = gdbm_open (file_name, 512, GDBM_READER, 00664, NULL); else if (newdb) ! gdbm_file = gdbm_open (file_name, 512, GDBM_NEWDB, 00664, NULL); else ! gdbm_file = gdbm_open (file_name, 512, GDBM_WRCREAT, 00664, NULL); if (gdbm_file == NULL) { if (gdbm_errno != GDBM_CANT_BE_WRITER) --- 188,198 ---- data_data.dptr = data_line; if (reader) ! gdbm_file = gdbm_open (file_name, 512, GDBM_READER, 0664, NULL); else if (newdb) ! gdbm_file = gdbm_open (file_name, 512, GDBM_NEWDB, 0664, NULL); else ! gdbm_file = gdbm_open (file_name, 512, GDBM_WRCREAT, 0664, NULL); if (gdbm_file == NULL) { if (gdbm_errno != GDBM_CANT_BE_WRITER)