OLD | NEW |
1 /* | 1 /* |
2 ** 2006 August 23 | 2 ** 2006 August 23 |
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 ** Test extension for testing the sqlite3_auto_extension() function. | 12 ** Test extension for testing the sqlite3_auto_extension() function. |
13 */ | 13 */ |
14 #include "tcl.h" | 14 #if defined(INCLUDE_SQLITE_TCL_H) |
| 15 # include "sqlite_tcl.h" |
| 16 #else |
| 17 # include "tcl.h" |
| 18 # ifndef SQLITE_TCLAPI |
| 19 # define SQLITE_TCLAPI |
| 20 # endif |
| 21 #endif |
15 #include "sqlite3ext.h" | 22 #include "sqlite3ext.h" |
16 | 23 |
17 #ifndef SQLITE_OMIT_LOAD_EXTENSION | 24 #ifndef SQLITE_OMIT_LOAD_EXTENSION |
18 SQLITE_EXTENSION_INIT1 | 25 SQLITE_EXTENSION_INIT1 |
19 | 26 |
20 /* | 27 /* |
21 ** The sqr() SQL function returns the square of its input value. | 28 ** The sqr() SQL function returns the square of its input value. |
22 */ | 29 */ |
23 static void sqrFunc( | 30 static void sqrFunc( |
24 sqlite3_context *context, | 31 sqlite3_context *context, |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 zErr = sqlite3_mprintf("broken autoext!"); | 87 zErr = sqlite3_mprintf("broken autoext!"); |
81 *pzErrMsg = zErr; | 88 *pzErrMsg = zErr; |
82 return 1; | 89 return 1; |
83 } | 90 } |
84 | 91 |
85 /* | 92 /* |
86 ** tclcmd: sqlite3_auto_extension_sqr | 93 ** tclcmd: sqlite3_auto_extension_sqr |
87 ** | 94 ** |
88 ** Register the "sqr" extension to be loaded automatically. | 95 ** Register the "sqr" extension to be loaded automatically. |
89 */ | 96 */ |
90 static int autoExtSqrObjCmd( | 97 static int SQLITE_TCLAPI autoExtSqrObjCmd( |
91 void * clientData, | 98 void * clientData, |
92 Tcl_Interp *interp, | 99 Tcl_Interp *interp, |
93 int objc, | 100 int objc, |
94 Tcl_Obj *CONST objv[] | 101 Tcl_Obj *CONST objv[] |
95 ){ | 102 ){ |
96 int rc = sqlite3_auto_extension((void*)sqr_init); | 103 int rc = sqlite3_auto_extension((void(*)(void))sqr_init); |
97 Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); | 104 Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); |
98 return SQLITE_OK; | 105 return SQLITE_OK; |
99 } | 106 } |
100 | 107 |
101 /* | 108 /* |
102 ** tclcmd: sqlite3_cancel_auto_extension_sqr | 109 ** tclcmd: sqlite3_cancel_auto_extension_sqr |
103 ** | 110 ** |
104 ** Unregister the "sqr" extension. | 111 ** Unregister the "sqr" extension. |
105 */ | 112 */ |
106 static int cancelAutoExtSqrObjCmd( | 113 static int SQLITE_TCLAPI cancelAutoExtSqrObjCmd( |
107 void * clientData, | 114 void * clientData, |
108 Tcl_Interp *interp, | 115 Tcl_Interp *interp, |
109 int objc, | 116 int objc, |
110 Tcl_Obj *CONST objv[] | 117 Tcl_Obj *CONST objv[] |
111 ){ | 118 ){ |
112 int rc = sqlite3_cancel_auto_extension((void*)sqr_init); | 119 int rc = sqlite3_cancel_auto_extension((void(*)(void))sqr_init); |
113 Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); | 120 Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); |
114 return SQLITE_OK; | 121 return SQLITE_OK; |
115 } | 122 } |
116 | 123 |
117 /* | 124 /* |
118 ** tclcmd: sqlite3_auto_extension_cube | 125 ** tclcmd: sqlite3_auto_extension_cube |
119 ** | 126 ** |
120 ** Register the "cube" extension to be loaded automatically. | 127 ** Register the "cube" extension to be loaded automatically. |
121 */ | 128 */ |
122 static int autoExtCubeObjCmd( | 129 static int SQLITE_TCLAPI autoExtCubeObjCmd( |
123 void * clientData, | 130 void * clientData, |
124 Tcl_Interp *interp, | 131 Tcl_Interp *interp, |
125 int objc, | 132 int objc, |
126 Tcl_Obj *CONST objv[] | 133 Tcl_Obj *CONST objv[] |
127 ){ | 134 ){ |
128 int rc = sqlite3_auto_extension((void*)cube_init); | 135 int rc = sqlite3_auto_extension((void(*)(void))cube_init); |
129 Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); | 136 Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); |
130 return SQLITE_OK; | 137 return SQLITE_OK; |
131 } | 138 } |
132 | 139 |
133 /* | 140 /* |
134 ** tclcmd: sqlite3_cancel_auto_extension_cube | 141 ** tclcmd: sqlite3_cancel_auto_extension_cube |
135 ** | 142 ** |
136 ** Unregister the "cube" extension. | 143 ** Unregister the "cube" extension. |
137 */ | 144 */ |
138 static int cancelAutoExtCubeObjCmd( | 145 static int SQLITE_TCLAPI cancelAutoExtCubeObjCmd( |
139 void * clientData, | 146 void * clientData, |
140 Tcl_Interp *interp, | 147 Tcl_Interp *interp, |
141 int objc, | 148 int objc, |
142 Tcl_Obj *CONST objv[] | 149 Tcl_Obj *CONST objv[] |
143 ){ | 150 ){ |
144 int rc = sqlite3_cancel_auto_extension((void*)cube_init); | 151 int rc = sqlite3_cancel_auto_extension((void(*)(void))cube_init); |
145 Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); | 152 Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); |
146 return SQLITE_OK; | 153 return SQLITE_OK; |
147 } | 154 } |
148 | 155 |
149 /* | 156 /* |
150 ** tclcmd: sqlite3_auto_extension_broken | 157 ** tclcmd: sqlite3_auto_extension_broken |
151 ** | 158 ** |
152 ** Register the broken extension to be loaded automatically. | 159 ** Register the broken extension to be loaded automatically. |
153 */ | 160 */ |
154 static int autoExtBrokenObjCmd( | 161 static int SQLITE_TCLAPI autoExtBrokenObjCmd( |
155 void * clientData, | 162 void * clientData, |
156 Tcl_Interp *interp, | 163 Tcl_Interp *interp, |
157 int objc, | 164 int objc, |
158 Tcl_Obj *CONST objv[] | 165 Tcl_Obj *CONST objv[] |
159 ){ | 166 ){ |
160 int rc = sqlite3_auto_extension((void*)broken_init); | 167 int rc = sqlite3_auto_extension((void(*)(void))broken_init); |
161 Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); | 168 Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); |
162 return SQLITE_OK; | 169 return SQLITE_OK; |
163 } | 170 } |
164 | 171 |
165 /* | 172 /* |
166 ** tclcmd: sqlite3_cancel_auto_extension_broken | 173 ** tclcmd: sqlite3_cancel_auto_extension_broken |
167 ** | 174 ** |
168 ** Unregister the broken extension. | 175 ** Unregister the broken extension. |
169 */ | 176 */ |
170 static int cancelAutoExtBrokenObjCmd( | 177 static int SQLITE_TCLAPI cancelAutoExtBrokenObjCmd( |
171 void * clientData, | 178 void * clientData, |
172 Tcl_Interp *interp, | 179 Tcl_Interp *interp, |
173 int objc, | 180 int objc, |
174 Tcl_Obj *CONST objv[] | 181 Tcl_Obj *CONST objv[] |
175 ){ | 182 ){ |
176 int rc = sqlite3_cancel_auto_extension((void*)broken_init); | 183 int rc = sqlite3_cancel_auto_extension((void(*)(void))broken_init); |
177 Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); | 184 Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); |
178 return SQLITE_OK; | 185 return SQLITE_OK; |
179 } | 186 } |
180 | 187 |
181 #endif /* SQLITE_OMIT_LOAD_EXTENSION */ | 188 #endif /* SQLITE_OMIT_LOAD_EXTENSION */ |
182 | 189 |
183 | 190 |
184 /* | 191 /* |
185 ** tclcmd: sqlite3_reset_auto_extension | 192 ** tclcmd: sqlite3_reset_auto_extension |
186 ** | 193 ** |
187 ** Reset all auto-extensions | 194 ** Reset all auto-extensions |
188 */ | 195 */ |
189 static int resetAutoExtObjCmd( | 196 static int SQLITE_TCLAPI resetAutoExtObjCmd( |
190 void * clientData, | 197 void * clientData, |
191 Tcl_Interp *interp, | 198 Tcl_Interp *interp, |
192 int objc, | 199 int objc, |
193 Tcl_Obj *CONST objv[] | 200 Tcl_Obj *CONST objv[] |
194 ){ | 201 ){ |
195 sqlite3_reset_auto_extension(); | 202 sqlite3_reset_auto_extension(); |
196 return SQLITE_OK; | 203 return SQLITE_OK; |
197 } | 204 } |
198 | 205 |
199 | 206 |
(...skipping 12 matching lines...) Expand all Loading... |
212 cancelAutoExtSqrObjCmd, 0, 0); | 219 cancelAutoExtSqrObjCmd, 0, 0); |
213 Tcl_CreateObjCommand(interp, "sqlite3_cancel_auto_extension_cube", | 220 Tcl_CreateObjCommand(interp, "sqlite3_cancel_auto_extension_cube", |
214 cancelAutoExtCubeObjCmd, 0, 0); | 221 cancelAutoExtCubeObjCmd, 0, 0); |
215 Tcl_CreateObjCommand(interp, "sqlite3_cancel_auto_extension_broken", | 222 Tcl_CreateObjCommand(interp, "sqlite3_cancel_auto_extension_broken", |
216 cancelAutoExtBrokenObjCmd, 0, 0); | 223 cancelAutoExtBrokenObjCmd, 0, 0); |
217 #endif | 224 #endif |
218 Tcl_CreateObjCommand(interp, "sqlite3_reset_auto_extension", | 225 Tcl_CreateObjCommand(interp, "sqlite3_reset_auto_extension", |
219 resetAutoExtObjCmd, 0, 0); | 226 resetAutoExtObjCmd, 0, 0); |
220 return TCL_OK; | 227 return TCL_OK; |
221 } | 228 } |
OLD | NEW |