• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 ** 2006 June 7
3 **
4 ** The author disclaims copyright to this source code.  In place of
5 ** a legal notice, here is a blessing:
6 **
7 **    May you do good and not evil.
8 **    May you find forgiveness for yourself and forgive others.
9 **    May you share freely, never taking more than you give.
10 **
11 *************************************************************************
12 ** This header file defines the SQLite interface for use by
13 ** shared libraries that want to be imported as extensions into
14 ** an SQLite instance.  Shared libraries that intend to be loaded
15 ** as extensions by SQLite should #include this file instead of
16 ** sqlite3.h.
17 **
18 ** @(#) $Id: sqlite3ext.h,v 1.10 2007/03/29 18:46:01 drh Exp $
19 */
20 #ifndef _SQLITE3EXT_H_
21 #define _SQLITE3EXT_H_
22 #include "sqlite3.h"
23 
24 typedef struct sqlite3_api_routines sqlite3_api_routines;
25 
26 /*
27 ** The following structure hold pointers to all of the SQLite API
28 ** routines.
29 */
30 struct sqlite3_api_routines {
31   void * (*aggregate_context)(sqlite3_context*,int nBytes);
32   int  (*aggregate_count)(sqlite3_context*);
33   int  (*bind_blob)(sqlite3_stmt*,int,const void*,int n,void(*)(void*));
34   int  (*bind_double)(sqlite3_stmt*,int,double);
35   int  (*bind_int)(sqlite3_stmt*,int,int);
36   int  (*bind_int64)(sqlite3_stmt*,int,sqlite_int64);
37   int  (*bind_null)(sqlite3_stmt*,int);
38   int  (*bind_parameter_count)(sqlite3_stmt*);
39   int  (*bind_parameter_index)(sqlite3_stmt*,const char*zName);
40   const char * (*bind_parameter_name)(sqlite3_stmt*,int);
41   int  (*bind_text)(sqlite3_stmt*,int,const char*,int n,void(*)(void*));
42   int  (*bind_text16)(sqlite3_stmt*,int,const void*,int,void(*)(void*));
43   int  (*bind_value)(sqlite3_stmt*,int,const sqlite3_value*);
44   int  (*busy_handler)(sqlite3*,int(*)(void*,int),void*);
45   int  (*busy_timeout)(sqlite3*,int ms);
46   int  (*changes)(sqlite3*);
47   int  (*close)(sqlite3*);
48   int  (*collation_needed)(sqlite3*,void*,void(*)(void*,sqlite3*,int eTextRep,const char*));
49   int  (*collation_needed16)(sqlite3*,void*,void(*)(void*,sqlite3*,int eTextRep,const void*));
50   const void * (*column_blob)(sqlite3_stmt*,int iCol);
51   int  (*column_bytes)(sqlite3_stmt*,int iCol);
52   int  (*column_bytes16)(sqlite3_stmt*,int iCol);
53   int  (*column_count)(sqlite3_stmt*pStmt);
54   const char * (*column_database_name)(sqlite3_stmt*,int);
55   const void * (*column_database_name16)(sqlite3_stmt*,int);
56   const char * (*column_decltype)(sqlite3_stmt*,int i);
57   const void * (*column_decltype16)(sqlite3_stmt*,int);
58   double  (*column_double)(sqlite3_stmt*,int iCol);
59   int  (*column_int)(sqlite3_stmt*,int iCol);
60   sqlite_int64  (*column_int64)(sqlite3_stmt*,int iCol);
61   const char * (*column_name)(sqlite3_stmt*,int);
62   const void * (*column_name16)(sqlite3_stmt*,int);
63   const char * (*column_origin_name)(sqlite3_stmt*,int);
64   const void * (*column_origin_name16)(sqlite3_stmt*,int);
65   const char * (*column_table_name)(sqlite3_stmt*,int);
66   const void * (*column_table_name16)(sqlite3_stmt*,int);
67   const unsigned char * (*column_text)(sqlite3_stmt*,int iCol);
68   const void * (*column_text16)(sqlite3_stmt*,int iCol);
69   int  (*column_type)(sqlite3_stmt*,int iCol);
70   sqlite3_value* (*column_value)(sqlite3_stmt*,int iCol);
71   void * (*commit_hook)(sqlite3*,int(*)(void*),void*);
72   int  (*complete)(const char*sql);
73   int  (*complete16)(const void*sql);
74   int  (*create_collation)(sqlite3*,const char*,int,void*,int(*)(void*,int,const void*,int,const void*));
75   int  (*create_collation16)(sqlite3*,const char*,int,void*,int(*)(void*,int,const void*,int,const void*));
76   int  (*create_function)(sqlite3*,const char*,int,int,void*,void (*xFunc)(sqlite3_context*,int,sqlite3_value**),void (*xStep)(sqlite3_context*,int,sqlite3_value**),void (*xFinal)(sqlite3_context*));
77   int  (*create_function16)(sqlite3*,const void*,int,int,void*,void (*xFunc)(sqlite3_context*,int,sqlite3_value**),void (*xStep)(sqlite3_context*,int,sqlite3_value**),void (*xFinal)(sqlite3_context*));
78   int (*create_module)(sqlite3*,const char*,const sqlite3_module*,void*);
79   int  (*data_count)(sqlite3_stmt*pStmt);
80   sqlite3 * (*db_handle)(sqlite3_stmt*);
81   int (*declare_vtab)(sqlite3*,const char*);
82   int  (*enable_shared_cache)(int);
83   int  (*errcode)(sqlite3*db);
84   const char * (*errmsg)(sqlite3*);
85   const void * (*errmsg16)(sqlite3*);
86   int  (*exec)(sqlite3*,const char*,sqlite3_callback,void*,char**);
87   int  (*expired)(sqlite3_stmt*);
88   int  (*finalize)(sqlite3_stmt*pStmt);
89   void  (*free)(void*);
90   void  (*free_table)(char**result);
91   int  (*get_autocommit)(sqlite3*);
92   void * (*get_auxdata)(sqlite3_context*,int);
93   int  (*get_table)(sqlite3*,const char*,char***,int*,int*,char**);
94   int  (*global_recover)(void);
95   void  (*interruptx)(sqlite3*);
96   sqlite_int64  (*last_insert_rowid)(sqlite3*);
97   const char * (*libversion)(void);
98   int  (*libversion_number)(void);
99   void *(*malloc)(int);
100   char * (*mprintf)(const char*,...);
101   int  (*open)(const char*,sqlite3**);
102   int  (*open16)(const void*,sqlite3**);
103   int  (*prepare)(sqlite3*,const char*,int,sqlite3_stmt**,const char**);
104   int  (*prepare16)(sqlite3*,const void*,int,sqlite3_stmt**,const void**);
105   void * (*profile)(sqlite3*,void(*)(void*,const char*,sqlite_uint64),void*);
106   void  (*progress_handler)(sqlite3*,int,int(*)(void*),void*);
107   void *(*realloc)(void*,int);
108   int  (*reset)(sqlite3_stmt*pStmt);
109   void  (*result_blob)(sqlite3_context*,const void*,int,void(*)(void*));
110   void  (*result_double)(sqlite3_context*,double);
111   void  (*result_error)(sqlite3_context*,const char*,int);
112   void  (*result_error16)(sqlite3_context*,const void*,int);
113   void  (*result_int)(sqlite3_context*,int);
114   void  (*result_int64)(sqlite3_context*,sqlite_int64);
115   void  (*result_null)(sqlite3_context*);
116   void  (*result_text)(sqlite3_context*,const char*,int,void(*)(void*));
117   void  (*result_text16)(sqlite3_context*,const void*,int,void(*)(void*));
118   void  (*result_text16be)(sqlite3_context*,const void*,int,void(*)(void*));
119   void  (*result_text16le)(sqlite3_context*,const void*,int,void(*)(void*));
120   void  (*result_value)(sqlite3_context*,sqlite3_value*);
121   void * (*rollback_hook)(sqlite3*,void(*)(void*),void*);
122   int  (*set_authorizer)(sqlite3*,int(*)(void*,int,const char*,const char*,const char*,const char*),void*);
123   void  (*set_auxdata)(sqlite3_context*,int,void*,void (*)(void*));
124   char * (*snprintf)(int,char*,const char*,...);
125   int  (*step)(sqlite3_stmt*);
126   int  (*table_column_metadata)(sqlite3*,const char*,const char*,const char*,char const**,char const**,int*,int*,int*);
127   void  (*thread_cleanup)(void);
128   int  (*total_changes)(sqlite3*);
129   void * (*trace)(sqlite3*,void(*xTrace)(void*,const char*),void*);
130   int  (*transfer_bindings)(sqlite3_stmt*,sqlite3_stmt*);
131   void * (*update_hook)(sqlite3*,void(*)(void*,int ,char const*,char const*,sqlite_int64),void*);
132   void * (*user_data)(sqlite3_context*);
133   const void * (*value_blob)(sqlite3_value*);
134   int  (*value_bytes)(sqlite3_value*);
135   int  (*value_bytes16)(sqlite3_value*);
136   double  (*value_double)(sqlite3_value*);
137   int  (*value_int)(sqlite3_value*);
138   sqlite_int64  (*value_int64)(sqlite3_value*);
139   int  (*value_numeric_type)(sqlite3_value*);
140   const unsigned char * (*value_text)(sqlite3_value*);
141   const void * (*value_text16)(sqlite3_value*);
142   const void * (*value_text16be)(sqlite3_value*);
143   const void * (*value_text16le)(sqlite3_value*);
144   int  (*value_type)(sqlite3_value*);
145   char *(*vmprintf)(const char*,va_list);
146   int (*overload_function)(sqlite3*, const char *zFuncName, int nArg);
147   int (*prepare_v2)(sqlite3*,const char*,int,sqlite3_stmt**,const char**);
148   int (*prepare16_v2)(sqlite3*,const void*,int,sqlite3_stmt**,const void**);
149   int (*clear_bindings)(sqlite3_stmt*);
150 };
151 
152 /*
153 ** The following macros redefine the API routines so that they are
154 ** redirected throught the global sqlite3_api structure.
155 **
156 ** This header file is also used by the loadext.c source file
157 ** (part of the main SQLite library - not an extension) so that
158 ** it can get access to the sqlite3_api_routines structure
159 ** definition.  But the main library does not want to redefine
160 ** the API.  So the redefinition macros are only valid if the
161 ** SQLITE_CORE macros is undefined.
162 */
163 #ifndef SQLITE_CORE
164 #define sqlite3_aggregate_context      sqlite3_api->aggregate_context
165 #define sqlite3_aggregate_count        sqlite3_api->aggregate_count
166 #define sqlite3_bind_blob              sqlite3_api->bind_blob
167 #define sqlite3_bind_double            sqlite3_api->bind_double
168 #define sqlite3_bind_int               sqlite3_api->bind_int
169 #define sqlite3_bind_int64             sqlite3_api->bind_int64
170 #define sqlite3_bind_null              sqlite3_api->bind_null
171 #define sqlite3_bind_parameter_count   sqlite3_api->bind_parameter_count
172 #define sqlite3_bind_parameter_index   sqlite3_api->bind_parameter_index
173 #define sqlite3_bind_parameter_name    sqlite3_api->bind_parameter_name
174 #define sqlite3_bind_text              sqlite3_api->bind_text
175 #define sqlite3_bind_text16            sqlite3_api->bind_text16
176 #define sqlite3_bind_value             sqlite3_api->bind_value
177 #define sqlite3_busy_handler           sqlite3_api->busy_handler
178 #define sqlite3_busy_timeout           sqlite3_api->busy_timeout
179 #define sqlite3_changes                sqlite3_api->changes
180 #define sqlite3_close                  sqlite3_api->close
181 #define sqlite3_collation_needed       sqlite3_api->collation_needed
182 #define sqlite3_collation_needed16     sqlite3_api->collation_needed16
183 #define sqlite3_column_blob            sqlite3_api->column_blob
184 #define sqlite3_column_bytes           sqlite3_api->column_bytes
185 #define sqlite3_column_bytes16         sqlite3_api->column_bytes16
186 #define sqlite3_column_count           sqlite3_api->column_count
187 #define sqlite3_column_database_name   sqlite3_api->column_database_name
188 #define sqlite3_column_database_name16 sqlite3_api->column_database_name16
189 #define sqlite3_column_decltype        sqlite3_api->column_decltype
190 #define sqlite3_column_decltype16      sqlite3_api->column_decltype16
191 #define sqlite3_column_double          sqlite3_api->column_double
192 #define sqlite3_column_int             sqlite3_api->column_int
193 #define sqlite3_column_int64           sqlite3_api->column_int64
194 #define sqlite3_column_name            sqlite3_api->column_name
195 #define sqlite3_column_name16          sqlite3_api->column_name16
196 #define sqlite3_column_origin_name     sqlite3_api->column_origin_name
197 #define sqlite3_column_origin_name16   sqlite3_api->column_origin_name16
198 #define sqlite3_column_table_name      sqlite3_api->column_table_name
199 #define sqlite3_column_table_name16    sqlite3_api->column_table_name16
200 #define sqlite3_column_text            sqlite3_api->column_text
201 #define sqlite3_column_text16          sqlite3_api->column_text16
202 #define sqlite3_column_type            sqlite3_api->column_type
203 #define sqlite3_column_value           sqlite3_api->column_value
204 #define sqlite3_commit_hook            sqlite3_api->commit_hook
205 #define sqlite3_complete               sqlite3_api->complete
206 #define sqlite3_complete16             sqlite3_api->complete16
207 #define sqlite3_create_collation       sqlite3_api->create_collation
208 #define sqlite3_create_collation16     sqlite3_api->create_collation16
209 #define sqlite3_create_function        sqlite3_api->create_function
210 #define sqlite3_create_function16      sqlite3_api->create_function16
211 #define sqlite3_create_module          sqlite3_api->create_module
212 #define sqlite3_data_count             sqlite3_api->data_count
213 #define sqlite3_db_handle              sqlite3_api->db_handle
214 #define sqlite3_declare_vtab           sqlite3_api->declare_vtab
215 #define sqlite3_enable_shared_cache    sqlite3_api->enable_shared_cache
216 #define sqlite3_errcode                sqlite3_api->errcode
217 #define sqlite3_errmsg                 sqlite3_api->errmsg
218 #define sqlite3_errmsg16               sqlite3_api->errmsg16
219 #define sqlite3_exec                   sqlite3_api->exec
220 #define sqlite3_expired                sqlite3_api->expired
221 #define sqlite3_finalize               sqlite3_api->finalize
222 #define sqlite3_free                   sqlite3_api->free
223 #define sqlite3_free_table             sqlite3_api->free_table
224 #define sqlite3_get_autocommit         sqlite3_api->get_autocommit
225 #define sqlite3_get_auxdata            sqlite3_api->get_auxdata
226 #define sqlite3_get_table              sqlite3_api->get_table
227 #define sqlite3_global_recover         sqlite3_api->global_recover
228 #define sqlite3_interrupt              sqlite3_api->interruptx
229 #define sqlite3_last_insert_rowid      sqlite3_api->last_insert_rowid
230 #define sqlite3_libversion             sqlite3_api->libversion
231 #define sqlite3_libversion_number      sqlite3_api->libversion_number
232 #define sqlite3_malloc                 sqlite3_api->malloc
233 #define sqlite3_mprintf                sqlite3_api->mprintf
234 #define sqlite3_open                   sqlite3_api->open
235 #define sqlite3_open16                 sqlite3_api->open16
236 #define sqlite3_prepare                sqlite3_api->prepare
237 #define sqlite3_prepare16              sqlite3_api->prepare16
238 #define sqlite3_prepare_v2             sqlite3_api->prepare_v2
239 #define sqlite3_prepare16_v2           sqlite3_api->prepare16_v2
240 #define sqlite3_profile                sqlite3_api->profile
241 #define sqlite3_progress_handler       sqlite3_api->progress_handler
242 #define sqlite3_realloc                sqlite3_api->realloc
243 #define sqlite3_reset                  sqlite3_api->reset
244 #define sqlite3_result_blob            sqlite3_api->result_blob
245 #define sqlite3_result_double          sqlite3_api->result_double
246 #define sqlite3_result_error           sqlite3_api->result_error
247 #define sqlite3_result_error16         sqlite3_api->result_error16
248 #define sqlite3_result_int             sqlite3_api->result_int
249 #define sqlite3_result_int64           sqlite3_api->result_int64
250 #define sqlite3_result_null            sqlite3_api->result_null
251 #define sqlite3_result_text            sqlite3_api->result_text
252 #define sqlite3_result_text16          sqlite3_api->result_text16
253 #define sqlite3_result_text16be        sqlite3_api->result_text16be
254 #define sqlite3_result_text16le        sqlite3_api->result_text16le
255 #define sqlite3_result_value           sqlite3_api->result_value
256 #define sqlite3_rollback_hook          sqlite3_api->rollback_hook
257 #define sqlite3_set_authorizer         sqlite3_api->set_authorizer
258 #define sqlite3_set_auxdata            sqlite3_api->set_auxdata
259 #define sqlite3_snprintf               sqlite3_api->snprintf
260 #define sqlite3_step                   sqlite3_api->step
261 #define sqlite3_table_column_metadata  sqlite3_api->table_column_metadata
262 #define sqlite3_thread_cleanup         sqlite3_api->thread_cleanup
263 #define sqlite3_total_changes          sqlite3_api->total_changes
264 #define sqlite3_trace                  sqlite3_api->trace
265 #define sqlite3_transfer_bindings      sqlite3_api->transfer_bindings
266 #define sqlite3_update_hook            sqlite3_api->update_hook
267 #define sqlite3_user_data              sqlite3_api->user_data
268 #define sqlite3_value_blob             sqlite3_api->value_blob
269 #define sqlite3_value_bytes            sqlite3_api->value_bytes
270 #define sqlite3_value_bytes16          sqlite3_api->value_bytes16
271 #define sqlite3_value_double           sqlite3_api->value_double
272 #define sqlite3_value_int              sqlite3_api->value_int
273 #define sqlite3_value_int64            sqlite3_api->value_int64
274 #define sqlite3_value_numeric_type     sqlite3_api->value_numeric_type
275 #define sqlite3_value_text             sqlite3_api->value_text
276 #define sqlite3_value_text16           sqlite3_api->value_text16
277 #define sqlite3_value_text16be         sqlite3_api->value_text16be
278 #define sqlite3_value_text16le         sqlite3_api->value_text16le
279 #define sqlite3_value_type             sqlite3_api->value_type
280 #define sqlite3_vmprintf               sqlite3_api->vmprintf
281 #define sqlite3_overload_function      sqlite3_api->overload_function
282 #define sqlite3_prepare_v2             sqlite3_api->prepare_v2
283 #define sqlite3_prepare16_v2           sqlite3_api->prepare16_v2
284 #define sqlite3_clear_bindings         sqlite3_api->clear_bindings
285 #endif /* SQLITE_CORE */
286 
287 #define SQLITE_EXTENSION_INIT1     const sqlite3_api_routines *sqlite3_api;
288 #define SQLITE_EXTENSION_INIT2(v)  sqlite3_api = v;
289 
290 #endif /* _SQLITE3EXT_H_ */
291