diff options
author | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2014-04-09 15:03:51 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2014-04-09 15:04:03 +0200 |
commit | 830d607ef6c590243d874d40fe99db2360634e17 (patch) | |
tree | 9fb034881102351024160e21a12d20ee3d2144f5 | |
parent | 5008cef3a6a5d40e30a356e6e5a317550d9a554f (diff) | |
download | gnutls-830d607ef6c590243d874d40fe99db2360634e17.tar.gz |
Added connect gnulib module.
-rw-r--r-- | src/gl/Makefile.am | 11 | ||||
-rw-r--r-- | src/gl/connect.c | 56 | ||||
-rw-r--r-- | src/gl/m4/gnulib-cache.m4 | 3 | ||||
-rw-r--r-- | src/gl/m4/gnulib-comp.m4 | 7 |
4 files changed, 75 insertions, 2 deletions
diff --git a/src/gl/Makefile.am b/src/gl/Makefile.am index 1e089767e7..dff58fb1a3 100644 --- a/src/gl/Makefile.am +++ b/src/gl/Makefile.am @@ -21,7 +21,7 @@ # the same distribution terms as the rest of that program. # # Generated by gnulib-tool. -# Reproduce by: gnulib-tool --import --dir=. --local-dir=src/gl/override --lib=libgnu_gpl --source-base=src/gl --m4-base=src/gl/m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-dependencies --libtool --macro-prefix=ggl --no-vc-files accept close getaddrinfo getpass inet_ntop inet_pton listen parse-datetime progname recv recvfrom select send sendto servent setsockopt shutdown socket sockets socklen +# Reproduce by: gnulib-tool --import --dir=. --local-dir=src/gl/override --lib=libgnu_gpl --source-base=src/gl --m4-base=src/gl/m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-dependencies --libtool --macro-prefix=ggl --no-vc-files accept close connect getaddrinfo getpass inet_ntop inet_pton listen parse-datetime progname recv recvfrom select send sendto servent setsockopt shutdown socket sockets socklen AUTOMAKE_OPTIONS = 1.9.6 gnits @@ -163,6 +163,15 @@ EXTRA_libgnu_gpl_la_SOURCES += close.c ## end gnulib module close +## begin gnulib module connect + + +EXTRA_DIST += connect.c w32sock.h + +EXTRA_libgnu_gpl_la_SOURCES += connect.c + +## end gnulib module connect + ## begin gnulib module dup2 diff --git a/src/gl/connect.c b/src/gl/connect.c new file mode 100644 index 0000000000..8671278324 --- /dev/null +++ b/src/gl/connect.c @@ -0,0 +1,56 @@ +/* connect.c --- wrappers for Windows connect function + + Copyright (C) 2008-2014 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 connect + +int +rpl_connect (int fd, const struct sockaddr *sockaddr, socklen_t len) +{ + SOCKET sock = FD_TO_SOCKET (fd); + + if (sock == INVALID_SOCKET) + { + errno = EBADF; + return -1; + } + else + { + int r = connect (sock, sockaddr, len); + if (r < 0) + { + /* EINPROGRESS is not returned by WinSock 2.0; for backwards + compatibility, connect(2) uses EWOULDBLOCK. */ + if (WSAGetLastError () == WSAEWOULDBLOCK) + WSASetLastError (WSAEINPROGRESS); + + set_winsock_errno (); + } + + return r; + } +} diff --git a/src/gl/m4/gnulib-cache.m4 b/src/gl/m4/gnulib-cache.m4 index 1594538e14..648dc63cf9 100644 --- a/src/gl/m4/gnulib-cache.m4 +++ b/src/gl/m4/gnulib-cache.m4 @@ -27,13 +27,14 @@ # Specification in the form of a command-line invocation: -# gnulib-tool --import --dir=. --local-dir=src/gl/override --lib=libgnu_gpl --source-base=src/gl --m4-base=src/gl/m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-dependencies --libtool --macro-prefix=ggl --no-vc-files accept close getaddrinfo getpass inet_ntop inet_pton listen parse-datetime progname recv recvfrom select send sendto servent setsockopt shutdown socket sockets socklen +# gnulib-tool --import --dir=. --local-dir=src/gl/override --lib=libgnu_gpl --source-base=src/gl --m4-base=src/gl/m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-dependencies --libtool --macro-prefix=ggl --no-vc-files accept close connect getaddrinfo getpass inet_ntop inet_pton listen parse-datetime progname recv recvfrom select send sendto servent setsockopt shutdown socket sockets socklen # Specification in the form of a few gnulib-tool.m4 macro invocations: gl_LOCAL_DIR([src/gl/override]) gl_MODULES([ accept close + connect getaddrinfo getpass inet_ntop diff --git a/src/gl/m4/gnulib-comp.m4 b/src/gl/m4/gnulib-comp.m4 index 7dd831aef3..0194e13d72 100644 --- a/src/gl/m4/gnulib-comp.m4 +++ b/src/gl/m4/gnulib-comp.m4 @@ -46,6 +46,7 @@ AC_DEFUN([ggl_EARLY], # Code from module c-ctype: # Code from module clock-time: # Code from module close: + # Code from module connect: # Code from module dup2: # Code from module environ: # Code from module errno: @@ -172,6 +173,11 @@ AC_SUBST([LTALLOCA]) AC_LIBOBJ([close]) fi gl_UNISTD_MODULE_INDICATOR([close]) + 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]) gl_FUNC_DUP2 if test $HAVE_DUP2 = 0 || test $REPLACE_DUP2 = 1; then AC_LIBOBJ([dup2]) @@ -584,6 +590,7 @@ AC_DEFUN([ggl_FILE_LIST], [ lib/c-ctype.c lib/c-ctype.h lib/close.c + lib/connect.c lib/dup2.c lib/errno.in.h lib/error.c |