]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Update.
authorSimon Josefsson <simon@josefsson.org>
Mon, 12 Mar 2007 13:25:25 +0000 (13:25 +0000)
committerSimon Josefsson <simon@josefsson.org>
Mon, 12 Mar 2007 13:25:25 +0000 (13:25 +0000)
25 files changed:
gl/gnulib.mk
gl/m4/gnulib-comp.m4
gl/m4/netinet_in_h.m4
gl/m4/sys_socket_h.m4
gl/netinet_in_.h [new file with mode: 0644]
gl/socket_.h
lgl/Makefile.am
lgl/des.c
lgl/des.h
lgl/dummy.c
lgl/gc-gnulib.c
lgl/m4/gnulib-comp.m4
lgl/m4/snprintf.m4
lgl/m4/stdbool.m4 [new file with mode: 0644]
lgl/m4/stdio_h.m4
lgl/m4/sys_socket_h.m4
lgl/m4/vasnprintf.m4
lgl/snprintf.c
lgl/socket_.h
lgl/stdbool_.h [new file with mode: 0644]
lgl/stdint_.h
lgl/stdio_.h
lgl/vasnprintf.c
lgl/vasnprintf.h
lgl/vasprintf.h

index 3f99da8ba4cbc5a3a450f8ea3262815931a5d4bb..852ee192c9970e1f018cb2d7f0c7f9053d659cdc 100644 (file)
@@ -125,12 +125,16 @@ netinet/in.h:
        @MKDIR_P@ netinet
        rm -f $@-t $@
        { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
-         echo '#include <sys/socket.h>'; \
+         sed -e 's|@''ABSOLUTE_NETINET_IN_H''@|$(ABSOLUTE_NETINET_IN_H)|g' \
+             -e 's|@''HAVE_NETINET_IN_H''@|$(HAVE_NETINET_IN_H)|g' \
+             < $(srcdir)/netinet_in_.h; \
        } > $@-t
        mv $@-t $@
 MOSTLYCLEANFILES += netinet/in.h netinet/in.h-t
 MOSTLYCLEANDIRS += netinet
 
+EXTRA_DIST += netinet_in_.h
+
 ## end   gnulib module netinet_in
 
 ## begin gnulib module progname
@@ -246,7 +250,11 @@ BUILT_SOURCES += $(SYS_SOCKET_H)
 sys/socket.h: socket_.h
        @MKDIR_P@ sys
        { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
-         cat $(srcdir)/socket_.h; \
+         sed -e 's|@''ABSOLUTE_SYS_SOCKET_H''@|$(ABSOLUTE_SYS_SOCKET_H)|g' \
+             -e 's|@''HAVE_SYS_SOCKET_H''@|$(HAVE_SYS_SOCKET_H)|g' \
+             -e 's|@''HAVE_WINSOCK2_H''@|$(HAVE_WINSOCK2_H)|g' \
+             -e 's|@''HAVE_WS2TCPIP_H''@|$(HAVE_WS2TCPIP_H)|g' \
+             < $(srcdir)/socket_.h; \
        } > $@-t
        mv -f $@-t $@
 MOSTLYCLEANFILES += sys/socket.h sys/socket.h-t
index 2cb226967b6971a2ed830a9808d23400b138a4ef..a28591f35307b4f60bc6c32151067bdee1e5314c 100644 (file)
@@ -126,6 +126,7 @@ AC_DEFUN([gl_FILE_LIST], [
   lib/inet_ntop.h
   lib/inet_pton.c
   lib/inet_pton.h
+  lib/netinet_in_.h
   lib/progname.c
   lib/progname.h
   lib/readline.c
index d73531a051eb2b0d2474797c3472f86f89bb0cdd..966bfe6a11c6ea7bc354846f86c12ea03d3b4f22 100644 (file)
@@ -1,18 +1,32 @@
-# netinet_in_h.m4 serial 1
-dnl Copyright (C) 2006 Free Software Foundation, Inc.
+# netinet_in_h.m4 serial 2
+dnl Copyright (C) 2006-2007 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.
 
-dnl Written by Simon Josefsson
-
 AC_DEFUN([gl_HEADER_NETINET_IN],
 [
-  AC_CHECK_HEADERS_ONCE([netinet/in.h])
-  if test $ac_cv_header_netinet_in_h = yes; then
+  AC_CACHE_CHECK([whether <netinet/in.h> is self-contained],
+    [gl_cv_header_netinet_in_h_selfcontained],
+    [
+      AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <netinet/in.h>], [])],
+        [gl_cv_header_netinet_in_h_selfcontained=yes],
+        [gl_cv_header_netinet_in_h_selfcontained=no])
+    ])
+  if test $gl_cv_header_netinet_in_h_selfcontained = yes; then
     NETINET_IN_H=''
   else
     NETINET_IN_H='netinet/in.h'
+    AC_CHECK_HEADERS([netinet/in.h])
+    gl_ABSOLUTE_HEADER([netinet/in.h])
+    ABSOLUTE_NETINET_IN_H=\"$gl_cv_absolute_netinet_in_h\"
+    AC_SUBST([ABSOLUTE_NETINET_IN_H])
+    if test $ac_cv_header_netinet_in_h = yes; then
+      HAVE_NETINET_IN_H=1
+    else
+      HAVE_NETINET_IN_H=0
+    fi
+    AC_SUBST([HAVE_NETINET_IN_H])
   fi
-  AC_SUBST(NETINET_IN_H)
+  AC_SUBST([NETINET_IN_H])
 ])
index d3e45b48c1500018186bd193e765d2f07dae625a..ce5acf6e24f128e876837d6e8298d3ad136fc405 100644 (file)
@@ -1,5 +1,5 @@
-# sys_socket_h.m4 serial 2
-dnl Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+# sys_socket_h.m4 serial 3
+dnl Copyright (C) 2005, 2006, 2007 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.
@@ -8,16 +8,47 @@ dnl From Simon Josefsson.
 
 AC_DEFUN([gl_HEADER_SYS_SOCKET],
 [
-  AC_CHECK_HEADERS_ONCE([sys/socket.h])
-  if test $ac_cv_header_sys_socket_h = yes; then
+  AC_CACHE_CHECK([whether <sys/socket.h> is self-contained],
+    [gl_cv_header_sys_socket_h_selfcontained],
+    [
+      AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/socket.h>], [])],
+        [gl_cv_header_sys_socket_h_selfcontained=yes],
+        [gl_cv_header_sys_socket_h_selfcontained=no])
+    ])
+  if test $gl_cv_header_sys_socket_h_selfcontained = yes; then
     SYS_SOCKET_H=''
   else
-    dnl We cannot use AC_CHECK_HEADERS_ONCE here, because that would make
-    dnl the check for those headers unconditional; yet cygwin reports
-    dnl that the headers are present but cannot be compiled (since on
-    dnl cygwin, all socket information should come from sys/socket.h).
-    AC_CHECK_HEADERS([winsock2.h ws2tcpip.h])
     SYS_SOCKET_H='sys/socket.h'
+
+    AC_CHECK_HEADERS([sys/socket.h])
+    gl_ABSOLUTE_HEADER([sys/socket.h])
+    ABSOLUTE_SYS_SOCKET_H=\"$gl_cv_absolute_sys_socket_h\"
+    AC_SUBST([ABSOLUTE_SYS_SOCKET_H])
+    if test $ac_cv_header_sys_socket_h = yes; then
+      HAVE_SYS_SOCKET_H=1
+      HAVE_WINSOCK2_H=0
+      HAVE_WS2TCPIP_H=0
+    else
+      HAVE_SYS_SOCKET_H=0
+      dnl We cannot use AC_CHECK_HEADERS_ONCE here, because that would make
+      dnl the check for those headers unconditional; yet cygwin reports
+      dnl that the headers are present but cannot be compiled (since on
+      dnl cygwin, all socket information should come from sys/socket.h).
+      AC_CHECK_HEADERS([winsock2.h ws2tcpip.h])
+      if test $ac_cv_header_winsock2_h = yes; then
+        HAVE_WINSOCK2_H=1
+      else
+        HAVE_WINSOCK2_H=0
+      fi
+      if test $ac_cv_header_ws2tcpip_h = yes; then
+        HAVE_WS2TCPIP_H=1
+      else
+        HAVE_WS2TCPIP_H=0
+      fi
+    fi
+    AC_SUBST([HAVE_SYS_SOCKET_H])
+    AC_SUBST([HAVE_WINSOCK2_H])
+    AC_SUBST([HAVE_WS2TCPIP_H])
   fi
-  AC_SUBST(SYS_SOCKET_H)
+  AC_SUBST([SYS_SOCKET_H])
 ])
diff --git a/gl/netinet_in_.h b/gl/netinet_in_.h
new file mode 100644 (file)
index 0000000..4a53605
--- /dev/null
@@ -0,0 +1,37 @@
+/* Substitute for <netinet/in.h>.
+   Copyright (C) 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 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 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_NETINET_IN_H
+#define _GL_NETINET_IN_H
+
+#if @HAVE_NETINET_IN_H@
+
+/* On many platforms, <netinet/in.h> assumes prior inclusion of
+   <sys/types.h>.  */
+
+# include <sys/types.h>
+# include @ABSOLUTE_NETINET_IN_H@
+
+#else
+
+/* A platform that lacks <netinet/in.h>.  */
+
+# include <sys/socket.h>
+
+#endif
+
+#endif /* _GL_NETINET_IN_H */
index 8b28b5ed39c753dcb783c7f0cc95b93858efa1e6..623c98c2f17b510c6c0e0169072d80f0db06f84b 100644 (file)
@@ -1,5 +1,5 @@
 /* Provide a sys/socket header file for systems lacking it (read: MinGW).
-   Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+   Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
    Written by Simon Josefsson.
 
    This program is free software; you can redistribute it and/or modify
    along with this program; if not, write to the Free Software Foundation,
    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
 
-#ifndef _SYS_SOCKET_H
-#define _SYS_SOCKET_H
+#ifndef _GL_SYS_SOCKET_H
+#define _GL_SYS_SOCKET_H
 
-/* This file is supposed to be used on platforms that lack
-   sys/socket.h.  It is intended to provide definitions and prototypes
-   needed by an application.
+/* This file is supposed to be used on platforms that lack <sys/socket.h>
+   and on platforms where <sys/socket.h> cannot be included standalone.
+   It is intended to provide definitions and prototypes needed by an
+   application.  */
+
+#if @HAVE_SYS_SOCKET_H@
+
+/* On many platforms, <sys/socket.h> assumes prior inclusion of
+   <sys/types.h>.  */
+
+# include <sys/types.h>
+# include @ABSOLUTE_SYS_SOCKET_H@
+
+#else
+
+/* A platform that lacks <sys/socket.h>.
 
    Currently only MinGW is supported.  See the gnulib manual regarding
    Windows sockets.  MinGW has the header files winsock2.h and
    releases. */
 
 
-#if HAVE_WINSOCK2_H
-# include <winsock2.h>
-#endif
-#if HAVE_WS2TCPIP_H
-# include <ws2tcpip.h>
-#endif
+# if @HAVE_WINSOCK2_H@
+#  include <winsock2.h>
+# endif
+# if @HAVE_WS2TCPIP_H@
+#  include <ws2tcpip.h>
+# endif
 
 /* For shutdown(). */
-#if !defined SHUT_RD && defined SD_RECEIVE
-# define SHUT_RD SD_RECEIVE
-#endif
-#if !defined SHUT_WR && defined SD_SEND
-# define SHUT_WR SD_SEND
-#endif
-#if !defined SHUT_RDWR && defined SD_BOTH
-# define SHUT_RDWR SD_BOTH
-#endif
-
-#if defined _WIN32 || defined __WIN32__
-# define ENOTSOCK                WSAENOTSOCK
-# define EADDRINUSE              WSAEADDRINUSE
-# define ENETRESET               WSAENETRESET
-# define ECONNABORTED            WSAECONNABORTED
-# define ECONNRESET              WSAECONNRESET
-# define ENOTCONN                WSAENOTCONN
-# define ESHUTDOWN               WSAESHUTDOWN
-#endif
-
-#endif /* _SYS_SOCKET_H */
+# if !defined SHUT_RD && defined SD_RECEIVE
+#  define SHUT_RD SD_RECEIVE
+# endif
+# if !defined SHUT_WR && defined SD_SEND
+#  define SHUT_WR SD_SEND
+# endif
+# if !defined SHUT_RDWR && defined SD_BOTH
+#  define SHUT_RDWR SD_BOTH
+# endif
+
+# if defined _WIN32 || defined __WIN32__
+#  define ENOTSOCK                WSAENOTSOCK
+#  define EADDRINUSE              WSAEADDRINUSE
+#  define ENETRESET               WSAENETRESET
+#  define ECONNABORTED            WSAECONNABORTED
+#  define ECONNRESET              WSAECONNRESET
+#  define ENOTCONN                WSAENOTCONN
+#  define ESHUTDOWN               WSAESHUTDOWN
+# endif
+
+#endif /* HAVE_SYS_SOCKET_H */
+
+#endif /* _GL_SYS_SOCKET_H */
index fc1211bab9a3283c5248e49b189d75ac55fc09d0..a8d74a038a9c39f45008703fe98c53c782365b87 100644 (file)
@@ -238,6 +238,24 @@ EXTRA_liblgnu_la_SOURCES += snprintf.c
 
 ## end   gnulib module snprintf
 
+## begin gnulib module stdbool
+
+BUILT_SOURCES += $(STDBOOL_H)
+
+# We need the following in order to create <stdbool.h> when the system
+# doesn't have one that works.
+stdbool.h: stdbool_.h
+       rm -f $@-t $@
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+         sed -e 's/@''HAVE__BOOL''@/$(HAVE__BOOL)/g' < $(srcdir)/stdbool_.h; \
+       } > $@-t
+       mv $@-t $@
+MOSTLYCLEANFILES += stdbool.h stdbool.h-t
+
+EXTRA_DIST += stdbool_.h
+
+## end   gnulib module stdbool
+
 ## begin gnulib module stdint
 
 BUILT_SOURCES += $(STDINT_H)
@@ -287,10 +305,24 @@ stdio.h: stdio_.h
        rm -f $@-t $@
        { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
          sed -e 's|@''ABSOLUTE_STDIO_H''@|$(ABSOLUTE_STDIO_H)|g' \
+             -e 's|@''GNULIB_FPRINTF_POSIX''@|$(GNULIB_FPRINTF_POSIX)|g' \
+             -e 's|@''GNULIB_PRINTF_POSIX''@|$(GNULIB_PRINTF_POSIX)|g' \
              -e 's|@''GNULIB_SNPRINTF''@|$(GNULIB_SNPRINTF)|g' \
+             -e 's|@''GNULIB_SPRINTF_POSIX''@|$(GNULIB_SPRINTF_POSIX)|g' \
+             -e 's|@''GNULIB_VFPRINTF_POSIX''@|$(GNULIB_VFPRINTF_POSIX)|g' \
+             -e 's|@''GNULIB_VPRINTF_POSIX''@|$(GNULIB_VPRINTF_POSIX)|g' \
              -e 's|@''GNULIB_VSNPRINTF''@|$(GNULIB_VSNPRINTF)|g' \
+             -e 's|@''GNULIB_VSPRINTF_POSIX''@|$(GNULIB_VSPRINTF_POSIX)|g' \
+             -e 's|@''REPLACE_FPRINTF''@|$(REPLACE_FPRINTF)|g' \
+             -e 's|@''REPLACE_VFPRINTF''@|$(REPLACE_VFPRINTF)|g' \
+             -e 's|@''REPLACE_PRINTF''@|$(REPLACE_PRINTF)|g' \
+             -e 's|@''REPLACE_VPRINTF''@|$(REPLACE_VPRINTF)|g' \
+             -e 's|@''REPLACE_SNPRINTF''@|$(REPLACE_SNPRINTF)|g' \
              -e 's|@''HAVE_DECL_SNPRINTF''@|$(HAVE_DECL_SNPRINTF)|g' \
+             -e 's|@''REPLACE_VSNPRINTF''@|$(REPLACE_VSNPRINTF)|g' \
              -e 's|@''HAVE_DECL_VSNPRINTF''@|$(HAVE_DECL_VSNPRINTF)|g' \
+             -e 's|@''REPLACE_SPRINTF''@|$(REPLACE_SPRINTF)|g' \
+             -e 's|@''REPLACE_VSPRINTF''@|$(REPLACE_VSPRINTF)|g' \
              -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
              < $(srcdir)/stdio_.h; \
        } > $@-t
@@ -381,7 +413,11 @@ BUILT_SOURCES += $(SYS_SOCKET_H)
 sys/socket.h: socket_.h
        @MKDIR_P@ sys
        { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
-         cat $(srcdir)/socket_.h; \
+         sed -e 's|@''ABSOLUTE_SYS_SOCKET_H''@|$(ABSOLUTE_SYS_SOCKET_H)|g' \
+             -e 's|@''HAVE_SYS_SOCKET_H''@|$(HAVE_SYS_SOCKET_H)|g' \
+             -e 's|@''HAVE_WINSOCK2_H''@|$(HAVE_WINSOCK2_H)|g' \
+             -e 's|@''HAVE_WS2TCPIP_H''@|$(HAVE_WS2TCPIP_H)|g' \
+             < $(srcdir)/socket_.h; \
        } > $@-t
        mv -f $@-t $@
 MOSTLYCLEANFILES += sys/socket.h sys/socket.h-t
index 8f36231a542f6af94c025911b2a144f373d1b6c0..b09261c38af67101c516540aaca711f852b0c8a6 100644 (file)
--- a/lgl/des.c
+++ b/lgl/des.c
@@ -1,5 +1,5 @@
 /* des.c --- DES and Triple-DES encryption/decryption Algorithm
- * Copyright (C) 1998, 1999, 2001, 2002, 2003, 2004, 2005, 2006
+ * Copyright (C) 1998, 1999, 2001, 2002, 2003, 2004, 2005, 2006, 2007
  *    Free Software Foundation, Inc.
  *
  * This file is free software; you can redistribute it and/or modify
@@ -54,7 +54,7 @@
  *     unsigned char plaintext[8];
  *     unsigned char ciphertext[8];
  *     unsigned char recoverd[8];
- *     des_ctx context;
+ *     gl_des_ctx context;
  *
  *     // Fill 'key' and 'plaintext' with some data
  *     ....
  *     unsigned char plaintext[8];
  *     unsigned char ciphertext[8];
  *     unsigned char recoverd[8];
- *     tripledes_ctx context;
+ *     gl_3des_ctx context;
  *
  *     // If you would like to use two 64bit keys, fill 'key1' and'key2'
  *     // then setup the encryption context:
- *     tripledes_set2keys(&context, key1, key2);
+ *     gl_3des_set2keys(&context, key1, key2);
  *
  *     // To use three 64bit keys with Triple-DES use:
- *     tripledes_set3keys(&context, key1, key2, key3);
+ *     gl_3des_set3keys(&context, key1, key2, key3);
  *
  *     // Encrypting plaintext with Triple-DES
- *     tripledes_ecb_encrypt(&context, plaintext, ciphertext);
+ *     gl_3des_ecb_encrypt(&context, plaintext, ciphertext);
  *
  *     // Decrypting ciphertext to recover the plaintext with Triple-DES
- *     tripledes_ecb_decrypt(&context, ciphertext, recoverd);
+ *     gl_3des_ecb_decrypt(&context, ciphertext, recoverd);
  */
 
 
@@ -324,7 +324,7 @@ static const unsigned char weak_keys_chksum[20] = {
 };
 
 bool
-des_is_weak_key (const char * key)
+gl_des_is_weak_key (const char * key)
 {
   char work[8];
   int i, left, right, middle, cmp_result;
@@ -423,14 +423,6 @@ des_is_weak_key (const char * key)
     data[4] = (right >> 24) &0xff; data[5] = (right >> 16) &0xff;         \
     data[6] = (right >> 8) &0xff; data[7] = right &0xff;
 
-/*
- * Handy macros for encryption and decryption of data
- */
-#define des_ecb_encrypt(ctx, from, to)       des_ecb_crypt(ctx, from, to, 0)
-#define des_ecb_decrypt(ctx, from, to)       des_ecb_crypt(ctx, from, to, 1)
-#define tripledes_ecb_encrypt(ctx, from, to) tripledes_ecb_crypt(ctx,from,to,0)
-#define tripledes_ecb_decrypt(ctx, from, to) tripledes_ecb_crypt(ctx,from,to,1)
-
 /*
  * des_key_schedule():   Calculate 16 subkeys pairs (even/odd) for
  *                       16 encryption rounds.
@@ -530,7 +522,7 @@ des_key_schedule (const char * _rawkey, uint32_t * subkey)
 }
 
 void
-des_setkey (des_ctx *ctx, const char * key)
+gl_des_setkey (gl_des_ctx *ctx, const char * key)
 {
   int i;
 
@@ -544,7 +536,7 @@ des_setkey (des_ctx *ctx, const char * key)
 }
 
 bool
-des_makekey (des_ctx *ctx, const char * key, size_t keylen)
+gl_des_makekey (gl_des_ctx *ctx, const char * key, size_t keylen)
 {
   if (keylen != 8)
     return false;
@@ -555,7 +547,7 @@ des_makekey (des_ctx *ctx, const char * key, size_t keylen)
 }
 
 void
-des_ecb_crypt (des_ctx *ctx, const char * _from, char * _to, int mode)
+gl_des_ecb_crypt (gl_des_ctx *ctx, const char * _from, char * _to, int mode)
 {
   const unsigned char *from = (const unsigned char *) _from;
   unsigned char *to = (unsigned char *) _to;
@@ -579,7 +571,7 @@ des_ecb_crypt (des_ctx *ctx, const char * _from, char * _to, int mode)
 }
 
 void
-tripledes_set2keys (tripledes_ctx *ctx, const char * key1, const char * key2)
+gl_3des_set2keys (gl_3des_ctx *ctx, const char * key1, const char * key2)
 {
   int i;
 
@@ -603,7 +595,7 @@ tripledes_set2keys (tripledes_ctx *ctx, const char * key1, const char * key2)
 }
 
 void
-tripledes_set3keys (tripledes_ctx *ctx, const char * key1,
+gl_3des_set3keys (gl_3des_ctx *ctx, const char * key1,
                    const char * key2, const char * key3)
 {
   int i;
@@ -626,9 +618,9 @@ tripledes_set3keys (tripledes_ctx *ctx, const char * key1,
 }
 
 void
-tripledes_ecb_crypt (tripledes_ctx *ctx,
-                    const char * _from,
-                    char * _to, int mode)
+gl_3des_ecb_crypt (gl_3des_ctx *ctx,
+                  const char * _from,
+                  char * _to, int mode)
 {
   const unsigned char *from = (const unsigned char *) _from;
   unsigned char *to = (unsigned char *) _to;
@@ -668,12 +660,12 @@ tripledes_ecb_crypt (tripledes_ctx *ctx,
 }
 
 bool
-tripledes_makekey (tripledes_ctx *ctx, const char * key, size_t keylen)
+gl_3des_makekey (gl_3des_ctx *ctx, const char * key, size_t keylen)
 {
   if (keylen != 24)
     return false;
 
-  tripledes_set3keys (ctx, key, key + 8, key + 16);
+  gl_3des_set3keys (ctx, key, key + 8, key + 16);
 
   return !(des_is_weak_key (key)
           || des_is_weak_key (key + 8)
index 2b5f71237a8db90815b314c948f8d095631d87d1..fdc8686f9a43a10688fd90f8babbf39cddd6c714 100644 (file)
--- a/lgl/des.h
+++ b/lgl/des.h
@@ -1,5 +1,5 @@
 /* des.h --- DES cipher implementation.
- * Copyright (C) 2005 Free Software Foundation, Inc.
+ * Copyright (C) 2005, 2007 Free Software Foundation, Inc.
  *
  * This file is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published
@@ -34,7 +34,7 @@ typedef struct
 {
   uint32_t encrypt_subkeys[32];
   uint32_t decrypt_subkeys[32];
-} des_ctx;
+} gl_des_ctx;
 
 /*
  * Encryption/Decryption context of Triple-DES
@@ -43,12 +43,12 @@ typedef struct
 {
   uint32_t encrypt_subkeys[96];
   uint32_t decrypt_subkeys[96];
-} tripledes_ctx;
+} gl_3des_ctx;
 
 /* Check whether the 8 byte key is weak.  Does not check the parity
  * bits of the key but simple ignore them. */
 extern bool
-des_is_weak_key (const char * key);
+gl_des_is_weak_key (const char * key);
 
 /*
  * DES
@@ -59,21 +59,21 @@ des_is_weak_key (const char * key);
  * Does not check parity bits, but simply ignore them.  Does not check
  * for weak keys. */
 extern void
-des_setkey (des_ctx *ctx, const char * key);
+gl_des_setkey (gl_des_ctx *ctx, const char * key);
 
 /* Fill a DES context CTX with subkeys calculated from 64bit KEY, with
  * weak key checking.  Does not check parity bits, but simply ignore
  * them. */
 extern bool
-des_makekey (des_ctx *ctx, const char * key, size_t keylen);
+gl_des_makekey (gl_des_ctx *ctx, const char * key, size_t keylen);
 
 /* Electronic Codebook Mode DES encryption/decryption of data
  * according to 'mode'. */
 extern void
-des_ecb_crypt (des_ctx *ctx, const char * from,  char * to, int mode);
+gl_des_ecb_crypt (gl_des_ctx *ctx, const char * from,  char * to, int mode);
 
-#define des_ecb_encrypt(ctx, from, to)       des_ecb_crypt(ctx, from, to, 0)
-#define des_ecb_decrypt(ctx, from, to)       des_ecb_crypt(ctx, from, to, 1)
+#define gl_des_ecb_encrypt(ctx, from, to)  gl_des_ecb_crypt(ctx, from, to, 0)
+#define gl_des_ecb_decrypt(ctx, from, to)  gl_des_ecb_crypt(ctx, from, to, 1)
 
 /* Triple-DES
  * ----------
@@ -83,7 +83,9 @@ des_ecb_crypt (des_ctx *ctx, const char * from,  char * to, int mode);
  * 64bit keys in KEY1 and KEY2.  Does not check the parity bits of the
  * keys, but simply ignore them.  Does not check for weak keys. */
 extern void
-tripledes_set2keys (tripledes_ctx *ctx, const char * key1, const char * key2);
+gl_3des_set2keys (gl_3des_ctx *ctx,
+                 const char * key1,
+                 const char * key2);
 
 /*
  * Fill a Triple-DES context CTX with subkeys calculated from three
@@ -91,24 +93,29 @@ tripledes_set2keys (tripledes_ctx *ctx, const char * key1, const char * key2);
  * of the keys, but simply ignore them.  Does not check for weak
  * keys. */
 extern void
-tripledes_set3keys (tripledes_ctx *ctx, const char * key1,
-                   const char * key2, const char * key3);
+gl_3des_set3keys (gl_3des_ctx *ctx,
+                 const char * key1,
+                 const char * key2,
+                 const char * key3);
 
 /* Fill a Triple-DES context CTX with subkeys calculated from three
  * concatenated 64bit keys in KEY, with weak key checking.  Does not
  * check the parity bits of the keys, but simply ignore them. */
 extern bool
-tripledes_makekey (tripledes_ctx *ctx, const char * key, size_t keylen);
+gl_3des_makekey (gl_3des_ctx *ctx,
+                const char * key,
+                size_t keylen);
 
 /* Electronic Codebook Mode Triple-DES encryption/decryption of data
  * according to 'mode'.  Sometimes this mode is named 'EDE' mode
  * (Encryption-Decryption-Encryption). */
 extern void
-tripledes_ecb_crypt (tripledes_ctx *ctx,
-                    const char * from,
-                    char * to, int mode);
+gl_3des_ecb_crypt (gl_3des_ctx *ctx,
+                  const char * from,
+                  char * to,
+                  int mode);
 
-#define tripledes_ecb_encrypt(ctx, from, to) tripledes_ecb_crypt(ctx,from,to,0)
-#define tripledes_ecb_decrypt(ctx, from, to) tripledes_ecb_crypt(ctx,from,to,1)
+#define gl_3des_ecb_encrypt(ctx, from, to) gl_3des_ecb_crypt(ctx,from,to,0)
+#define gl_3des_ecb_decrypt(ctx, from, to) gl_3des_ecb_crypt(ctx,from,to,1)
 
 #endif /* DES_H */
index df147e47787df91a107dc6ea2e5dde10bb974608..53bd5319d16afe2e55e2b6d41a21a0df887a5c55 100644 (file)
@@ -1,5 +1,5 @@
 /* A dummy file, to prevent empty libraries from breaking builds.
-   Copyright (C) 2004 Free Software Foundation, Inc.
+   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 Lesser General Public License as published by
    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 dummy;
+#else
 /* This declaration is solely to ensure that after preprocessing
    this file is never empty.  */
 typedef int dummy;
+#endif
index 7d4dd11ec604eab003e22f96e6e5d631e1408c72..c3cf0c529e59ae4b2f3d65f70e409230e8bde443 100644 (file)
@@ -187,7 +187,7 @@ typedef struct _gc_cipher_ctx {
   arcfour_context arcfourContext;
 #endif
 #ifdef GNULIB_GC_DES
-  des_ctx desContext;
+  gl_des_ctx desContext;
 #endif
 #ifdef GNULIB_GC_RIJNDAEL
   rijndaelKeyInstance aesEncKey;
@@ -305,7 +305,7 @@ gc_cipher_setkey (gc_cipher_handle handle, size_t keylen, const char *key)
     case GC_DES:
       if (keylen != 8)
        return GC_INVALID_CIPHER;
-      des_setkey (&ctx->desContext, key);
+      gl_des_setkey (&ctx->desContext, key);
       break;
 #endif
 
@@ -443,7 +443,7 @@ gc_cipher_encrypt_inline (gc_cipher_handle handle, size_t len, char *data)
 #ifdef GNULIB_GC_DES
     case GC_DES:
       for (; len >= 8; len -= 8, data += 8)
-       des_ecb_encrypt (&ctx->desContext, data, data);
+       gl_des_ecb_encrypt (&ctx->desContext, data, data);
       break;
 #endif
 
@@ -515,7 +515,7 @@ gc_cipher_decrypt_inline (gc_cipher_handle handle, size_t len, char *data)
 #ifdef GNULIB_GC_DES
     case GC_DES:
       for (; len >= 8; len -= 8, data += 8)
-       des_ecb_decrypt (&ctx->desContext, data, data);
+       gl_des_ecb_decrypt (&ctx->desContext, data, data);
       break;
 #endif
 
index 5442a06ee5034b672e7866ad5646ffc4c6f7677d..a0d51cafa7ecf8cd36695b3117d97d88cd6f2f4f 100644 (file)
@@ -80,6 +80,7 @@ AC_DEFUN([lgl_INIT],
   gl_FUNC_SNPRINTF
   gl_STDIO_MODULE_INDICATOR([snprintf])
   gl_TYPE_SOCKLEN_T
+  AM_STDBOOL_H
   gl_STDINT_H
   gl_STDIO_H
   gl_HEADER_STRING_H
@@ -179,6 +180,7 @@ AC_DEFUN([lgl_FILE_LIST], [
   lib/snprintf.c
   lib/socket_.h
   lib/stat_.h
+  lib/stdbool_.h
   lib/stdint_.h
   lib/stdio_.h
   lib/string_.h
@@ -253,6 +255,7 @@ AC_DEFUN([lgl_FILE_LIST], [
   m4/snprintf.m4
   m4/socklen.m4
   m4/sockpfaf.m4
+  m4/stdbool.m4
   m4/stdint.m4
   m4/stdint_h.m4
   m4/stdio_h.m4
index b6f9f672d282273b93f9280c747386e4a044f574..f21200dceae21545280f5edb354a10694c99f181 100644 (file)
@@ -1,4 +1,4 @@
-# snprintf.m4 serial 3
+# snprintf.m4 serial 4
 dnl Copyright (C) 2002, 2003, 2004, 2007 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -7,11 +7,23 @@ dnl with or without modifications, as long as this notice is preserved.
 AC_DEFUN([gl_FUNC_SNPRINTF],
 [
   AC_REQUIRE([gl_STDIO_H_DEFAULTS])
-  AC_REPLACE_FUNCS(snprintf)
-  AC_CHECK_DECLS_ONCE(snprintf)
+  AC_CHECK_FUNCS([snprintf])
+  if test $ac_cv_func_snprintf = no; then
+    gl_REPLACE_SNPRINTF
+  fi
+  AC_CHECK_DECLS_ONCE([snprintf])
   if test $ac_cv_have_decl_snprintf = no; then
     HAVE_DECL_SNPRINTF=0
   fi
+])
+
+AC_DEFUN([gl_REPLACE_SNPRINTF],
+[
+  AC_REQUIRE([gl_STDIO_H_DEFAULTS])
+  AC_LIBOBJ([snprintf])
+  if test $ac_cv_func_snprintf = yes; then
+    REPLACE_SNPRINTF=1
+  fi
   gl_PREREQ_SNPRINTF
 ])
 
diff --git a/lgl/m4/stdbool.m4 b/lgl/m4/stdbool.m4
new file mode 100644 (file)
index 0000000..2204ecd
--- /dev/null
@@ -0,0 +1,115 @@
+# Check for stdbool.h that conforms to C99.
+
+dnl Copyright (C) 2002-2006 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.
+
+# Prepare for substituting <stdbool.h> if it is not supported.
+
+AC_DEFUN([AM_STDBOOL_H],
+[
+  AC_REQUIRE([AC_HEADER_STDBOOL])
+
+  # Define two additional variables used in the Makefile substitution.
+
+  if test "$ac_cv_header_stdbool_h" = yes; then
+    STDBOOL_H=''
+  else
+    STDBOOL_H='stdbool.h'
+  fi
+  AC_SUBST([STDBOOL_H])
+
+  if test "$ac_cv_type__Bool" = yes; then
+    HAVE__BOOL=1
+  else
+    HAVE__BOOL=0
+  fi
+  AC_SUBST([HAVE__BOOL])
+])
+
+# AM_STDBOOL_H will be renamed to gl_STDBOOL_H in the future.
+AC_DEFUN([gl_STDBOOL_H], [AM_STDBOOL_H])
+
+# This macro is only needed in autoconf <= 2.59.  Newer versions of autoconf
+# have this macro built-in.
+
+AC_DEFUN([AC_HEADER_STDBOOL],
+  [AC_CACHE_CHECK([for stdbool.h that conforms to C99],
+     [ac_cv_header_stdbool_h],
+     [AC_TRY_COMPILE(
+       [
+         #include <stdbool.h>
+         #ifndef bool
+          "error: bool is not defined"
+         #endif
+         #ifndef false
+          "error: false is not defined"
+         #endif
+         #if false
+          "error: false is not 0"
+         #endif
+         #ifndef true
+          "error: true is not defined"
+         #endif
+         #if true != 1
+          "error: true is not 1"
+         #endif
+         #ifndef __bool_true_false_are_defined
+          "error: __bool_true_false_are_defined is not defined"
+         #endif
+
+         struct s { _Bool s: 1; _Bool t; } s;
+
+         char a[true == 1 ? 1 : -1];
+         char b[false == 0 ? 1 : -1];
+         char c[__bool_true_false_are_defined == 1 ? 1 : -1];
+         char d[(bool) 0.5 == true ? 1 : -1];
+         bool e = &s;
+         char f[(_Bool) 0.0 == false ? 1 : -1];
+         char g[true];
+         char h[sizeof (_Bool)];
+         char i[sizeof s.t];
+         enum { j = false, k = true, l = false * true, m = true * 256 };
+         _Bool n[m];
+         char o[sizeof n == m * sizeof n[0] ? 1 : -1];
+         char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
+         #if defined __xlc__ || defined __GNUC__
+          /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0
+             reported by James Lemley on 2005-10-05; see
+             http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html
+             This test is not quite right, since xlc is allowed to
+             reject this program, as the initializer for xlcbug is
+             not one of the forms that C requires support for.
+             However, doing the test right would require a run-time
+             test, and that would make cross-compilation harder.
+             Let us hope that IBM fixes the xlc bug, and also adds
+             support for this kind of constant expression.  In the
+             meantime, this test will reject xlc, which is OK, since
+             our stdbool.h substitute should suffice.  We also test
+             this with GCC, where it should work, to detect more
+             quickly whether someone messes up the test in the
+             future.  */
+          char digs[] = "0123456789";
+          int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1);
+         #endif
+         /* Catch a bug in an HP-UX C compiler.  See
+            http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
+            http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
+          */
+         _Bool q = true;
+         _Bool *pq = &q;
+       ],
+       [
+         *pq |= q;
+         *pq |= ! q;
+         /* Refer to every declared value, to avoid compiler optimizations.  */
+         return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
+                 + !m + !n + !o + !p + !q + !pq);
+       ],
+       [ac_cv_header_stdbool_h=yes],
+       [ac_cv_header_stdbool_h=no])])
+   AC_CHECK_TYPES([_Bool])
+   if test $ac_cv_header_stdbool_h = yes; then
+     AC_DEFINE(HAVE_STDBOOL_H, 1, [Define to 1 if stdbool.h conforms to C99.])
+   fi])
index 3ece71a466757553533444eb3cd7b90232d44d73..6b4170b1bb1d5ce367480008eb43b0004e116ad3 100644 (file)
@@ -1,4 +1,4 @@
-# stdio_h.m4 serial 1
+# stdio_h.m4 serial 2
 dnl Copyright (C) 2007 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -21,9 +21,23 @@ AC_DEFUN([gl_STDIO_MODULE_INDICATOR],
 
 AC_DEFUN([gl_STDIO_H_DEFAULTS],
 [
-  GNULIB_SNPRINTF=0;     AC_SUBST([GNULIB_SNPRINTF])
-  GNULIB_VSNPRINTF=0;    AC_SUBST([GNULIB_VSNPRINTF])
+  GNULIB_FPRINTF_POSIX=0;  AC_SUBST([GNULIB_FPRINTF_POSIX])
+  GNULIB_PRINTF_POSIX=0;   AC_SUBST([GNULIB_PRINTF_POSIX])
+  GNULIB_SNPRINTF=0;       AC_SUBST([GNULIB_SNPRINTF])
+  GNULIB_SPRINTF_POSIX=0;  AC_SUBST([GNULIB_SPRINTF_POSIX])
+  GNULIB_VFPRINTF_POSIX=0; AC_SUBST([GNULIB_VFPRINTF_POSIX])
+  GNULIB_VPRINTF_POSIX=0;  AC_SUBST([GNULIB_VPRINTF_POSIX])
+  GNULIB_VSNPRINTF=0;      AC_SUBST([GNULIB_VSNPRINTF])
+  GNULIB_VSPRINTF_POSIX=0; AC_SUBST([GNULIB_VSPRINTF_POSIX])
   dnl Assume proper GNU behavior unless another module says otherwise.
-  HAVE_DECL_SNPRINTF=1;  AC_SUBST([HAVE_DECL_SNPRINTF])
-  HAVE_DECL_VSNPRINTF=1; AC_SUBST([HAVE_DECL_VSNPRINTF])
+  REPLACE_FPRINTF=0;       AC_SUBST([REPLACE_FPRINTF])
+  REPLACE_VFPRINTF=0;      AC_SUBST([REPLACE_VFPRINTF])
+  REPLACE_PRINTF=0;        AC_SUBST([REPLACE_PRINTF])
+  REPLACE_VPRINTF=0;       AC_SUBST([REPLACE_VPRINTF])
+  REPLACE_SNPRINTF=0;      AC_SUBST([REPLACE_SNPRINTF])
+  HAVE_DECL_SNPRINTF=1;    AC_SUBST([HAVE_DECL_SNPRINTF])
+  REPLACE_VSNPRINTF=0;     AC_SUBST([REPLACE_VSNPRINTF])
+  HAVE_DECL_VSNPRINTF=1;   AC_SUBST([HAVE_DECL_VSNPRINTF])
+  REPLACE_SPRINTF=0;       AC_SUBST([REPLACE_SPRINTF])
+  REPLACE_VSPRINTF=0;      AC_SUBST([REPLACE_VSPRINTF])
 ])
index d3e45b48c1500018186bd193e765d2f07dae625a..ce5acf6e24f128e876837d6e8298d3ad136fc405 100644 (file)
@@ -1,5 +1,5 @@
-# sys_socket_h.m4 serial 2
-dnl Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+# sys_socket_h.m4 serial 3
+dnl Copyright (C) 2005, 2006, 2007 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.
@@ -8,16 +8,47 @@ dnl From Simon Josefsson.
 
 AC_DEFUN([gl_HEADER_SYS_SOCKET],
 [
-  AC_CHECK_HEADERS_ONCE([sys/socket.h])
-  if test $ac_cv_header_sys_socket_h = yes; then
+  AC_CACHE_CHECK([whether <sys/socket.h> is self-contained],
+    [gl_cv_header_sys_socket_h_selfcontained],
+    [
+      AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/socket.h>], [])],
+        [gl_cv_header_sys_socket_h_selfcontained=yes],
+        [gl_cv_header_sys_socket_h_selfcontained=no])
+    ])
+  if test $gl_cv_header_sys_socket_h_selfcontained = yes; then
     SYS_SOCKET_H=''
   else
-    dnl We cannot use AC_CHECK_HEADERS_ONCE here, because that would make
-    dnl the check for those headers unconditional; yet cygwin reports
-    dnl that the headers are present but cannot be compiled (since on
-    dnl cygwin, all socket information should come from sys/socket.h).
-    AC_CHECK_HEADERS([winsock2.h ws2tcpip.h])
     SYS_SOCKET_H='sys/socket.h'
+
+    AC_CHECK_HEADERS([sys/socket.h])
+    gl_ABSOLUTE_HEADER([sys/socket.h])
+    ABSOLUTE_SYS_SOCKET_H=\"$gl_cv_absolute_sys_socket_h\"
+    AC_SUBST([ABSOLUTE_SYS_SOCKET_H])
+    if test $ac_cv_header_sys_socket_h = yes; then
+      HAVE_SYS_SOCKET_H=1
+      HAVE_WINSOCK2_H=0
+      HAVE_WS2TCPIP_H=0
+    else
+      HAVE_SYS_SOCKET_H=0
+      dnl We cannot use AC_CHECK_HEADERS_ONCE here, because that would make
+      dnl the check for those headers unconditional; yet cygwin reports
+      dnl that the headers are present but cannot be compiled (since on
+      dnl cygwin, all socket information should come from sys/socket.h).
+      AC_CHECK_HEADERS([winsock2.h ws2tcpip.h])
+      if test $ac_cv_header_winsock2_h = yes; then
+        HAVE_WINSOCK2_H=1
+      else
+        HAVE_WINSOCK2_H=0
+      fi
+      if test $ac_cv_header_ws2tcpip_h = yes; then
+        HAVE_WS2TCPIP_H=1
+      else
+        HAVE_WS2TCPIP_H=0
+      fi
+    fi
+    AC_SUBST([HAVE_SYS_SOCKET_H])
+    AC_SUBST([HAVE_WINSOCK2_H])
+    AC_SUBST([HAVE_WS2TCPIP_H])
   fi
-  AC_SUBST(SYS_SOCKET_H)
+  AC_SUBST([SYS_SOCKET_H])
 ])
index e7b51dc413203c29942d1ce832c4de2de83c06ef..5aa05bc61ce960d1b885e4a086f3178a0963ddca 100644 (file)
@@ -1,4 +1,4 @@
-# vasnprintf.m4 serial 8
+# vasnprintf.m4 serial 9
 dnl Copyright (C) 2002-2004, 2006-2007 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -7,7 +7,7 @@ dnl with or without modifications, as long as this notice is preserved.
 AC_DEFUN([gl_FUNC_VASNPRINTF],
 [
   AC_REQUIRE([gl_EOVERFLOW])
-  AC_CHECK_FUNCS([vasnprintf])
+  AC_CHECK_FUNCS_ONCE([vasnprintf])
   if test $ac_cv_func_vasnprintf = no; then
     gl_REPLACE_VASNPRINTF
   fi
@@ -15,6 +15,7 @@ AC_DEFUN([gl_FUNC_VASNPRINTF],
 
 AC_DEFUN([gl_REPLACE_VASNPRINTF],
 [
+  AC_CHECK_FUNCS_ONCE([vasnprintf])
   AC_LIBOBJ([vasnprintf])
   AC_LIBOBJ([printf-args])
   AC_LIBOBJ([printf-parse])
index c00bfd7f42132a133130c0c9fabb6cdd991835cb..5c45bdc5e563c13554ec6531f6e5e9134212c62f 100644 (file)
@@ -38,7 +38,7 @@
    additional length SIZE limit how much is written into STR.  Returns
    string length of formatted string (which may be larger than SIZE).
    STR may be NULL, in which case nothing will be written.  On error,
-   return a negative value. */
+   return a negative value.  */
 int
 snprintf (char *str, size_t size, const char *format, ...)
 {
index 3f104b7df4304aa39f915f698f00b6ac5f7ce4a4..8e3701eb36b9aafc87c61f6fbdea36b6a4eaf978 100644 (file)
@@ -1,5 +1,5 @@
 /* Provide a sys/socket header file for systems lacking it (read: MinGW).
-   Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+   Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
    Written by Simon Josefsson.
 
    This program is free software; you can redistribute it and/or modify
    along with this program; if not, write to the Free Software Foundation,
    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
 
-#ifndef _SYS_SOCKET_H
-#define _SYS_SOCKET_H
+#ifndef _GL_SYS_SOCKET_H
+#define _GL_SYS_SOCKET_H
 
-/* This file is supposed to be used on platforms that lack
-   sys/socket.h.  It is intended to provide definitions and prototypes
-   needed by an application.
+/* This file is supposed to be used on platforms that lack <sys/socket.h>
+   and on platforms where <sys/socket.h> cannot be included standalone.
+   It is intended to provide definitions and prototypes needed by an
+   application.  */
+
+#if @HAVE_SYS_SOCKET_H@
+
+/* On many platforms, <sys/socket.h> assumes prior inclusion of
+   <sys/types.h>.  */
+
+# include <sys/types.h>
+# include @ABSOLUTE_SYS_SOCKET_H@
+
+#else
+
+/* A platform that lacks <sys/socket.h>.
 
    Currently only MinGW is supported.  See the gnulib manual regarding
    Windows sockets.  MinGW has the header files winsock2.h and
    releases. */
 
 
-#if HAVE_WINSOCK2_H
-# include <winsock2.h>
-#endif
-#if HAVE_WS2TCPIP_H
-# include <ws2tcpip.h>
-#endif
+# if @HAVE_WINSOCK2_H@
+#  include <winsock2.h>
+# endif
+# if @HAVE_WS2TCPIP_H@
+#  include <ws2tcpip.h>
+# endif
 
 /* For shutdown(). */
-#if !defined SHUT_RD && defined SD_RECEIVE
-# define SHUT_RD SD_RECEIVE
-#endif
-#if !defined SHUT_WR && defined SD_SEND
-# define SHUT_WR SD_SEND
-#endif
-#if !defined SHUT_RDWR && defined SD_BOTH
-# define SHUT_RDWR SD_BOTH
-#endif
-
-#if defined _WIN32 || defined __WIN32__
-# define ENOTSOCK                WSAENOTSOCK
-# define EADDRINUSE              WSAEADDRINUSE
-# define ENETRESET               WSAENETRESET
-# define ECONNABORTED            WSAECONNABORTED
-# define ECONNRESET              WSAECONNRESET
-# define ENOTCONN                WSAENOTCONN
-# define ESHUTDOWN               WSAESHUTDOWN
-#endif
-
-#endif /* _SYS_SOCKET_H */
+# if !defined SHUT_RD && defined SD_RECEIVE
+#  define SHUT_RD SD_RECEIVE
+# endif
+# if !defined SHUT_WR && defined SD_SEND
+#  define SHUT_WR SD_SEND
+# endif
+# if !defined SHUT_RDWR && defined SD_BOTH
+#  define SHUT_RDWR SD_BOTH
+# endif
+
+# if defined _WIN32 || defined __WIN32__
+#  define ENOTSOCK                WSAENOTSOCK
+#  define EADDRINUSE              WSAEADDRINUSE
+#  define ENETRESET               WSAENETRESET
+#  define ECONNABORTED            WSAECONNABORTED
+#  define ECONNRESET              WSAECONNRESET
+#  define ENOTCONN                WSAENOTCONN
+#  define ESHUTDOWN               WSAESHUTDOWN
+# endif
+
+#endif /* HAVE_SYS_SOCKET_H */
+
+#endif /* _GL_SYS_SOCKET_H */
diff --git a/lgl/stdbool_.h b/lgl/stdbool_.h
new file mode 100644 (file)
index 0000000..1381b95
--- /dev/null
@@ -0,0 +1,118 @@
+/* Copyright (C) 2001, 2002, 2003, 2006, 2007 Free Software Foundation, Inc.
+   Written by Bruno Haible <haible@clisp.cons.org>, 2001.
+
+   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, 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 _STDBOOL_H
+#define _STDBOOL_H
+
+/* ISO C 99 <stdbool.h> for platforms that lack it.  */
+
+/* Usage suggestions:
+
+   Programs that use <stdbool.h> should be aware of some limitations
+   and standards compliance issues.
+
+   Standards compliance:
+
+       - <stdbool.h> must be #included before 'bool', 'false', 'true'
+         can be used.
+
+       - You cannot assume that sizeof (bool) == 1.
+
+       - Programs should not undefine the macros bool, true, and false,
+         as C99 lists that as an "obsolescent feature".
+
+   Limitations of this substitute, when used in a C89 environment:
+
+       - <stdbool.h> must be #included before the '_Bool' type can be used.
+
+       - You cannot assume that _Bool is a typedef; it might be a macro.
+
+       - Bit-fields of type 'bool' are not supported.  Portable code
+         should use 'unsigned int foo : 1;' rather than 'bool foo : 1;'.
+
+       - In C99, casts and automatic conversions to '_Bool' or 'bool' are
+         performed in such a way that every nonzero value gets converted
+         to 'true', and zero gets converted to 'false'.  This doesn't work
+         with this substitute.  With this substitute, only the values 0 and 1
+         give the expected result when converted to _Bool' or 'bool'.
+
+   Also, it is suggested that programs use 'bool' rather than '_Bool';
+   this isn't required, but 'bool' is more common.  */
+
+
+/* 7.16. Boolean type and values */
+
+/* BeOS <sys/socket.h> already #defines false 0, true 1.  We use the same
+   definitions below, but temporarily we have to #undef them.  */
+#ifdef __BEOS__
+# include <OS.h> /* defines bool but not _Bool */
+# undef false
+# undef true
+#endif
+
+/* For the sake of symbolic names in gdb, we define true and false as
+   enum constants, not only as macros.
+   It is tempting to write
+      typedef enum { false = 0, true = 1 } _Bool;
+   so that gdb prints values of type 'bool' symbolically. But if we do
+   this, values of type '_Bool' may promote to 'int' or 'unsigned int'
+   (see ISO C 99 6.7.2.2.(4)); however, '_Bool' must promote to 'int'
+   (see ISO C 99 6.3.1.1.(2)).  So we add a negative value to the
+   enum; this ensures that '_Bool' promotes to 'int'.  */
+#if defined __cplusplus || defined __BEOS__
+  /* A compiler known to have 'bool'.  */
+  /* If the compiler already has both 'bool' and '_Bool', we can assume they
+     are the same types.  */
+# if !@HAVE__BOOL@
+typedef bool _Bool;
+# endif
+#else
+# if !defined __GNUC__
+   /* If @HAVE__BOOL@:
+        Some HP-UX cc and AIX IBM C compiler versions have compiler bugs when
+        the built-in _Bool type is used.  See
+          http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
+          http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
+          http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html
+        Similar bugs are likely with other compilers as well; this file
+        wouldn't be used if <stdbool.h> was working.
+        So we override the _Bool type.
+      If !@HAVE__BOOL@:
+        Need to define _Bool ourselves. As 'signed char' or as an enum type?
+        Use of a typedef, with SunPRO C, leads to a stupid
+          "warning: _Bool is a keyword in ISO C99".
+        Use of an enum type, with IRIX cc, leads to a stupid
+          "warning(1185): enumerated type mixed with another type".
+        The only benefit of the enum type, debuggability, is not important
+        with these compilers.  So use 'signed char' and no typedef.  */
+#  define _Bool signed char
+enum { false = 0, true = 1 };
+# else
+   /* With this compiler, trust the _Bool type if the compiler has it.  */
+#  if !@HAVE__BOOL@
+typedef enum { _Bool_must_promote_to_int = -1, false = 0, true = 1 } _Bool;
+#  endif
+# endif
+#endif
+#define bool _Bool
+
+/* The other macros must be usable in preprocessor directives.  */
+#define false 0
+#define true 1
+#define __bool_true_false_are_defined 1
+
+#endif /* _STDBOOL_H */
index c04b0c9c4bb429ba96c47109df84a29ac54d968a..75654a6e0e28c99c41fbffb804ab1dd2edc35ae7 100644 (file)
 #define int32_t int
 #define uint32_t unsigned int
 
-#undef int64_t
+/* Do not undefine int64_t if gnulib is not being used with 64-bit
+   types, since otherwise it breaks platforms like Tandem/NSK.  */
 #if LONG_MAX >> 31 >> 31 == 1
+# undef int64_t
 # define int64_t long int
+# define GL_INT64_T
 #elif defined _MSC_VER
+# undef int64_t
 # define int64_t __int64
+# define GL_INT64_T
 #elif @HAVE_LONG_LONG_INT@
+# undef int64_t
 # define int64_t long long int
+# define GL_INT64_T
 #endif
 
-#undef uint64_t
 #if ULONG_MAX >> 31 >> 31 >> 1 == 1
+# undef uint64_t
 # define uint64_t unsigned long int
+# define GL_UINT64_T
 #elif defined _MSC_VER
+# undef uint64_t
 # define uint64_t unsigned __int64
+# define GL_UINT64_T
 #elif @HAVE_UNSIGNED_LONG_LONG_INT@
+# undef uint64_t
 # define uint64_t unsigned long long int
+# define GL_UINT64_T
 #endif
 
 /* Avoid collision with Solaris 2.5.1 <pthread.h> etc.  */
 #define uint_least16_t uint16_t
 #define int_least32_t int32_t
 #define uint_least32_t uint32_t
-#ifdef int64_t
+#ifdef GL_INT64_T
 # define int_least64_t int64_t
 #endif
-#ifdef uint64_t
+#ifdef GL_UINT64_T
 # define uint_least64_t uint64_t
 #endif
 
 #define uint_fast16_t unsigned int_fast16_t
 #define int_fast32_t long int
 #define uint_fast32_t unsigned int_fast32_t
-#ifdef int64_t
+#ifdef GL_INT64_T
 # define int_fast64_t int64_t
 #endif
-#ifdef uint64_t
+#ifdef GL_UINT64_T
 # define uint_fast64_t uint64_t
 #endif
 
 #undef intmax_t
 #if @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1
 # define intmax_t long long int
-#elif defined int64_t
+#elif defined GL_INT64_T
 # define intmax_t int64_t
 #else
 # define intmax_t long int
 #undef uintmax_t
 #if @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1
 # define uintmax_t unsigned long long int
-#elif defined uint64_t
+#elif defined GL_UINT64_T
 # define uintmax_t uint64_t
 #else
 # define uintmax_t unsigned long int
 
 #undef INT64_MIN
 #undef INT64_MAX
-#ifdef int64_t
-# define INT64_MIN  (~ INT64_MAX)
+#ifdef GL_INT64_T
+/* Prefer (- INTMAX_C (1) << 63) over (~ INT64_MAX) because SunPRO C 5.0
+   evaluates the latter incorrectly in preprocessor expressions.  */
+# define INT64_MIN  (- INTMAX_C (1) << 63)
 # define INT64_MAX  INTMAX_C (9223372036854775807)
 #endif
 
 #undef UINT64_MAX
-#ifdef uint64_t
+#ifdef GL_UINT64_T
 # define UINT64_MAX  UINTMAX_C (18446744073709551615)
 #endif
 
 
 #undef INT_LEAST64_MIN
 #undef INT_LEAST64_MAX
-#ifdef int64_t
+#ifdef GL_INT64_T
 # define INT_LEAST64_MIN  INT64_MIN
 # define INT_LEAST64_MAX  INT64_MAX
 #endif
 
 #undef UINT_LEAST64_MAX
-#ifdef uint64_t
+#ifdef GL_UINT64_T
 # define UINT_LEAST64_MAX  UINT64_MAX
 #endif
 
 
 #undef INT_FAST64_MIN
 #undef INT_FAST64_MAX
-#ifdef int64_t
+#ifdef GL_INT64_T
 # define INT_FAST64_MIN  INT64_MIN
 # define INT_FAST64_MAX  INT64_MAX
 #endif
 
 #undef UINT_FAST64_MAX
-#ifdef uint64_t
+#ifdef GL_UINT64_T
 # define UINT_FAST64_MAX  UINT64_MAX
 #endif
 
 
 #undef INTMAX_MIN
 #undef INTMAX_MAX
-#define INTMAX_MIN  (~ INTMAX_MAX)
 #ifdef INT64_MAX
+# define INTMAX_MIN  INT64_MIN
 # define INTMAX_MAX  INT64_MAX
 #else
+# define INTMAX_MIN  INT32_MIN
 # define INTMAX_MAX  INT32_MAX
 #endif
 
 #undef INTMAX_C
 #if @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1
 # define INTMAX_C(x)   x##LL
-#elif defined int64_t
+#elif defined GL_INT64_T
 # define INTMAX_C(x)   INT64_C(x)
 #else
 # define INTMAX_C(x)   x##L
 #undef UINTMAX_C
 #if @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1
 # define UINTMAX_C(x)  x##ULL
-#elif defined uint64_t
+#elif defined GL_UINT64_T
 # define UINTMAX_C(x)  UINT64_C(x)
 #else
 # define UINTMAX_C(x)  x##UL
index 793f387ee8fd90537de139f5895749d371404007..125a0938c61f80ba3c4da8c3cb1eff8f9ce2736b 100644 (file)
@@ -16,7 +16,7 @@
    along with this program; if not, write to the Free Software Foundation,
    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
 
-#if defined __need_FILE
+#if defined __need_FILE || defined __need___FILE
 /* Special invocation convention inside glibc header files.  */
 
 #include @ABSOLUTE_STDIO_H@
 #include <stdarg.h>
 #include <stddef.h>
 
+#ifndef __attribute__
+/* This feature is available in gcc versions 2.5 and later.  */
+# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
+#  define __attribute__(Spec) /* empty */
+# endif
+/* The __-protected variants of `format' and `printf' attributes
+   are accepted by gcc versions 2.6.4 (effectively 2.7) and later.  */
+# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
+#  define __format__ format
+#  define __printf__ printf
+# endif
+#endif
+
 
 /* The definition of GL_LINK_WARNING is copied here.  */
 
@@ -40,9 +53,81 @@ extern "C" {
 #endif
 
 
+#if @GNULIB_FPRINTF_POSIX@
+# if @REPLACE_FPRINTF@
+#  define fprintf rpl_fprintf
+extern int fprintf (FILE *fp, const char *format, ...)
+       __attribute__ ((__format__ (__printf__, 2, 3)));
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef fprintf
+# define fprintf \
+    (GL_LINK_WARNING ("fprintf is not always POSIX compliant - " \
+                      "use gnulib module fprintf-posix for portable " \
+                      "POSIX compliance"), \
+     fprintf)
+#endif
+
+#if @GNULIB_VFPRINTF_POSIX@
+# if @REPLACE_VFPRINTF@
+#  define vfprintf rpl_vfprintf
+extern int vfprintf (FILE *fp, const char *format, va_list args)
+       __attribute__ ((__format__ (__printf__, 2, 0)));
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef vfprintf
+# define vfprintf(s,f,a) \
+    (GL_LINK_WARNING ("vfprintf is not always POSIX compliant - " \
+                      "use gnulib module vfprintf-posix for portable " \
+                      "POSIX compliance"), \
+     vfprintf (s, f, a))
+#endif
+
+#if @GNULIB_PRINTF_POSIX@
+# if @REPLACE_PRINTF@
+/* Don't break __attribute__((format(printf,M,N))).  */
+#  define printf __printf__
+extern int printf (const char *format, ...)
+       __attribute__ ((__format__ (__printf__, 1, 2)));
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef printf
+# define printf \
+    (GL_LINK_WARNING ("printf is not always POSIX compliant - " \
+                      "use gnulib module printf-posix for portable " \
+                      "POSIX compliance"), \
+     printf)
+/* Don't break __attribute__((format(printf,M,N))).  */
+# define format(kind,m,n) format (__##kind##__, m, n)
+# define __format__(kind,m,n) __format__ (__##kind##__, m, n)
+# define ____printf____ __printf__
+# define ____scanf____ __scanf__
+# define ____strftime____ __strftime__
+# define ____strfmon____ __strfmon__
+#endif
+
+#if @GNULIB_VPRINTF_POSIX@
+# if @REPLACE_VPRINTF@
+#  define vprintf rpl_vprintf
+extern int vprintf (const char *format, va_list args)
+       __attribute__ ((__format__ (__printf__, 1, 0)));
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef vprintf
+# define vprintf(f,a) \
+    (GL_LINK_WARNING ("vprintf is not always POSIX compliant - " \
+                      "use gnulib module vprintf-posix for portable " \
+                      "POSIX compliance"), \
+     vprintf (f, a))
+#endif
+
 #if @GNULIB_SNPRINTF@
-# if !@HAVE_DECL_SNPRINTF@
-extern int snprintf (char *str, size_t size, const char *format, ...);
+# if @REPLACE_SNPRINTF@
+#  define snprintf rpl_snprintf
+# endif
+# if @REPLACE_SNPRINTF@ || !@HAVE_DECL_SNPRINTF@
+extern int snprintf (char *str, size_t size, const char *format, ...)
+       __attribute__ ((__format__ (__printf__, 3, 4)));
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef snprintf
@@ -53,8 +138,12 @@ extern int snprintf (char *str, size_t size, const char *format, ...);
 #endif
 
 #if @GNULIB_VSNPRINTF@
-# if !@HAVE_DECL_VSNPRINTF@
-extern int vsnprintf (char *str, size_t size, const char *format, va_list args);
+# if @REPLACE_VSNPRINTF@
+#  define vsnprintf rpl_vsnprintf
+# endif
+# if @REPLACE_VSNPRINTF@ || !@HAVE_DECL_VSNPRINTF@
+extern int vsnprintf (char *str, size_t size, const char *format, va_list args)
+       __attribute__ ((__format__ (__printf__, 3, 0)));
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef vsnprintf
@@ -64,6 +153,36 @@ extern int vsnprintf (char *str, size_t size, const char *format, va_list args);
      vsnprintf (b, s, f, a))
 #endif
 
+#if @GNULIB_SPRINTF_POSIX@
+# if @REPLACE_SPRINTF@
+#  define sprintf rpl_sprintf
+extern int sprintf (char *str, const char *format, ...)
+       __attribute__ ((__format__ (__printf__, 2, 3)));
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef sprintf
+# define sprintf \
+    (GL_LINK_WARNING ("sprintf is not always POSIX compliant - " \
+                      "use gnulib module sprintf-posix for portable " \
+                      "POSIX compliance"), \
+     sprintf)
+#endif
+
+#if @GNULIB_VSPRINTF_POSIX@
+# if @REPLACE_VSPRINTF@
+#  define vsprintf rpl_vsprintf
+extern int vsprintf (char *str, const char *format, va_list args)
+       __attribute__ ((__format__ (__printf__, 2, 0)));
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef vsprintf
+# define vsprintf(b,f,a) \
+    (GL_LINK_WARNING ("vsprintf is not always POSIX compliant - " \
+                      "use gnulib module vsprintf-posix for portable " \
+                      "POSIX compliance"), \
+     vsprintf (b, f, a))
+#endif
+
 
 #ifdef __cplusplus
 }
index 15b426b875b48de9a8318a66484eec5df01b1f87..7a04391d0efe62e090b8acfc6731ddd9c3f7cc57 100644 (file)
@@ -34,6 +34,7 @@
 # include "vasnprintf.h"
 #endif
 
+#include <locale.h>    /* localeconv() */
 #include <stdio.h>     /* snprintf(), sprintf() */
 #include <stdlib.h>    /* abort(), malloc(), realloc(), free() */
 #include <string.h>    /* memcpy(), strlen() */
@@ -109,8 +110,12 @@ local_wcslen (const wchar_t *s)
 # else
    /* Unix.  */
 #  define SNPRINTF snprintf
+   /* Here we need to call the native snprintf, not rpl_snprintf.  */
+#  undef snprintf
 # endif
 #endif
+/* Here we need to call the native sprintf, not rpl_sprintf.  */
+#undef sprintf
 
 CHAR_T *
 VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list args)
@@ -492,7 +497,11 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
                              if ((flags & FLAG_ALT)
                                  || mantissa > 0.0L || precision > 0)
                                {
-                                 *p++ = '.';
+                                 const char *point =
+                                   localeconv () -> decimal_point;
+                                 /* The decimal point is always a single byte:
+                                    either '.' or ','.  */
+                                 *p++ = (point[0] != '\0' ? point[0] : '.');
                                  /* This loop terminates because we assume
                                     that FLT_RADIX is a power of 2.  */
                                  while (mantissa > 0.0L)
@@ -636,7 +645,11 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
                              if ((flags & FLAG_ALT)
                                  || mantissa > 0.0 || precision > 0)
                                {
-                                 *p++ = '.';
+                                 const char *point =
+                                   localeconv () -> decimal_point;
+                                 /* The decimal point is always a single byte:
+                                    either '.' or ','.  */
+                                 *p++ = (point[0] != '\0' ? point[0] : '.');
                                  /* This loop terminates because we assume
                                     that FLT_RADIX is a power of 2.  */
                                  while (mantissa > 0.0)
index f2a035b61af1f71c33ab5bfa1a5f0d5870202b26..4524ce77ff17e57decf6301e20aa4ed634727590 100644 (file)
@@ -37,7 +37,7 @@
 # endif
 #endif
 
-#ifdef __cplusplus
+#ifdef __cplusplus
 extern "C" {
 #endif
 
@@ -74,7 +74,7 @@ extern char * asnprintf (char *resultbuf, size_t *lengthp, const char *format, .
 extern char * vasnprintf (char *resultbuf, size_t *lengthp, const char *format, va_list args)
        __attribute__ ((__format__ (__printf__, 3, 0)));
 
-#ifdef __cplusplus
+#ifdef __cplusplus
 }
 #endif
 
index 37e7e47e6240c282001666494dd979313aab3895..c590832fb03cf33c2c6c84491c1b19905a567f51 100644 (file)
@@ -43,7 +43,7 @@
 # endif
 #endif
 
-#ifdef __cplusplus
+#ifdef __cplusplus
 extern "C" {
 #endif
 
@@ -60,7 +60,7 @@ extern int asprintf (char **result, const char *format, ...)
 extern int vasprintf (char **result, const char *format, va_list args)
        __attribute__ ((__format__ (__printf__, 2, 0)));
 
-#ifdef __cplusplus
+#ifdef __cplusplus
 }
 #endif