OLD | NEW |
1 /* | 1 /* |
2 ** 2005 November 29 | 2 ** 2005 November 29 |
3 ** | 3 ** |
4 ** The author disclaims copyright to this source code. In place of | 4 ** The author disclaims copyright to this source code. In place of |
5 ** a legal notice, here is a blessing: | 5 ** a legal notice, here is a blessing: |
6 ** | 6 ** |
7 ** May you do good and not evil. | 7 ** May you do good and not evil. |
8 ** May you find forgiveness for yourself and forgive others. | 8 ** May you find forgiveness for yourself and forgive others. |
9 ** May you share freely, never taking more than you give. | 9 ** May you share freely, never taking more than you give. |
10 ** | 10 ** |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 ** Register a VFS with the system. It is harmless to register the same | 354 ** Register a VFS with the system. It is harmless to register the same |
355 ** VFS multiple times. The new VFS becomes the default if makeDflt is | 355 ** VFS multiple times. The new VFS becomes the default if makeDflt is |
356 ** true. | 356 ** true. |
357 */ | 357 */ |
358 int sqlite3_vfs_register(sqlite3_vfs *pVfs, int makeDflt){ | 358 int sqlite3_vfs_register(sqlite3_vfs *pVfs, int makeDflt){ |
359 MUTEX_LOGIC(sqlite3_mutex *mutex;) | 359 MUTEX_LOGIC(sqlite3_mutex *mutex;) |
360 #ifndef SQLITE_OMIT_AUTOINIT | 360 #ifndef SQLITE_OMIT_AUTOINIT |
361 int rc = sqlite3_initialize(); | 361 int rc = sqlite3_initialize(); |
362 if( rc ) return rc; | 362 if( rc ) return rc; |
363 #endif | 363 #endif |
| 364 #ifdef SQLITE_ENABLE_API_ARMOR |
| 365 if( pVfs==0 ) return SQLITE_MISUSE_BKPT; |
| 366 #endif |
| 367 |
364 MUTEX_LOGIC( mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); ) | 368 MUTEX_LOGIC( mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); ) |
365 sqlite3_mutex_enter(mutex); | 369 sqlite3_mutex_enter(mutex); |
366 vfsUnlink(pVfs); | 370 vfsUnlink(pVfs); |
367 if( makeDflt || vfsList==0 ){ | 371 if( makeDflt || vfsList==0 ){ |
368 pVfs->pNext = vfsList; | 372 pVfs->pNext = vfsList; |
369 vfsList = pVfs; | 373 vfsList = pVfs; |
370 }else{ | 374 }else{ |
371 pVfs->pNext = vfsList->pNext; | 375 pVfs->pNext = vfsList->pNext; |
372 vfsList->pNext = pVfs; | 376 vfsList->pNext = pVfs; |
373 } | 377 } |
374 assert(vfsList); | 378 assert(vfsList); |
375 sqlite3_mutex_leave(mutex); | 379 sqlite3_mutex_leave(mutex); |
376 return SQLITE_OK; | 380 return SQLITE_OK; |
377 } | 381 } |
378 | 382 |
379 /* | 383 /* |
380 ** Unregister a VFS so that it is no longer accessible. | 384 ** Unregister a VFS so that it is no longer accessible. |
381 */ | 385 */ |
382 int sqlite3_vfs_unregister(sqlite3_vfs *pVfs){ | 386 int sqlite3_vfs_unregister(sqlite3_vfs *pVfs){ |
383 #if SQLITE_THREADSAFE | 387 #if SQLITE_THREADSAFE |
384 sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); | 388 sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); |
385 #endif | 389 #endif |
386 sqlite3_mutex_enter(mutex); | 390 sqlite3_mutex_enter(mutex); |
387 vfsUnlink(pVfs); | 391 vfsUnlink(pVfs); |
388 sqlite3_mutex_leave(mutex); | 392 sqlite3_mutex_leave(mutex); |
389 return SQLITE_OK; | 393 return SQLITE_OK; |
390 } | 394 } |
OLD | NEW |