* gpg.texi (GPG Esoteric Options): Tweak mention of Tempest font to
[gnupg.git] / common / init.c
blob5425acee85b1cb08e3bd89a55a2b5d50c3f5c1ef
1 /* init.c - Various initializations
2 * Copyright (C) 2007 Free Software Foundation, Inc.
4 * This file is part of GnuPG.
6 * GnuPG is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * GnuPG is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
20 #include <config.h>
22 #ifdef WITHOUT_GNU_PTH /* Give the Makefile a chance to build without Pth. */
23 #undef HAVE_PTH
24 #undef USE_GNU_PTH
25 #endif
27 #ifdef HAVE_W32_SYSTEM
28 #include <windows.h>
29 #endif
30 #ifdef HAVE_PTH
31 #include <pth.h>
32 #endif
34 #include "estream.h"
35 #include "util.h"
38 /* This function is to be used early at program startup to make sure
39 that some subsystems are initialized. This is in particular
40 important for W32 to initialize the sockets so that our socket
41 emulation code used directly as well as in libassuan may be used.
42 It should best be called before any I/O is done so that setup
43 required for logging is ready. CAUTION: This might be called while
44 running suid(root). */
45 void
46 init_common_subsystems (void)
48 /* Try to auto set the character set. */
49 set_native_charset (NULL);
51 #ifdef HAVE_W32_SYSTEM
52 /* For W32 we need to initialize the socket layer. This is because
53 we use recv and send in libassuan as well as at some other
54 places. If we are building with PTH we let pth_init do it. We
55 can't do much on error so we ignore them. An error would anyway
56 later pop up if one of the socket functions is used. */
57 # ifdef HAVE_PTH
58 pth_init ();
59 # else
61 WSADATA wsadat;
63 WSAStartup (0x202, &wsadat);
65 # endif /*!HAVE_PTH*/
66 #endif
68 /* Initialize the Estream library. */
69 es_init ();