diff options
author | EuAndreh <eu@euandre.org> | 2024-10-01 15:50:33 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2024-10-01 15:50:33 -0300 |
commit | bf67f44cfbc551b644542e25b953566ee383d5bd (patch) | |
tree | ac36f31e50850bf1a11b79fc344b4d685fff469c /doc/examples/mod_regexp/sqlite3_mod_regexp.c | |
parent | tests/golite.go: Enable slow tests (diff) | |
download | golite-bf67f44cfbc551b644542e25b953566ee383d5bd.tar.gz golite-bf67f44cfbc551b644542e25b953566ee383d5bd.tar.xz |
Turn example files into tests under tests/functional/
Diffstat (limited to 'doc/examples/mod_regexp/sqlite3_mod_regexp.c')
-rw-r--r-- | doc/examples/mod_regexp/sqlite3_mod_regexp.c | 35 |
1 files changed, 0 insertions, 35 deletions
diff --git a/doc/examples/mod_regexp/sqlite3_mod_regexp.c b/doc/examples/mod_regexp/sqlite3_mod_regexp.c deleted file mode 100644 index d3ad149..0000000 --- a/doc/examples/mod_regexp/sqlite3_mod_regexp.c +++ /dev/null @@ -1,35 +0,0 @@ -#include <pcre.h> -#include <string.h> -#include <stdio.h> -#include <sqlite3ext.h> - -SQLITE_EXTENSION_INIT1 -static void regexp_func(sqlite3_context *context, int argc, sqlite3_value **argv) { - if (argc >= 2) { - const char *target = (const char *)sqlite3_value_text(argv[1]); - const char *pattern = (const char *)sqlite3_value_text(argv[0]); - const char* errstr = NULL; - int erroff = 0; - int vec[500]; - int n, rc; - pcre* re = pcre_compile(pattern, 0, &errstr, &erroff, NULL); - if (!re) { - sqlite3_result_error(context, errstr, 0); - return; - } - rc = pcre_exec(re, NULL, target, strlen(target), 0, 0, vec, 500); - if (rc <= 0) { - sqlite3_result_int(context, 0); - return; - } - sqlite3_result_int(context, 1); - } -} - -#ifdef _WIN32 -__declspec(dllexport) -#endif -int sqlite3_extension_init(sqlite3 *db, char **errmsg, const sqlite3_api_routines *api) { - SQLITE_EXTENSION_INIT2(api); - return sqlite3_create_function(db, "regexp", 2, SQLITE_UTF8, (void*)db, regexp_func, NULL, NULL); -} |