OLD | NEW |
1 /* | 1 /* |
2 ** 2010 November 19 | 2 ** 2010 November 19 |
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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 | 249 |
250 /* | 250 /* |
251 ** End of example code. Everything below here is the test harness. | 251 ** End of example code. Everything below here is the test harness. |
252 ************************************************************************** | 252 ************************************************************************** |
253 ************************************************************************** | 253 ************************************************************************** |
254 *************************************************************************/ | 254 *************************************************************************/ |
255 | 255 |
256 | 256 |
257 #ifdef SQLITE_TEST | 257 #ifdef SQLITE_TEST |
258 | 258 |
259 #include <tcl.h> | 259 #if defined(INCLUDE_SQLITE_TCL_H) |
| 260 # include "sqlite_tcl.h" |
| 261 #else |
| 262 # include "tcl.h" |
| 263 # ifndef SQLITE_TCLAPI |
| 264 # define SQLITE_TCLAPI |
| 265 # endif |
| 266 #endif |
260 | 267 |
261 struct InterpAndScript { | 268 struct InterpAndScript { |
262 Tcl_Interp *interp; | 269 Tcl_Interp *interp; |
263 Tcl_Obj *pScript; | 270 Tcl_Obj *pScript; |
264 }; | 271 }; |
265 typedef struct InterpAndScript InterpAndScript; | 272 typedef struct InterpAndScript InterpAndScript; |
266 | 273 |
267 static void superunlock_del(ClientData cd){ | 274 static void SQLITE_TCLAPI superunlock_del(ClientData cd){ |
268 sqlite3demo_superunlock((void *)cd); | 275 sqlite3demo_superunlock((void *)cd); |
269 } | 276 } |
270 | 277 |
271 static int superunlock_cmd( | 278 static int SQLITE_TCLAPI superunlock_cmd( |
272 ClientData cd, | 279 ClientData cd, |
273 Tcl_Interp *interp, | 280 Tcl_Interp *interp, |
274 int objc, | 281 int objc, |
275 Tcl_Obj *CONST objv[] | 282 Tcl_Obj *CONST objv[] |
276 ){ | 283 ){ |
277 if( objc!=1 ){ | 284 if( objc!=1 ){ |
278 Tcl_WrongNumArgs(interp, 1, objv, ""); | 285 Tcl_WrongNumArgs(interp, 1, objv, ""); |
279 return TCL_ERROR; | 286 return TCL_ERROR; |
280 } | 287 } |
281 Tcl_DeleteCommand(interp, Tcl_GetString(objv[0])); | 288 Tcl_DeleteCommand(interp, Tcl_GetString(objv[0])); |
(...skipping 11 matching lines...) Expand all Loading... |
293 Tcl_EvalObjEx(p->interp, pEval, TCL_EVAL_GLOBAL); | 300 Tcl_EvalObjEx(p->interp, pEval, TCL_EVAL_GLOBAL); |
294 Tcl_GetIntFromObj(p->interp, Tcl_GetObjResult(p->interp), &iVal); | 301 Tcl_GetIntFromObj(p->interp, Tcl_GetObjResult(p->interp), &iVal); |
295 Tcl_DecrRefCount(pEval); | 302 Tcl_DecrRefCount(pEval); |
296 | 303 |
297 return iVal; | 304 return iVal; |
298 } | 305 } |
299 | 306 |
300 /* | 307 /* |
301 ** Tclcmd: sqlite3demo_superlock CMDNAME PATH VFS BUSY-HANDLER-SCRIPT | 308 ** Tclcmd: sqlite3demo_superlock CMDNAME PATH VFS BUSY-HANDLER-SCRIPT |
302 */ | 309 */ |
303 static int superlock_cmd( | 310 static int SQLITE_TCLAPI superlock_cmd( |
304 ClientData cd, | 311 ClientData cd, |
305 Tcl_Interp *interp, | 312 Tcl_Interp *interp, |
306 int objc, | 313 int objc, |
307 Tcl_Obj *CONST objv[] | 314 Tcl_Obj *CONST objv[] |
308 ){ | 315 ){ |
309 void *pLock; /* Lock context */ | 316 void *pLock; /* Lock context */ |
310 char *zPath; | 317 char *zPath; |
311 char *zVfs = 0; | 318 char *zVfs = 0; |
312 InterpAndScript busy = {0, 0}; | 319 InterpAndScript busy = {0, 0}; |
313 int (*xBusy)(void*,int) = 0; /* Busy handler callback */ | 320 int (*xBusy)(void*,int) = 0; /* Busy handler callback */ |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 ); | 354 ); |
348 Tcl_SetObjResult(interp, objv[1]); | 355 Tcl_SetObjResult(interp, objv[1]); |
349 return TCL_OK; | 356 return TCL_OK; |
350 } | 357 } |
351 | 358 |
352 int SqliteSuperlock_Init(Tcl_Interp *interp){ | 359 int SqliteSuperlock_Init(Tcl_Interp *interp){ |
353 Tcl_CreateObjCommand(interp, "sqlite3demo_superlock", superlock_cmd, 0, 0); | 360 Tcl_CreateObjCommand(interp, "sqlite3demo_superlock", superlock_cmd, 0, 0); |
354 return TCL_OK; | 361 return TCL_OK; |
355 } | 362 } |
356 #endif | 363 #endif |
OLD | NEW |