diff options
author | Simon Josefsson <simon@josefsson.org> | 2008-10-30 21:32:41 +0100 |
---|---|---|
committer | Simon Josefsson <simon@josefsson.org> | 2008-10-30 21:32:41 +0100 |
commit | ca6cb894f25316ba54d98063b4113b27446e54d4 (patch) | |
tree | a362d96070c052f081ad6633d99ecc582e3a91ed | |
parent | 916941fce34a49740f3d98f3eb205d596cca81e4 (diff) | |
download | gnutls-ca6cb894f25316ba54d98063b4113b27446e54d4.tar.gz |
Use sockets module.
-rw-r--r-- | gl/Makefile.am | 146 | ||||
-rw-r--r-- | gl/m4/gnulib-cache.m4 | 10 | ||||
-rw-r--r-- | gl/m4/gnulib-comp.m4 | 98 | ||||
-rw-r--r-- | gl/shutdown.c | 40 | ||||
-rw-r--r-- | gl/tests/Makefile.am | 112 | ||||
-rw-r--r-- | gl/tests/dummy.c | 42 | ||||
-rw-r--r-- | gl/w32sock.h | 62 | ||||
-rw-r--r-- | lib/Makefile.am | 2 | ||||
-rw-r--r-- | src/common.h | 6 |
9 files changed, 462 insertions, 56 deletions
diff --git a/gl/Makefile.am b/gl/Makefile.am index a0d1fc9b4b..2e07d02407 100644 --- a/gl/Makefile.am +++ b/gl/Makefile.am @@ -9,7 +9,7 @@ # 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=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=gl/tests --aux-dir=build-aux --with-tests --libtool --macro-prefix=gl --no-vc-files arpa_inet autobuild error fdl gendocs getaddrinfo getline getpass-gnu gnupload gpl-3.0 inet_ntop inet_pton lgpl-2.1 maintainer-makefile progname readline version-etc-fsf +# Reproduce by: gnulib-tool --import --dir=. --local-dir=gl/override --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=gl/tests --aux-dir=build-aux --with-tests --libtool --macro-prefix=gl --no-vc-files accept arpa_inet autobuild bind close error fdl gendocs getaddrinfo getline getpass-gnu gnupload gpl-3.0 inet_ntop inet_pton lgpl-2.1 listen maintainer-makefile progname readline select setsockopt shutdown socket version-etc-fsf AUTOMAKE_OPTIONS = 1.5 gnits @@ -38,6 +38,26 @@ libgnu_la_DEPENDENCIES = $(gl_LTLIBOBJS) EXTRA_libgnu_la_SOURCES = libgnu_la_LDFLAGS = $(AM_LDFLAGS) +## begin gnulib module accept + + +EXTRA_DIST += accept.c w32sock.h + +EXTRA_libgnu_la_SOURCES += accept.c + +## end gnulib module accept + +## begin gnulib module alloca + + +EXTRA_DIST += alloca.c + +EXTRA_libgnu_la_SOURCES += alloca.c + +libgnu_la_LIBADD += @LTALLOCA@ +libgnu_la_DEPENDENCIES += @LTALLOCA@ +## end gnulib module alloca + ## begin gnulib module alloca-opt BUILT_SOURCES += $(ALLOCA_H) @@ -84,12 +104,30 @@ EXTRA_DIST += arpa_inet.in.h ## end gnulib module arpa_inet +## begin gnulib module bind + + +EXTRA_DIST += bind.c w32sock.h + +EXTRA_libgnu_la_SOURCES += bind.c + +## end gnulib module bind + ## begin gnulib module c-ctype libgnu_la_SOURCES += c-ctype.h c-ctype.c ## end gnulib module c-ctype +## begin gnulib module close + + +EXTRA_DIST += close.c + +EXTRA_libgnu_la_SOURCES += close.c + +## end gnulib module close + ## begin gnulib module errno BUILT_SOURCES += $(ERRNO_H) @@ -126,6 +164,15 @@ EXTRA_libgnu_la_SOURCES += error.c ## end gnulib module error +## begin gnulib module fclose + + +EXTRA_DIST += fclose.c + +EXTRA_libgnu_la_SOURCES += fclose.c + +## end gnulib module fclose + ## begin gnulib module float BUILT_SOURCES += $(FLOAT_H) @@ -262,6 +309,15 @@ EXTRA_DIST += $(top_srcdir)/build-aux/link-warning.h ## end gnulib module link-warning +## begin gnulib module listen + + +EXTRA_DIST += listen.c w32sock.h + +EXTRA_libgnu_la_SOURCES += listen.c + +## end gnulib module listen + ## begin gnulib module lseek @@ -348,6 +404,33 @@ EXTRA_libgnu_la_SOURCES += realloc.c ## end gnulib module realloc-posix +## begin gnulib module select + + +EXTRA_DIST += winsock-select.c + +EXTRA_libgnu_la_SOURCES += winsock-select.c + +## end gnulib module select + +## begin gnulib module setsockopt + + +EXTRA_DIST += setsockopt.c w32sock.h + +EXTRA_libgnu_la_SOURCES += setsockopt.c + +## end gnulib module setsockopt + +## begin gnulib module shutdown + + +EXTRA_DIST += shutdown.c w32sock.h + +EXTRA_libgnu_la_SOURCES += shutdown.c + +## end gnulib module shutdown + ## begin gnulib module size_max libgnu_la_SOURCES += size_max.h @@ -363,6 +446,15 @@ EXTRA_libgnu_la_SOURCES += snprintf.c ## end gnulib module snprintf +## begin gnulib module socket + + +EXTRA_DIST += socket.c w32sock.h + +EXTRA_libgnu_la_SOURCES += socket.c + +## end gnulib module socket + ## begin gnulib module stdarg BUILT_SOURCES += $(STDARG_H) @@ -672,6 +764,33 @@ EXTRA_DIST += string.in.h ## end gnulib module string +## begin gnulib module sys_select + +BUILT_SOURCES += $(SYS_SELECT_H) + +# We need the following in order to create <sys/select.h> when the system +# doesn't have one that works with the given compiler. +sys/select.h: sys_select.in.h + @MKDIR_P@ sys + rm -f $@-t $@ + { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ + sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ + -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''NEXT_SYS_SELECT_H''@|$(NEXT_SYS_SELECT_H)|g' \ + -e 's|@''HAVE_SYS_SELECT_H''@|$(HAVE_SYS_SELECT_H)|g' \ + -e 's|@''GNULIB_SELECT''@|$(GNULIB_SELECT)|g' \ + -e 's|@''HAVE_WINSOCK2_H''@|$(HAVE_WINSOCK2_H)|g' \ + -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ + < $(srcdir)/sys_select.in.h; \ + } > $@-t + mv $@-t $@ +MOSTLYCLEANFILES += sys/select.h sys/select.h-t +MOSTLYCLEANDIRS += sys + +EXTRA_DIST += sys_select.in.h + +## end gnulib module sys_select + ## begin gnulib module sys_socket BUILT_SOURCES += $(SYS_SOCKET_H) @@ -713,6 +832,31 @@ EXTRA_DIST += sys_socket.in.h ## end gnulib module sys_socket +## begin gnulib module sys_time + +BUILT_SOURCES += $(SYS_TIME_H) + +# We need the following in order to create <sys/time.h> when the system +# doesn't have one that works with the given compiler. +sys/time.h: sys_time.in.h + @MKDIR_P@ sys + rm -f $@-t $@ + { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ + sed -e 's/@''HAVE_SYS_TIME_H''@/$(HAVE_SYS_TIME_H)/g' \ + -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ + -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''NEXT_SYS_TIME_H''@|$(NEXT_SYS_TIME_H)|g' \ + -e 's/@''REPLACE_GETTIMEOFDAY''@/$(REPLACE_GETTIMEOFDAY)/g' \ + -e 's/@''HAVE_STRUCT_TIMEVAL''@/$(HAVE_STRUCT_TIMEVAL)/g' \ + < $(srcdir)/sys_time.in.h; \ + } > $@-t + mv $@-t $@ +MOSTLYCLEANFILES += sys/time.h sys/time.h-t + +EXTRA_DIST += sys_time.in.h + +## end gnulib module sys_time + ## begin gnulib module unistd BUILT_SOURCES += unistd.h diff --git a/gl/m4/gnulib-cache.m4 b/gl/m4/gnulib-cache.m4 index 18fbd1c517..71e0501577 100644 --- a/gl/m4/gnulib-cache.m4 +++ b/gl/m4/gnulib-cache.m4 @@ -15,13 +15,16 @@ # Specification in the form of a command-line invocation: -# gnulib-tool --import --dir=. --local-dir=gl/override --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=gl/tests --aux-dir=build-aux --with-tests --libtool --macro-prefix=gl --no-vc-files arpa_inet autobuild error fdl gendocs getaddrinfo getline getpass-gnu gnupload gpl-3.0 inet_ntop inet_pton lgpl-2.1 maintainer-makefile progname readline version-etc-fsf +# gnulib-tool --import --dir=. --local-dir=gl/override --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=gl/tests --aux-dir=build-aux --with-tests --libtool --macro-prefix=gl --no-vc-files accept arpa_inet autobuild bind close error fdl gendocs getaddrinfo getline getpass-gnu gnupload gpl-3.0 inet_ntop inet_pton lgpl-2.1 listen maintainer-makefile progname readline select setsockopt shutdown socket version-etc-fsf # Specification in the form of a few gnulib-tool.m4 macro invocations: gl_LOCAL_DIR([gl/override]) gl_MODULES([ + accept arpa_inet autobuild + bind + close error fdl gendocs @@ -33,9 +36,14 @@ gl_MODULES([ inet_ntop inet_pton lgpl-2.1 + listen maintainer-makefile progname readline + select + setsockopt + shutdown + socket version-etc-fsf ]) gl_AVOID([]) diff --git a/gl/m4/gnulib-comp.m4 b/gl/m4/gnulib-comp.m4 index 197bf81f98..3770bad63e 100644 --- a/gl/m4/gnulib-comp.m4 +++ b/gl/m4/gnulib-comp.m4 @@ -49,14 +49,32 @@ AC_DEFUN([gl_INIT], m4_pushdef([gl_LIBSOURCES_DIR], []) gl_COMMON gl_source_base='gl' + AC_REQUIRE([gl_HEADER_SYS_SOCKET]) + if test "$ac_cv_header_winsock2_h" = yes; then + AC_LIBOBJ([accept]) + fi + gl_SYS_SOCKET_MODULE_INDICATOR([accept]) +changequote(,)dnl +LTALLOCA=`echo "$ALLOCA" | sed 's/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'` +changequote([, ])dnl +AC_SUBST([LTALLOCA]) gl_FUNC_ALLOCA gl_HEADER_ARPA_INET AC_PROG_MKDIR_P + AC_REQUIRE([gl_HEADER_SYS_SOCKET]) + if test "$ac_cv_header_winsock2_h" = yes; then + AC_LIBOBJ([bind]) + fi + gl_SYS_SOCKET_MODULE_INDICATOR([bind]) + gl_FUNC_CLOSE + gl_UNISTD_MODULE_INDICATOR([close]) gl_HEADER_ERRNO_H gl_ERROR m4_ifdef([AM_XGETTEXT_OPTION], [AM_XGETTEXT_OPTION([--flag=error:3:c-format]) AM_XGETTEXT_OPTION([--flag=error_at_line:5:c-format])]) + gl_FUNC_FCLOSE + gl_STDIO_MODULE_INDICATOR([fclose]) gl_FLOAT_H gl_FUNC_FSEEKO gl_STDIO_MODULE_INDICATOR([fseeko]) @@ -83,6 +101,11 @@ AC_DEFUN([gl_INIT], gl_ARPA_INET_MODULE_INDICATOR([inet_ntop]) gl_INET_PTON gl_ARPA_INET_MODULE_INDICATOR([inet_pton]) + AC_REQUIRE([gl_HEADER_SYS_SOCKET]) + if test "$ac_cv_header_winsock2_h" = yes; then + AC_LIBOBJ([listen]) + fi + gl_SYS_SOCKET_MODULE_INDICATOR([listen]) gl_FUNC_LSEEK gl_UNISTD_MODULE_INDICATOR([lseek]) gl_HEADER_NETDB @@ -91,9 +114,29 @@ AC_DEFUN([gl_INIT], gl_FUNC_READLINE gl_FUNC_REALLOC_POSIX gl_STDLIB_MODULE_INDICATOR([realloc-posix]) + AC_REQUIRE([gl_HEADER_SYS_SELECT]) + if test "$ac_cv_header_winsock2_h" = yes; then + AC_LIBOBJ([winsock-select]) + fi + gl_SYS_SELECT_MODULE_INDICATOR([select]) + AC_REQUIRE([gl_HEADER_SYS_SOCKET]) + if test "$ac_cv_header_winsock2_h" = yes; then + AC_LIBOBJ([setsockopt]) + fi + gl_SYS_SOCKET_MODULE_INDICATOR([setsockopt]) + AC_REQUIRE([gl_HEADER_SYS_SOCKET]) + if test "$ac_cv_header_winsock2_h" = yes; then + AC_LIBOBJ([shutdown]) + fi + gl_SYS_SOCKET_MODULE_INDICATOR([shutdown]) gl_SIZE_MAX gl_FUNC_SNPRINTF gl_STDIO_MODULE_INDICATOR([snprintf]) + AC_REQUIRE([gl_HEADER_SYS_SOCKET]) + if test "$ac_cv_header_winsock2_h" = yes; then + AC_LIBOBJ([socket]) + fi + gl_SYS_SOCKET_MODULE_INDICATOR([socket]) gl_TYPE_SOCKLEN_T gl_STDARG_H AM_STDBOOL_H @@ -103,9 +146,13 @@ AC_DEFUN([gl_INIT], gl_FUNC_STRERROR gl_STRING_MODULE_INDICATOR([strerror]) gl_HEADER_STRING_H + gl_HEADER_SYS_SELECT + AC_PROG_MKDIR_P gl_HEADER_SYS_SOCKET gl_MODULE_INDICATOR([sys_socket]) AC_PROG_MKDIR_P + gl_HEADER_SYS_TIME_H + AC_PROG_MKDIR_P gl_UNISTD_H gl_FUNC_VASNPRINTF gl_WCHAR_H @@ -149,8 +196,25 @@ AC_DEFUN([gl_INIT], m4_pushdef([gltests_LIBSOURCES_DIR], []) gl_COMMON gl_source_base='gl/tests' + AC_REQUIRE([gl_HEADER_SYS_SOCKET]) + if test "$ac_cv_header_winsock2_h" = yes; then + AC_LIBOBJ([connect]) + fi + gl_SYS_SOCKET_MODULE_INDICATOR([connect]) + AC_REQUIRE([gl_HEADER_SYS_SOCKET]) + if test "$ac_cv_header_winsock2_h" = yes; then + AC_LIBOBJ([ioctl]) + gl_REPLACE_SYS_IOCTL_H + fi + gl_SYS_IOCTL_MODULE_INDICATOR([ioctl]) + gl_MODULE_INDICATOR([ioctl]) + gl_FUNC_PERROR + gl_STRING_MODULE_INDICATOR([perror]) + gl_SOCKETS gt_TYPE_WCHAR_T gt_TYPE_WINT_T + gl_SYS_IOCTL_H + AC_PROG_MKDIR_P AC_CHECK_FUNCS([shutdown]) m4_ifval(gltests_LIBSOURCES_LIST, [ m4_syscmd([test ! -d ]m4_defn([gltests_LIBSOURCES_DIR])[ || @@ -251,14 +315,19 @@ AC_DEFUN([gl_FILE_LIST], [ doc/gendocs_template doc/gpl-3.0.texi doc/lgpl-2.1.texi + lib/accept.c + lib/alloca.c lib/alloca.in.h lib/arpa_inet.in.h lib/asnprintf.c + lib/bind.c lib/c-ctype.c lib/c-ctype.h + lib/close.c lib/errno.in.h lib/error.c lib/error.h + lib/fclose.c lib/float+.h lib/float.in.h lib/fseeko.c @@ -272,6 +341,7 @@ AC_DEFUN([gl_FILE_LIST], [ lib/inet_ntop.c lib/inet_pton.c lib/intprops.h + lib/listen.c lib/lseek.c lib/netdb.in.h lib/netinet_in.in.h @@ -284,8 +354,11 @@ AC_DEFUN([gl_FILE_LIST], [ lib/readline.c lib/readline.h lib/realloc.c + lib/setsockopt.c + lib/shutdown.c lib/size_max.h lib/snprintf.c + lib/socket.c lib/stdarg.in.h lib/stdbool.in.h lib/stdint.in.h @@ -295,21 +368,27 @@ AC_DEFUN([gl_FILE_LIST], [ lib/stdlib.in.h lib/strerror.c lib/string.in.h + lib/sys_select.in.h lib/sys_socket.in.h + lib/sys_time.in.h lib/unistd.in.h lib/vasnprintf.c lib/vasnprintf.h lib/version-etc-fsf.c lib/version-etc.c lib/version-etc.h + lib/w32sock.h lib/wchar.in.h + lib/winsock-select.c lib/xsize.h m4/alloca.m4 m4/arpa_inet_h.m4 m4/autobuild.m4 + m4/close.m4 m4/errno_h.m4 m4/error.m4 m4/extensions.m4 + m4/fclose.m4 m4/float_h.m4 m4/fseeko.m4 m4/getaddrinfo.m4 @@ -330,11 +409,13 @@ AC_DEFUN([gl_FILE_LIST], [ m4/malloc.m4 m4/netdb_h.m4 m4/netinet_in_h.m4 + m4/perror.m4 m4/printf.m4 m4/readline.m4 m4/realloc.m4 m4/size_max.m4 m4/snprintf.m4 + m4/sockets.m4 m4/socklen.m4 m4/sockpfaf.m4 m4/stdarg.m4 @@ -345,7 +426,10 @@ AC_DEFUN([gl_FILE_LIST], [ m4/stdlib_h.m4 m4/strerror.m4 m4/string_h.m4 + m4/sys_ioctl_h.m4 + m4/sys_select_h.m4 m4/sys_socket_h.m4 + m4/sys_time_h.m4 m4/unistd_h.m4 m4/vasnprintf.m4 m4/wchar.m4 @@ -365,19 +449,31 @@ AC_DEFUN([gl_FILE_LIST], [ tests/test-lseek.sh tests/test-netdb.c tests/test-netinet_in.c + tests/test-perror.c + tests/test-perror.sh + tests/test-select.c tests/test-snprintf.c + tests/test-sockets.c tests/test-stdbool.c tests/test-stdint.c tests/test-stdio.c tests/test-stdlib.c tests/test-strerror.c tests/test-string.c + tests/test-sys_select.c tests/test-sys_socket.c + tests/test-sys_time.c tests/test-unistd.c tests/test-vasnprintf.c tests/test-wchar.c - tests=lib/dummy.c + tests=lib/connect.c + tests=lib/ioctl.c + tests=lib/perror.c + tests=lib/sockets.c + tests=lib/sockets.h + tests=lib/sys_ioctl.in.h tests=lib/verify.h + tests=lib/w32sock.h top/GNUmakefile top/maint.mk ]) diff --git a/gl/shutdown.c b/gl/shutdown.c new file mode 100644 index 0000000000..290d70616e --- /dev/null +++ b/gl/shutdown.c @@ -0,0 +1,40 @@ +/* shutdown.c --- wrappers for Windows shutdown function + + 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 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/>. */ + +/* Written by Paolo Bonzini */ + +#include <config.h> + +#define WIN32_LEAN_AND_MEAN +/* Get winsock2.h. */ +#include <sys/socket.h> + +/* Get set_winsock_errno, FD_TO_SOCKET etc. */ +#include "w32sock.h" + +#undef shutdown + +int +rpl_shutdown (int fd, int how) +{ + SOCKET sock = FD_TO_SOCKET (fd); + int r = shutdown (sock, how); + if (r < 0) + set_winsock_errno (); + + return r; +} diff --git a/gl/tests/Makefile.am b/gl/tests/Makefile.am index f65b513f8e..6212ffda41 100644 --- a/gl/tests/Makefile.am +++ b/gl/tests/Makefile.am @@ -69,6 +69,15 @@ EXTRA_DIST += test-c-ctype.c ## end gnulib module c-ctype-tests +## begin gnulib module connect + + +EXTRA_DIST += connect.c w32sock.h + +EXTRA_libtests_a_SOURCES += connect.c + +## end gnulib module connect + ## begin gnulib module errno-tests TESTS += test-errno @@ -115,6 +124,15 @@ EXTRA_DIST += test-getline.c ## end gnulib module getline-tests +## begin gnulib module ioctl + + +EXTRA_DIST += ioctl.c w32sock.h + +EXTRA_libtests_a_SOURCES += ioctl.c + +## end gnulib module ioctl + ## begin gnulib module lseek-tests TESTS += test-lseek.sh @@ -142,6 +160,34 @@ EXTRA_DIST += test-netinet_in.c ## end gnulib module netinet_in-tests +## begin gnulib module perror + + +EXTRA_DIST += perror.c + +EXTRA_libtests_a_SOURCES += perror.c + +## end gnulib module perror + +## begin gnulib module perror-tests + +TESTS += test-perror.sh +TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='$(srcdir)' +check_PROGRAMS += test-perror +EXTRA_DIST += test-perror.c test-perror.sh + +## end gnulib module perror-tests + +## begin gnulib module select-tests + +TESTS += test-select +check_PROGRAMS += test-select +test_select_LDADD = $(LDADD) @LIBSOCKET@ + +EXTRA_DIST += test-select.c + +## end gnulib module select-tests + ## begin gnulib module snprintf-tests TESTS += test-snprintf @@ -151,6 +197,21 @@ EXTRA_DIST += test-snprintf.c ## end gnulib module snprintf-tests +## begin gnulib module sockets + +libtests_a_SOURCES += sockets.h sockets.c + +## end gnulib module sockets + +## 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 @@ -204,6 +265,42 @@ EXTRA_DIST += test-string.c ## end gnulib module string-tests +## begin gnulib module sys_ioctl + +BUILT_SOURCES += $(SYS_IOCTL_H) + +# We need the following in order to create <sys/ioctl.h> when the system +# does not have a complete one. +sys/ioctl.h: sys_ioctl.in.h + @MKDIR_P@ sys + rm -f $@-t $@ + { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ + sed -e 's|@''HAVE_SYS_IOCTL_H''@|$(HAVE_SYS_IOCTL_H)|g' \ + -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ + -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''NEXT_SYS_IOCTL_H''@|$(NEXT_SYS_IOCTL_H)|g' \ + -e 's|@''GNULIB_IOCTL''@|$(GNULIB_IOCTL)|g' \ + -e 's|@''SYS_IOCTL_H_HAVE_WINSOCK2_H''@|$(SYS_IOCTL_H_HAVE_WINSOCK2_H)|g' \ + -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ + < $(srcdir)/sys_ioctl.in.h; \ + } > $@-t + mv $@-t $@ +MOSTLYCLEANFILES += sys/ioctl.h sys/ioctl.h-t +MOSTLYCLEANDIRS += sys + +EXTRA_DIST += sys_ioctl.in.h + +## end gnulib module sys_ioctl + +## begin gnulib module sys_select-tests + +TESTS += test-sys_select +check_PROGRAMS += test-sys_select + +EXTRA_DIST += test-sys_select.c + +## end gnulib module sys_select-tests + ## begin gnulib module sys_socket-tests TESTS += test-sys_socket @@ -213,6 +310,15 @@ EXTRA_DIST += test-sys_socket.c ## end gnulib module sys_socket-tests +## begin gnulib module sys_time-tests + +TESTS += test-sys_time +check_PROGRAMS += test-sys_time + +EXTRA_DIST += test-sys_time.c + +## end gnulib module sys_time-tests + ## begin gnulib module unistd-tests TESTS += test-unistd @@ -246,12 +352,6 @@ EXTRA_DIST += test-wchar.c ## end gnulib module wchar-tests -## begin gnulib module dummy - -libtests_a_SOURCES += dummy.c - -## end gnulib module dummy - # Clean up after Solaris cc. clean-local: rm -rf SunWS_cache diff --git a/gl/tests/dummy.c b/gl/tests/dummy.c deleted file mode 100644 index ccb5c26f87..0000000000 --- a/gl/tests/dummy.c +++ /dev/null @@ -1,42 +0,0 @@ -/* A dummy file, to prevent empty libraries from breaking builds. - Copyright (C) 2004, 2007 Free Software Foundation, Inc. - - 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/>. */ - -/* Some systems, reportedly OpenBSD and Mac OS X, refuse to create - libraries without any object files. You might get an error like: - - > ar cru .libs/libgl.a - > ar: no archive members specified - - Compiling this file, and adding its object file to the library, will - prevent the library from being empty. */ - -/* Some systems, such as Solaris with cc 5.0, refuse to work with libraries - that don't export any symbol. You might get an error like: - - > cc ... libgnu.a - > ild: (bad file) garbled symbol table in archive ../gllib/libgnu.a - - Compiling this file, and adding its object file to the library, will - prevent the library from exporting no symbols. */ - -#ifdef __sun -/* This declaration ensures that the library will export at least 1 symbol. */ -int gl_dummy_symbol; -#else -/* This declaration is solely to ensure that after preprocessing - this file is never empty. */ -typedef int dummy; -#endif diff --git a/gl/w32sock.h b/gl/w32sock.h new file mode 100644 index 0000000000..0622985b81 --- /dev/null +++ b/gl/w32sock.h @@ -0,0 +1,62 @@ +/* w32sock.h --- internal auxilliary functions 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 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/>. */ + +/* Written by Paolo Bonzini */ + +#include <errno.h> + +/* Get O_RDWR and O_BINARY. */ +#include <fcntl.h> + +/* Get _get_osfhandle() and _open_osfhandle(). */ +#include <io.h> + +#define FD_TO_SOCKET(fd) ((SOCKET) _get_osfhandle ((fd))) +#define SOCKET_TO_FD(fh) (_open_osfhandle ((long) (fh), O_RDWR | O_BINARY)) + +static inline void +set_winsock_errno (void) +{ + int err = WSAGetLastError (); + WSASetLastError (0); + + /* Map some WSAE* errors to the runtime library's error codes. */ + switch (err) + { + case WSA_INVALID_HANDLE: + errno = EBADF; + break; + case WSA_NOT_ENOUGH_MEMORY: + errno = ENOMEM; + break; + case WSA_INVALID_PARAMETER: + errno = EINVAL; + break; + case WSAEWOULDBLOCK: + errno = EWOULDBLOCK; + break; + case WSAENAMETOOLONG: + errno = ENAMETOOLONG; + break; + case WSAENOTEMPTY: + errno = ENOTEMPTY; + break; + default: + errno = (err > 10000 && err < 10025) ? err - 10000 : err; + break; + } +} diff --git a/lib/Makefile.am b/lib/Makefile.am index 1134b640a6..0077753363 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -107,7 +107,7 @@ libgnutls_la_LDFLAGS = -no-undefined \ -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) libgnutls_la_LIBADD = gl/liblgnu.la x509/libgnutls_x509.la \ - $(LTLIBZ) $(LTLIBGCRYPT) $(LTLIBINTL) + $(LTLIBZ) $(LTLIBGCRYPT) $(LTLIBINTL) $(LIBSOCKET) if ENABLE_OPENPGP libgnutls_la_LIBADD += openpgp/libgnutls_openpgp.la diff --git a/src/common.h b/src/common.h index 4d600e2eaf..5ca2b3b97c 100644 --- a/src/common.h +++ b/src/common.h @@ -8,13 +8,11 @@ #include <arpa/inet.h> #include <netdb.h> #include <unistd.h> +#include <netinet/in.h> +#include <signal.h> #ifdef _WIN32 # include <io.h> # include <winbase.h> -# define close closesocket -#else -# include <netinet/in.h> -# include <signal.h> #endif /* the number of elements in the priority structures. |