aboutsummaryrefslogtreecommitdiff
path: root/ext/wasm/example_extra_init.c
diff options
context:
space:
mode:
authorstephan <stephan@noemail.net>2023-02-27 07:12:28 +0000
committerstephan <stephan@noemail.net>2023-02-27 07:12:28 +0000
commit9885c76c4c86f4de670ce8b762c4df2ce1e99007 (patch)
tree0d6ad9ba2fe4ded6717660ae3c1b9d4f3ddff0d6 /ext/wasm/example_extra_init.c
parentd7ddec765cbc5dd97705fd33c8d49b2e16340806 (diff)
downloadsqlite-9885c76c4c86f4de670ce8b762c4df2ce1e99007.tar.gz
sqlite-9885c76c4c86f4de670ce8b762c4df2ce1e99007.zip
Extend wasm build to enable inclusion of client-custom C code, initialized via the SQLITE_EXTRA_INIT mechanism, per discussion in [forum:1e1c04f3ed1bc96b|forum post 1e1c04f3ed1bc96b].
FossilOrigin-Name: 68a52cafff60f19c9c998133d04f192b1e8b23f78b8cee13807d76845ef5e13d
Diffstat (limited to 'ext/wasm/example_extra_init.c')
-rw-r--r--ext/wasm/example_extra_init.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/ext/wasm/example_extra_init.c b/ext/wasm/example_extra_init.c
new file mode 100644
index 000000000..ca7038631
--- /dev/null
+++ b/ext/wasm/example_extra_init.c
@@ -0,0 +1,22 @@
+/*
+** If the canonical build process finds the file
+** sqlite3_wasm_extra_init.c in the main wasm build directory, it
+** arranges to include that file in the build of sqlite3.wasm and
+** defines SQLITE_EXTRA_INIT=sqlite3_wasm_extra_init.
+**
+** sqlite3_wasm_extra_init() must be a function with this signature:
+**
+** int sqlite3_wasm_extra_init(const char *)
+**
+** and the sqlite3 library will call it with an argument of NULL one
+** time during sqlite3_initialize(). If it returns non-0,
+** initialization of the library will fail.
+*/
+
+#include "sqlite3.h"
+#include <stdio.h>
+
+int sqlite3_wasm_extra_init(const char *z){
+ fprintf(stderr,"%s: %s()\n", __FILE__, __func__);
+ return 0;
+}