diff options
author | Werner Koch <[email protected]> | 2007-06-14 17:05:07 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2007-06-14 17:05:07 +0000 |
commit | 0cfbfd6186c7b28a355069ebb89b9739908318c6 (patch) | |
tree | a1e2990f266ca151fc47f06d41f40bca743eea76 /common/init.c | |
parent | Syntax fix - should build now - however not tested. (diff) | |
download | gnupg-0cfbfd6186c7b28a355069ebb89b9739908318c6.tar.gz gnupg-0cfbfd6186c7b28a355069ebb89b9739908318c6.zip |
A whole bunch of changes to allow building for Windows.
See the ChangeLogs for details.
Diffstat (limited to 'common/init.c')
-rw-r--r-- | common/init.c | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/common/init.c b/common/init.c new file mode 100644 index 000000000..9ac6006c2 --- /dev/null +++ b/common/init.c @@ -0,0 +1,73 @@ +/* init.c - Various initializations + * Copyright (C) 2007 Free Software Foundation, Inc. + * + * This file is part of GnuPG. + * + * GnuPG is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * GnuPG is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + */ + +#include <config.h> + +#ifdef WITHOUT_GNU_PTH /* Give the Makefile a chance to build without Pth. */ +#undef HAVE_PTH +#undef USE_GNU_PTH +#endif + +#ifdef HAVE_W32_SYSTEM +#include <windows.h> +#endif +#ifdef HAVE_PTH +#include <pth.h> +#endif + +#include "estream.h" +#include "util.h" + + +/* This function is to be used early at program startup to make sure + that some subsystems are initialized. This is in particualr + important for W32 to initialize the sockets so that our socket + emulation code used directly as well as in libassuan may be used. + It should best be called before any I/O is done so that setup + required for logging is ready. CAUTION: This might be called while + running suid(root). */ +void +init_common_subsystems (void) +{ + /* Try to auto set the character set. */ + set_native_charset (NULL); + +#ifdef HAVE_W32_SYSTEM + /* For W32 we need to initialize the socket layer. This is becuase + we use recv and send in libassuan as well as at some other + places. If we are building with PTH we let pth_init do it. We + can't do much on error so we ignore them. An error would anyway + later pop up if one of the socket functions is used. */ +# ifdef HAVE_PTH + pth_init (); +# else + { + WSADATA wsadat; + + WSAStartup (0x202, &wsadat); + } +# endif /*!HAVE_PTH*/ +#endif + + /* Initialize the Estream library. */ + es_init (); +} + |