Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Move the shared-library loading routines into the OS portability layer, thus enabling the os_win.c code to handle the character encoding confusion of win95/nt/ce. Ticket #2023. (CVS 3541) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
a1bcc6de578992b28924c1cf974ea582 |
User & Date: | drh 2006-12-21 01:29:23.000 |
Context
2006-12-21
| ||
01:37 | Reduce the number of utf8->unicode conversions required in wince. Ticket #2122 (CVS 3542) (check-in: 6d2ff0962d user: drh tags: trunk) | |
01:29 | Move the shared-library loading routines into the OS portability layer, thus enabling the os_win.c code to handle the character encoding confusion of win95/nt/ce. Ticket #2023. (CVS 3541) (check-in: a1bcc6de57 user: drh tags: trunk) | |
00:46 | Change a parameter type from "int" to "DWORD" in the windows interface. Ticket #2122. (CVS 3540) (check-in: cca1eb3dfa user: drh tags: trunk) | |
Changes
Changes to src/loadext.c.
︙ | ︙ | |||
213 214 215 216 217 218 219 | ** sqlite3_libversion_number() to make sure they are dealing with ** a library that is new enough to support that API. ************************************************************************* */ sqlite3_overload_function, }; | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | | | | | | < < < < < < < | < | 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 | ** sqlite3_libversion_number() to make sure they are dealing with ** a library that is new enough to support that API. ************************************************************************* */ sqlite3_overload_function, }; /* ** Attempt to load an SQLite extension library contained in the file ** zFile. The entry point is zProc. zProc may be 0 in which case a ** default entry point name (sqlite3_extension_init) is used. Use ** of the default name is recommended. ** ** Return SQLITE_OK on success and SQLITE_ERROR if something goes wrong. ** ** If an error occurs and pzErrMsg is not 0, then fill *pzErrMsg with ** error message text. The calling function should free this memory ** by calling sqlite3_free(). */ int sqlite3_load_extension( sqlite3 *db, /* Load the extension into this database connection */ const char *zFile, /* Name of the shared library containing extension */ const char *zProc, /* Entry point. Use "sqlite3_extension_init" if 0 */ char **pzErrMsg /* Put error message here if not 0 */ ){ void *handle; int (*xInit)(sqlite3*,char**,const sqlite3_api_routines*); char *zErrmsg = 0; void **aHandle; /* Ticket #1863. To avoid a creating security problems for older ** applications that relink against newer versions of SQLite, the ** ability to run load_extension is turned off by default. One ** must call sqlite3_enable_load_extension() to turn on extension ** loading. Otherwise you get the following error. */ if( (db->flags & SQLITE_LoadExtension)==0 ){ if( pzErrMsg ){ *pzErrMsg = sqlite3_mprintf("not authorized"); } return SQLITE_ERROR; } if( zProc==0 ){ zProc = "sqlite3_extension_init"; } handle = sqlite3OsDlopen(zFile); if( handle==0 ){ if( pzErrMsg ){ *pzErrMsg = sqlite3_mprintf("unable to open shared library [%s]", zFile); } return SQLITE_ERROR; } xInit = (int(*)(sqlite3*,char**,const sqlite3_api_routines*)) sqlite3OsDlsym(handle, zProc); if( xInit==0 ){ if( pzErrMsg ){ *pzErrMsg = sqlite3_mprintf("no entry point [%s] in shared library [%s]", zProc, zFile); } sqlite3OsDlclose(handle); return SQLITE_ERROR; }else if( xInit(db, &zErrmsg, &sqlite3_apis) ){ if( pzErrMsg ){ *pzErrMsg = sqlite3_mprintf("error during initialization: %s", zErrmsg); } sqlite3_free(zErrmsg); sqlite3OsDlclose(handle); return SQLITE_ERROR; } /* Append the new shared library handle to the db->aExtension array. */ db->nExtension++; aHandle = sqliteMalloc(sizeof(handle)*db->nExtension); if( aHandle==0 ){ return SQLITE_NOMEM; } if( db->nExtension>0 ){ memcpy(aHandle, db->aExtension, sizeof(handle)*(db->nExtension-1)); } sqliteFree(db->aExtension); db->aExtension = aHandle; db->aExtension[db->nExtension-1] = handle; return SQLITE_OK; } /* ** Call this routine when the database connection is closing in order ** to clean up loaded extensions */ void sqlite3CloseExtensions(sqlite3 *db){ int i; for(i=0; i<db->nExtension; i++){ sqlite3OsDlclose(db->aExtension[i]); } sqliteFree(db->aExtension); } /* ** Enable or disable extension loading. Extension loading is disabled by ** default so as not to open security holes in older applications. */ int sqlite3_enable_load_extension(sqlite3 *db, int onoff){ |
︙ | ︙ |
Changes to src/os.h.
︙ | ︙ | |||
118 119 120 121 122 123 124 125 126 127 128 129 130 131 | #define sqlite3OsLeaveMutex sqlite3UnixLeaveMutex #define sqlite3OsInMutex sqlite3UnixInMutex #define sqlite3OsThreadSpecificData sqlite3UnixThreadSpecificData #define sqlite3OsMalloc sqlite3GenericMalloc #define sqlite3OsRealloc sqlite3GenericRealloc #define sqlite3OsFree sqlite3GenericFree #define sqlite3OsAllocationSize sqlite3GenericAllocationSize #endif #if OS_WIN #define sqlite3OsOpenReadWrite sqlite3WinOpenReadWrite #define sqlite3OsOpenExclusive sqlite3WinOpenExclusive #define sqlite3OsOpenReadOnly sqlite3WinOpenReadOnly #define sqlite3OsDelete sqlite3WinDelete #define sqlite3OsFileExists sqlite3WinFileExists | > > > | 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | #define sqlite3OsLeaveMutex sqlite3UnixLeaveMutex #define sqlite3OsInMutex sqlite3UnixInMutex #define sqlite3OsThreadSpecificData sqlite3UnixThreadSpecificData #define sqlite3OsMalloc sqlite3GenericMalloc #define sqlite3OsRealloc sqlite3GenericRealloc #define sqlite3OsFree sqlite3GenericFree #define sqlite3OsAllocationSize sqlite3GenericAllocationSize #define sqlite3OsDlopen sqlite3UnixDlopen #define sqlite3OsDlsym sqlite3UnixDlsym #define sqlite3OsDlclose sqlite3UnixDlclose #endif #if OS_WIN #define sqlite3OsOpenReadWrite sqlite3WinOpenReadWrite #define sqlite3OsOpenExclusive sqlite3WinOpenExclusive #define sqlite3OsOpenReadOnly sqlite3WinOpenReadOnly #define sqlite3OsDelete sqlite3WinDelete #define sqlite3OsFileExists sqlite3WinFileExists |
︙ | ︙ | |||
140 141 142 143 144 145 146 147 148 149 150 151 152 153 | #define sqlite3OsLeaveMutex sqlite3WinLeaveMutex #define sqlite3OsInMutex sqlite3WinInMutex #define sqlite3OsThreadSpecificData sqlite3WinThreadSpecificData #define sqlite3OsMalloc sqlite3GenericMalloc #define sqlite3OsRealloc sqlite3GenericRealloc #define sqlite3OsFree sqlite3GenericFree #define sqlite3OsAllocationSize sqlite3GenericAllocationSize #endif #if OS_OS2 #define sqlite3OsOpenReadWrite sqlite3Os2OpenReadWrite #define sqlite3OsOpenExclusive sqlite3Os2OpenExclusive #define sqlite3OsOpenReadOnly sqlite3Os2OpenReadOnly #define sqlite3OsDelete sqlite3Os2Delete #define sqlite3OsFileExists sqlite3Os2FileExists | > > > | 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | #define sqlite3OsLeaveMutex sqlite3WinLeaveMutex #define sqlite3OsInMutex sqlite3WinInMutex #define sqlite3OsThreadSpecificData sqlite3WinThreadSpecificData #define sqlite3OsMalloc sqlite3GenericMalloc #define sqlite3OsRealloc sqlite3GenericRealloc #define sqlite3OsFree sqlite3GenericFree #define sqlite3OsAllocationSize sqlite3GenericAllocationSize #define sqlite3OsDlopen sqlite3WinDlopen #define sqlite3OsDlsym sqlite3WinDlsym #define sqlite3OsDlclose sqlite3WinDlclose #endif #if OS_OS2 #define sqlite3OsOpenReadWrite sqlite3Os2OpenReadWrite #define sqlite3OsOpenExclusive sqlite3Os2OpenExclusive #define sqlite3OsOpenReadOnly sqlite3Os2OpenReadOnly #define sqlite3OsDelete sqlite3Os2Delete #define sqlite3OsFileExists sqlite3Os2FileExists |
︙ | ︙ | |||
162 163 164 165 166 167 168 169 170 171 172 173 174 175 | #define sqlite3OsLeaveMutex sqlite3Os2LeaveMutex #define sqlite3OsInMutex sqlite3Os2InMutex #define sqlite3OsThreadSpecificData sqlite3Os2ThreadSpecificData #define sqlite3OsMalloc sqlite3GenericMalloc #define sqlite3OsRealloc sqlite3GenericRealloc #define sqlite3OsFree sqlite3GenericFree #define sqlite3OsAllocationSize sqlite3GenericAllocationSize #endif /* ** If using an alternative OS interface, then we must have an "os_other.h" | > > > | 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | #define sqlite3OsLeaveMutex sqlite3Os2LeaveMutex #define sqlite3OsInMutex sqlite3Os2InMutex #define sqlite3OsThreadSpecificData sqlite3Os2ThreadSpecificData #define sqlite3OsMalloc sqlite3GenericMalloc #define sqlite3OsRealloc sqlite3GenericRealloc #define sqlite3OsFree sqlite3GenericFree #define sqlite3OsAllocationSize sqlite3GenericAllocationSize #define sqlite3OsDlopen sqlite3Os2Dlopen #define sqlite3OsDlsym sqlite3Os2Dlsym #define sqlite3OsDlclose sqlite3Os2Dlclose #endif /* ** If using an alternative OS interface, then we must have an "os_other.h" |
︙ | ︙ | |||
345 346 347 348 349 350 351 352 353 354 355 356 357 358 | void sqlite3OsLeaveMutex(void); int sqlite3OsInMutex(int); ThreadData *sqlite3OsThreadSpecificData(int); void *sqlite3OsMalloc(int); void *sqlite3OsRealloc(void *, int); void sqlite3OsFree(void *); int sqlite3OsAllocationSize(void *); /* ** If the SQLITE_ENABLE_REDEF_IO macro is defined, then the OS-layer ** interface routines are not called directly but are invoked using ** pointers to functions. This allows the implementation of various ** OS-layer interface routines to be modified at run-time. There are ** obscure but legitimate reasons for wanting to do this. But for | > > > | 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 | void sqlite3OsLeaveMutex(void); int sqlite3OsInMutex(int); ThreadData *sqlite3OsThreadSpecificData(int); void *sqlite3OsMalloc(int); void *sqlite3OsRealloc(void *, int); void sqlite3OsFree(void *); int sqlite3OsAllocationSize(void *); void *sqlite3OsDlopen(const char*); void *sqlite3OsDlsym(void*, const char*); int sqlite3OsDlclose(void*); /* ** If the SQLITE_ENABLE_REDEF_IO macro is defined, then the OS-layer ** interface routines are not called directly but are invoked using ** pointers to functions. This allows the implementation of various ** OS-layer interface routines to be modified at run-time. There are ** obscure but legitimate reasons for wanting to do this. But for |
︙ | ︙ | |||
389 390 391 392 393 394 395 396 397 398 | int (*xInMutex)(int); ThreadData *(*xThreadSpecificData)(int); void *(*xMalloc)(int); void *(*xRealloc)(void *, int); void (*xFree)(void *); int (*xAllocationSize)(void *); }; /* Macro used to comment out routines that do not exists when there is | > > > > | > > > > > > | 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 | int (*xInMutex)(int); ThreadData *(*xThreadSpecificData)(int); void *(*xMalloc)(int); void *(*xRealloc)(void *, int); void (*xFree)(void *); int (*xAllocationSize)(void *); void *(*xDlopen)(const char*); void *(*xDlsym)(void*, const char*); int (*xDlclose)(void*); }; /* Macro used to comment out routines that do not exists when there is ** no disk I/O or extension loading */ #ifdef SQLITE_OMIT_DISKIO # define IF_DISKIO(X) 0 #else # define IF_DISKIO(X) X #endif #ifdef SQLITE_OMIT_LOAD_EXTENSION # define IF_DLOPEN(X) 0 #else # define IF_DLOPEN(X) X #endif #ifdef _SQLITE_OS_C_ /* ** The os.c file implements the global virtual function table. */ struct sqlite3OsVtbl sqlite3Os = { IF_DISKIO( sqlite3OsOpenReadWrite ), |
︙ | ︙ | |||
424 425 426 427 428 429 430 | sqlite3OsEnterMutex, sqlite3OsLeaveMutex, sqlite3OsInMutex, sqlite3OsThreadSpecificData, sqlite3OsMalloc, sqlite3OsRealloc, sqlite3OsFree, | | > > > | 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 | sqlite3OsEnterMutex, sqlite3OsLeaveMutex, sqlite3OsInMutex, sqlite3OsThreadSpecificData, sqlite3OsMalloc, sqlite3OsRealloc, sqlite3OsFree, sqlite3OsAllocationSize, IF_DLOPEN( sqlite3OsDlopen ), IF_DLOPEN( sqlite3OsDlsym ), IF_DLOPEN( sqlite3OsDlclose ), }; #else /* ** Files other than os.c just reference the global virtual function table. */ extern struct sqlite3OsVtbl sqlite3Os; #endif /* _SQLITE_OS_C_ */ |
︙ | ︙ |
Changes to src/os_os2.c.
︙ | ︙ | |||
763 764 765 766 767 768 769 770 771 772 773 774 775 776 | } #endif /* SQLITE_OMIT_DISKIO */ /*************************************************************************** ** Everything above deals with file I/O. Everything that follows deals ** with other miscellanous aspects of the operating system interface ****************************************************************************/ /* ** Get information to seed the random number generator. The seed ** is written into the buffer zBuf[256]. The calling function must ** supply a sufficiently large buffer. */ int sqlite3Os2RandomSeed( char *zBuf ){ | > > > > > > > > > > > > > > > > > | 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 | } #endif /* SQLITE_OMIT_DISKIO */ /*************************************************************************** ** Everything above deals with file I/O. Everything that follows deals ** with other miscellanous aspects of the operating system interface ****************************************************************************/ #ifndef SQLITE_OMIT_LOAD_EXTENSION /* ** Interfaces for opening a shared library, finding entry points ** within the shared library, and closing the shared library. */ void *sqlite3Os2Dlopen(const char *zFilename){ return 0; } void *sqlite3Os2Dlsym(void *pHandle, const char *zSymbol){ return 0; } int sqlite3Os2Dlclose(void *pHandle){ return 0; } #endif /* SQLITE_OMIT_LOAD_EXTENSION */ /* ** Get information to seed the random number generator. The seed ** is written into the buffer zBuf[256]. The calling function must ** supply a sufficiently large buffer. */ int sqlite3Os2RandomSeed( char *zBuf ){ |
︙ | ︙ |
Changes to src/os_unix.c.
︙ | ︙ | |||
2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 | #endif /* SQLITE_OMIT_DISKIO */ /*************************************************************************** ** Everything above deals with file I/O. Everything that follows deals ** with other miscellanous aspects of the operating system interface ****************************************************************************/ /* ** Get information to seed the random number generator. The seed ** is written into the buffer zBuf[256]. The calling function must ** supply a sufficiently large buffer. */ int sqlite3UnixRandomSeed(char *zBuf){ /* We have to initialize zBuf to prevent valgrind from reporting | > > > > > > > > > > > > > > > > > | 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 | #endif /* SQLITE_OMIT_DISKIO */ /*************************************************************************** ** Everything above deals with file I/O. Everything that follows deals ** with other miscellanous aspects of the operating system interface ****************************************************************************/ #ifndef SQLITE_OMIT_LOAD_EXTENSION /* ** Interfaces for opening a shared library, finding entry points ** within the shared library, and closing the shared library. */ #include <dlfcn.h> void *sqlite3UnixDlopen(const char *zFilename){ return dlopen(zFilename, RTLD_NOW | RTLD_GLOBAL); } void *sqlite3UnixDlsym(void *pHandle, const char *zSymbol){ return dlsym(pHandle, zSymbol); } int sqlite3UnixDlclose(void *pHandle){ return dlclose(pHandle); } #endif /* SQLITE_OMIT_LOAD_EXTENSION */ /* ** Get information to seed the random number generator. The seed ** is written into the buffer zBuf[256]. The calling function must ** supply a sufficiently large buffer. */ int sqlite3UnixRandomSeed(char *zBuf){ /* We have to initialize zBuf to prevent valgrind from reporting |
︙ | ︙ |
Changes to src/os_win.c.
︙ | ︙ | |||
1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 | #endif /* SQLITE_OMIT_DISKIO */ /*************************************************************************** ** Everything above deals with file I/O. Everything that follows deals ** with other miscellanous aspects of the operating system interface ****************************************************************************/ /* ** Get information to seed the random number generator. The seed ** is written into the buffer zBuf[256]. The calling function must ** supply a sufficiently large buffer. */ int sqlite3WinRandomSeed(char *zBuf){ | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 | #endif /* SQLITE_OMIT_DISKIO */ /*************************************************************************** ** Everything above deals with file I/O. Everything that follows deals ** with other miscellanous aspects of the operating system interface ****************************************************************************/ #if !defined(SQLITE_OMIT_LOAD_EXTENSION) /* ** Interfaces for opening a shared library, finding entry points ** within the shared library, and closing the shared library. */ void *sqlite3WinDlopen(const char *zFilename){ HANDLE h; void *zConverted = convertUtf8Filename(zFilename); if( zConverted==0 ){ return 0; } if( isNT() ){ h = LoadLibraryW(zConverted); }else{ #if OS_WINCE return SQLITE_NOMEM; #else h = LoadLibraryA(zConverted); #endif } sqliteFree(zConverted); return (void*)h; } void *sqlite3WinDlsym(void *pHandle, const char *zSymbol){ return GetProcAddress((HANDLE)pHandle, zSymbol); } int sqlite3WinDlclose(void *pHandle){ return FreeLibrary((HANDLE)pHandle); } #endif /* !SQLITE_OMIT_LOAD_EXTENSION */ /* ** Get information to seed the random number generator. The seed ** is written into the buffer zBuf[256]. The calling function must ** supply a sufficiently large buffer. */ int sqlite3WinRandomSeed(char *zBuf){ |
︙ | ︙ |
Changes to src/sqliteInt.h.
1 2 3 4 5 6 7 8 9 10 11 12 13 | /* ** 2001 September 15 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** Internal interface definitions for SQLite. ** | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | /* ** 2001 September 15 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** Internal interface definitions for SQLite. ** ** @(#) $Id: sqliteInt.h,v 1.532 2006/12/21 01:29:23 drh Exp $ */ #ifndef _SQLITEINT_H_ #define _SQLITEINT_H_ /* ** Extra interface definitions for those who need them */ |
︙ | ︙ | |||
459 460 461 462 463 464 465 | int nTotalChange; /* Value returned by sqlite3_total_changes() */ struct sqlite3InitInfo { /* Information used during initialization */ int iDb; /* When back is being initialized */ int newTnum; /* Rootpage of table being initialized */ u8 busy; /* TRUE if currently initializing */ } init; int nExtension; /* Number of loaded extensions */ | | | 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 | int nTotalChange; /* Value returned by sqlite3_total_changes() */ struct sqlite3InitInfo { /* Information used during initialization */ int iDb; /* When back is being initialized */ int newTnum; /* Rootpage of table being initialized */ u8 busy; /* TRUE if currently initializing */ } init; int nExtension; /* Number of loaded extensions */ void **aExtension; /* Array of shared libraray handles */ struct Vdbe *pVdbe; /* List of active virtual machines */ int activeVdbeCnt; /* Number of vdbes currently executing */ void (*xTrace)(void*,const char*); /* Trace function */ void *pTraceArg; /* Argument to the trace function */ void (*xProfile)(void*,const char*,u64); /* Profiling function */ void *pProfileArg; /* Argument to profile function */ void *pCommitArg; /* Argument to xCommitCallback() */ |
︙ | ︙ |