Changeset 523 for trunk/gsdl/packages/wingdbm/global.c
- Timestamp:
- 1999-09-02T21:44:30+12:00 (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/packages/wingdbm/global.c
r18 r523 35 35 #include "gdbmerrno.h" 36 36 37 #include <io.h> 38 #include <windows.h> 37 39 38 40 /* The global variables used for the "original" interface. */ … … 45 47 /* The dbm error number is placed in the variable GDBM_ERRNO. */ 46 48 gdbm_error gdbm_errno = GDBM_NO_ERROR; 49 50 51 /* a simple locking function for windows that uses file descriptors */ 52 int my_locking(int fh, int lmode, long lockoffset, long nbytes) { 53 int result = -1; 54 int trys = 10; 55 56 lseek (fh, lockoffset, L_SET); 57 58 while (trys > 0 && result != 0) { 59 if (lmode == MY_UNLOCK) { 60 if (UnlockFile((HANDLE)_get_osfhandle(fh),lockoffset,0,nbytes,0)) 61 result = 0; 62 63 } else if (lmode == MY_READLOCK) { 64 /* if (LockFileEx((HANDLE)_get_osfhandle(fh),0,0,nbytes,0,0))*/ 65 if (LockFile((HANDLE)_get_osfhandle(fh),lockoffset,0,nbytes,0)) 66 result = 0; 67 68 } else if (lmode == MY_WRITELOCK) { 69 if (LockFile((HANDLE)_get_osfhandle(fh),lockoffset,0,nbytes,0)) 70 result = 0; 71 } 72 73 Sleep(100L); 74 trys--; 75 } 76 77 return result; 78 }
Note:
See TracChangeset
for help on using the changeset viewer.