_gcc_gnu89_inline=yes, _gcc_gnu89_inline=no)
AC_MSG_RESULT($_gcc_gnu89_inline)
CFLAGS="$_gcc_cflags_save"
-
- AC_MSG_CHECKING([whether we have GNU assembler])
- GAS=`as --version < /dev/null 2>/dev/null | grep GNU`
- if test "$GAS"; then
- AM_CFLAGS="${AM_CFLAGS} -pipe"
- AC_MSG_RESULT(yes)
- else
- AC_MSG_RESULT(no)
- fi
fi
# Needs to be called outside of 'if' clause.
AC_MSG_CHECKING([whether to use the included libcfg])
AC_MSG_RESULT($libcfg_enabled)
-# Windows hacks.
-
-AC_DEFINE([WINVER], [0x0501], [Windows 2000 or before not supported.])
-save_LIBS="$LIBS"
-LIBS="$LIBS -lws2_32"
-AC_TRY_LINK([#include <winsock2.h>], [
- WORD wVersionRequested = MAKEWORD(2, 2);
- WSADATA wsaData;
- int err = WSAStartup(wVersionRequested, &wsaData);
- WSACleanup ();], wsastartup=yes, wsastartup=no)
-LIBS="$save_LIBS"
-if test "$wsastartup" = "yes"; then
- AC_DEFINE(HAVE_WINSOCK, 1, [Call WSAStartup in gnutls_global_init])
-fi
-AC_MSG_CHECKING([if we have Windows and WSAStartup/WSACleanup in -lws2_32])
-AC_MSG_RESULT($wsastartup)
-
-dnl Gnulib files
-dnl
-
AC_MSG_RESULT([***
*** Setting up gnulib compatibility files...
])
AC_LIBTOOL_WIN32_DLL
AC_PROG_LIBTOOL
-AC_SUBST(AM_CFLAGS)
-
AC_CONFIG_SUBDIRS([lib])
AC_CONFIG_SUBDIRS([libextra])
# the same distribution terms as the rest of that program.
#
# Generated by gnulib-tool.
-# Reproduce by: gnulib-tool --import --dir=. --local-dir=gl/override --lib=liblgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=gl/tests --aux-dir=build-aux --with-tests --lgpl=2 --libtool --macro-prefix=lgl --no-vc-files byteswap c-ctype fseeko func gettext memmem-simple memmove minmax netdb read-file snprintf socklen stdint strcase strverscmp sys_socket sys_stat time_r unistd vasprintf
+# Reproduce by: gnulib-tool --import --dir=. --local-dir=gl/override --lib=liblgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=gl/tests --aux-dir=build-aux --with-tests --lgpl=2 --libtool --macro-prefix=lgl --no-vc-files byteswap c-ctype fseeko func gettext memmem-simple memmove minmax netdb read-file snprintf sockets socklen stdint strcase strverscmp sys_socket sys_stat time_r unistd vasprintf
AUTOMAKE_OPTIONS = 1.5 gnits
## end gnulib module snprintf
+## begin gnulib module sockets
+
+liblgnu_la_SOURCES += sockets.h sockets.c
+
+## end gnulib module sockets
+
## begin gnulib module stdbool
BUILT_SOURCES += $(STDBOOL_H)
# Specification in the form of a command-line invocation:
-# gnulib-tool --import --dir=. --local-dir=gl/override --lib=liblgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=gl/tests --aux-dir=build-aux --with-tests --lgpl=2 --libtool --macro-prefix=lgl --no-vc-files byteswap c-ctype fseeko func gettext memmem-simple memmove minmax netdb read-file snprintf socklen stdint strcase strverscmp sys_socket sys_stat time_r unistd vasprintf
+# gnulib-tool --import --dir=. --local-dir=gl/override --lib=liblgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=gl/tests --aux-dir=build-aux --with-tests --lgpl=2 --libtool --macro-prefix=lgl --no-vc-files byteswap c-ctype fseeko func gettext memmem-simple memmove minmax netdb read-file snprintf sockets socklen stdint strcase strverscmp sys_socket sys_stat time_r unistd vasprintf
# Specification in the form of a few gnulib-tool.m4 macro invocations:
gl_LOCAL_DIR([gl/override])
netdb
read-file
snprintf
+ sockets
socklen
stdint
strcase
gl_SIZE_MAX
gl_FUNC_SNPRINTF
gl_STDIO_MODULE_INDICATOR([snprintf])
+ gl_SOCKETS
gl_TYPE_SOCKLEN_T
AM_STDBOOL_H
gl_STDINT_H
lib/realloc.c
lib/size_max.h
lib/snprintf.c
+ lib/sockets.c
+ lib/sockets.h
lib/stdbool.in.h
lib/stdint.in.h
lib/stdio-impl.h
m4/realloc.m4
m4/size_max.m4
m4/snprintf.m4
+ m4/sockets.m4
m4/socklen.m4
m4/sockpfaf.m4
m4/stdbool.m4
tests/test-netdb.c
tests/test-read-file.c
tests/test-snprintf.c
+ tests/test-sockets.c
tests/test-stdbool.c
tests/test-stdint.c
tests/test-stdio.c
--- /dev/null
+# sockets.m4 serial 2
+dnl Copyright (C) 2008 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_SOCKETS],
+[
+ gl_PREREQ_SYS_H_WINSOCK2 dnl for HAVE_WINSOCK2_H
+ LIBSOCKET=
+ if test $HAVE_WINSOCK2_H = 1; then
+ dnl Native Windows API (not Cygwin).
+ AC_CACHE_CHECK([if we need to call WSAStartup in winsock2.h and -lws2_32],
+ [gl_cv_func_wsastartup], [
+ gl_save_LIBS="$LIBS"
+ LIBS="$LIBS -lws2_32"
+ AC_TRY_LINK([
+#ifdef HAVE_WINSOCK2_H
+# include <winsock2.h>
+#endif], [
+ WORD wVersionRequested = MAKEWORD(1, 1);
+ WSADATA wsaData;
+ int err = WSAStartup(wVersionRequested, &wsaData);
+ WSACleanup ();],
+ gl_cv_func_wsastartup=yes, gl_cv_func_wsastartup=no)
+ LIBS="$gl_save_LIBS"
+ ])
+ if test "$gl_cv_func_wsastartup" = "yes"; then
+ AC_DEFINE([WINDOWS_SOCKETS], 1, [Define if WSAStartup is needed.])
+ LIBSOCKET='-lws2_32'
+ fi
+ else
+ dnl Unix API.
+ dnl Solaris has most socket functions in libsocket.
+ AC_CACHE_CHECK([whether setsockopt requires -lsocket], [gl_cv_lib_socket], [
+ gl_cv_lib_socket=no
+ AC_TRY_LINK([extern
+#ifdef __cplusplus
+"C"
+#endif
+char setsockopt();], [setsockopt();],
+ [],
+ [gl_save_LIBS="$LIBS"
+ LIBS="$LIBS -lsocket"
+ AC_TRY_LINK([extern
+#ifdef __cplusplus
+"C"
+#endif
+char setsockopt();], [setsockopt();],
+ [gl_cv_lib_socket=yes])
+ LIBS="$gl_save_LIBS"
+ ])
+ ])
+ if test $gl_cv_lib_socket = yes; then
+ LIBSOCKET='-lsocket'
+ fi
+ fi
+ AC_SUBST([LIBSOCKET])
+ gl_PREREQ_SOCKETS
+])
+
+# Prerequisites of lib/sockets.c.
+AC_DEFUN([gl_PREREQ_SOCKETS], [
+ :
+])
--- /dev/null
+/* sockets.c --- wrappers for Windows socket functions
+
+ Copyright (C) 2008 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ This program 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 Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Written by Simon Josefsson */
+
+#include <config.h>
+
+/* This includes winsock2.h on MinGW. */
+#include <sys/socket.h>
+
+#include "sockets.h"
+
+int
+gl_sockets_startup (int version)
+{
+#if WINDOWS_SOCKETS
+ WSADATA data;
+ int err;
+
+ err = WSAStartup (version, &data);
+ if (err != 0)
+ return 1;
+
+ if (data.wVersion < version)
+ return 2;
+#endif
+
+ return 0;
+}
+
+int
+gl_sockets_cleanup (void)
+{
+#if WINDOWS_SOCKETS
+ int err;
+
+ err = WSACleanup ();
+ if (err != 0)
+ return 1;
+#endif
+
+ return 0;
+}
--- /dev/null
+/* sockets.h - wrappers for Windows socket functions
+
+ Copyright (C) 2008 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ This program 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 Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Written by Simon Josefsson */
+
+#ifndef SOCKETS_H
+# define SOCKETS_H 1
+
+#define SOCKETS_1_0 0x100
+#define SOCKETS_1_1 0x101
+#define SOCKETS_2_0 0x200
+#define SOCKETS_2_1 0x201
+#define SOCKETS_2_2 0x202
+
+int gl_sockets_startup (int version);
+int gl_sockets_cleanup (void);
+
+#endif
## end gnulib module snprintf-tests
+## begin gnulib module sockets-tests
+
+TESTS += test-sockets
+check_PROGRAMS += test-sockets
+test_sockets_LDADD = $(LDADD) @LIBSOCKET@
+EXTRA_DIST += test-sockets.c
+
+## end gnulib module sockets-tests
+
## begin gnulib module stdbool-tests
TESTS += test-stdbool
--- /dev/null
+/*
+ * Copyright (C) 2008 Free Software Foundation
+ * Written by Simon Josefsson.
+ *
+ * This program 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+#include <stdio.h>
+
+#include "sockets.h"
+
+int
+main (int argc, char *argv[])
+{
+ int err;
+
+ err = gl_sockets_startup (SOCKETS_1_1);
+ if (err != 0)
+ {
+ printf ("wsastartup failed %d\n", err);
+ return 1;
+ }
+
+ err = gl_sockets_cleanup ();
+ if (err != 0)
+ {
+ printf ("wsacleanup failed %d\n", err);
+ return 1;
+ }
+
+ return 0;
+}
{
i = recv (GNUTLS_POINTER_TO_INT (fd), &ptr[sizeOfPtr - left],
left, flags);
-#if HAVE_WINSOCK
+#if HAVE_WINSOCK2_H
if (i < 0)
{
int tmperr = WSAGetLastError ();
if (session->internals._gnutls_push_func == NULL)
{
i = send (GNUTLS_POINTER_TO_INT (fd), &ptr[n - left], left, 0);
-#if HAVE_WINSOCK
+#if HAVE_WINSOCK2_H
if (i < 0)
{
int tmperr = WSAGetLastError ();
#include <gnutls_extensions.h> /* for _gnutls_ext_init */
-#ifdef HAVE_WINSOCK
-# include <winsock2.h>
-#endif
-
+#include "sockets.h"
#include "gettext.h"
#define gnutls_log_func LOG_FUNC
if (_gnutls_init++)
goto out;
-#if HAVE_WINSOCK
- {
- WORD requested;
- WSADATA data;
- int err;
-
- requested = MAKEWORD (1, 1);
- err = WSAStartup (requested, &data);
- if (err != 0)
- {
- _gnutls_debug_log ("WSAStartup failed: %d.\n", err);
- return GNUTLS_E_LIBRARY_VERSION_MISMATCH;
- }
-
- if (data.wVersion < requested)
- {
- _gnutls_debug_log ("WSAStartup version check failed (%d < %d).\n",
- data.wVersion, requested);
- WSACleanup ();
- return GNUTLS_E_LIBRARY_VERSION_MISMATCH;
- }
- }
-#endif
+ if (gl_sockets_startup (SOCKETS_1_1))
+ return GNUTLS_E_LIBRARY_VERSION_MISMATCH;
bindtextdomain (PACKAGE, LOCALEDIR);
{
if (_gnutls_init == 1)
{
-#if HAVE_WINSOCK
- WSACleanup ();
-#endif
+ gl_sockets_cleanup ();
_gnutls_rnd_deinit ();
asn1_delete_structure (&_gnutls_gnutls_asn);
asn1_delete_structure (&_gnutls_pkix1_asn);