aboutsummaryrefslogtreecommitdiffstats
path: root/src/sqlite.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/sqlite.c')
-rw-r--r--src/sqlite.c48
1 files changed, 16 insertions, 32 deletions
diff --git a/src/sqlite.c b/src/sqlite.c
index aea79406aa6..47829cbdf7f 100644
--- a/src/sqlite.c
+++ b/src/sqlite.c
@@ -151,43 +151,32 @@ load_dll_functions (HMODULE library)
151 LOAD_DLL_FN (library, sqlite3_prepare_v2); 151 LOAD_DLL_FN (library, sqlite3_prepare_v2);
152 return true; 152 return true;
153} 153}
154
155static bool
156sqlite_loaded_p (void)
157{
158 Lisp_Object found = Fassq (Qsqlite3, Vlibrary_cache);
159
160 return CONSP (found) && EQ (XCDR (found), Qt);
161}
162#endif /* WINDOWSNT */ 154#endif /* WINDOWSNT */
163 155
164static bool 156static bool
165init_sqlite_functions (void) 157init_sqlite_functions (void)
166{ 158{
167#ifdef WINDOWSNT 159#ifdef WINDOWSNT
168 if (sqlite_loaded_p ()) 160 static bool sqlite3_initialized;
169 return true; 161
170 else 162 if (!sqlite3_initialized)
171 { 163 {
172 HMODULE library; 164 HMODULE library = w32_delayed_load (Qsqlite3);
173 165
174 if (!(library = w32_delayed_load (Qsqlite3))) 166 if (!library)
167 message1 ("sqlite3 library was not found");
168 else if (load_dll_functions (library))
175 { 169 {
176 message1 ("sqlite3 library not found"); 170 sqlite3_initialized = true;
177 return false; 171 Vlibrary_cache = Fcons (Fcons (Qsqlite3, Qt), Vlibrary_cache);
172 }
173 else
174 {
175 message1 ("sqlite3 library was found, but could not be loaded successfully");
176 Vlibrary_cache = Fcons (Fcons (Qsqlite3, Qnil), Vlibrary_cache);
178 } 177 }
179
180 if (! load_dll_functions (library))
181 goto bad_library;
182
183 Vlibrary_cache = Fcons (Fcons (Qsqlite3, Qt), Vlibrary_cache);
184 return true;
185 } 178 }
186 179 return sqlite3_initialized;
187 bad_library:
188 Vlibrary_cache = Fcons (Fcons (Qsqlite3, Qnil), Vlibrary_cache);
189
190 return false;
191#else /* !WINDOWSNT */ 180#else /* !WINDOWSNT */
192 return true; 181 return true;
193#endif /* !WINDOWSNT */ 182#endif /* !WINDOWSNT */
@@ -674,12 +663,7 @@ DEFUN ("sqlite-available-p", Fsqlite_available_p, Ssqlite_available_p, 0, 0, 0,
674 if (CONSP (found)) 663 if (CONSP (found))
675 return XCDR (found); 664 return XCDR (found);
676 else 665 else
677 { 666 return init_sqlite_functions () ? Qt : Qnil;
678 Lisp_Object status;
679 status = init_sqlite_functions () ? Qt : Qnil;
680 Vlibrary_cache = Fcons (Fcons (Qsqlite3, status), Vlibrary_cache);
681 return status;
682 }
683# else 667# else
684 return Qt; 668 return Qt;
685#endif 669#endif