YAZ 5.35.1
init_globals.c
Go to the documentation of this file.
1/* This file is part of the YAZ toolkit.
2 * Copyright (C) Index Data
3 * See the file LICENSE for details.
4 */
5
11#if HAVE_CONFIG_H
12#include <config.h>
13#endif
14
15#include <yaz/log.h>
16
17#if YAZ_POSIX_THREADS
18#include <pthread.h>
19#endif
20#include <errno.h>
21
22#if HAVE_GNUTLS_H
23#include <gnutls/gnutls.h>
24#endif
25
26#if YAZ_HAVE_XML2
27#include <libxml/parser.h>
28#endif
29
30#if YAZ_HAVE_XSLT
31#include <libxslt/xslt.h>
32#endif
33
34#if YAZ_HAVE_EXSLT
35#include <libexslt/exslt.h>
36#endif
37
38static int yaz_init_flag = 0;
39#if YAZ_POSIX_THREADS
40static pthread_mutex_t yaz_init_mutex = PTHREAD_MUTEX_INITIALIZER;
41#endif
42
43extern void yaz_log_init_globals(void);
44extern void yaz_log_deinit_globals(void);
45extern void nmem_init_globals(void);
46
48{
49 if (yaz_init_flag)
50 return;
51#if YAZ_POSIX_THREADS
52 pthread_mutex_lock(&yaz_init_mutex);
53#endif
54 if (!yaz_init_flag)
55 {
58#if HAVE_GNUTLS_H
59 gnutls_global_init();
60#endif
61#if YAZ_HAVE_XML2
62 xmlInitParser();
63#endif
64#if YAZ_HAVE_XSLT
65 xsltInit();
66#endif
67#if YAZ_HAVE_EXSLT
68 exsltRegisterAll();
69#endif
70 yaz_init_flag = 1; /* must be last, before unlocking */
71 }
72#if YAZ_POSIX_THREADS
73 pthread_mutex_unlock(&yaz_init_mutex);
74#endif
75}
76
78{
79 if (!yaz_init_flag)
80 return;
81#if YAZ_POSIX_THREADS
82 pthread_mutex_lock(&yaz_init_mutex);
83#endif
84 if (yaz_init_flag)
85 {
87#if HAVE_GNUTLS_H
88 gnutls_global_deinit();
89#endif
90#if YAZ_HAVE_XSLT
91 xsltCleanupGlobals();
92#endif
93#if YAZ_HAVE_XML2
94 xmlCleanupParser();
95#endif
96 yaz_init_flag = 0;
97 }
98#if YAZ_POSIX_THREADS
99 pthread_mutex_unlock(&yaz_init_mutex);
100#endif
101}
102
103/*
104 * Local variables:
105 * c-basic-offset: 4
106 * c-file-style: "Stroustrup"
107 * indent-tabs-mode: nil
108 * End:
109 * vim: shiftwidth=4 tabstop=8 expandtab
110 */
111
Header for errno utilities.
void yaz_log_init_globals(void)
Definition log.c:124
void nmem_init_globals(void)
Definition nmem.c:174
static int yaz_init_flag
void yaz_init_globals(void)
void yaz_log_deinit_globals(void)
Definition log.c:159
void yaz_deinit_globals(void)
Logging utility.