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 #if defined(INCLUDE_SQLITE_TCL_H) |
| 17 # include "sqlite_tcl.h" |
| 18 #else |
| 19 # include "tcl.h" |
| 20 # ifndef SQLITE_TCLAPI |
| 21 # define SQLITE_TCLAPI |
| 22 # endif |
| 23 #endif |
17 #include "sqlite3.h" | 24 #include "sqlite3.h" |
18 #include <assert.h> | 25 #include <assert.h> |
19 | 26 |
20 /* These functions are implemented in main.c. */ | 27 /* These functions are implemented in main.c. */ |
21 extern const char *sqlite3ErrName(int); | 28 extern const char *sqlite3ErrName(int); |
22 | 29 |
23 /* These functions are implemented in test1.c. */ | 30 /* These functions are implemented in test1.c. */ |
24 extern int getDbPointer(Tcl_Interp *, const char *, sqlite3 **); | 31 extern int getDbPointer(Tcl_Interp *, const char *, sqlite3 **); |
25 | 32 |
26 static int backupTestCmd( | 33 static int SQLITE_TCLAPI backupTestCmd( |
27 ClientData clientData, | 34 ClientData clientData, |
28 Tcl_Interp *interp, | 35 Tcl_Interp *interp, |
29 int objc, | 36 int objc, |
30 Tcl_Obj *const*objv | 37 Tcl_Obj *const*objv |
31 ){ | 38 ){ |
32 enum BackupSubCommandEnum { | 39 enum BackupSubCommandEnum { |
33 BACKUP_STEP, BACKUP_FINISH, BACKUP_REMAINING, BACKUP_PAGECOUNT | 40 BACKUP_STEP, BACKUP_FINISH, BACKUP_REMAINING, BACKUP_PAGECOUNT |
34 }; | 41 }; |
35 struct BackupSubCommand { | 42 struct BackupSubCommand { |
36 const char *zCmd; | 43 const char *zCmd; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 break; | 98 break; |
92 | 99 |
93 case BACKUP_PAGECOUNT: | 100 case BACKUP_PAGECOUNT: |
94 Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_backup_pagecount(p))); | 101 Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_backup_pagecount(p))); |
95 break; | 102 break; |
96 } | 103 } |
97 | 104 |
98 return TCL_OK; | 105 return TCL_OK; |
99 } | 106 } |
100 | 107 |
101 static void backupTestFinish(ClientData clientData){ | 108 static void SQLITE_TCLAPI backupTestFinish(ClientData clientData){ |
102 sqlite3_backup *pBackup = (sqlite3_backup *)clientData; | 109 sqlite3_backup *pBackup = (sqlite3_backup *)clientData; |
103 sqlite3_backup_finish(pBackup); | 110 sqlite3_backup_finish(pBackup); |
104 } | 111 } |
105 | 112 |
106 /* | 113 /* |
107 ** sqlite3_backup CMDNAME DESTHANDLE DESTNAME SRCHANDLE SRCNAME | 114 ** sqlite3_backup CMDNAME DESTHANDLE DESTNAME SRCHANDLE SRCNAME |
108 ** | 115 ** |
109 */ | 116 */ |
110 static int backupTestInit( | 117 static int SQLITE_TCLAPI backupTestInit( |
111 ClientData clientData, | 118 ClientData clientData, |
112 Tcl_Interp *interp, | 119 Tcl_Interp *interp, |
113 int objc, | 120 int objc, |
114 Tcl_Obj *const*objv | 121 Tcl_Obj *const*objv |
115 ){ | 122 ){ |
116 sqlite3_backup *pBackup; | 123 sqlite3_backup *pBackup; |
117 sqlite3 *pDestDb; | 124 sqlite3 *pDestDb; |
118 sqlite3 *pSrcDb; | 125 sqlite3 *pSrcDb; |
119 const char *zDestName; | 126 const char *zDestName; |
120 const char *zSrcName; | 127 const char *zSrcName; |
(...skipping 20 matching lines...) Expand all Loading... |
141 | 148 |
142 Tcl_CreateObjCommand(interp, zCmd, backupTestCmd, pBackup, backupTestFinish); | 149 Tcl_CreateObjCommand(interp, zCmd, backupTestCmd, pBackup, backupTestFinish); |
143 Tcl_SetObjResult(interp, objv[1]); | 150 Tcl_SetObjResult(interp, objv[1]); |
144 return TCL_OK; | 151 return TCL_OK; |
145 } | 152 } |
146 | 153 |
147 int Sqlitetestbackup_Init(Tcl_Interp *interp){ | 154 int Sqlitetestbackup_Init(Tcl_Interp *interp){ |
148 Tcl_CreateObjCommand(interp, "sqlite3_backup", backupTestInit, 0, 0); | 155 Tcl_CreateObjCommand(interp, "sqlite3_backup", backupTestInit, 0, 0); |
149 return TCL_OK; | 156 return TCL_OK; |
150 } | 157 } |
OLD | NEW |