Add initialization functions for internal usage in libsqlite3.so.

--- /ext/misc/amatch.c
+++ /ext/misc/amatch.c
@@ -1480,9 +1480,18 @@
 
 #endif /* SQLITE_OMIT_VIRTUALTABLE */
 
+int sqlite3AmatchInit(sqlite3 *db){
+  int rc = SQLITE_OK;
+#ifndef SQLITE_OMIT_VIRTUALTABLE
+  rc = sqlite3_create_module(db, "approximate_match", &amatchModule, 0);
+#endif /* SQLITE_OMIT_VIRTUALTABLE */
+  return rc;
+}
+
 /*
 ** Register the amatch virtual table
 */
+#if !defined(SQLITE_CORE) || defined(SQLITE_TEST)
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
@@ -1491,11 +1500,8 @@
   char **pzErrMsg, 
   const sqlite3_api_routines *pApi
 ){
-  int rc = SQLITE_OK;
   SQLITE_EXTENSION_INIT2(pApi);
   (void)pzErrMsg;  /* Not used */
-#ifndef SQLITE_OMIT_VIRTUALTABLE
-  rc = sqlite3_create_module(db, "approximate_match", &amatchModule, 0);
-#endif /* SQLITE_OMIT_VIRTUALTABLE */
-  return rc;
+  return sqlite3AmatchInit(db);
 }
+#endif /* !defined(SQLITE_CORE) || defined(SQLITE_TEST) */
--- /ext/misc/carray.c
+++ /ext/misc/carray.c
@@ -383,16 +383,8 @@
 
 #endif /* SQLITE_OMIT_VIRTUALTABLE */
 
-#ifdef _WIN32
-__declspec(dllexport)
-#endif
-int sqlite3_carray_init(
-  sqlite3 *db, 
-  char **pzErrMsg, 
-  const sqlite3_api_routines *pApi
-){
+int sqlite3CarrayInit(sqlite3 *db){
   int rc = SQLITE_OK;
-  SQLITE_EXTENSION_INIT2(pApi);
 #ifndef SQLITE_OMIT_VIRTUALTABLE
   rc = sqlite3_create_module(db, "carray", &carrayModule, 0);
 #ifdef SQLITE_TEST
@@ -404,3 +396,18 @@
 #endif /* SQLITE_OMIT_VIRTUALTABLE */
   return rc;
 }
+
+#if !defined(SQLITE_CORE) || defined(SQLITE_TEST)
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+int sqlite3_carray_init(
+  sqlite3 *db, 
+  char **pzErrMsg, 
+  const sqlite3_api_routines *pApi
+){
+  SQLITE_EXTENSION_INIT2(pApi);
+  (void)pzErrMsg;  /* Unused parameter */
+  return sqlite3CarrayInit(db);
+}
+#endif /* !defined(SQLITE_CORE) || defined(SQLITE_TEST) */
--- /ext/misc/completion.c
+++ /ext/misc/completion.c
@@ -483,12 +483,13 @@
   return rc;
 }
 
+#if !defined(SQLITE_CORE) || defined(SQLITE_TEST)
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
 int sqlite3_completion_init(
-  sqlite3 *db, 
-  char **pzErrMsg, 
+  sqlite3 *db,
+  char **pzErrMsg,
   const sqlite3_api_routines *pApi
 ){
   int rc = SQLITE_OK;
@@ -499,3 +500,4 @@
 #endif
   return rc;
 }
+#endif /* !defined(SQLITE_CORE) || defined(SQLITE_TEST) */
--- /ext/misc/csv.c
+++ /ext/misc/csv.c
@@ -928,6 +928,22 @@
 #endif /* !defined(SQLITE_OMIT_VIRTUALTABLE) */
 
 
+int sqlite3CsvInit(sqlite3 *db){
+#ifndef SQLITE_OMIT_VIRTUALTABLE
+  int rc;
+  rc = sqlite3_create_module(db, "csv", &CsvModule, 0);
+#ifdef SQLITE_TEST
+  if( rc==SQLITE_OK ){
+    rc = sqlite3_create_module(db, "csv_wr", &CsvModuleFauxWrite, 0);
+  }
+#endif
+  return rc;
+#else
+  return SQLITE_OK;
+#endif
+}
+
+#if !defined(SQLITE_CORE) || defined(SQLITE_TEST)
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
@@ -941,17 +957,8 @@
   char **pzErrMsg, 
   const sqlite3_api_routines *pApi
 ){
-#ifndef SQLITE_OMIT_VIRTUALTABLE	
-  int rc;
   SQLITE_EXTENSION_INIT2(pApi);
-  rc = sqlite3_create_module(db, "csv", &CsvModule, 0);
-#ifdef SQLITE_TEST
-  if( rc==SQLITE_OK ){
-    rc = sqlite3_create_module(db, "csv_wr", &CsvModuleFauxWrite, 0);
-  }
-#endif
-  return rc;
-#else
-  return SQLITE_OK;
-#endif
+  (void)pzErrMsg;  /* Unused parameter */
+  return sqlite3CsvInit(db);
 }
+#endif /* !defined(SQLITE_CORE) || defined(SQLITE_TEST) */
--- /ext/misc/dbdata.c
+++ /ext/misc/dbdata.c
@@ -803,7 +803,7 @@
 /*
 ** Invoke this routine to register the "sqlite_dbdata" virtual table module
 */
-static int sqlite3DbdataRegister(sqlite3 *db){
+int sqlite3DbdataRegister(sqlite3 *db){
   static sqlite3_module dbdata_module = {
     0,                            /* iVersion */
     0,                            /* xCreate */
@@ -838,6 +838,7 @@
   return rc;
 }
 
+#if !defined(SQLITE_CORE) || defined(SQLITE_TEST)
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
@@ -849,3 +850,4 @@
   SQLITE_EXTENSION_INIT2(pApi);
   return sqlite3DbdataRegister(db);
 }
+#endif /* !defined(SQLITE_CORE) || defined(SQLITE_TEST) */
--- /ext/misc/decimal.c
+++ /ext/misc/decimal.c
@@ -590,14 +590,7 @@
   decimal_free(pB);
 }
 
-#ifdef _WIN32
-__declspec(dllexport)
-#endif
-int sqlite3_decimal_init(
-  sqlite3 *db, 
-  char **pzErrMsg, 
-  const sqlite3_api_routines *pApi
-){
+int sqlite3DecimalInit(sqlite3 *db){
   int rc = SQLITE_OK;
   static const struct {
     const char *zFuncName;
@@ -611,10 +604,6 @@
     { "decimal_mul",   2,   decimalMulFunc     },
   };
   unsigned int i;
-  (void)pzErrMsg;  /* Unused parameter */
-
-  SQLITE_EXTENSION_INIT2(pApi);
-
   for(i=0; i<sizeof(aFunc)/sizeof(aFunc[0]) && rc==SQLITE_OK; i++){
     rc = sqlite3_create_function(db, aFunc[i].zFuncName, aFunc[i].nArg,
                    SQLITE_UTF8|SQLITE_INNOCUOUS|SQLITE_DETERMINISTIC,
@@ -632,3 +621,20 @@
   }
   return rc;
 }
+
+#if !defined(SQLITE_CORE) || defined(SQLITE_TEST)
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+int sqlite3_decimal_init(
+  sqlite3 *db, 
+  char **pzErrMsg, 
+  const sqlite3_api_routines *pApi
+){
+  (void)pzErrMsg;  /* Unused parameter */
+
+  SQLITE_EXTENSION_INIT2(pApi);
+
+  return sqlite3DecimalInit(db);
+}
+#endif /* !defined(SQLITE_CORE) || defined(SQLITE_TEST) */
--- /ext/misc/eval.c
+++ /ext/misc/eval.c
@@ -102,6 +102,20 @@
 }
 
 
+int sqlite3EvalInit(sqlite3 *db){
+  int rc = SQLITE_OK;
+  rc = sqlite3_create_function(db, "eval", 1,
+                               SQLITE_UTF8|SQLITE_DIRECTONLY, 0,
+                               sqlEvalFunc, 0, 0);
+  if( rc==SQLITE_OK ){
+    rc = sqlite3_create_function(db, "eval", 2,
+                                 SQLITE_UTF8|SQLITE_DIRECTONLY, 0,
+                                 sqlEvalFunc, 0, 0);
+  }
+  return rc;
+}
+
+#if !defined(SQLITE_CORE) || defined(SQLITE_TEST)
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
@@ -110,16 +124,8 @@
   char **pzErrMsg, 
   const sqlite3_api_routines *pApi
 ){
-  int rc = SQLITE_OK;
   SQLITE_EXTENSION_INIT2(pApi);
   (void)pzErrMsg;  /* Unused parameter */
-  rc = sqlite3_create_function(db, "eval", 1, 
-                               SQLITE_UTF8|SQLITE_DIRECTONLY, 0,
-                               sqlEvalFunc, 0, 0);
-  if( rc==SQLITE_OK ){
-    rc = sqlite3_create_function(db, "eval", 2,
-                                 SQLITE_UTF8|SQLITE_DIRECTONLY, 0,
-                                 sqlEvalFunc, 0, 0);
-  }
-  return rc;
+  return sqlite3EvalInit(db);
 }
+#endif /* !defined(SQLITE_CORE) || defined(SQLITE_TEST) */
--- /ext/misc/fileio.c
+++ /ext/misc/fileio.c
@@ -340,7 +340,7 @@
 ** This function does the work for the writefile() UDF. Refer to 
 ** header comments at the top of this file for details.
 */
-static int writeFile(
+static int writeFileContents(
   sqlite3_context *pCtx,          /* Context to return bytes written in */
   const char *zFile,              /* File to write */
   sqlite3_value *pData,           /* Data to write */
@@ -480,10 +480,10 @@
     mtime = sqlite3_value_int64(argv[3]);
   }
 
-  res = writeFile(context, zFile, argv[1], mode, mtime);
+  res = writeFileContents(context, zFile, argv[1], mode, mtime);
   if( res==1 && errno==ENOENT ){
     if( makeDirectory(zFile)==SQLITE_OK ){
-      res = writeFile(context, zFile, argv[1], mode, mtime);
+      res = writeFileContents(context, zFile, argv[1], mode, mtime);
     }
   }
 
@@ -970,18 +970,9 @@
 # define fsdirRegister(x) SQLITE_OK
 #endif
 
-#ifdef _WIN32
-__declspec(dllexport)
-#endif
-int sqlite3_fileio_init(
-  sqlite3 *db, 
-  char **pzErrMsg, 
-  const sqlite3_api_routines *pApi
-){
+int sqlite3FileioInit(sqlite3 *db){
   int rc = SQLITE_OK;
-  SQLITE_EXTENSION_INIT2(pApi);
-  (void)pzErrMsg;  /* Unused parameter */
-  rc = sqlite3_create_function(db, "readfile", 1, 
+  rc = sqlite3_create_function(db, "readfile", 1,
                                SQLITE_UTF8|SQLITE_DIRECTONLY, 0,
                                readfileFunc, 0, 0);
   if( rc==SQLITE_OK ){
@@ -998,3 +989,18 @@
   }
   return rc;
 }
+
+#if !defined(SQLITE_CORE) || defined(SQLITE_TEST)
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+int sqlite3_fileio_init(
+  sqlite3 *db, 
+  char **pzErrMsg, 
+  const sqlite3_api_routines *pApi
+){
+  SQLITE_EXTENSION_INIT2(pApi);
+  (void)pzErrMsg;  /* Unused parameter */
+  return sqlite3FileioInit(db);
+}
+#endif /* !defined(SQLITE_CORE) || defined(SQLITE_TEST) */
--- /ext/misc/ieee754.c
+++ /ext/misc/ieee754.c
@@ -245,14 +245,7 @@
 }
 
 
-#ifdef _WIN32
-__declspec(dllexport)
-#endif
-int sqlite3_ieee_init(
-  sqlite3 *db, 
-  char **pzErrMsg, 
-  const sqlite3_api_routines *pApi
-){
+int sqlite3IeeeInit(sqlite3 *db){
   static const struct {
     char *zFName;
     int nArg;
@@ -269,13 +262,26 @@
   };
   unsigned int i;
   int rc = SQLITE_OK;
-  SQLITE_EXTENSION_INIT2(pApi);
-  (void)pzErrMsg;  /* Unused parameter */
   for(i=0; i<sizeof(aFunc)/sizeof(aFunc[0]) && rc==SQLITE_OK; i++){
-    rc = sqlite3_create_function(db, aFunc[i].zFName, aFunc[i].nArg,	
+    rc = sqlite3_create_function(db, aFunc[i].zFName, aFunc[i].nArg,
                                SQLITE_UTF8|SQLITE_INNOCUOUS,
                                (void*)&aFunc[i].iAux,
                                aFunc[i].xFunc, 0, 0);
   }
   return rc;
 }
+
+#if !defined(SQLITE_CORE) || defined(SQLITE_TEST)
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+int sqlite3_ieee_init(
+  sqlite3 *db, 
+  char **pzErrMsg, 
+  const sqlite3_api_routines *pApi
+){
+  SQLITE_EXTENSION_INIT2(pApi);
+  (void)pzErrMsg;  /* Unused parameter */
+  return sqlite3IeeeInit(db);
+}
+#endif /* !defined(SQLITE_CORE) || defined(SQLITE_TEST) */
--- /ext/misc/nextchar.c
+++ /ext/misc/nextchar.c
@@ -286,17 +286,8 @@
   sqlite3_free(c.aResult);
 }
 
-#ifdef _WIN32
-__declspec(dllexport)
-#endif
-int sqlite3_nextchar_init(
-  sqlite3 *db, 
-  char **pzErrMsg, 
-  const sqlite3_api_routines *pApi
-){
+int sqlite3NextcharInit(sqlite3 *db){
   int rc = SQLITE_OK;
-  SQLITE_EXTENSION_INIT2(pApi);
-  (void)pzErrMsg;  /* Unused parameter */
   rc = sqlite3_create_function(db, "next_char", 3,
                                SQLITE_UTF8|SQLITE_INNOCUOUS, 0,
                                nextCharFunc, 0, 0);
@@ -312,3 +303,18 @@
   }
   return rc;
 }
+
+#if !defined(SQLITE_CORE) || defined(SQLITE_TEST)
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+int sqlite3_nextchar_init(
+  sqlite3 *db, 
+  char **pzErrMsg, 
+  const sqlite3_api_routines *pApi
+){
+  SQLITE_EXTENSION_INIT2(pApi);
+  (void)pzErrMsg;  /* Unused parameter */
+  return sqlite3NextcharInit(db);
+}
+#endif /* !defined(SQLITE_CORE) || defined(SQLITE_TEST) */
