Add init_global.c YAZ-740
[yaz-moved-to-github.git] / src / init_globals.c
1 /* This file is part of the YAZ toolkit.
2  * Copyright (C) Index Data
3  * See the file LICENSE for details.
4  */
5
6 /**
7  * \file init_globals.c
8  * \brief Initialize global things
9  */
10
11 #if HAVE_CONFIG_H
12 #include <config.h>
13 #endif
14
15 #if YAZ_POSIX_THREADS
16 #include <pthread.h>
17 #endif
18
19 #if HAVE_GNUTLS_H
20 #include <gnutls/gnutls.h>
21 #endif
22
23 #if HAVE_GCRYPT_H
24 #include <gcrypt.h>
25 #endif
26
27 static int yaz_init_flag = 0;
28
29 extern void yaz_log_init_globals(void);
30
31 void yaz_init_globals(void)
32 {
33     if (!yaz_init_flag)
34     {
35         yaz_init_flag = 1;
36         yaz_log_init_globals();
37 #if HAVE_GNUTLS_H
38         gnutls_global_init();
39 #endif
40 #if HAVE_GCRYPT_H
41         /* most likely, GnuTLS has initialized libgcrypt */
42         if (gcry_control(GCRYCTL_ANY_INITIALIZATION_P) == 0)
43         {
44             gcry_control(GCRYCTL_INITIALIZATION_FINISHED, NULL, 0);
45         }
46 #endif
47     }
48 }
49
50 /*
51  * Local variables:
52  * c-basic-offset: 4
53  * c-file-style: "Stroustrup"
54  * indent-tabs-mode: nil
55  * End:
56  * vim: shiftwidth=4 tabstop=8 expandtab
57  */
58