| OLD | NEW |
| 1 /* | 1 /* |
| 2 ** 2009 January 28 | 2 ** 2009 January 28 |
| 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 ** This file contains test logic for the sqlite3_backup() interface. | 12 ** This file contains test logic for the sqlite3_backup() interface. |
| 13 ** | 13 ** |
| 14 */ | 14 */ |
| 15 | 15 |
| 16 #include "tcl.h" | 16 #include "tcl.h" |
| 17 #include <sqlite3.h> | 17 #include <sqlite3.h> |
| 18 #include <assert.h> | 18 #include <assert.h> |
| 19 | 19 |
| 20 /* These functions are implemented in main.c. */ |
| 21 extern const char *sqlite3ErrName(int); |
| 22 |
| 20 /* These functions are implemented in test1.c. */ | 23 /* These functions are implemented in test1.c. */ |
| 21 int getDbPointer(Tcl_Interp *, const char *, sqlite3 **); | 24 extern int getDbPointer(Tcl_Interp *, const char *, sqlite3 **); |
| 22 const char *sqlite3TestErrorName(int); | |
| 23 | 25 |
| 24 static int backupTestCmd( | 26 static int backupTestCmd( |
| 25 ClientData clientData, | 27 ClientData clientData, |
| 26 Tcl_Interp *interp, | 28 Tcl_Interp *interp, |
| 27 int objc, | 29 int objc, |
| 28 Tcl_Obj *const*objv | 30 Tcl_Obj *const*objv |
| 29 ){ | 31 ){ |
| 30 enum BackupSubCommandEnum { | 32 enum BackupSubCommandEnum { |
| 31 BACKUP_STEP, BACKUP_FINISH, BACKUP_REMAINING, BACKUP_PAGECOUNT | 33 BACKUP_STEP, BACKUP_FINISH, BACKUP_REMAINING, BACKUP_PAGECOUNT |
| 32 }; | 34 }; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 63 case BACKUP_FINISH: { | 65 case BACKUP_FINISH: { |
| 64 const char *zCmdName; | 66 const char *zCmdName; |
| 65 Tcl_CmdInfo cmdInfo; | 67 Tcl_CmdInfo cmdInfo; |
| 66 zCmdName = Tcl_GetString(objv[0]); | 68 zCmdName = Tcl_GetString(objv[0]); |
| 67 Tcl_GetCommandInfo(interp, zCmdName, &cmdInfo); | 69 Tcl_GetCommandInfo(interp, zCmdName, &cmdInfo); |
| 68 cmdInfo.deleteProc = 0; | 70 cmdInfo.deleteProc = 0; |
| 69 Tcl_SetCommandInfo(interp, zCmdName, &cmdInfo); | 71 Tcl_SetCommandInfo(interp, zCmdName, &cmdInfo); |
| 70 Tcl_DeleteCommand(interp, zCmdName); | 72 Tcl_DeleteCommand(interp, zCmdName); |
| 71 | 73 |
| 72 rc = sqlite3_backup_finish(p); | 74 rc = sqlite3_backup_finish(p); |
| 73 Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_STATIC); | 75 Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_STATIC); |
| 74 break; | 76 break; |
| 75 } | 77 } |
| 76 | 78 |
| 77 case BACKUP_STEP: { | 79 case BACKUP_STEP: { |
| 78 int nPage; | 80 int nPage; |
| 79 if( TCL_OK!=Tcl_GetIntFromObj(interp, objv[2], &nPage) ){ | 81 if( TCL_OK!=Tcl_GetIntFromObj(interp, objv[2], &nPage) ){ |
| 80 return TCL_ERROR; | 82 return TCL_ERROR; |
| 81 } | 83 } |
| 82 rc = sqlite3_backup_step(p, nPage); | 84 rc = sqlite3_backup_step(p, nPage); |
| 83 Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_STATIC); | 85 Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_STATIC); |
| 84 break; | 86 break; |
| 85 } | 87 } |
| 86 | 88 |
| 87 case BACKUP_REMAINING: | 89 case BACKUP_REMAINING: |
| 88 Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_backup_remaining(p))); | 90 Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_backup_remaining(p))); |
| 89 break; | 91 break; |
| 90 | 92 |
| 91 case BACKUP_PAGECOUNT: | 93 case BACKUP_PAGECOUNT: |
| 92 Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_backup_pagecount(p))); | 94 Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_backup_pagecount(p))); |
| 93 break; | 95 break; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 | 141 |
| 140 Tcl_CreateObjCommand(interp, zCmd, backupTestCmd, pBackup, backupTestFinish); | 142 Tcl_CreateObjCommand(interp, zCmd, backupTestCmd, pBackup, backupTestFinish); |
| 141 Tcl_SetObjResult(interp, objv[1]); | 143 Tcl_SetObjResult(interp, objv[1]); |
| 142 return TCL_OK; | 144 return TCL_OK; |
| 143 } | 145 } |
| 144 | 146 |
| 145 int Sqlitetestbackup_Init(Tcl_Interp *interp){ | 147 int Sqlitetestbackup_Init(Tcl_Interp *interp){ |
| 146 Tcl_CreateObjCommand(interp, "sqlite3_backup", backupTestInit, 0, 0); | 148 Tcl_CreateObjCommand(interp, "sqlite3_backup", backupTestInit, 0, 0); |
| 147 return TCL_OK; | 149 return TCL_OK; |
| 148 } | 150 } |
| OLD | NEW |