sqlite3.inc 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578
  1. {$mode objfpc}
  2. {$ifdef BSD}
  3. {$linklib c}
  4. {$linklib pthread}
  5. {$endif}
  6. interface
  7. uses
  8. {$ifdef LOAD_DYNAMICALLY}
  9. SysUtils, DynLibs;
  10. {$else}
  11. DynLibs;
  12. {$endif}
  13. {
  14. Automatically converted by H2Pas 0.99.16 from sqlite3.h
  15. The following command line parameters were used:
  16. -D
  17. -c
  18. sqlite3.h
  19. Manual corrections made by Luiz Américo - 2005
  20. }
  21. {$PACKRECORDS C}
  22. const
  23. {$IFDEF WINDOWS}
  24. Sqlite3Lib = 'sqlite3.dll';
  25. {$else}
  26. Sqlite3Lib = 'libsqlite3.'+sharedsuffix;
  27. {$endif}
  28. SQLITE_INTEGER = 1;
  29. SQLITE_FLOAT = 2;
  30. { #define SQLITE_TEXT 3 // See below }
  31. SQLITE_BLOB = 4;
  32. SQLITE_NULL = 5;
  33. SQLITE_TEXT = 3;
  34. SQLITE3_TEXT = 3;
  35. SQLITE_UTF8 = 1;
  36. SQLITE_UTF16LE = 2;
  37. SQLITE_UTF16BE = 3;
  38. { Use native byte order }
  39. SQLITE_UTF16 = 4;
  40. { sqlite3_create_function only }
  41. SQLITE_ANY = 5;
  42. //sqlite_exec return values
  43. SQLITE_OK = 0;
  44. SQLITE_ERROR = 1;{ SQL error or missing database }
  45. SQLITE_INTERNAL = 2;{ An internal logic error in SQLite }
  46. SQLITE_PERM = 3; { Access permission denied }
  47. SQLITE_ABORT = 4; { Callback routine requested an abort }
  48. SQLITE_BUSY = 5; { The database file is locked }
  49. SQLITE_LOCKED = 6;{ A table in the database is locked }
  50. SQLITE_NOMEM = 7; { A malloc() failed }
  51. SQLITE_READONLY = 8;{ Attempt to write a readonly database }
  52. SQLITE_INTERRUPT = 9;{ Operation terminated by sqlite3_interrupt() }
  53. SQLITE_IOERR = 10; { Some kind of disk I/O error occurred }
  54. SQLITE_CORRUPT = 11; { The database disk image is malformed }
  55. SQLITE_NOTFOUND = 12; { (Internal Only) Table or record not found }
  56. SQLITE_FULL = 13; { Insertion failed because database is full }
  57. SQLITE_CANTOPEN = 14; { Unable to open the database file }
  58. SQLITE_PROTOCOL = 15; { Database lock protocol error }
  59. SQLITE_EMPTY = 16; { Database is empty }
  60. SQLITE_SCHEMA = 17; { The database schema changed }
  61. SQLITE_TOOBIG = 18; { Too much data for one row of a table }
  62. SQLITE_CONSTRAINT = 19; { Abort due to contraint violation }
  63. SQLITE_MISMATCH = 20; { Data type mismatch }
  64. SQLITE_MISUSE = 21; { Library used incorrectly }
  65. SQLITE_NOLFS = 22; { Uses OS features not supported on host }
  66. SQLITE_AUTH = 23; { Authorization denied }
  67. SQLITE_FORMAT = 24; { Auxiliary database format error }
  68. SQLITE_RANGE = 25; { 2nd parameter to sqlite3_bind out of range }
  69. SQLITE_NOTADB = 26; { File opened that is not a database file }
  70. SQLITE_ROW = 100; { sqlite3_step() has another row ready }
  71. SQLITE_DONE = 101; { sqlite3_step() has finished executing }
  72. SQLITE_COPY = 0;
  73. SQLITE_CREATE_INDEX = 1;
  74. SQLITE_CREATE_TABLE = 2;
  75. SQLITE_CREATE_TEMP_INDEX = 3;
  76. SQLITE_CREATE_TEMP_TABLE = 4;
  77. SQLITE_CREATE_TEMP_TRIGGER = 5;
  78. SQLITE_CREATE_TEMP_VIEW = 6;
  79. SQLITE_CREATE_TRIGGER = 7;
  80. SQLITE_CREATE_VIEW = 8;
  81. SQLITE_DELETE = 9;
  82. SQLITE_DROP_INDEX = 10;
  83. SQLITE_DROP_TABLE = 11;
  84. SQLITE_DROP_TEMP_INDEX = 12;
  85. SQLITE_DROP_TEMP_TABLE = 13;
  86. SQLITE_DROP_TEMP_TRIGGER = 14;
  87. SQLITE_DROP_TEMP_VIEW = 15;
  88. SQLITE_DROP_TRIGGER = 16;
  89. SQLITE_DROP_VIEW = 17;
  90. SQLITE_INSERT = 18;
  91. SQLITE_PRAGMA = 19;
  92. SQLITE_READ = 20;
  93. SQLITE_SELECT = 21;
  94. SQLITE_TRANSACTION = 22;
  95. SQLITE_UPDATE = 23;
  96. SQLITE_ATTACH = 24;
  97. SQLITE_DETACH = 25;
  98. SQLITE_ALTER_TABLE = 26;
  99. SQLITE_REINDEX = 27;
  100. SQLITE_DENY = 1;
  101. SQLITE_IGNORE = 2;
  102. // Original from sqlite3.h:
  103. //#define SQLITE_STATIC ((void(*)(void *))0)
  104. //#define SQLITE_TRANSIENT ((void(*)(void *))-1)
  105. Const
  106. SQLITE_STATIC = 0;
  107. SQLITE_TRANSIENT = -1;
  108. type
  109. sqlite_int64 = int64;
  110. sqlite_uint64 = qword;
  111. PPPChar = ^PPChar;
  112. Psqlite3 = Pointer;
  113. PPSqlite3 = ^PSqlite3;
  114. Psqlite3_context = Pointer;
  115. Psqlite3_stmt = Pointer;
  116. PPsqlite3_stmt = ^Psqlite3_stmt;
  117. Psqlite3_value = Pointer;
  118. PPsqlite3_value = ^Psqlite3_value;
  119. //Callback function types
  120. //Notice that most functions were named using as prefix the function name that uses them,
  121. //rather than describing their functions
  122. sqlite3_callback = function (_para1:pointer; _para2:longint; _para3:PPchar; _para4:PPchar):longint;cdecl;
  123. busy_handler_func = function (_para1:pointer; _para2:longint):longint;cdecl;
  124. sqlite3_set_authorizer_func = function (_para1:pointer; _para2:longint; _para3:Pchar; _para4:Pchar; _para5:Pchar; _para6:Pchar):longint;cdecl;
  125. sqlite3_trace_func = procedure (_para1:pointer; _para2:Pchar);cdecl;
  126. sqlite3_progress_handler_func = function (_para1:pointer):longint;cdecl;
  127. sqlite3_commit_hook_func = function (_para1:pointer):longint;cdecl;
  128. bind_destructor_func = procedure (_para1:pointer);cdecl;
  129. create_function_step_func = procedure (_para1:Psqlite3_context; _para2:longint; _para3:PPsqlite3_value);cdecl;
  130. create_function_func_func = procedure (_para1:Psqlite3_context; _para2:longint; _para3:PPsqlite3_value);cdecl;
  131. create_function_final_func = procedure (_para1:Psqlite3_context);cdecl;
  132. sqlite3_set_auxdata_func = procedure (_para1:pointer);cdecl;
  133. sqlite3_result_func = procedure (_para1:pointer);cdecl;
  134. sqlite3_create_collation_func = function (_para1:pointer; _para2:longint; _para3:pointer; _para4:longint; _para5:pointer):longint;cdecl;
  135. sqlite3_collation_needed_func = procedure (_para1:pointer; _para2:Psqlite3; eTextRep:longint; _para4:Pchar);cdecl;
  136. {$ifndef win32}
  137. var
  138. //This is not working under windows. Any clues?
  139. sqlite3_temp_directory : Pchar;cvar; external;
  140. {$endif}
  141. {$IFNDEF LOAD_DYNAMICALLY}
  142. function sqlite3_close(_para1:Psqlite3):longint;cdecl; external Sqlite3Lib name 'sqlite3_close';
  143. function sqlite3_exec(_para1:Psqlite3; sql:Pchar; _para3:sqlite3_callback; _para4:pointer; errmsg:PPchar):longint;cdecl; external Sqlite3Lib name 'sqlite3_exec';
  144. function sqlite3_last_insert_rowid(_para1:Psqlite3):sqlite_int64;cdecl; external Sqlite3Lib name 'sqlite3_last_insert_rowid';
  145. function sqlite3_changes(_para1:Psqlite3):longint;cdecl; external Sqlite3Lib name 'sqlite3_changes';
  146. function sqlite3_total_changes(_para1:Psqlite3):longint;cdecl; external Sqlite3Lib name 'sqlite3_total_changes';
  147. procedure sqlite3_interrupt(_para1:Psqlite3);cdecl; external Sqlite3Lib name 'sqlite3_interrupt';
  148. function sqlite3_complete(sql:Pchar):longint;cdecl; external Sqlite3Lib name 'sqlite3_complete';
  149. function sqlite3_complete16(sql:pointer):longint;cdecl; external Sqlite3Lib name 'sqlite3_complete16';
  150. function sqlite3_busy_handler(_para1:Psqlite3; _para2:busy_handler_func; _para3:pointer):longint;cdecl; external Sqlite3Lib name 'sqlite3_busy_handler';
  151. function sqlite3_busy_timeout(_para1:Psqlite3; ms:longint):longint;cdecl; external Sqlite3Lib name 'sqlite3_busy_timeout';
  152. function sqlite3_get_table(_para1:Psqlite3; sql:Pchar; resultp:PPPchar; nrow:Plongint; ncolumn:Plongint; errmsg:PPchar):longint;cdecl; external Sqlite3Lib name 'sqlite3_get_table';
  153. procedure sqlite3_free_table(result:PPchar);cdecl; external Sqlite3Lib name 'sqlite3_free_table';
  154. // Todo: see how translate sqlite3_mprintf, sqlite3_vmprintf, sqlite3_snprintf
  155. // function sqlite3_mprintf(_para1:Pchar; args:array of const):Pchar;cdecl; external Sqlite3Lib name 'sqlite3_mprintf';
  156. function sqlite3_mprintf(_para1:Pchar):Pchar;cdecl; external Sqlite3Lib name 'sqlite3_mprintf';
  157. //function sqlite3_vmprintf(_para1:Pchar; _para2:va_list):Pchar;cdecl; external Sqlite3Lib name 'sqlite3_vmprintf';
  158. procedure sqlite3_free(z:Pchar);cdecl; external Sqlite3Lib name 'sqlite3_free';
  159. //function sqlite3_snprintf(_para1:longint; _para2:Pchar; _para3:Pchar; args:array of const):Pchar;cdecl; external Sqlite3Lib name 'sqlite3_snprintf';
  160. function sqlite3_snprintf(_para1:longint; _para2:Pchar; _para3:Pchar):Pchar;cdecl; external Sqlite3Lib name 'sqlite3_snprintf';
  161. function sqlite3_set_authorizer(_para1:Psqlite3; xAuth:sqlite3_set_authorizer_func; pUserData:pointer):longint;cdecl; external Sqlite3Lib name 'sqlite3_set_authorizer';
  162. function sqlite3_trace(_para1:Psqlite3; xTrace:sqlite3_trace_func; _para3:pointer):pointer;cdecl; external Sqlite3Lib name 'sqlite3_trace';
  163. procedure sqlite3_progress_handler(_para1:Psqlite3; _para2:longint; _para3:sqlite3_progress_handler_func; _para4:pointer);cdecl; external Sqlite3Lib name 'sqlite3_progress_handler';
  164. function sqlite3_commit_hook(_para1:Psqlite3; _para2:sqlite3_commit_hook_func; _para3:pointer):pointer;cdecl; external Sqlite3Lib name 'sqlite3_commit_hook';
  165. function sqlite3_open(filename:Pchar; ppDb:PPsqlite3):longint;cdecl; external Sqlite3Lib name 'sqlite3_open';
  166. function sqlite3_open16(filename:pointer; ppDb:PPsqlite3):longint;cdecl; external Sqlite3Lib name 'sqlite3_open16';
  167. function sqlite3_errcode(db:Psqlite3):longint;cdecl; external Sqlite3Lib name 'sqlite3_errcode';
  168. function sqlite3_errmsg(_para1:Psqlite3):Pchar;cdecl; external Sqlite3Lib name 'sqlite3_errmsg';
  169. function sqlite3_errmsg16(_para1:Psqlite3):pointer;cdecl; external Sqlite3Lib name 'sqlite3_errmsg16';
  170. function sqlite3_prepare(db:Psqlite3; zSql:Pchar; nBytes:longint; ppStmt:PPsqlite3_stmt; pzTail:PPchar):longint;cdecl; external Sqlite3Lib name 'sqlite3_prepare';
  171. function sqlite3_prepare16(db:Psqlite3; zSql:pointer; nBytes:longint; ppStmt:PPsqlite3_stmt; pzTail:Ppointer):longint;cdecl; external Sqlite3Lib name 'sqlite3_prepare16';
  172. function sqlite3_bind_blob(_para1:Psqlite3_stmt; _para2:longint; _para3:pointer; n:longint; _para5:bind_destructor_func):longint;cdecl; external Sqlite3Lib name 'sqlite3_bind_blob';
  173. function sqlite3_bind_double(_para1:Psqlite3_stmt; _para2:longint; _para3:double):longint;cdecl; external Sqlite3Lib name 'sqlite3_bind_double';
  174. function sqlite3_bind_int(_para1:Psqlite3_stmt; _para2:longint; _para3:longint):longint;cdecl; external Sqlite3Lib name 'sqlite3_bind_int';
  175. function sqlite3_bind_int64(_para1:Psqlite3_stmt; _para2:longint; _para3:sqlite_int64):longint;cdecl; external Sqlite3Lib name 'sqlite3_bind_int64';
  176. function sqlite3_bind_null(_para1:Psqlite3_stmt; _para2:longint):longint;cdecl; external Sqlite3Lib name 'sqlite3_bind_null';
  177. function sqlite3_bind_text(_para1:Psqlite3_stmt; _para2:longint; _para3:Pchar; n:longint; _para5:bind_destructor_func):longint;cdecl; external Sqlite3Lib name 'sqlite3_bind_text';
  178. function sqlite3_bind_text16(_para1:Psqlite3_stmt; _para2:longint; _para3:pointer; _para4:longint; _para5:bind_destructor_func):longint;cdecl; external Sqlite3Lib name 'sqlite3_bind_text16';
  179. //function sqlite3_bind_value(_para1:Psqlite3_stmt; _para2:longint; _para3:Psqlite3_value):longint;cdecl; external Sqlite3Lib name 'sqlite3_bind_value';
  180. //These overloaded functions were introduced to allow the use of SQLITE_STATIC and SQLITE_TRANSIENT
  181. //It's the c world man ;-)
  182. function sqlite3_bind_blob(_para1:Psqlite3_stmt; _para2:longint; _para3:pointer; n:longint; _para5:longint):longint;cdecl; external Sqlite3Lib name 'sqlite3_bind_blob';
  183. function sqlite3_bind_text(_para1:Psqlite3_stmt; _para2:longint; _para3:Pchar; n:longint; _para5:longint):longint;cdecl; external Sqlite3Lib name 'sqlite3_bind_text';
  184. function sqlite3_bind_text16(_para1:Psqlite3_stmt; _para2:longint; _para3:pointer; _para4:longint; _para5:longint):longint;cdecl; external Sqlite3Lib name 'sqlite3_bind_text16';
  185. function sqlite3_bind_parameter_count(_para1:Psqlite3_stmt):longint;cdecl; external Sqlite3Lib name 'sqlite3_bind_parameter_count';
  186. function sqlite3_bind_parameter_name(_para1:Psqlite3_stmt; _para2:longint):Pchar;cdecl; external Sqlite3Lib name 'sqlite3_bind_parameter_name';
  187. function sqlite3_bind_parameter_index(_para1:Psqlite3_stmt; zName:Pchar):longint;cdecl; external Sqlite3Lib name 'sqlite3_bind_parameter_index';
  188. //function sqlite3_clear_bindings(_para1:Psqlite3_stmt):longint;cdecl; external Sqlite3Lib name 'sqlite3_clear_bindings';
  189. function sqlite3_column_count(pStmt:Psqlite3_stmt):longint;cdecl; external Sqlite3Lib name 'sqlite3_column_count';
  190. function sqlite3_column_name(_para1:Psqlite3_stmt; _para2:longint):Pchar;cdecl; external Sqlite3Lib name 'sqlite3_column_name';
  191. function sqlite3_column_name16(_para1:Psqlite3_stmt; _para2:longint):pointer;cdecl; external Sqlite3Lib name 'sqlite3_column_name16';
  192. function sqlite3_column_decltype(_para1:Psqlite3_stmt; i:longint):Pchar;cdecl; external Sqlite3Lib name 'sqlite3_column_decltype';
  193. function sqlite3_column_decltype16(_para1:Psqlite3_stmt; _para2:longint):pointer;cdecl; external Sqlite3Lib name 'sqlite3_column_decltype16';
  194. function sqlite3_step(_para1:Psqlite3_stmt):longint;cdecl; external Sqlite3Lib name 'sqlite3_step';
  195. function sqlite3_data_count(pStmt:Psqlite3_stmt):longint;cdecl; external Sqlite3Lib name 'sqlite3_data_count';
  196. function sqlite3_column_blob(_para1:Psqlite3_stmt; iCol:longint):pointer;cdecl; external Sqlite3Lib name 'sqlite3_column_blob';
  197. function sqlite3_column_bytes(_para1:Psqlite3_stmt; iCol:longint):longint;cdecl; external Sqlite3Lib name 'sqlite3_column_bytes';
  198. function sqlite3_column_bytes16(_para1:Psqlite3_stmt; iCol:longint):longint;cdecl; external Sqlite3Lib name 'sqlite3_column_bytes16';
  199. function sqlite3_column_double(_para1:Psqlite3_stmt; iCol:longint):double;cdecl; external Sqlite3Lib name 'sqlite3_column_double';
  200. function sqlite3_column_int(_para1:Psqlite3_stmt; iCol:longint):longint;cdecl; external Sqlite3Lib name 'sqlite3_column_int';
  201. function sqlite3_column_int64(_para1:Psqlite3_stmt; iCol:longint):sqlite_int64;cdecl; external Sqlite3Lib name 'sqlite3_column_int64';
  202. function sqlite3_column_text(_para1:Psqlite3_stmt; iCol:longint):PChar;cdecl; external Sqlite3Lib name 'sqlite3_column_text';
  203. function sqlite3_column_text16(_para1:Psqlite3_stmt; iCol:longint):pointer;cdecl; external Sqlite3Lib name 'sqlite3_column_text16';
  204. function sqlite3_column_type(_para1:Psqlite3_stmt; iCol:longint):longint;cdecl; external Sqlite3Lib name 'sqlite3_column_type';
  205. function sqlite3_finalize(pStmt:Psqlite3_stmt):longint;cdecl; external Sqlite3Lib name 'sqlite3_finalize';
  206. function sqlite3_reset(pStmt:Psqlite3_stmt):longint;cdecl; external Sqlite3Lib name 'sqlite3_reset';
  207. function sqlite3_create_function(_para1:Psqlite3; zFunctionName:Pchar; nArg:longint; eTextRep:longint; _para5:pointer; xFunc:create_function_func_func; xStep:create_function_step_func; xFinal:create_function_final_func):longint;cdecl; external Sqlite3Lib name 'sqlite3_create_function';
  208. function sqlite3_create_function16(_para1:Psqlite3; zFunctionName:pointer; nArg:longint; eTextRep:longint; _para5:pointer; xFunc:create_function_func_func; xStep:create_function_step_func; xFinal:create_function_final_func):longint;cdecl; external Sqlite3Lib name 'sqlite3_create_function16';
  209. function sqlite3_aggregate_count(_para1:Psqlite3_context):longint;cdecl; external Sqlite3Lib name 'sqlite3_aggregate_count';
  210. function sqlite3_value_blob(_para1:Psqlite3_value):pointer;cdecl; external Sqlite3Lib name 'sqlite3_value_blob';
  211. function sqlite3_value_bytes(_para1:Psqlite3_value):longint;cdecl; external Sqlite3Lib name 'sqlite3_value_bytes';
  212. function sqlite3_value_bytes16(_para1:Psqlite3_value):longint;cdecl; external Sqlite3Lib name 'sqlite3_value_bytes16';
  213. function sqlite3_value_double(_para1:Psqlite3_value):double;cdecl; external Sqlite3Lib name 'sqlite3_value_double';
  214. function sqlite3_value_int(_para1:Psqlite3_value):longint;cdecl; external Sqlite3Lib name 'sqlite3_value_int';
  215. function sqlite3_value_int64(_para1:Psqlite3_value):sqlite_int64;cdecl; external Sqlite3Lib name 'sqlite3_value_int64';
  216. function sqlite3_value_text(_para1:Psqlite3_value):PChar;cdecl; external Sqlite3Lib name 'sqlite3_value_text';
  217. function sqlite3_value_text16(_para1:Psqlite3_value):pointer;cdecl; external Sqlite3Lib name 'sqlite3_value_text16';
  218. function sqlite3_value_text16le(_para1:Psqlite3_value):pointer;cdecl; external Sqlite3Lib name 'sqlite3_value_text16le';
  219. function sqlite3_value_text16be(_para1:Psqlite3_value):pointer;cdecl; external Sqlite3Lib name 'sqlite3_value_text16be';
  220. function sqlite3_value_type(_para1:Psqlite3_value):longint;cdecl; external Sqlite3Lib name 'sqlite3_value_type';
  221. function sqlite3_aggregate_context(_para1:Psqlite3_context; nBytes:longint):pointer;cdecl; external Sqlite3Lib name 'sqlite3_aggregate_context';
  222. function sqlite3_user_data(_para1:Psqlite3_context):pointer;cdecl; external Sqlite3Lib name 'sqlite3_user_data';
  223. function sqlite3_get_auxdata(_para1:Psqlite3_context; _para2:longint):pointer;cdecl; external Sqlite3Lib name 'sqlite3_get_auxdata';
  224. procedure sqlite3_set_auxdata(_para1:Psqlite3_context; _para2:longint; _para3:pointer; _para4:sqlite3_set_auxdata_func);cdecl; external Sqlite3Lib name 'sqlite3_set_auxdata';
  225. procedure sqlite3_result_blob(_para1:Psqlite3_context; _para2:pointer; _para3:longint; _para4:sqlite3_result_func);cdecl; external Sqlite3Lib name 'sqlite3_result_blob';
  226. procedure sqlite3_result_double(_para1:Psqlite3_context; _para2:double);cdecl; external Sqlite3Lib name 'sqlite3_result_double';
  227. procedure sqlite3_result_error(_para1:Psqlite3_context; _para2:Pchar; _para3:longint);cdecl; external Sqlite3Lib name 'sqlite3_result_error';
  228. procedure sqlite3_result_error16(_para1:Psqlite3_context; _para2:pointer; _para3:longint);cdecl; external Sqlite3Lib name 'sqlite3_result_error16';
  229. procedure sqlite3_result_int(_para1:Psqlite3_context; _para2:longint);cdecl; external Sqlite3Lib name 'sqlite3_result_int';
  230. procedure sqlite3_result_int64(_para1:Psqlite3_context; _para2:sqlite_int64);cdecl; external Sqlite3Lib name 'sqlite3_result_int64';
  231. procedure sqlite3_result_null(_para1:Psqlite3_context);cdecl; external Sqlite3Lib name 'sqlite3_result_null';
  232. procedure sqlite3_result_text(_para1:Psqlite3_context; _para2:Pchar; _para3:longint; _para4:sqlite3_result_func);cdecl; external Sqlite3Lib name 'sqlite3_result_text';
  233. procedure sqlite3_result_text16(_para1:Psqlite3_context; _para2:pointer; _para3:longint; _para4:sqlite3_result_func);cdecl; external Sqlite3Lib name 'sqlite3_result_text16';
  234. procedure sqlite3_result_text16le(_para1:Psqlite3_context; _para2:pointer; _para3:longint; _para4:sqlite3_result_func);cdecl; external Sqlite3Lib name 'sqlite3_result_text16le';
  235. procedure sqlite3_result_text16be(_para1:Psqlite3_context; _para2:pointer; _para3:longint; _para4:sqlite3_result_func);cdecl; external Sqlite3Lib name 'sqlite3_result_text16be';
  236. procedure sqlite3_result_value(_para1:Psqlite3_context; _para2:Psqlite3_value);cdecl; external Sqlite3Lib name 'sqlite3_result_value';
  237. function sqlite3_create_collation(_para1:Psqlite3; zName:Pchar; eTextRep:longint; _para4:pointer; xCompare:sqlite3_create_collation_func):longint;cdecl; external Sqlite3Lib name 'sqlite3_create_collation';
  238. function sqlite3_create_collation16(_para1:Psqlite3; zName:Pchar; eTextRep:longint; _para4:pointer; xCompare:sqlite3_create_collation_func):longint;cdecl; external Sqlite3Lib name 'sqlite3_create_collation16';
  239. function sqlite3_collation_needed(_para1:Psqlite3; _para2:pointer; _para3:sqlite3_collation_needed_func):longint;cdecl; external Sqlite3Lib name 'sqlite3_collation_needed';
  240. function sqlite3_collation_needed16(_para1:Psqlite3; _para2:pointer; _para3:sqlite3_collation_needed_func):longint;cdecl; external Sqlite3Lib name 'sqlite3_collation_needed16';
  241. function sqlite3_libversion:PChar;cdecl; external Sqlite3Lib name 'sqlite3_libversion';
  242. //Alias for allowing better code portability (win32 is not working with external variables)
  243. function sqlite3_version:PChar;cdecl; external Sqlite3Lib name 'sqlite3_libversion';
  244. // Not published functions
  245. function sqlite3_libversion_number:longint;cdecl; external Sqlite3Lib name 'sqlite3_libversion_number';
  246. //function sqlite3_key(db:Psqlite3; pKey:pointer; nKey:longint):longint;cdecl; external Sqlite3Lib name 'sqlite3_key';
  247. //function sqlite3_rekey(db:Psqlite3; pKey:pointer; nKey:longint):longint;cdecl; external Sqlite3Lib name 'sqlite3_rekey';
  248. //function sqlite3_sleep(_para1:longint):longint;cdecl; external Sqlite3Lib name 'sqlite3_sleep';
  249. //function sqlite3_expired(_para1:Psqlite3_stmt):longint;cdecl; external Sqlite3Lib name 'sqlite3_expired';
  250. //function sqlite3_global_recover:longint;cdecl; external Sqlite3Lib name 'sqlite3_global_recover';
  251. {$ELSE LOAD_DYNAMICALLY}
  252. Var
  253. sqlite3_close : function (_para1:Psqlite3):longint;cdecl;
  254. sqlite3_exec : function (_para1:Psqlite3; sql:Pchar; _para3:sqlite3_callback; _para4:pointer; errmsg:PPchar):longint;cdecl;
  255. sqlite3_last_insert_rowid : function (_para1:Psqlite3):sqlite_int64;cdecl;
  256. sqlite3_changes : function (_para1:Psqlite3):longint;cdecl;
  257. sqlite3_total_changes : function (_para1:Psqlite3):longint;cdecl;
  258. sqlite3_interrupt : procedure (_para1:Psqlite3);cdecl;
  259. sqlite3_complete : function (sql:Pchar):longint;cdecl;
  260. sqlite3_complete16 : function (sql:pointer):longint;cdecl;
  261. sqlite3_busy_handler : function (_para1:Psqlite3; _para2:busy_handler_func; _para3:pointer):longint;cdecl;
  262. sqlite3_busy_timeout : function (_para1:Psqlite3; ms:longint):longint;cdecl;
  263. sqlite3_get_table : function (_para1:Psqlite3; sql:Pchar; resultp:PPPchar; nrow:Plongint; ncolumn:Plongint; errmsg:PPchar):longint;cdecl;
  264. sqlite3_free_table : procedure (result:PPchar);cdecl;
  265. // Todo: see how translate sqlite3_mprintf, sqlite3_vmprintf, sqlite3_snprintf
  266. // sqlite3_mprintf : function (_para1:Pchar; args:array of const):Pchar;cdecl;
  267. sqlite3_mprintf : function (_para1:Pchar):Pchar;cdecl;
  268. // sqlite3_vmprintf : function (_para1:Pchar; _para2:va_list):Pchar;cdecl;
  269. sqlite3_free : procedure (z:Pchar);cdecl;
  270. // sqlite3_snprintf : function (_para1:longint; _para2:Pchar; _para3:Pchar; args:array of const):Pchar;cdecl;
  271. sqlite3_snprintf : function (_para1:longint; _para2:Pchar; _para3:Pchar):Pchar;cdecl;
  272. sqlite3_set_authorizer : function (_para1:Psqlite3; xAuth:sqlite3_set_authorizer_func; pUserData:pointer):longint;cdecl;
  273. sqlite3_trace : function (_para1:Psqlite3; xTrace:sqlite3_trace_func; _para3:pointer):pointer;cdecl;
  274. sqlite3_progress_handler : procedure (_para1:Psqlite3; _para2:longint; _para3:sqlite3_progress_handler_func; _para4:pointer);cdecl;
  275. sqlite3_commit_hook : function (_para1:Psqlite3; _para2:sqlite3_commit_hook_func; _para3:pointer):pointer;cdecl;
  276. sqlite3_open : function (filename:Pchar; ppDb:PPsqlite3):longint;cdecl;
  277. sqlite3_open16 : function (filename:pointer; ppDb:PPsqlite3):longint;cdecl;
  278. sqlite3_errcode : function (db:Psqlite3):longint;cdecl;
  279. sqlite3_errmsg : function (_para1:Psqlite3):Pchar;cdecl;
  280. sqlite3_errmsg16 : function (_para1:Psqlite3):pointer;cdecl;
  281. sqlite3_prepare : function (db:Psqlite3; zSql:Pchar; nBytes:longint; ppStmt:PPsqlite3_stmt; pzTail:PPchar):longint;cdecl;
  282. sqlite3_prepare16 : function (db:Psqlite3; zSql:pointer; nBytes:longint; ppStmt:PPsqlite3_stmt; pzTail:Ppointer):longint;cdecl;
  283. sqlite3_bind_blob : function (_para1:Psqlite3_stmt; _para2:longint; _para3:pointer; n:longint; _para5:bind_destructor_func):longint;cdecl;
  284. sqlite3_bind_double : function (_para1:Psqlite3_stmt; _para2:longint; _para3:double):longint;cdecl;
  285. sqlite3_bind_int : function (_para1:Psqlite3_stmt; _para2:longint; _para3:longint):longint;cdecl;
  286. sqlite3_bind_int64 : function (_para1:Psqlite3_stmt; _para2:longint; _para3:sqlite_int64):longint;cdecl;
  287. sqlite3_bind_null : function (_para1:Psqlite3_stmt; _para2:longint):longint;cdecl;
  288. sqlite3_bind_text : function (_para1:Psqlite3_stmt; _para2:longint; _para3:Pchar; n:longint; _para5:bind_destructor_func):longint;cdecl;
  289. sqlite3_bind_text16 : function (_para1:Psqlite3_stmt; _para2:longint; _para3:pointer; _para4:longint; _para5:bind_destructor_func):longint;cdecl;
  290. // sqlite3_bind_value : function (_para1:Psqlite3_stmt; _para2:longint; _para3:Psqlite3_value):longint;cdecl;
  291. //These overloaded functions were introduced to allow the use of SQLITE_STATIC and SQLITE_TRANSIENT
  292. //It's the c world man ;-)
  293. sqlite3_bind_blob1 : function (_para1:Psqlite3_stmt; _para2:longint; _para3:pointer; n:longint; _para5:longint):longint;cdecl;
  294. sqlite3_bind_text1 : function (_para1:Psqlite3_stmt; _para2:longint; _para3:Pchar; n:longint; _para5:longint):longint;cdecl;
  295. sqlite3_bind_text161 : function (_para1:Psqlite3_stmt; _para2:longint; _para3:pointer; _para4:longint; _para5:longint):longint;cdecl;
  296. sqlite3_bind_parameter_count : function (_para1:Psqlite3_stmt):longint;cdecl;
  297. sqlite3_bind_parameter_name : function (_para1:Psqlite3_stmt; _para2:longint):Pchar;cdecl;
  298. sqlite3_bind_parameter_index : function (_para1:Psqlite3_stmt; zName:Pchar):longint;cdecl;
  299. // sqlite3_clear_bindings : function (_para1:Psqlite3_stmt):longint;cdecl;
  300. sqlite3_column_count : function (pStmt:Psqlite3_stmt):longint;cdecl;
  301. sqlite3_column_name : function (_para1:Psqlite3_stmt; _para2:longint):Pchar;cdecl;
  302. sqlite3_column_name16 : function (_para1:Psqlite3_stmt; _para2:longint):pointer;cdecl;
  303. sqlite3_column_decltype : function (_para1:Psqlite3_stmt; i:longint):Pchar;cdecl;
  304. sqlite3_column_decltype16 : function (_para1:Psqlite3_stmt; _para2:longint):pointer;cdecl;
  305. sqlite3_step : function (_para1:Psqlite3_stmt):longint;cdecl;
  306. sqlite3_data_count : function (pStmt:Psqlite3_stmt):longint;cdecl;
  307. sqlite3_column_blob : function (_para1:Psqlite3_stmt; iCol:longint):pointer;cdecl;
  308. sqlite3_column_bytes : function (_para1:Psqlite3_stmt; iCol:longint):longint;cdecl;
  309. sqlite3_column_bytes16 : function (_para1:Psqlite3_stmt; iCol:longint):longint;cdecl;
  310. sqlite3_column_double : function (_para1:Psqlite3_stmt; iCol:longint):double;cdecl;
  311. sqlite3_column_int : function (_para1:Psqlite3_stmt; iCol:longint):longint;cdecl;
  312. sqlite3_column_int64 : function (_para1:Psqlite3_stmt; iCol:longint):sqlite_int64;cdecl;
  313. sqlite3_column_text : function (_para1:Psqlite3_stmt; iCol:longint):PChar;cdecl;
  314. sqlite3_column_text16 : function (_para1:Psqlite3_stmt; iCol:longint):pointer;cdecl;
  315. sqlite3_column_type : function (_para1:Psqlite3_stmt; iCol:longint):longint;cdecl;
  316. sqlite3_finalize : function (pStmt:Psqlite3_stmt):longint;cdecl;
  317. sqlite3_reset : function (pStmt:Psqlite3_stmt):longint;cdecl;
  318. sqlite3_create_function : function (_para1:Psqlite3; zFunctionName:Pchar; nArg:longint; eTextRep:longint; _para5:pointer; xFunc:create_function_func_func; xStep:create_function_step_func; xFinal:create_function_final_func):longint;cdecl;
  319. sqlite3_create_function16 : function (_para1:Psqlite3; zFunctionName:pointer; nArg:longint; eTextRep:longint; _para5:pointer; xFunc:create_function_func_func; xStep:create_function_step_func; xFinal:create_function_final_func):longint;cdecl;
  320. sqlite3_aggregate_count : function (_para1:Psqlite3_context):longint;cdecl;
  321. sqlite3_value_blob : function (_para1:Psqlite3_value):pointer;cdecl;
  322. sqlite3_value_bytes : function (_para1:Psqlite3_value):longint;cdecl;
  323. sqlite3_value_bytes16 : function (_para1:Psqlite3_value):longint;cdecl;
  324. sqlite3_value_double : function (_para1:Psqlite3_value):double;cdecl;
  325. sqlite3_value_int : function (_para1:Psqlite3_value):longint;cdecl;
  326. sqlite3_value_int64 : function (_para1:Psqlite3_value):sqlite_int64;cdecl;
  327. sqlite3_value_text : function (_para1:Psqlite3_value):PChar;cdecl;
  328. sqlite3_value_text16 : function (_para1:Psqlite3_value):pointer;cdecl;
  329. sqlite3_value_text16le : function (_para1:Psqlite3_value):pointer;cdecl;
  330. sqlite3_value_text16be : function (_para1:Psqlite3_value):pointer;cdecl;
  331. sqlite3_value_type : function (_para1:Psqlite3_value):longint;cdecl;
  332. sqlite3_aggregate_context : function (_para1:Psqlite3_context; nBytes:longint):pointer;cdecl;
  333. sqlite3_user_data : function (_para1:Psqlite3_context):pointer;cdecl;
  334. sqlite3_get_auxdata : function (_para1:Psqlite3_context; _para2:longint):pointer;cdecl;
  335. sqlite3_set_auxdata : procedure (_para1:Psqlite3_context; _para2:longint; _para3:pointer; _para4:sqlite3_set_auxdata_func);cdecl;
  336. sqlite3_result_blob : procedure (_para1:Psqlite3_context; _para2:pointer; _para3:longint; _para4:sqlite3_result_func);cdecl;
  337. sqlite3_result_double : procedure (_para1:Psqlite3_context; _para2:double);cdecl;
  338. sqlite3_result_error : procedure (_para1:Psqlite3_context; _para2:Pchar; _para3:longint);cdecl;
  339. sqlite3_result_error16 : procedure (_para1:Psqlite3_context; _para2:pointer; _para3:longint);cdecl;
  340. sqlite3_result_int : procedure (_para1:Psqlite3_context; _para2:longint);cdecl;
  341. sqlite3_result_int64 : procedure (_para1:Psqlite3_context; _para2:sqlite_int64);cdecl;
  342. sqlite3_result_null : procedure (_para1:Psqlite3_context);cdecl;
  343. sqlite3_result_text : procedure (_para1:Psqlite3_context; _para2:Pchar; _para3:longint; _para4:sqlite3_result_func);cdecl;
  344. sqlite3_result_text16 : procedure (_para1:Psqlite3_context; _para2:pointer; _para3:longint; _para4:sqlite3_result_func);cdecl;
  345. sqlite3_result_text16le : procedure (_para1:Psqlite3_context; _para2:pointer; _para3:longint; _para4:sqlite3_result_func);cdecl;
  346. sqlite3_result_text16be : procedure (_para1:Psqlite3_context; _para2:pointer; _para3:longint; _para4:sqlite3_result_func);cdecl;
  347. sqlite3_result_value : procedure (_para1:Psqlite3_context; _para2:Psqlite3_value);cdecl;
  348. sqlite3_create_collation : function (_para1:Psqlite3; zName:Pchar; eTextRep:longint; _para4:pointer; xCompare:sqlite3_create_collation_func):longint;cdecl;
  349. sqlite3_create_collation16 : function (_para1:Psqlite3; zName:Pchar; eTextRep:longint; _para4:pointer; xCompare:sqlite3_create_collation_func):longint;cdecl;
  350. sqlite3_collation_needed : function (_para1:Psqlite3; _para2:pointer; _para3:sqlite3_collation_needed_func):longint;cdecl;
  351. sqlite3_collation_needed16 : function (_para1:Psqlite3; _para2:pointer; _para3:sqlite3_collation_needed_func):longint;cdecl;
  352. sqlite3_libversion: function : PChar;cdecl;
  353. //Alias for allowing better code portability (win32 is not working with external variables)
  354. sqlite3_version: function: PChar;cdecl;
  355. // Not published functions
  356. sqlite3_libversion_number : Function :longint;cdecl;
  357. // sqlite3_key : function (db:Psqlite3; pKey:pointer; nKey:longint):longint;cdecl;
  358. // sqlite3_rekey : function (db:Psqlite3; pKey:pointer; nKey:longint):longint;cdecl;
  359. // sqlite3_sleep : function (_para1:longint):longint;cdecl;
  360. // sqlite3_expired : function (_para1:Psqlite3_stmt):longint;cdecl;
  361. //function sqlite3_global_recover:longint;cdecl;
  362. Procedure InitialiseSQLite;
  363. Procedure InitialiseSQLite(LibraryName : String);
  364. Procedure ReleaseSQLite;
  365. var
  366. SQLiteLibraryHandle : TLibHandle;
  367. DefaultLibrary : String = Sqlite3Lib;
  368. {$ENDIF LOAD_DYNAMICALLY}
  369. implementation
  370. {$IFDEF LOAD_DYNAMICALLY}
  371. ResourceString
  372. SErrLoadFailed = 'Can not load SQLite client library "%s". Check your installation.';
  373. SErrAlreadyLoaded = 'SQLIte interface already initialized from library %s.';
  374. Procedure LoadAddresses(LibHandle : TLibHandle);
  375. begin
  376. pointer(sqlite3_close) := GetProcedureAddress(LibHandle,'sqlite3_close');
  377. pointer(sqlite3_exec) := GetProcedureAddress(LibHandle,'sqlite3_exec');
  378. pointer(sqlite3_last_insert_rowid) := GetProcedureAddress(LibHandle,'sqlite3_last_insert_rowid');
  379. pointer(sqlite3_changes) := GetProcedureAddress(LibHandle,'sqlite3_changes');
  380. pointer(sqlite3_total_changes) := GetProcedureAddress(LibHandle,'sqlite3_total_changes');
  381. pointer(sqlite3_interrupt) := GetProcedureAddress(LibHandle,'sqlite3_interrupt');
  382. pointer(sqlite3_complete) := GetProcedureAddress(LibHandle,'sqlite3_complete');
  383. pointer(sqlite3_complete16) := GetProcedureAddress(LibHandle,'sqlite3_complete16');
  384. pointer(sqlite3_busy_handler) := GetProcedureAddress(LibHandle,'sqlite3_busy_handler');
  385. pointer(sqlite3_busy_timeout) := GetProcedureAddress(LibHandle,'sqlite3_busy_timeout');
  386. pointer(sqlite3_get_table) := GetProcedureAddress(LibHandle,'sqlite3_get_table');
  387. pointer(sqlite3_free_table) := GetProcedureAddress(LibHandle,'sqlite3_free_table');
  388. // Todo: see how translate sqlite3_mprintf, sqlite3_vmprintf, sqlite3_snprintf
  389. // pointer(sqlite3_mprintf) := GetProcedureAddress(LibHandle,'sqlite3_mprintf');
  390. pointer(sqlite3_mprintf) := GetProcedureAddress(LibHandle,'sqlite3_mprintf');
  391. // pointer(sqlite3_vmprintf) := GetProcedureAddress(LibHandle,'sqlite3_vmprintf');
  392. pointer(sqlite3_free) := GetProcedureAddress(LibHandle,'sqlite3_free');
  393. // pointer(sqlite3_snprintf) := GetProcedureAddress(LibHandle,'sqlite3_snprintf');
  394. pointer(sqlite3_snprintf) := GetProcedureAddress(LibHandle,'sqlite3_snprintf');
  395. pointer(sqlite3_set_authorizer) := GetProcedureAddress(LibHandle,'sqlite3_set_authorizer');
  396. pointer(sqlite3_trace) := GetProcedureAddress(LibHandle,'sqlite3_trace');
  397. pointer(sqlite3_progress_handler) := GetProcedureAddress(LibHandle,'sqlite3_progress_handler');
  398. pointer(sqlite3_commit_hook) := GetProcedureAddress(LibHandle,'sqlite3_commit_hook');
  399. pointer(sqlite3_open) := GetProcedureAddress(LibHandle,'sqlite3_open');
  400. pointer(sqlite3_open16) := GetProcedureAddress(LibHandle,'sqlite3_open16');
  401. pointer(sqlite3_errcode) := GetProcedureAddress(LibHandle,'sqlite3_errcode');
  402. pointer(sqlite3_errmsg) := GetProcedureAddress(LibHandle,'sqlite3_errmsg');
  403. pointer(sqlite3_errmsg16) := GetProcedureAddress(LibHandle,'sqlite3_errmsg16');
  404. pointer(sqlite3_prepare) := GetProcedureAddress(LibHandle,'sqlite3_prepare');
  405. pointer(sqlite3_prepare16) := GetProcedureAddress(LibHandle,'sqlite3_prepare16');
  406. pointer(sqlite3_bind_blob) := GetProcedureAddress(LibHandle,'sqlite3_bind_blob');
  407. pointer(sqlite3_bind_double) := GetProcedureAddress(LibHandle,'sqlite3_bind_double');
  408. pointer(sqlite3_bind_int) := GetProcedureAddress(LibHandle,'sqlite3_bind_int');
  409. pointer(sqlite3_bind_int64) := GetProcedureAddress(LibHandle,'sqlite3_bind_int64');
  410. pointer(sqlite3_bind_null) := GetProcedureAddress(LibHandle,'sqlite3_bind_null');
  411. pointer(sqlite3_bind_text) := GetProcedureAddress(LibHandle,'sqlite3_bind_text');
  412. pointer(sqlite3_bind_text16) := GetProcedureAddress(LibHandle,'sqlite3_bind_text16');
  413. // pointer(sqlite3_bind_value) := GetProcedureAddress(LibHandle,'sqlite3_bind_value');
  414. //These overloaded functions were introduced to allow the use of SQLITE_STATIC and SQLITE_TRANSIENT
  415. //It's the c world man ;-)
  416. pointer(sqlite3_bind_blob1) := GetProcedureAddress(LibHandle,'sqlite3_bind_blob');
  417. pointer(sqlite3_bind_text1) := GetProcedureAddress(LibHandle,'sqlite3_bind_text');
  418. pointer(sqlite3_bind_text161) := GetProcedureAddress(LibHandle,'sqlite3_bind_text16');
  419. pointer(sqlite3_bind_parameter_count) := GetProcedureAddress(LibHandle,'sqlite3_bind_parameter_count');
  420. pointer(sqlite3_bind_parameter_name) := GetProcedureAddress(LibHandle,'sqlite3_bind_parameter_name');
  421. pointer(sqlite3_bind_parameter_index) := GetProcedureAddress(LibHandle,'sqlite3_bind_parameter_index');
  422. // pointer(sqlite3_clear_bindings) := GetProcedureAddress(LibHandle,'sqlite3_clear_bindings');
  423. pointer(sqlite3_column_count) := GetProcedureAddress(LibHandle,'sqlite3_column_count');
  424. pointer(sqlite3_column_name) := GetProcedureAddress(LibHandle,'sqlite3_column_name');
  425. pointer(sqlite3_column_name16) := GetProcedureAddress(LibHandle,'sqlite3_column_name16');
  426. pointer(sqlite3_column_decltype) := GetProcedureAddress(LibHandle,'sqlite3_column_decltype');
  427. pointer(sqlite3_column_decltype16) := GetProcedureAddress(LibHandle,'sqlite3_column_decltype16');
  428. pointer(sqlite3_step) := GetProcedureAddress(LibHandle,'sqlite3_step');
  429. pointer(sqlite3_data_count) := GetProcedureAddress(LibHandle,'sqlite3_data_count');
  430. pointer(sqlite3_column_blob) := GetProcedureAddress(LibHandle,'sqlite3_column_blob');
  431. pointer(sqlite3_column_bytes) := GetProcedureAddress(LibHandle,'sqlite3_column_bytes');
  432. pointer(sqlite3_column_bytes16) := GetProcedureAddress(LibHandle,'sqlite3_column_bytes16');
  433. pointer(sqlite3_column_double) := GetProcedureAddress(LibHandle,'sqlite3_column_double');
  434. pointer(sqlite3_column_int) := GetProcedureAddress(LibHandle,'sqlite3_column_int');
  435. pointer(sqlite3_column_int64) := GetProcedureAddress(LibHandle,'sqlite3_column_int64');
  436. pointer(sqlite3_column_text) := GetProcedureAddress(LibHandle,'sqlite3_column_text');
  437. pointer(sqlite3_column_text16) := GetProcedureAddress(LibHandle,'sqlite3_column_text16');
  438. pointer(sqlite3_column_type) := GetProcedureAddress(LibHandle,'sqlite3_column_type');
  439. pointer(sqlite3_finalize) := GetProcedureAddress(LibHandle,'sqlite3_finalize');
  440. pointer(sqlite3_reset) := GetProcedureAddress(LibHandle,'sqlite3_reset');
  441. pointer(sqlite3_create_function) := GetProcedureAddress(LibHandle,'sqlite3_create_function');
  442. pointer(sqlite3_create_function16) := GetProcedureAddress(LibHandle,'sqlite3_create_function16');
  443. pointer(sqlite3_aggregate_count) := GetProcedureAddress(LibHandle,'sqlite3_aggregate_count');
  444. pointer(sqlite3_value_blob) := GetProcedureAddress(LibHandle,'sqlite3_value_blob');
  445. pointer(sqlite3_value_bytes) := GetProcedureAddress(LibHandle,'sqlite3_value_bytes');
  446. pointer(sqlite3_value_bytes16) := GetProcedureAddress(LibHandle,'sqlite3_value_bytes16');
  447. pointer(sqlite3_value_double) := GetProcedureAddress(LibHandle,'sqlite3_value_double');
  448. pointer(sqlite3_value_int) := GetProcedureAddress(LibHandle,'sqlite3_value_int');
  449. pointer(sqlite3_value_int64) := GetProcedureAddress(LibHandle,'sqlite3_value_int64');
  450. pointer(sqlite3_value_text) := GetProcedureAddress(LibHandle,'sqlite3_value_text');
  451. pointer(sqlite3_value_text16) := GetProcedureAddress(LibHandle,'sqlite3_value_text16');
  452. pointer(sqlite3_value_text16le) := GetProcedureAddress(LibHandle,'sqlite3_value_text16le');
  453. pointer(sqlite3_value_text16be) := GetProcedureAddress(LibHandle,'sqlite3_value_text16be');
  454. pointer(sqlite3_value_type) := GetProcedureAddress(LibHandle,'sqlite3_value_type');
  455. pointer(sqlite3_aggregate_context) := GetProcedureAddress(LibHandle,'sqlite3_aggregate_context');
  456. pointer(sqlite3_user_data) := GetProcedureAddress(LibHandle,'sqlite3_user_data');
  457. pointer(sqlite3_get_auxdata) := GetProcedureAddress(LibHandle,'sqlite3_get_auxdata');
  458. pointer(sqlite3_set_auxdata) := GetProcedureAddress(LibHandle,'sqlite3_set_auxdata');
  459. pointer(sqlite3_result_blob) := GetProcedureAddress(LibHandle,'sqlite3_result_blob');
  460. pointer(sqlite3_result_double) := GetProcedureAddress(LibHandle,'sqlite3_result_double');
  461. pointer(sqlite3_result_error) := GetProcedureAddress(LibHandle,'sqlite3_result_error');
  462. pointer(sqlite3_result_error16) := GetProcedureAddress(LibHandle,'sqlite3_result_error16');
  463. pointer(sqlite3_result_int) := GetProcedureAddress(LibHandle,'sqlite3_result_int');
  464. pointer(sqlite3_result_int64) := GetProcedureAddress(LibHandle,'sqlite3_result_int64');
  465. pointer(sqlite3_result_null) := GetProcedureAddress(LibHandle,'sqlite3_result_null');
  466. pointer(sqlite3_result_text) := GetProcedureAddress(LibHandle,'sqlite3_result_text');
  467. pointer(sqlite3_result_text16) := GetProcedureAddress(LibHandle,'sqlite3_result_text16');
  468. pointer(sqlite3_result_text16le) := GetProcedureAddress(LibHandle,'sqlite3_result_text16le');
  469. pointer(sqlite3_result_text16be) := GetProcedureAddress(LibHandle,'sqlite3_result_text16be');
  470. pointer(sqlite3_result_value) := GetProcedureAddress(LibHandle,'sqlite3_result_value');
  471. pointer(sqlite3_create_collation) := GetProcedureAddress(LibHandle,'sqlite3_create_collation');
  472. pointer(sqlite3_create_collation16) := GetProcedureAddress(LibHandle,'sqlite3_create_collation16');
  473. pointer(sqlite3_collation_needed) := GetProcedureAddress(LibHandle,'sqlite3_collation_needed');
  474. pointer(sqlite3_collation_needed16) := GetProcedureAddress(LibHandle,'sqlite3_collation_needed16');
  475. pointer(sqlite3_libversion):=GetProcedureAddress(LibHandle,'sqlite3_libversion');
  476. //Alias for allowing better code portability (win32 is not working with external variables)
  477. pointer(sqlite3_version):=GetProcedureAddress(LibHandle,'sqlite3_libversion');
  478. // Not published functions
  479. pointer(sqlite3_libversion_number):=GetProcedureAddress(LibHandle,'sqlite3_libversion_number');
  480. // pointer(sqlite3_key) := GetProcedureAddress(LibHandle,'sqlite3_key');
  481. // pointer(sqlite3_rekey) := GetProcedureAddress(LibHandle,'sqlite3_rekey');
  482. // pointer(sqlite3_sleep) := GetProcedureAddress(LibHandle,'sqlite3_sleep');
  483. // pointer(sqlite3_expired) := GetProcedureAddress(LibHandle,'sqlite3_expired');
  484. // function sqlite3_global_recover:longint;cdecl;
  485. end;
  486. var
  487. RefCount : integer;
  488. LoadedLibrary : String;
  489. Function TryInitialiseSqlite(Const LibraryName : String) : Boolean;
  490. begin
  491. Result:=False;
  492. if (RefCount=0) then
  493. begin
  494. SQLiteLibraryHandle:=LoadLibrary(LibraryName);
  495. Result:=(SQLiteLibraryHandle<>nilhandle);
  496. If not Result then
  497. Exit;
  498. inc(RefCount);
  499. LoadedLibrary:=LibraryName;
  500. LoadAddresses(SQLiteLibraryHandle);
  501. end
  502. else
  503. begin
  504. If (LoadedLibrary<>LibraryName) then
  505. Raise EInoutError.CreateFmt(SErrAlreadyLoaded,[LoadedLibrary]);
  506. inc(RefCount);
  507. Result:=True;
  508. end;
  509. end;
  510. Procedure InitialiseSQLite;
  511. begin
  512. InitialiseSQLite(DefaultLibrary);
  513. end;
  514. Procedure InitialiseSQLite(LibraryName : String);
  515. begin
  516. If Not TryInitialiseSQLIte(LibraryName) then
  517. Raise EInOutError.CreateFmt(SErrLoadFailed,[LibraryName]);
  518. end;
  519. Procedure ReleaseSQLITE;
  520. begin
  521. if RefCount>1 then
  522. Dec(RefCount)
  523. else if UnloadLibrary(SQLITELibraryHandle) then
  524. begin
  525. Dec(RefCount);
  526. SQLITELibraryHandle := NilHandle;
  527. LoadedLibrary:='';
  528. end;
  529. end;
  530. {$ENDIF}
  531. end.