1 /* Add your header comment here */
2 /* Do not use <sqlite3.h>! */
3 #include <sqlite3ext.h>
7 /* Insert your extension code here */
9 /* TODO: Change the entry point name so that "extension" is replaced by
10 ** text derived from the shared library filename as follows: Copy every
11 ** ASCII alphabetic character from the filename after the last "/" through
12 ** the next following ".", converting each character to lowercase, and
13 ** discarding the first three characters if they are "lib".
16 static int vercmp(void *not_used, int lena, const void *a,
17 int lenb, const void *b) {
18 /* not sure what the ints are, possibly string lengths */
19 if (not_used != 0) fprintf(stderr, "sqlite vercmp not_used = %p\n",
21 if (lena == 0 && lenb > 0) return 1;
22 return zpm_vercmp(a, b);
25 static int zpm_sqlite_vercmp_init(sqlite3 *db, char **pzErrMsg,
26 const sqlite3_api_routines *pApi
29 SQLITE_EXTENSION_INIT2(pApi);
30 rc = sqlite3_create_collation(db, "vercmp", SQLITE_UTF8, NULL, vercmp);
31 /* Insert here calls to
32 ** sqlite3_create_function_v2(),
33 ** sqlite3_create_collation_v2(),
34 ** sqlite3_create_module_v2(), and/or
35 ** sqlite3_vfs_register()
36 ** to register the new features that your extension adds.
39 if (rc == SQLITE_OK) {
40 fprintf(stderr, "vercmp collation created\n");
46 void zpm_setup_extensions(void) {
47 sqlite3_auto_extension( (void (*)(void))zpm_sqlite_vercmp_init);