-#if HAVE_GCRYPT_H
- /* most likely, GnuTLS has already initialized libgcrypt */
- if (gcry_control(GCRYCTL_ANY_INITIALIZATION_P) == 0)
- {
- gcry_control(GCRYCTL_INITIALIZATION_FINISHED, NULL, 0);
- }
+#if YAZ_HAVE_XML2
+ xmlInitParser();
+#endif
+#if YAZ_HAVE_XSLT
+ xsltInit();
+#endif
+#if YAZ_HAVE_EXSLT
+ exsltRegisterAll();
+#endif
+ yaz_init_flag = 1; /* must be last, before unlocking */
+ }
+#if YAZ_POSIX_THREADS
+ pthread_mutex_unlock(&yaz_init_mutex);
+#endif
+}
+
+void yaz_deinit_globals(void)
+{
+ if (!yaz_init_flag)
+ return;
+#if YAZ_POSIX_THREADS
+ pthread_mutex_lock(&yaz_init_mutex);
+#endif
+ if (yaz_init_flag)
+ {
+ yaz_log_deinit_globals();
+#if HAVE_GNUTLS_H
+ gnutls_global_deinit();
+#endif
+#if YAZ_HAVE_XSLT
+ xsltCleanupGlobals();
+#endif
+#if YAZ_HAVE_XML2
+ xmlCleanupParser();