Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/sqlite/blob/master/ext/misc/basexx.c # sqlite [Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `sqlite / ext / misc / basexx.c` 89 lines ยท 2775 bytes Raw Blame History 1 /* 2 ** 2022-11-20 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 ** 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). 16 ** 17 ** Presently, it combines the base64.c and base85.c extensions. However, 18 ** it can be used as a template for other combinations. 19 ** 20 ** Example usages: 21 ** 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 25 ** 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% 36 */ 37 38 #ifndef SQLITE_SHELL_EXTFUNCS /* Guard for #include as built-in extension. */ 39 # include "sqlite3ext.h" 40 SQLITE_EXTENSION_INIT1; 41 #endif 42 43 static void init_api_ptr(const sqlite3_api_routines *pApi){ 44 SQLITE_EXTENSION_INIT2(pApi); 45 } 46 47 #undef SQLITE_EXTENSION_INIT1 48 #define SQLITE_EXTENSION_INIT1 /* */ 49 #undef SQLITE_EXTENSION_INIT2 50 #define SQLITE_EXTENSION_INIT2(v) (void)v 51 52 typedef unsigned char u8; 53 #define U8_TYPEDEF 54 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. 58 */ 59 #undef sqlite3_base_init 60 #define sqlite3_base_init sqlite3_base64_init 61 #include "base64.c" 62 63 #undef sqlite3_base_init 64 #define sqlite3_base_init sqlite3_base85_init 65 #include "base85.c" 66 67 #ifdef _WIN32 68 __declspec(dllexport) 69 #endif 70 int sqlite3_basexx_init(sqlite3 *db, char **pzErr, 71 const sqlite3_api_routines *pApi){ 72 int rc1; 73 int rc2; 74 75 init_api_ptr(pApi); 76 rc1 = BASE64_INIT(db); 77 rc2 = BASE85_INIT(db); 78 79 if( rc1==SQLITE_OK && rc2==SQLITE_OK ){ 80 BASE64_EXPOSE(db, pzErr); 81 BASE64_EXPOSE(db, pzErr); 82 return SQLITE_OK; 83 }else{ 84 return SQLITE_ERROR; 85 } 86 } 87 88 # define BASEXX_INIT(db) sqlite3_basexx_init(db, 0, 0) 89 # define BASEXX_EXPOSE(db, pzErr) /* Not needed, ..._init() does this. */