Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | make OS/2 VFS functions static (CVS 5376) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
b40d9496d03b16a25c164bbb69486053 |
User & Date: | pweilbacher 2008-07-08 19:46:24.000 |
Context
2008-07-08
| ||
22:15 | Added test_mutex.c (for testfixture) to input file for configure script. (CVS 5377) (check-in: bfca089dbf user: shane tags: trunk) | |
19:46 | make OS/2 VFS functions static (CVS 5376) (check-in: b40d9496d0 user: pweilbacher tags: trunk) | |
19:45 | Fix a bug in where.c introduced by check-in (5373). (CVS 5375) (check-in: 1ed98f9e61 user: drh tags: trunk) | |
Changes
Changes to src/os_os2.c.
︙ | ︙ | |||
8 9 10 11 12 13 14 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ****************************************************************************** ** ** This file contains code that is specific to OS/2. ** | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ****************************************************************************** ** ** This file contains code that is specific to OS/2. ** ** $Id: os_os2.c,v 1.48 2008/07/08 19:46:24 pweilbacher Exp $ */ #include "sqliteInt.h" #if SQLITE_OS_OS2 /* |
︙ | ︙ | |||
75 76 77 78 79 80 81 | ** The next group of routines implement the I/O methods specified ** by the sqlite3_io_methods object. ******************************************************************************/ /* ** Close a file. */ | | | 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | ** The next group of routines implement the I/O methods specified ** by the sqlite3_io_methods object. ******************************************************************************/ /* ** Close a file. */ static int os2Close( sqlite3_file *id ){ APIRET rc = NO_ERROR; os2File *pFile; if( id && (pFile = (os2File*)id) != 0 ){ OSTRACE2( "CLOSE %d\n", pFile->h ); rc = DosClose( pFile->h ); pFile->locktype = NO_LOCK; if( pFile->pathToDel != NULL ){ |
︙ | ︙ | |||
99 100 101 102 103 104 105 | } /* ** Read data from a file into a buffer. Return SQLITE_OK if all ** bytes were read successfully and SQLITE_IOERR if anything goes ** wrong. */ | | | 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | } /* ** Read data from a file into a buffer. Return SQLITE_OK if all ** bytes were read successfully and SQLITE_IOERR if anything goes ** wrong. */ static int os2Read( sqlite3_file *id, /* File to read from */ void *pBuf, /* Write content into this buffer */ int amt, /* Number of bytes to read */ sqlite3_int64 offset /* Begin reading at this offset */ ){ ULONG fileLocation = 0L; ULONG got; |
︙ | ︙ | |||
129 130 131 132 133 134 135 | } } /* ** Write data from a buffer into a file. Return SQLITE_OK on success ** or some other error code on failure. */ | | | 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | } } /* ** Write data from a buffer into a file. Return SQLITE_OK on success ** or some other error code on failure. */ static int os2Write( sqlite3_file *id, /* File to write into */ const void *pBuf, /* The bytes to be written */ int amt, /* Number of bytes to write */ sqlite3_int64 offset /* Offset into the file to begin writing at */ ){ ULONG fileLocation = 0L; APIRET rc = NO_ERROR; |
︙ | ︙ | |||
161 162 163 164 165 166 167 | return ( rc != NO_ERROR || amt > (int)wrote ) ? SQLITE_FULL : SQLITE_OK; } /* ** Truncate an open file to a specified size */ | | | | | 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | return ( rc != NO_ERROR || amt > (int)wrote ) ? SQLITE_FULL : SQLITE_OK; } /* ** Truncate an open file to a specified size */ static int os2Truncate( sqlite3_file *id, i64 nByte ){ APIRET rc = NO_ERROR; os2File *pFile = (os2File*)id; OSTRACE3( "TRUNCATE %d %lld\n", pFile->h, nByte ); SimulateIOError( return SQLITE_IOERR_TRUNCATE ); rc = DosSetFileSize( pFile->h, nByte ); return rc == NO_ERROR ? SQLITE_OK : SQLITE_IOERR; } #ifdef SQLITE_TEST /* ** Count the number of fullsyncs and normal syncs. This is used to test ** that syncs and fullsyncs are occuring at the right times. */ int sqlite3_sync_count = 0; int sqlite3_fullsync_count = 0; #endif /* ** Make sure all writes to a particular file are committed to disk. */ static int os2Sync( sqlite3_file *id, int flags ){ os2File *pFile = (os2File*)id; OSTRACE3( "SYNC %d lock=%d\n", pFile->h, pFile->locktype ); #ifdef SQLITE_TEST if( flags & SQLITE_SYNC_FULL){ sqlite3_fullsync_count++; } sqlite3_sync_count++; #endif return DosResetBuffer( pFile->h ) == NO_ERROR ? SQLITE_OK : SQLITE_IOERR; } /* ** Determine the current size of a file in bytes */ static int os2FileSize( sqlite3_file *id, sqlite3_int64 *pSize ){ APIRET rc = NO_ERROR; FILESTATUS3 fsts3FileInfo; memset(&fsts3FileInfo, 0, sizeof(fsts3FileInfo)); assert( id!=0 ); SimulateIOError( return SQLITE_IOERR ); rc = DosQueryFileInfo( ((os2File*)id)->h, FIL_STANDARD, &fsts3FileInfo, sizeof(FILESTATUS3) ); if( rc == NO_ERROR ){ |
︙ | ︙ | |||
274 275 276 277 278 279 280 | ** PENDING -> EXCLUSIVE ** ** This routine will only increase a lock. The os2Unlock() routine ** erases all locks at once and returns us immediately to locking level 0. ** It is not possible to lower the locking level one step at a time. You ** must go straight to locking level 0. */ | | | 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 | ** PENDING -> EXCLUSIVE ** ** This routine will only increase a lock. The os2Unlock() routine ** erases all locks at once and returns us immediately to locking level 0. ** It is not possible to lower the locking level one step at a time. You ** must go straight to locking level 0. */ static int os2Lock( sqlite3_file *id, int locktype ){ int rc = SQLITE_OK; /* Return code from subroutines */ APIRET res = NO_ERROR; /* Result of an OS/2 lock call */ int newLocktype; /* Set pFile->locktype to this value before exiting */ int gotPendingLock = 0;/* True if we acquired a PENDING lock this time */ FILELOCK LockArea, UnlockArea; os2File *pFile = (os2File*)id; |
︙ | ︙ | |||
410 411 412 413 414 415 416 | } /* ** This routine checks if there is a RESERVED lock held on the specified ** file by this or any other process. If such a lock is held, return ** non-zero, otherwise zero. */ | | | 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 | } /* ** This routine checks if there is a RESERVED lock held on the specified ** file by this or any other process. If such a lock is held, return ** non-zero, otherwise zero. */ static int os2CheckReservedLock( sqlite3_file *id, int *pOut ){ int r = 0; os2File *pFile = (os2File*)id; assert( pFile!=0 ); if( pFile->locktype>=RESERVED_LOCK ){ r = 1; OSTRACE3( "TEST WR-LOCK %d %d (local)\n", pFile->h, r ); }else{ |
︙ | ︙ | |||
456 457 458 459 460 461 462 | ** If the locking level of the file descriptor is already at or below ** the requested locking level, this routine is a no-op. ** ** It is not possible for this routine to fail if the second argument ** is NO_LOCK. If the second argument is SHARED_LOCK then this routine ** might return SQLITE_IOERR; */ | | | 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 | ** If the locking level of the file descriptor is already at or below ** the requested locking level, this routine is a no-op. ** ** It is not possible for this routine to fail if the second argument ** is NO_LOCK. If the second argument is SHARED_LOCK then this routine ** might return SQLITE_IOERR; */ static int os2Unlock( sqlite3_file *id, int locktype ){ int type; os2File *pFile = (os2File*)id; APIRET rc = SQLITE_OK; APIRET res = NO_ERROR; FILELOCK LockArea, UnlockArea; memset(&LockArea, 0, sizeof(LockArea)); |
︙ | ︙ | |||
549 550 551 552 553 554 555 | /* ** Helper function to convert UTF-8 filenames to local OS/2 codepage. ** The two-step process: first convert the incoming UTF-8 string ** into UCS-2 and then from UCS-2 to the current codepage. ** The returned char pointer has to be freed. */ | | | 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 | /* ** Helper function to convert UTF-8 filenames to local OS/2 codepage. ** The two-step process: first convert the incoming UTF-8 string ** into UCS-2 and then from UCS-2 to the current codepage. ** The returned char pointer has to be freed. */ static char *convertUtf8PathToCp(const char *in) { UconvObject uconv; UniChar ucsUtf8Cp[12], tempPath[CCHMAXPATH]; char *out; int rc = 0; |
︙ | ︙ | |||
579 580 581 582 583 584 585 | /* ** Helper function to convert filenames from local codepage to UTF-8. ** The two-step process: first convert the incoming codepage-specific ** string into UCS-2 and then from UCS-2 to the codepage of UTF-8. ** The returned char pointer has to be freed. */ | | | 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 | /* ** Helper function to convert filenames from local codepage to UTF-8. ** The two-step process: first convert the incoming codepage-specific ** string into UCS-2 and then from UCS-2 to the codepage of UTF-8. ** The returned char pointer has to be freed. */ static char *convertCpPathToUtf8(const char *in) { UconvObject uconv; UniChar ucsUtf8Cp[12], tempPath[CCHMAXPATH]; char *out; int rc = 0; |
︙ | ︙ | |||
795 796 797 798 799 800 801 | OSTRACE3( "OPEN %d pOutFlags=%d\n", pFile->h, pOutFlags ); return SQLITE_OK; } /* ** Delete the named file. */ | | | 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 | OSTRACE3( "OPEN %d pOutFlags=%d\n", pFile->h, pOutFlags ); return SQLITE_OK; } /* ** Delete the named file. */ static int os2Delete( sqlite3_vfs *pVfs, /* Not used on os2 */ const char *zFilename, /* Name of file to delete */ int syncDir /* Not used on os2 */ ){ APIRET rc = NO_ERROR; char *zFilenameCp = convertUtf8PathToCp( zFilename ); SimulateIOError( return SQLITE_IOERR_DELETE ); |
︙ | ︙ | |||
894 895 896 897 898 899 900 | /* ** A no-op since the error code is returned on the DosLoadModule call. ** os2Dlopen returns zero if DosLoadModule is not successful. */ static void os2DlError(sqlite3_vfs *pVfs, int nBuf, char *zBufOut){ /* no-op */ } | | | | 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 | /* ** A no-op since the error code is returned on the DosLoadModule call. ** os2Dlopen returns zero if DosLoadModule is not successful. */ static void os2DlError(sqlite3_vfs *pVfs, int nBuf, char *zBufOut){ /* no-op */ } static void *os2DlSym(sqlite3_vfs *pVfs, void *pHandle, const char *zSymbol){ PFN pfn; APIRET rc; rc = DosQueryProcAddr((HMODULE)pHandle, 0L, zSymbol, &pfn); if( rc != NO_ERROR ){ /* if the symbol itself was not found, search again for the same * symbol with an extra underscore, that might be needed depending * on the calling convention */ char _zSymbol[256] = "_"; strncat(_zSymbol, zSymbol, 255); rc = DosQueryProcAddr((HMODULE)pHandle, 0L, _zSymbol, &pfn); } return rc != NO_ERROR ? 0 : (void*)pfn; } static void os2DlClose(sqlite3_vfs *pVfs, void *pHandle){ DosFreeModule((HMODULE)pHandle); } #else /* if SQLITE_OMIT_LOAD_EXTENSION is defined: */ #define os2DlOpen 0 #define os2DlError 0 #define os2DlSym 0 #define os2DlClose 0 |
︙ | ︙ | |||
1067 1068 1069 1070 1071 1072 1073 | os2DlClose, /* xDlClose */ os2Randomness, /* xRandomness */ os2Sleep, /* xSleep */ os2CurrentTime, /* xCurrentTime */ os2GetLastError /* xGetLastError */ }; sqlite3_vfs_register(&os2Vfs, 1); | | | | | 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 | os2DlClose, /* xDlClose */ os2Randomness, /* xRandomness */ os2Sleep, /* xSleep */ os2CurrentTime, /* xCurrentTime */ os2GetLastError /* xGetLastError */ }; sqlite3_vfs_register(&os2Vfs, 1); return SQLITE_OK; } int sqlite3_os_end(void){ return SQLITE_OK; } #endif /* SQLITE_OS_OS2 */ |