Author: yoann
Date: 2008-11-14 17:21:43 +0100 (Fri, 14 Nov 2008)
New Revision: 11093
Added:
libprelude/trunk/libmissing/accept.c
libprelude/trunk/libmissing/bind.c
libprelude/trunk/libmissing/close.c
libprelude/trunk/libmissing/fclose.c
libprelude/trunk/libmissing/ioctl.c
libprelude/trunk/libmissing/listen.c
libprelude/trunk/libmissing/sys_ioctl.in.h
Removed:
libprelude/trunk/libmissing/tests/accept.c
libprelude/trunk/libmissing/tests/bind.c
libprelude/trunk/libmissing/tests/close.c
libprelude/trunk/libmissing/tests/fclose.c
libprelude/trunk/libmissing/tests/ioctl.c
libprelude/trunk/libmissing/tests/listen.c
libprelude/trunk/libmissing/tests/sys_ioctl.in.h
libprelude/trunk/libmissing/tests/w32sock.h
Modified:
libprelude/trunk/libmissing/Makefile.am
libprelude/trunk/libmissing/m4/gnulib-cache.m4
libprelude/trunk/libmissing/m4/gnulib-comp.m4
libprelude/trunk/libmissing/tests/Makefile.am
Log:
Update GnuLib code.
Modified: libprelude/trunk/libmissing/Makefile.am
===================================================================
--- libprelude/trunk/libmissing/Makefile.am 2008-11-12 14:21:59 UTC (rev 11092)
+++ libprelude/trunk/libmissing/Makefile.am 2008-11-14 16:21:43 UTC (rev 11093)
@@ -9,7 +9,7 @@
# the same distribution terms as the rest of that program.
#
# Generated by gnulib-tool.
-# Reproduce by: gnulib-tool --import --dir=. --lib=libmissing --source-base=libmissing --m4-base=libmissing/m4 --doc-base=libmissing/doc --tests-base=libmissing/tests --aux-dir=. --with-tests --lgpl --libtool --macro-prefix=gl --no-vc-files cond connect dup2 fopen ftw getaddrinfo getpass getsockname gettimeofday inet_ntop inet_pton lock lseek memmem minmax pathmax perror poll regex relocatable-lib-lgpl select setsockopt sigprocmask sleep snprintf socket socklen strcase strcasestr strdup strerror strndup strptime strsep sys_stat thread time_r timegm tls uname vsnprintf write
+# Reproduce by: gnulib-tool --import --dir=. --lib=libmissing --source-base=libmissing --m4-base=libmissing/m4 --doc-base=libmissing/doc --tests-base=libmissing/tests --aux-dir=. --with-tests --lgpl --libtool --macro-prefix=gl --no-vc-files accept bind close cond connect dup2 fclose fopen ftw getaddrinfo getpass getsockname gettimeofday inet_ntop inet_pton ioctl listen lock lseek memmem minmax pathmax perror poll regex relocatable-lib-lgpl select setsockopt sigprocmask sleep snprintf socket socklen strcase strcasestr strdup strerror strndup strptime strsep sys_stat thread time_r timegm tls uname vsnprintf write
AUTOMAKE_OPTIONS = 1.5 gnits subdir-objects
@@ -38,6 +38,15 @@
EXTRA_libmissing_la_SOURCES =
libmissing_la_LDFLAGS = $(AM_LDFLAGS)
+## begin gnulib module accept
+
+
+EXTRA_DIST += accept.c w32sock.h
+
+EXTRA_libmissing_la_SOURCES += accept.c
+
+## end gnulib module accept
+
## begin gnulib module alloca
@@ -95,12 +104,30 @@
## end gnulib module arpa_inet
+## begin gnulib module bind
+
+
+EXTRA_DIST += bind.c w32sock.h
+
+EXTRA_libmissing_la_SOURCES += bind.c
+
+## end gnulib module bind
+
## begin gnulib module c-ctype
libmissing_la_SOURCES += c-ctype.h c-ctype.c
## end gnulib module c-ctype
+## begin gnulib module close
+
+
+EXTRA_DIST += close.c w32sock.h
+
+EXTRA_libmissing_la_SOURCES += close.c
+
+## end gnulib module close
+
## begin gnulib module cond
libmissing_la_SOURCES += glthread/cond.h glthread/cond.c
@@ -208,6 +235,15 @@
## end gnulib module errno
+## begin gnulib module fclose
+
+
+EXTRA_DIST += fclose.c
+
+EXTRA_libmissing_la_SOURCES += fclose.c
+
+## end gnulib module fclose
+
## begin gnulib module float
BUILT_SOURCES += $(FLOAT_H)
@@ -349,6 +385,15 @@
## end gnulib module intprops
+## begin gnulib module ioctl
+
+
+EXTRA_DIST += ioctl.c w32sock.h
+
+EXTRA_libmissing_la_SOURCES += ioctl.c
+
+## end gnulib module ioctl
+
## begin gnulib module link-warning
LINK_WARNING_H=$(top_srcdir)/./link-warning.h
@@ -357,6 +402,15 @@
## end gnulib module link-warning
+## begin gnulib module listen
+
+
+EXTRA_DIST += listen.c w32sock.h
+
+EXTRA_libmissing_la_SOURCES += listen.c
+
+## end gnulib module listen
+
## begin gnulib module localcharset
libmissing_la_SOURCES += localcharset.h localcharset.c
@@ -1061,6 +1115,33 @@
## end gnulib module strsep
+## 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
BUILT_SOURCES += $(SYS_SELECT_H)
Copied: libprelude/trunk/libmissing/accept.c (from rev 11092, libprelude/trunk/libmissing/tests/accept.c)
===================================================================
--- libprelude/trunk/libmissing/accept.c (rev 0)
+++ libprelude/trunk/libmissing/accept.c 2008-11-14 16:21:43 UTC (rev 11093)
@@ -0,0 +1,42 @@
+/* accept.c --- wrappers for Windows accept 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 Lesser 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 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 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 accept
+
+int
+rpl_accept (int fd, struct sockaddr *addr, int *addrlen)
+{
+ SOCKET fh = accept (FD_TO_SOCKET (fd), addr, addrlen);
+ if (fh == INVALID_SOCKET)
+ {
+ set_winsock_errno ();
+ return -1;
+ }
+ else
+ return SOCKET_TO_FD (fh);
+}
Copied: libprelude/trunk/libmissing/bind.c (from rev 11092, libprelude/trunk/libmissing/tests/bind.c)
===================================================================
--- libprelude/trunk/libmissing/bind.c (rev 0)
+++ libprelude/trunk/libmissing/bind.c 2008-11-14 16:21:43 UTC (rev 11093)
@@ -0,0 +1,40 @@
+/* bind.c --- wrappers for Windows bind 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 Lesser 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 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 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 bind
+
+int
+rpl_bind (int fd, struct sockaddr *sockaddr, int len)
+{
+ SOCKET sock = FD_TO_SOCKET (fd);
+ int r = bind (sock, sockaddr, len);
+ if (r < 0)
+ set_winsock_errno ();
+
+ return r;
+}
Copied: libprelude/trunk/libmissing/close.c (from rev 11092, libprelude/trunk/libmissing/tests/close.c)
===================================================================
--- libprelude/trunk/libmissing/close.c (rev 0)
+++ libprelude/trunk/libmissing/close.c 2008-11-14 16:21:43 UTC (rev 11093)
@@ -0,0 +1,82 @@
+/* close replacement.
+ 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 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 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/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include <unistd.h>
+
+#if GNULIB_SYS_SOCKET
+# define WIN32_LEAN_AND_MEAN
+# include <sys/socket.h>
+#endif
+
+#if HAVE__GL_CLOSE_FD_MAYBE_SOCKET
+
+/* Get set_winsock_errno, FD_TO_SOCKET etc. */
+#include "w32sock.h"
+
+static int
+_gl_close_fd_maybe_socket (int fd)
+{
+ SOCKET sock = FD_TO_SOCKET (fd);
+ WSANETWORKEVENTS ev;
+
+ ev.lNetworkEvents = 0xDEADBEEF;
+ WSAEnumNetworkEvents (sock, NULL, &ev);
+ if (ev.lNetworkEvents != 0xDEADBEEF)
+ {
+ /* FIXME: other applications, like squid, use an undocumented
+ _free_osfhnd free function. But this is not enough: The 'osfile'
+ flags for fd also needs to be cleared, but it is hard to access it.
+ Instead, here we just close twice the file descriptor. */
+ if (closesocket (sock))
+ {
+ set_winsock_errno ();
+ return -1;
+ }
+ else
+ {
+ /* This call frees the file descriptor and does a
+ CloseHandle ((HANDLE) _get_osfhandle (fd)), which fails. */
+ _close (fd);
+ return 0;
+ }
+ }
+ else
+ return _close (fd);
+}
+#endif
+
+/* Override close() to call into other gnulib modules. */
+
+int
+rpl_close (int fd)
+#undef close
+{
+#if HAVE__GL_CLOSE_FD_MAYBE_SOCKET
+ int retval = _gl_close_fd_maybe_socket (fd);
+#else
+ int retval = close (fd);
+#endif
+
+#ifdef FCHDIR_REPLACEMENT
+ if (retval >= 0)
+ _gl_unregister_fd (fd);
+#endif
+
+ return retval;
+}
Copied: libprelude/trunk/libmissing/fclose.c (from rev 11092, libprelude/trunk/libmissing/tests/fclose.c)
===================================================================
--- libprelude/trunk/libmissing/fclose.c (rev 0)
+++ libprelude/trunk/libmissing/fclose.c 2008-11-14 16:21:43 UTC (rev 11093)
@@ -0,0 +1,47 @@
+/* fclose replacement.
+ 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 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 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/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include <stdio.h>
+
+#include <errno.h>
+#include <unistd.h>
+
+/* Override fclose() to call the overridden close(). */
+
+int
+rpl_fclose (FILE *fp)
+#undef fclose
+{
+ int saved_errno = 0;
+
+ if (fflush (fp))
+ saved_errno = errno;
+
+ if (close (fileno (fp)) < 0 && saved_errno == 0)
+ saved_errno = errno;
+
+ fclose (fp); /* will fail with errno = EBADF */
+
+ if (saved_errno != 0)
+ {
+ errno = saved_errno;
+ return EOF;
+ }
+ return 0;
+}
Copied: libprelude/trunk/libmissing/ioctl.c (from rev 11092, libprelude/trunk/libmissing/tests/ioctl.c)
===================================================================
--- libprelude/trunk/libmissing/ioctl.c (rev 0)
+++ libprelude/trunk/libmissing/ioctl.c 2008-11-14 16:21:43 UTC (rev 11093)
@@ -0,0 +1,49 @@
+/* ioctl.c --- wrappers for Windows ioctl 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 Lesser 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 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 Paolo Bonzini */
+
+#include <config.h>
+
+#include <stdarg.h>
+
+#define WIN32_LEAN_AND_MEAN
+/* Get winsock2.h. */
+#include <sys/socket.h>
+
+/* Get set_winsock_errno, FD_TO_SOCKET etc. */
+#include "w32sock.h"
+
+int
+rpl_ioctl (int fd, int req, ...)
+{
+ void *buf;
+ va_list args;
+ SOCKET sock;
+ int r;
+
+ va_start (args, req);
+ buf = va_arg (args, void *);
+ va_end (args);
+
+ sock = FD_TO_SOCKET (fd);
+ r = ioctlsocket (sock, req, buf);
+ if (r < 0)
+ set_winsock_errno ();
+
+ return r;
+}
Copied: libprelude/trunk/libmissing/listen.c (from rev 11092, libprelude/trunk/libmissing/tests/listen.c)
===================================================================
--- libprelude/trunk/libmissing/listen.c (rev 0)
+++ libprelude/trunk/libmissing/listen.c 2008-11-14 16:21:43 UTC (rev 11093)
@@ -0,0 +1,40 @@
+/* listen.c --- wrappers for Windows listen 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 Lesser 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 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 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 listen
+
+int
+rpl_listen (int fd, int backlog)
+{
+ SOCKET sock = FD_TO_SOCKET (fd);
+ int r = listen (sock, backlog);
+ if (r < 0)
+ set_winsock_errno ();
+
+ return r;
+}
Modified: libprelude/trunk/libmissing/m4/gnulib-cache.m4
===================================================================
--- libprelude/trunk/libmissing/m4/gnulib-cache.m4 2008-11-12 14:21:59 UTC (rev 11092)
+++ libprelude/trunk/libmissing/m4/gnulib-cache.m4 2008-11-14 16:21:43 UTC (rev 11093)
@@ -15,14 +15,18 @@
# Specification in the form of a command-line invocation:
-# gnulib-tool --import --dir=. --lib=libmissing --source-base=libmissing --m4-base=libmissing/m4 --doc-base=libmissing/doc --tests-base=libmissing/tests --aux-dir=. --with-tests --lgpl --libtool --macro-prefix=gl --no-vc-files cond connect dup2 fopen ftw getaddrinfo getpass getsockname gettimeofday inet_ntop inet_pton lock lseek memmem minmax pathmax perror poll regex relocatable-lib-lgpl select setsockopt sigprocmask sleep snprintf socket socklen strcase strcasestr strdup strerror strndup strptime strsep sys_stat thread time_r timegm tls uname vsnprintf write
+# gnulib-tool --import --dir=. --lib=libmissing --source-base=libmissing --m4-base=libmissing/m4 --doc-base=libmissing/doc --tests-base=libmissing/tests --aux-dir=. --with-tests --lgpl --libtool --macro-prefix=gl --no-vc-files accept bind close cond connect dup2 fclose fopen ftw getaddrinfo getpass getsockname gettimeofday inet_ntop inet_pton ioctl listen lock lseek memmem minmax pathmax perror poll regex relocatable-lib-lgpl select setsockopt sigprocmask sleep snprintf socket socklen strcase strcasestr strdup strerror strndup strptime strsep sys_stat thread time_r timegm tls uname vsnprintf write
# Specification in the form of a few gnulib-tool.m4 macro invocations:
gl_LOCAL_DIR([])
gl_MODULES([
+ accept
+ bind
+ close
cond
connect
dup2
+ fclose
fopen
ftw
getaddrinfo
@@ -31,6 +35,8 @@
gettimeofday
inet_ntop
inet_pton
+ ioctl
+ listen
lock
lseek
memmem
Modified: libprelude/trunk/libmissing/m4/gnulib-comp.m4
===================================================================
--- libprelude/trunk/libmissing/m4/gnulib-comp.m4 2008-11-12 14:21:59 UTC (rev 11092)
+++ libprelude/trunk/libmissing/m4/gnulib-comp.m4 2008-11-14 16:21:43 UTC (rev 11093)
@@ -45,6 +45,11 @@
m4_pushdef([gl_LIBSOURCES_DIR], [])
gl_COMMON
gl_source_base='libmissing'
+ 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
@@ -52,6 +57,13 @@
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_COND
AC_REQUIRE([gl_HEADER_SYS_SOCKET])
if test "$ac_cv_header_winsock2_h" = yes; then
@@ -61,6 +73,8 @@
gl_FUNC_DUP2
gl_UNISTD_MODULE_INDICATOR([dup2])
gl_HEADER_ERRNO_H
+ gl_FUNC_FCLOSE
+ gl_STDIO_MODULE_INDICATOR([fclose])
gl_FLOAT_H
gl_FUNC_FOPEN
gl_STDIO_MODULE_INDICATOR([fopen])
@@ -86,6 +100,18 @@
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([ioctl])
+ gl_REPLACE_SYS_IOCTL_H
+ fi
+ gl_SYS_IOCTL_MODULE_INDICATOR([ioctl])
+ gl_MODULE_INDICATOR([ioctl])
+ 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_LOCALCHARSET
LOCALCHARSET_TESTS_ENVIRONMENT="CHARSETALIASDIR=\"\$(top_builddir)/$gl_source_base\""
AC_SUBST([LOCALCHARSET_TESTS_ENVIRONMENT])
@@ -160,6 +186,8 @@
gl_FUNC_STRPTIME
gl_FUNC_STRSEP
gl_STRING_MODULE_INDICATOR([strsep])
+ gl_SYS_IOCTL_H
+ AC_PROG_MKDIR_P
gl_HEADER_SYS_SELECT
AC_PROG_MKDIR_P
gl_HEADER_SYS_SOCKET
@@ -224,32 +252,6 @@
m4_pushdef([gltests_LIBSOURCES_DIR], [])
gl_COMMON
gl_source_base='libmissing/tests'
- 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])
- 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_FUNC_FCLOSE
- gl_STDIO_MODULE_INDICATOR([fclose])
- 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])
- 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])
AC_CHECK_DECLS_ONCE([alarm])
AC_CHECK_HEADERS_ONCE([unistd.h sys/wait.h])
AC_CHECK_HEADERS_ONCE([unistd.h sys/wait.h])
@@ -257,8 +259,6 @@
gt_TYPE_WCHAR_T
gt_TYPE_WINT_T
AC_CHECK_DECLS_ONCE([alarm])
- gl_SYS_IOCTL_H
- AC_PROG_MKDIR_P
AC_CHECK_FUNCS([shutdown])
gl_YIELD
m4_ifval(gltests_LIBSOURCES_LIST, [
@@ -355,16 +355,20 @@
build-aux/config.rpath
build-aux/link-warning.h
doc/relocatable.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/config.charset
lib/connect.c
lib/dup2.c
lib/errno.in.h
+ lib/fclose.c
lib/float+.h
lib/float.in.h
lib/fopen.c
@@ -392,6 +396,8 @@
lib/inet_ntop.c
lib/inet_pton.c
lib/intprops.h
+ lib/ioctl.c
+ lib/listen.c
lib/localcharset.c
lib/localcharset.h
lib/lseek.c
@@ -445,6 +451,7 @@
lib/strnlen.c
lib/strptime.c
lib/strsep.c
+ lib/sys_ioctl.in.h
lib/sys_select.in.h
lib/sys_socket.in.h
lib/sys_stat.in.h
@@ -606,16 +613,8 @@
tests/test-vsnprintf.c
tests/test-wchar.c
tests/test-wctype.c
- tests=lib/accept.c
- tests=lib/bind.c
- tests=lib/close.c
- tests=lib/fclose.c
tests=lib/glthread/yield.h
- tests=lib/ioctl.c
- tests=lib/listen.c
tests=lib/sockets.c
tests=lib/sockets.h
- tests=lib/sys_ioctl.in.h
tests=lib/verify.h
- tests=lib/w32sock.h
])
Copied: libprelude/trunk/libmissing/sys_ioctl.in.h (from rev 11092, libprelude/trunk/libmissing/tests/sys_ioctl.in.h)
===================================================================
--- libprelude/trunk/libmissing/sys_ioctl.in.h (rev 0)
+++ libprelude/trunk/libmissing/sys_ioctl.in.h 2008-11-14 16:21:43 UTC (rev 11093)
@@ -0,0 +1,70 @@
+/* Substitute for and wrapper around <sys/ioctl.h>.
+ 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, 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, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+#ifndef _GL_SYS_IOCTL_H
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+
+/* The include_next requires a split double-inclusion guard. */
+#if @HAVE_SYS_IOCTL_H@
+# @INCLUDE_NEXT@ @NEXT_SYS_IOCTL_H@
+#endif
+
+#ifndef _GL_SYS_IOCTL_H
+#define _GL_SYS_IOCTL_H
+
+/* AIX 5.1 and Solaris 10 declare ioctl() in <unistd.h> and in <stropts.h>,
+ but not in <sys/ioctl.h>. */
+#include <unistd.h>
+
+/* The definition of GL_LINK_WARNING is copied here. */
+
+
+/* Declare overridden functions. */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#if @GNULIB_IOCTL@
+# if @SYS_IOCTL_H_HAVE_WINSOCK2_H@
+# undef ioctl
+# define ioctl rpl_ioctl
+extern int ioctl (int fd, int request, ... /* {void *,char *} arg */);
+# endif
+#elif @SYS_IOCTL_H_HAVE_WINSOCK2_H@
+# undef ioctl
+# define ioctl ioctl_used_without_requesting_gnulib_module_ioctl
+#elif defined GNULIB_POSIXCHECK
+# undef ioctl
+# define ioctl(f,c,a) \
+ (GL_LINK_WARNING ("ioctl does not portably work on sockets - " \
+ "use gnulib module ioctl for portability"), \
+ ioctl (f, c, a))
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* _GL_SYS_IOCTL_H */
+#endif /* _GL_SYS_IOCTL_H */
Modified: libprelude/trunk/libmissing/tests/Makefile.am
===================================================================
--- libprelude/trunk/libmissing/tests/Makefile.am 2008-11-12 14:21:59 UTC (rev 11092)
+++ libprelude/trunk/libmissing/tests/Makefile.am 2008-11-14 16:21:43 UTC (rev 11093)
@@ -42,15 +42,6 @@
EXTRA_libtests_a_SOURCES =
AM_LIBTOOLFLAGS = --preserve-dup-deps
-## begin gnulib module accept
-
-
-EXTRA_DIST += accept.c w32sock.h
-
-EXTRA_libtests_a_SOURCES += accept.c
-
-## end gnulib module accept
-
## begin gnulib module alloca-opt-tests
TESTS += test-alloca-opt
@@ -69,15 +60,6 @@
## end gnulib module arpa_inet-tests
-## begin gnulib module bind
-
-
-EXTRA_DIST += bind.c w32sock.h
-
-EXTRA_libtests_a_SOURCES += bind.c
-
-## end gnulib module bind
-
## begin gnulib module c-ctype-tests
TESTS += test-c-ctype
@@ -87,15 +69,6 @@
## end gnulib module c-ctype-tests
-## begin gnulib module close
-
-
-EXTRA_DIST += close.c w32sock.h
-
-EXTRA_libtests_a_SOURCES += close.c
-
-## end gnulib module close
-
## begin gnulib module cond-tests
TESTS += test-cond
@@ -114,15 +87,6 @@
## end gnulib module errno-tests
-## begin gnulib module fclose
-
-
-EXTRA_DIST += fclose.c
-
-EXTRA_libtests_a_SOURCES += fclose.c
-
-## end gnulib module fclose
-
## begin gnulib module fopen-tests
TESTS += test-fopen
@@ -178,24 +142,6 @@
## end gnulib module gettimeofday-tests
-## begin gnulib module ioctl
-
-
-EXTRA_DIST += ioctl.c w32sock.h
-
-EXTRA_libtests_a_SOURCES += ioctl.c
-
-## end gnulib module ioctl
-
-## begin gnulib module listen
-
-
-EXTRA_DIST += listen.c w32sock.h
-
-EXTRA_libtests_a_SOURCES += listen.c
-
-## end gnulib module listen
-
## begin gnulib module lock-tests
TESTS += test-lock
@@ -377,33 +323,6 @@
## end gnulib module strings-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
Deleted: libprelude/trunk/libmissing/tests/accept.c
===================================================================
--- libprelude/trunk/libmissing/tests/accept.c 2008-11-12 14:21:59 UTC (rev 11092)
+++ libprelude/trunk/libmissing/tests/accept.c 2008-11-14 16:21:43 UTC (rev 11093)
@@ -1,42 +0,0 @@
-/* accept.c --- wrappers for Windows accept 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 accept
-
-int
-rpl_accept (int fd, struct sockaddr *addr, int *addrlen)
-{
- SOCKET fh = accept (FD_TO_SOCKET (fd), addr, addrlen);
- if (fh == INVALID_SOCKET)
- {
- set_winsock_errno ();
- return -1;
- }
- else
- return SOCKET_TO_FD (fh);
-}
Deleted: libprelude/trunk/libmissing/tests/bind.c
===================================================================
--- libprelude/trunk/libmissing/tests/bind.c 2008-11-12 14:21:59 UTC (rev 11092)
+++ libprelude/trunk/libmissing/tests/bind.c 2008-11-14 16:21:43 UTC (rev 11093)
@@ -1,40 +0,0 @@
-/* bind.c --- wrappers for Windows bind 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 bind
-
-int
-rpl_bind (int fd, struct sockaddr *sockaddr, int len)
-{
- SOCKET sock = FD_TO_SOCKET (fd);
- int r = bind (sock, sockaddr, len);
- if (r < 0)
- set_winsock_errno ();
-
- return r;
-}
Deleted: libprelude/trunk/libmissing/tests/close.c
===================================================================
--- libprelude/trunk/libmissing/tests/close.c 2008-11-12 14:21:59 UTC (rev 11092)
+++ libprelude/trunk/libmissing/tests/close.c 2008-11-14 16:21:43 UTC (rev 11093)
@@ -1,82 +0,0 @@
-/* close replacement.
- 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/>. */
-
-#include <config.h>
-
-/* Specification. */
-#include <unistd.h>
-
-#if GNULIB_SYS_SOCKET
-# define WIN32_LEAN_AND_MEAN
-# include <sys/socket.h>
-#endif
-
-#if HAVE__GL_CLOSE_FD_MAYBE_SOCKET
-
-/* Get set_winsock_errno, FD_TO_SOCKET etc. */
-#include "w32sock.h"
-
-static int
-_gl_close_fd_maybe_socket (int fd)
-{
- SOCKET sock = FD_TO_SOCKET (fd);
- WSANETWORKEVENTS ev;
-
- ev.lNetworkEvents = 0xDEADBEEF;
- WSAEnumNetworkEvents (sock, NULL, &ev);
- if (ev.lNetworkEvents != 0xDEADBEEF)
- {
- /* FIXME: other applications, like squid, use an undocumented
- _free_osfhnd free function. But this is not enough: The 'osfile'
- flags for fd also needs to be cleared, but it is hard to access it.
- Instead, here we just close twice the file descriptor. */
- if (closesocket (sock))
- {
- set_winsock_errno ();
- return -1;
- }
- else
- {
- /* This call frees the file descriptor and does a
- CloseHandle ((HANDLE) _get_osfhandle (fd)), which fails. */
- _close (fd);
- return 0;
- }
- }
- else
- return _close (fd);
-}
-#endif
-
-/* Override close() to call into other gnulib modules. */
-
-int
-rpl_close (int fd)
-#undef close
-{
-#if HAVE__GL_CLOSE_FD_MAYBE_SOCKET
- int retval = _gl_close_fd_maybe_socket (fd);
-#else
- int retval = close (fd);
-#endif
-
-#ifdef FCHDIR_REPLACEMENT
- if (retval >= 0)
- _gl_unregister_fd (fd);
-#endif
-
- return retval;
-}
Deleted: libprelude/trunk/libmissing/tests/fclose.c
===================================================================
--- libprelude/trunk/libmissing/tests/fclose.c 2008-11-12 14:21:59 UTC (rev 11092)
+++ libprelude/trunk/libmissing/tests/fclose.c 2008-11-14 16:21:43 UTC (rev 11093)
@@ -1,47 +0,0 @@
-/* fclose replacement.
- 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/>. */
-
-#include <config.h>
-
-/* Specification. */
-#include <stdio.h>
-
-#include <errno.h>
-#include <unistd.h>
-
-/* Override fclose() to call the overridden close(). */
-
-int
-rpl_fclose (FILE *fp)
-#undef fclose
-{
- int saved_errno = 0;
-
- if (fflush (fp))
- saved_errno = errno;
-
- if (close (fileno (fp)) < 0 && saved_errno == 0)
- saved_errno = errno;
-
- fclose (fp); /* will fail with errno = EBADF */
-
- if (saved_errno != 0)
- {
- errno = saved_errno;
- return EOF;
- }
- return 0;
-}
Deleted: libprelude/trunk/libmissing/tests/ioctl.c
===================================================================
--- libprelude/trunk/libmissing/tests/ioctl.c 2008-11-12 14:21:59 UTC (rev 11092)
+++ libprelude/trunk/libmissing/tests/ioctl.c 2008-11-14 16:21:43 UTC (rev 11093)
@@ -1,49 +0,0 @@
-/* ioctl.c --- wrappers for Windows ioctl 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>
-
-#include <stdarg.h>
-
-#define WIN32_LEAN_AND_MEAN
-/* Get winsock2.h. */
-#include <sys/socket.h>
-
-/* Get set_winsock_errno, FD_TO_SOCKET etc. */
-#include "w32sock.h"
-
-int
-rpl_ioctl (int fd, int req, ...)
-{
- void *buf;
- va_list args;
- SOCKET sock;
- int r;
-
- va_start (args, req);
- buf = va_arg (args, void *);
- va_end (args);
-
- sock = FD_TO_SOCKET (fd);
- r = ioctlsocket (sock, req, buf);
- if (r < 0)
- set_winsock_errno ();
-
- return r;
-}
Deleted: libprelude/trunk/libmissing/tests/listen.c
===================================================================
--- libprelude/trunk/libmissing/tests/listen.c 2008-11-12 14:21:59 UTC (rev 11092)
+++ libprelude/trunk/libmissing/tests/listen.c 2008-11-14 16:21:43 UTC (rev 11093)
@@ -1,40 +0,0 @@
-/* listen.c --- wrappers for Windows listen 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 listen
-
-int
-rpl_listen (int fd, int backlog)
-{
- SOCKET sock = FD_TO_SOCKET (fd);
- int r = listen (sock, backlog);
- if (r < 0)
- set_winsock_errno ();
-
- return r;
-}
Deleted: libprelude/trunk/libmissing/tests/sys_ioctl.in.h
===================================================================
--- libprelude/trunk/libmissing/tests/sys_ioctl.in.h 2008-11-12 14:21:59 UTC (rev 11092)
+++ libprelude/trunk/libmissing/tests/sys_ioctl.in.h 2008-11-14 16:21:43 UTC (rev 11093)
@@ -1,70 +0,0 @@
-/* Substitute for and wrapper around <sys/ioctl.h>.
- 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, 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, write to the Free Software Foundation,
- Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
-
-#ifndef _GL_SYS_IOCTL_H
-
-#if __GNUC__ >= 3
-@PRAGMA_SYSTEM_HEADER@
-#endif
-
-/* The include_next requires a split double-inclusion guard. */
-#if @HAVE_SYS_IOCTL_H@
-# @INCLUDE_NEXT@ @NEXT_SYS_IOCTL_H@
-#endif
-
-#ifndef _GL_SYS_IOCTL_H
-#define _GL_SYS_IOCTL_H
-
-/* AIX 5.1 and Solaris 10 declare ioctl() in <unistd.h> and in <stropts.h>,
- but not in <sys/ioctl.h>. */
-#include <unistd.h>
-
-/* The definition of GL_LINK_WARNING is copied here. */
-
-
-/* Declare overridden functions. */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#if @GNULIB_IOCTL@
-# if @SYS_IOCTL_H_HAVE_WINSOCK2_H@
-# undef ioctl
-# define ioctl rpl_ioctl
-extern int ioctl (int fd, int request, ... /* {void *,char *} arg */);
-# endif
-#elif @SYS_IOCTL_H_HAVE_WINSOCK2_H@
-# undef ioctl
-# define ioctl ioctl_used_without_requesting_gnulib_module_ioctl
-#elif defined GNULIB_POSIXCHECK
-# undef ioctl
-# define ioctl(f,c,a) \
- (GL_LINK_WARNING ("ioctl does not portably work on sockets - " \
- "use gnulib module ioctl for portability"), \
- ioctl (f, c, a))
-#endif
-
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif /* _GL_SYS_IOCTL_H */
-#endif /* _GL_SYS_IOCTL_H */
Deleted: libprelude/trunk/libmissing/tests/w32sock.h
===================================================================
--- libprelude/trunk/libmissing/tests/w32sock.h 2008-11-12 14:21:59 UTC (rev 11092)
+++ libprelude/trunk/libmissing/tests/w32sock.h 2008-11-14 16:21:43 UTC (rev 11093)
@@ -1,62 +0,0 @@
-/* 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;
- }
-}
_______________________________________________
Prelude-cvslog site list
[email protected]
http://lists.prelude-ids.org/mailman/listinfo/prelude-cvslog
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.