4 ** The author disclaims copyright to this source code. In place of
5 ** a legal notice, here is a blessing:
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.
11 *************************************************************************
13 ** This source allows multiple SQLite extensions to be either: combined
14 ** into a single runtime-loadable library; or built into the SQLite shell
15 ** using a preprocessing convention set by src/shell.c.in (and shell.c).
17 ** Presently, it combines the base64.c and base85.c extensions. However,
18 ** it can be used as a template for other combinations.
22 ** - Build a runtime-loadable extension from SQLite checkout directory:
23 ** *Nix, OSX: gcc -O2 -shared -I. -fPIC -o basexx.so ext/misc/basexx.c
24 ** Win32: cl /Os -I. ext/misc/basexx.c -link -dll -out:basexx.dll
26 ** - Incorporate as built-in in sqlite3 shell:
27 ** *Nix, OSX with gcc on a like platform:
28 ** export mop1=-DSQLITE_SHELL_EXTSRC=ext/misc/basexx.c
29 ** export mop2=-DSQLITE_SHELL_EXTFUNCS=BASEXX
30 ** make sqlite3 "OPTS=$mop1 $mop2"
31 ** Win32 with Microsoft toolset on Windows:
32 ** set mop1=-DSQLITE_SHELL_EXTSRC=ext/misc/basexx.c
33 ** set mop2=-DSQLITE_SHELL_EXTFUNCS=BASEXX
34 ** set mops="OPTS=%mop1% %mop2%"
35 ** nmake -f Makefile.msc sqlite3.exe %mops%
38 #ifndef SQLITE_SHELL_EXTFUNCS /* Guard for #include as built-in extension. */
39 # include "sqlite3ext.h"
40 SQLITE_EXTENSION_INIT1
;
43 static void init_api_ptr(const sqlite3_api_routines
*pApi
){
44 SQLITE_EXTENSION_INIT2(pApi
);
47 #undef SQLITE_EXTENSION_INIT1
48 #define SQLITE_EXTENSION_INIT1 /* */
49 #undef SQLITE_EXTENSION_INIT2
50 #define SQLITE_EXTENSION_INIT2(v) (void)v
52 typedef unsigned char u8
;
55 /* These next 2 undef's are only needed because the entry point names
56 * collide when formulated per the rules stated for loadable extension
57 * entry point names that will be deduced from the file basenames.
59 #undef sqlite3_base_init
60 #define sqlite3_base_init sqlite3_base64_init
63 #undef sqlite3_base_init
64 #define sqlite3_base_init sqlite3_base85_init
70 int sqlite3_basexx_init(sqlite3
*db
, char **pzErr
,
71 const sqlite3_api_routines
*pApi
){
76 rc1
= BASE64_INIT(db
);
77 rc2
= BASE85_INIT(db
);
79 if( rc1
==SQLITE_OK
&& rc2
==SQLITE_OK
){
80 BASE64_EXPOSE(db
, pzErr
);
81 BASE64_EXPOSE(db
, pzErr
);
88 # define BASEXX_INIT(db) sqlite3_basexx_init(db, 0, 0)
89 # define BASEXX_EXPOSE(db, pzErr) /* Not needed, ..._init() does this. */