| OLD | NEW |
| 1 /* | 1 /* |
| 2 ** 2005 December 14 | 2 ** 2005 December 14 |
| 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 ** |
| 11 ************************************************************************* | 11 ************************************************************************* |
| 12 ** | 12 ** |
| 13 ** This file contains a binding of the asynchronous IO extension interface | 13 ** This file contains a binding of the asynchronous IO extension interface |
| 14 ** (defined in ext/async/sqlite3async.h) to Tcl. | 14 ** (defined in ext/async/sqlite3async.h) to Tcl. |
| 15 */ | 15 */ |
| 16 | 16 |
| 17 #define TCL_THREADS | 17 #define TCL_THREADS |
| 18 #include <tcl.h> | 18 #include <tcl.h> |
| 19 | 19 |
| 20 #ifdef SQLITE_ENABLE_ASYNCIO | 20 #ifdef SQLITE_ENABLE_ASYNCIO |
| 21 | 21 |
| 22 #include "sqlite3async.h" | 22 #include "sqlite3async.h" |
| 23 #include "sqlite3.h" | 23 #include "sqlite3.h" |
| 24 #include <assert.h> | 24 #include <assert.h> |
| 25 | 25 |
| 26 /* From test1.c */ | 26 /* From main.c */ |
| 27 const char *sqlite3TestErrorName(int); | 27 extern const char *sqlite3ErrName(int); |
| 28 | 28 |
| 29 | 29 |
| 30 struct TestAsyncGlobal { | 30 struct TestAsyncGlobal { |
| 31 int isInstalled; /* True when async VFS is installed */ | 31 int isInstalled; /* True when async VFS is installed */ |
| 32 } testasync_g = { 0 }; | 32 } testasync_g = { 0 }; |
| 33 | 33 |
| 34 TCL_DECLARE_MUTEX(testasync_g_writerMutex); | 34 TCL_DECLARE_MUTEX(testasync_g_writerMutex); |
| 35 | 35 |
| 36 /* | 36 /* |
| 37 ** sqlite3async_initialize PARENT-VFS ISDEFAULT | 37 ** sqlite3async_initialize PARENT-VFS ISDEFAULT |
| (...skipping 15 matching lines...) Expand all Loading... |
| 53 zParent = Tcl_GetString(objv[1]); | 53 zParent = Tcl_GetString(objv[1]); |
| 54 if( !*zParent ) { | 54 if( !*zParent ) { |
| 55 zParent = 0; | 55 zParent = 0; |
| 56 } | 56 } |
| 57 if( Tcl_GetBooleanFromObj(interp, objv[2], &isDefault) ){ | 57 if( Tcl_GetBooleanFromObj(interp, objv[2], &isDefault) ){ |
| 58 return TCL_ERROR; | 58 return TCL_ERROR; |
| 59 } | 59 } |
| 60 | 60 |
| 61 rc = sqlite3async_initialize(zParent, isDefault); | 61 rc = sqlite3async_initialize(zParent, isDefault); |
| 62 if( rc!=SQLITE_OK ){ | 62 if( rc!=SQLITE_OK ){ |
| 63 Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3TestErrorName(rc), -1)); | 63 Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1)); |
| 64 return TCL_ERROR; | 64 return TCL_ERROR; |
| 65 } | 65 } |
| 66 return TCL_OK; | 66 return TCL_OK; |
| 67 } | 67 } |
| 68 | 68 |
| 69 /* | 69 /* |
| 70 ** sqlite3async_shutdown | 70 ** sqlite3async_shutdown |
| 71 */ | 71 */ |
| 72 static int testAsyncShutdown( | 72 static int testAsyncShutdown( |
| 73 void * clientData, | 73 void * clientData, |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 } | 201 } |
| 202 | 202 |
| 203 if( rc==SQLITE_OK ){ | 203 if( rc==SQLITE_OK ){ |
| 204 rc = sqlite3async_control( | 204 rc = sqlite3async_control( |
| 205 eOpt==SQLITEASYNC_HALT ? SQLITEASYNC_GET_HALT : | 205 eOpt==SQLITEASYNC_HALT ? SQLITEASYNC_GET_HALT : |
| 206 eOpt==SQLITEASYNC_DELAY ? SQLITEASYNC_GET_DELAY : | 206 eOpt==SQLITEASYNC_DELAY ? SQLITEASYNC_GET_DELAY : |
| 207 SQLITEASYNC_GET_LOCKFILES, &iVal); | 207 SQLITEASYNC_GET_LOCKFILES, &iVal); |
| 208 } | 208 } |
| 209 | 209 |
| 210 if( rc!=SQLITE_OK ){ | 210 if( rc!=SQLITE_OK ){ |
| 211 Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3TestErrorName(rc), -1)); | 211 Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1)); |
| 212 return TCL_ERROR; | 212 return TCL_ERROR; |
| 213 } | 213 } |
| 214 | 214 |
| 215 if( eOpt==SQLITEASYNC_HALT ){ | 215 if( eOpt==SQLITEASYNC_HALT ){ |
| 216 Tcl_SetObjResult(interp, Tcl_NewStringObj(az[iVal], -1)); | 216 Tcl_SetObjResult(interp, Tcl_NewStringObj(az[iVal], -1)); |
| 217 }else{ | 217 }else{ |
| 218 Tcl_SetObjResult(interp, Tcl_NewIntObj(iVal)); | 218 Tcl_SetObjResult(interp, Tcl_NewIntObj(iVal)); |
| 219 } | 219 } |
| 220 | 220 |
| 221 return TCL_OK; | 221 return TCL_OK; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 232 #ifdef SQLITE_ENABLE_ASYNCIO | 232 #ifdef SQLITE_ENABLE_ASYNCIO |
| 233 Tcl_CreateObjCommand(interp,"sqlite3async_start",testAsyncStart,0,0); | 233 Tcl_CreateObjCommand(interp,"sqlite3async_start",testAsyncStart,0,0); |
| 234 Tcl_CreateObjCommand(interp,"sqlite3async_wait",testAsyncWait,0,0); | 234 Tcl_CreateObjCommand(interp,"sqlite3async_wait",testAsyncWait,0,0); |
| 235 | 235 |
| 236 Tcl_CreateObjCommand(interp,"sqlite3async_control",testAsyncControl,0,0); | 236 Tcl_CreateObjCommand(interp,"sqlite3async_control",testAsyncControl,0,0); |
| 237 Tcl_CreateObjCommand(interp,"sqlite3async_initialize",testAsyncInit,0,0); | 237 Tcl_CreateObjCommand(interp,"sqlite3async_initialize",testAsyncInit,0,0); |
| 238 Tcl_CreateObjCommand(interp,"sqlite3async_shutdown",testAsyncShutdown,0,0); | 238 Tcl_CreateObjCommand(interp,"sqlite3async_shutdown",testAsyncShutdown,0,0); |
| 239 #endif /* SQLITE_ENABLE_ASYNCIO */ | 239 #endif /* SQLITE_ENABLE_ASYNCIO */ |
| 240 return TCL_OK; | 240 return TCL_OK; |
| 241 } | 241 } |
| OLD | NEW |