]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Use more warnings. Fix many warnings.
authorSimon Josefsson <simon@josefsson.org>
Mon, 17 Nov 2008 20:15:50 +0000 (21:15 +0100)
committerSimon Josefsson <simon@josefsson.org>
Mon, 17 Nov 2008 20:15:50 +0000 (21:15 +0100)
53 files changed:
configure.ac
doc/examples/Makefile.am
doc/examples/ex-alert.c
doc/examples/ex-client-psk.c
doc/examples/ex-pkcs12.c
doc/examples/ex-rfc2818.c
doc/examples/ex-session-info.c
doc/examples/ex-verify.c
doc/examples/ex-x509-info.c
doc/examples/tcp.c
gl/gettext.h
gl/override/lib/gettext.h.diff [new file with mode: 0644]
lib/gl/gettext.h
lib/gl/override/lib/gettext.h.diff [new file with mode: 0644]
lib/gnutls_hash_int.c
lib/gnutls_hash_int.h
lib/gnutls_state.c
lib/gnutls_str.h
lib/openpgp/output.c
lib/x509/Makefile.am
lib/x509/dn.c
lib/x509/output.c
lib/x509/privkey.c
libextra/fipsmd5.c
libextra/gnutls_extra.c
libextra/gnutls_openssl.c
src/Makefile.am
src/cli.c
src/common.h
src/crypt.c
src/prime.c
src/psk.c
src/serv.c
src/tls_test.c
tests/Makefile.am
tests/anonself.c
tests/crypto_rng.c
tests/dhepskself.c
tests/dn.c
tests/finished.c
tests/gc.c
tests/mini.c
tests/openpgpself.c
tests/pkcs12_s2k.c
tests/pskself.c
tests/resume.c
tests/set_pkcs12_cred.c
tests/tlsia.c
tests/utils.c
tests/utils.h
tests/x509dn.c
tests/x509self.c
tests/x509signself.c

index 657790a81e86042f8da251dca90c5c92cd8cebf5..89858f74763344e56b5868afa209cc4a8584e749 100644 (file)
@@ -42,7 +42,8 @@ if test "x$GAA" = "x"; then
    AC_MSG_WARN([[***
 *** GAA was not found.  It is only needed if you wish to modify
 *** the source code or command-line description files.  In this case,
-*** you may want to get it from http://gaa.sourceforge.net/
+*** you may want to get it from http://gaa.sourceforge.net/ and
+*** read doc/README.gaa.
 ***]])
 fi
 AM_CONDITIONAL(HAVE_GCC,   test "x$GCC" = "xyes")
@@ -172,12 +173,6 @@ AC_PROG_LIBTOOL
 
 gl_INIT
 
-# These are additional warnings we could enable:
-#
-# -Wshadow -Wunsafe-loop-optimizations Wcast-qual Wlogical-op
-# -Waggregate-return Wmissing-prototypes -Wmissing-declarations
-# -Wmissing-noreturn -Wmissing-format-attribute Wredundant-decls -Wvla
-#
 # These are warnings we have tried but have turned out not to be useful:
 #
 # -Wtraditional: warns on #elif which we use often
@@ -194,17 +189,47 @@ gl_INIT
 # -Wno-pointer-sign: too many warnings for now
 # -Wno-unused-parameter: added because -Wunused cause too many warns
 
-BASICS="-Wall -W"
-
-ADDITIONAL="-Wchar-subscripts -Wformat-security -Wnonnull -Winit-self -Wmissing-include-dirs -Wunused -Wfloat-equal -Wdeclaration-after-statement -Wpointer-arith -Wbad-function-cast  -Wcast-align -Wstrict-prototypes -Wold-style-definition -Wpacked -Wnested-externs -Winline -Wvolatile-register-var -Wdisabled-optimization -Wstack-protector -Woverlength-strings"
-
-REMOVE="-Wno-pointer-sign -Wno-unused-parameter"
-
-for w in $BASICS $ADDITIONAL $REMOVE; do
+gl_WARN_SUPPORTED([WARNINGS])
+
+# Useless warnings.
+USELESS_WARNINGS=" \
+  -Wc++-compat \
+  -Wsystem-headers \
+  -Wundef \
+  -Wtraditional \
+  -Wtraditional-conversion"
+gl_WARN_COMPLEMENT(WARNINGS, [$WARNINGS], [$USELESS_WARNINGS])
+# Review these from time to time.
+USELESS_WARNINGS=" \
+  -Wcast-qual \
+  -Wlogical-op \
+  -Waggregate-return \
+  -Wshadow \
+  -Wswitch-default \
+  -Wswitch-enum \
+  -Wconversion \
+  -Wsign-conversion \
+  -Wold-style-definition \
+  -Wpadded \
+  -Wsign-compare \
+  -Wunreachable-code \
+  -Wformat-y2k \
+  -Wunsafe-loop-optimizations \
+  -Wstrict-overflow"
+gl_WARN_COMPLEMENT(WARNINGS, [$WARNINGS], [$USELESS_WARNINGS])
+
+for w in $WARNINGS; do
   gl_WARN_ADD([$w])
 done
+
+gl_WARN_ADD([-Wno-missing-field-initializers])
+gl_WARN_ADD([-Wno-pointer-sign])
+gl_WARN_ADD([-Wno-unused-parameter])
+gl_WARN_ADD([-fdiagnostics-show-option])
 export WARN_CFLAGS
 
+gl_WARN_ADD([])
+
 AC_CONFIG_SUBDIRS([lib])
 AC_CONFIG_SUBDIRS([libextra])
 
index ecba23d680441831eb404ab320e9177fb910353a..3ba158f8d30d0e43125a0e9a11aeb8623e53d1d3 100644 (file)
@@ -70,5 +70,6 @@ endif
 
 noinst_LTLIBRARIES = libexamples.la
 
-libexamples_la_SOURCES = ex-alert.c ex-pkcs12.c ex-rfc2818.c   \
-       ex-session-info.c ex-x509-info.c ex-verify.c tcp.c
+libexamples_la_SOURCES = examples.h ex-alert.c ex-pkcs12.c             \
+       ex-rfc2818.c ex-session-info.c ex-x509-info.c ex-verify.c       \
+       tcp.c
index 7f5829925cf4c0cc5c8a359d0eaa65f648d72126..ba708a366c33cf6d88320d19fe1ebb96e65a4046 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright 2007 Free Software Foundation
+/* Copyright 2007, 2008 Free Software Foundation
  *
  * Copying and distribution of this file, with or without modification,
  * are permitted in any medium without royalty provided the copyright
@@ -13,6 +13,8 @@
 #include <stdlib.h>
 #include <gnutls/gnutls.h>
 
+#include "examples.h"
+
 /* This function will check whether the given return code from
  * a gnutls function (recv/send), is an alert, and will print
  * that alert.
index dc1b0f6a1205d7afce524a46acfbf8bad56515a3..9d62ccfae0ff28d421b0fa87fc1ed42dc0195f95 100644 (file)
@@ -36,7 +36,7 @@ main (void)
   char buffer[MAX_BUF + 1];
   const char *err;
   gnutls_psk_client_credentials_t pskcred;
-  const gnutls_datum_t key = { "DEADBEEF", 8 };
+  const gnutls_datum_t key = { (char*) "DEADBEEF", 8 };
 
   gnutls_global_init ();
 
index b017c85a455428c13984aaa94c4983d3cffc0e6f..23363c78d464fef3bf3de883bb752e87f2768695 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright 2007 Free Software Foundation
+/* Copyright 2007, 2008 Free Software Foundation
  *
  * Copying and distribution of this file, with or without modification,
  * are permitted in any medium without royalty provided the copyright
@@ -14,6 +14,8 @@
 #include <gnutls/gnutls.h>
 #include <gnutls/pkcs12.h>
 
+#include "examples.h"
+
 #define OUTFILE "out.p12"
 
 /* This function will write a pkcs12 structure into a file.
@@ -36,7 +38,7 @@ write_pkcs12 (const gnutls_datum_t * cert,
   /* A good idea might be to use gnutls_x509_privkey_get_key_id()
    * to obtain a unique ID.
    */
-  gnutls_datum_t key_id = { "\x00\x00\x07", 3 };
+  gnutls_datum_t key_id = { (char*) "\x00\x00\x07", 3 };
 
   gnutls_global_init ();
 
index 49fd7b608d93bd0b2a2546fe48c8077a427e0d9c..010fb30d670664a89c60236e8f1a5a9734df4bf2 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright 2007 Free Software Foundation
+/* Copyright 2007, 2008 Free Software Foundation
  *
  * Copying and distribution of this file, with or without modification,
  * are permitted in any medium without royalty provided the copyright
@@ -13,6 +13,8 @@
 #include <gnutls/gnutls.h>
 #include <gnutls/x509.h>
 
+#include "examples.h"
+
 /* This function will try to verify the peer's certificate, and
  * also check if the hostname matches, and the activation, expiration dates.
  */
index 6f1d07abaaa8fe626f955bba10430c3eb62c80ba..3ddbd3b38df8e42c30604977e6393071c31b6ab5 100644 (file)
@@ -14,7 +14,7 @@
 #include <gnutls/gnutls.h>
 #include <gnutls/x509.h>
 
-extern void print_x509_certificate_info (gnutls_session_t);
+#include "examples.h"
 
 /* This function will print some details of the
  * given session.
index e9337213bcbd542a95a5d7d16287ad7736085527..ab3f2c6dadfd2d5e9d44ed89b4447e0ca9ddfcb4 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright 2007 Free Software Foundation
+/* Copyright 2007, 2008 Free Software Foundation
  *
  * Copying and distribution of this file, with or without modification,
  * are permitted in any medium without royalty provided the copyright
@@ -14,6 +14,8 @@
 #include <gnutls/gnutls.h>
 #include <gnutls/x509.h>
 
+#include "examples.h"
+
 /* All the available CRLs
  */
 gnutls_x509_crl_t *crl_list;
index d1433ab559d7f9851b5c39f485f491b19069524e..1fe3684100192d17701e67d7304c5c8bff858ec9 100644 (file)
@@ -14,6 +14,8 @@
 #include <gnutls/gnutls.h>
 #include <gnutls/x509.h>
 
+#include "examples.h"
+
 static const char *
 bin2hex (const void *bin, size_t bin_size)
 {
index ec390e623e9ff69cf024e5287be42202d67d63ab..876e706057024bdde4398efb2fcb037db4b350af 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright 2007 Free Software Foundation
+/* Copyright 2007, 2008 Free Software Foundation
  *
  * Copying and distribution of this file, with or without modification,
  * are permitted in any medium without royalty provided the copyright
 
 #define SA struct sockaddr
 
+/* tcp.c */
+int tcp_connect (void);
+void tcp_close (int sd);
+
 /* Connects to the peer and returns a socket
  * descriptor.
  */
index 763dd3c1470ad11df04d2ed89d8c574f9c30a88f..daaaa9757668e32a9275b7483f14689978eef1e0 100644 (file)
@@ -162,109 +162,4 @@ npgettext_aux (const char *domain,
     return translation;
 }
 
-/* The same thing extended for non-constant arguments.  Here MSGCTXT and MSGID
-   can be arbitrary expressions.  But for string literals these macros are
-   less efficient than those above.  */
-
-#include <string.h>
-
-#define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS \
-  (((__GNUC__ >= 3 || __GNUG__ >= 2) && !__STRICT_ANSI__) \
-   /* || __STDC_VERSION__ >= 199901L */ )
-
-#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
-#include <stdlib.h>
-#endif
-
-#define pgettext_expr(Msgctxt, Msgid) \
-  dcpgettext_expr (NULL, Msgctxt, Msgid, LC_MESSAGES)
-#define dpgettext_expr(Domainname, Msgctxt, Msgid) \
-  dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES)
-
-#ifdef __GNUC__
-__inline
-#else
-#ifdef __cplusplus
-inline
-#endif
-#endif
-static const char *
-dcpgettext_expr (const char *domain,
-                const char *msgctxt, const char *msgid,
-                int category)
-{
-  size_t msgctxt_len = strlen (msgctxt) + 1;
-  size_t msgid_len = strlen (msgid) + 1;
-  const char *translation;
-#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
-  char msg_ctxt_id[msgctxt_len + msgid_len];
-#else
-  char buf[1024];
-  char *msg_ctxt_id =
-    (msgctxt_len + msgid_len <= sizeof (buf)
-     ? buf
-     : (char *) malloc (msgctxt_len + msgid_len));
-  if (msg_ctxt_id != NULL)
-#endif
-    {
-      memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
-      msg_ctxt_id[msgctxt_len - 1] = '\004';
-      memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
-      translation = dcgettext (domain, msg_ctxt_id, category);
-#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
-      if (msg_ctxt_id != buf)
-       free (msg_ctxt_id);
-#endif
-      if (translation != msg_ctxt_id)
-       return translation;
-    }
-  return msgid;
-}
-
-#define npgettext_expr(Msgctxt, Msgid, MsgidPlural, N) \
-  dcnpgettext_expr (NULL, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
-#define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
-  dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
-
-#ifdef __GNUC__
-__inline
-#else
-#ifdef __cplusplus
-inline
-#endif
-#endif
-static const char *
-dcnpgettext_expr (const char *domain,
-                 const char *msgctxt, const char *msgid,
-                 const char *msgid_plural, unsigned long int n,
-                 int category)
-{
-  size_t msgctxt_len = strlen (msgctxt) + 1;
-  size_t msgid_len = strlen (msgid) + 1;
-  const char *translation;
-#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
-  char msg_ctxt_id[msgctxt_len + msgid_len];
-#else
-  char buf[1024];
-  char *msg_ctxt_id =
-    (msgctxt_len + msgid_len <= sizeof (buf)
-     ? buf
-     : (char *) malloc (msgctxt_len + msgid_len));
-  if (msg_ctxt_id != NULL)
-#endif
-    {
-      memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
-      msg_ctxt_id[msgctxt_len - 1] = '\004';
-      memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
-      translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
-#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
-      if (msg_ctxt_id != buf)
-       free (msg_ctxt_id);
-#endif
-      if (!(translation == msg_ctxt_id || translation == msgid_plural))
-       return translation;
-    }
-  return (n == 1 ? msgid : msgid_plural);
-}
-
 #endif /* _LIBGETTEXT_H */
diff --git a/gl/override/lib/gettext.h.diff b/gl/override/lib/gettext.h.diff
new file mode 100644 (file)
index 0000000..fcd13cb
--- /dev/null
@@ -0,0 +1,112 @@
+--- gl/gettext.h.orig  2008-11-17 17:12:20.000000000 +0100
++++ gl/gettext.h       2008-11-17 17:12:29.000000000 +0100
+@@ -162,109 +162,4 @@
+     return translation;
+ }
+-/* The same thing extended for non-constant arguments.  Here MSGCTXT and MSGID
+-   can be arbitrary expressions.  But for string literals these macros are
+-   less efficient than those above.  */
+-
+-#include <string.h>
+-
+-#define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS \
+-  (((__GNUC__ >= 3 || __GNUG__ >= 2) && !__STRICT_ANSI__) \
+-   /* || __STDC_VERSION__ >= 199901L */ )
+-
+-#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+-#include <stdlib.h>
+-#endif
+-
+-#define pgettext_expr(Msgctxt, Msgid) \
+-  dcpgettext_expr (NULL, Msgctxt, Msgid, LC_MESSAGES)
+-#define dpgettext_expr(Domainname, Msgctxt, Msgid) \
+-  dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES)
+-
+-#ifdef __GNUC__
+-__inline
+-#else
+-#ifdef __cplusplus
+-inline
+-#endif
+-#endif
+-static const char *
+-dcpgettext_expr (const char *domain,
+-               const char *msgctxt, const char *msgid,
+-               int category)
+-{
+-  size_t msgctxt_len = strlen (msgctxt) + 1;
+-  size_t msgid_len = strlen (msgid) + 1;
+-  const char *translation;
+-#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+-  char msg_ctxt_id[msgctxt_len + msgid_len];
+-#else
+-  char buf[1024];
+-  char *msg_ctxt_id =
+-    (msgctxt_len + msgid_len <= sizeof (buf)
+-     ? buf
+-     : (char *) malloc (msgctxt_len + msgid_len));
+-  if (msg_ctxt_id != NULL)
+-#endif
+-    {
+-      memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
+-      msg_ctxt_id[msgctxt_len - 1] = '\004';
+-      memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
+-      translation = dcgettext (domain, msg_ctxt_id, category);
+-#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+-      if (msg_ctxt_id != buf)
+-      free (msg_ctxt_id);
+-#endif
+-      if (translation != msg_ctxt_id)
+-      return translation;
+-    }
+-  return msgid;
+-}
+-
+-#define npgettext_expr(Msgctxt, Msgid, MsgidPlural, N) \
+-  dcnpgettext_expr (NULL, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
+-#define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
+-  dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
+-
+-#ifdef __GNUC__
+-__inline
+-#else
+-#ifdef __cplusplus
+-inline
+-#endif
+-#endif
+-static const char *
+-dcnpgettext_expr (const char *domain,
+-                const char *msgctxt, const char *msgid,
+-                const char *msgid_plural, unsigned long int n,
+-                int category)
+-{
+-  size_t msgctxt_len = strlen (msgctxt) + 1;
+-  size_t msgid_len = strlen (msgid) + 1;
+-  const char *translation;
+-#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+-  char msg_ctxt_id[msgctxt_len + msgid_len];
+-#else
+-  char buf[1024];
+-  char *msg_ctxt_id =
+-    (msgctxt_len + msgid_len <= sizeof (buf)
+-     ? buf
+-     : (char *) malloc (msgctxt_len + msgid_len));
+-  if (msg_ctxt_id != NULL)
+-#endif
+-    {
+-      memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
+-      msg_ctxt_id[msgctxt_len - 1] = '\004';
+-      memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
+-      translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
+-#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+-      if (msg_ctxt_id != buf)
+-      free (msg_ctxt_id);
+-#endif
+-      if (!(translation == msg_ctxt_id || translation == msgid_plural))
+-      return translation;
+-    }
+-  return (n == 1 ? msgid : msgid_plural);
+-}
+-
+ #endif /* _LIBGETTEXT_H */
index bd214d5cec28734ec8081fb04fe822791f9326d8..a8ca5a4c21022a3cb9ac3057eaa12bbd28fa6d7b 100644 (file)
@@ -162,109 +162,4 @@ npgettext_aux (const char *domain,
     return translation;
 }
 
-/* The same thing extended for non-constant arguments.  Here MSGCTXT and MSGID
-   can be arbitrary expressions.  But for string literals these macros are
-   less efficient than those above.  */
-
-#include <string.h>
-
-#define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS \
-  (((__GNUC__ >= 3 || __GNUG__ >= 2) && !__STRICT_ANSI__) \
-   /* || __STDC_VERSION__ >= 199901L */ )
-
-#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
-#include <stdlib.h>
-#endif
-
-#define pgettext_expr(Msgctxt, Msgid) \
-  dcpgettext_expr (NULL, Msgctxt, Msgid, LC_MESSAGES)
-#define dpgettext_expr(Domainname, Msgctxt, Msgid) \
-  dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES)
-
-#ifdef __GNUC__
-__inline
-#else
-#ifdef __cplusplus
-inline
-#endif
-#endif
-static const char *
-dcpgettext_expr (const char *domain,
-                const char *msgctxt, const char *msgid,
-                int category)
-{
-  size_t msgctxt_len = strlen (msgctxt) + 1;
-  size_t msgid_len = strlen (msgid) + 1;
-  const char *translation;
-#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
-  char msg_ctxt_id[msgctxt_len + msgid_len];
-#else
-  char buf[1024];
-  char *msg_ctxt_id =
-    (msgctxt_len + msgid_len <= sizeof (buf)
-     ? buf
-     : (char *) malloc (msgctxt_len + msgid_len));
-  if (msg_ctxt_id != NULL)
-#endif
-    {
-      memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
-      msg_ctxt_id[msgctxt_len - 1] = '\004';
-      memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
-      translation = dcgettext (domain, msg_ctxt_id, category);
-#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
-      if (msg_ctxt_id != buf)
-       free (msg_ctxt_id);
-#endif
-      if (translation != msg_ctxt_id)
-       return translation;
-    }
-  return msgid;
-}
-
-#define npgettext_expr(Msgctxt, Msgid, MsgidPlural, N) \
-  dcnpgettext_expr (NULL, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
-#define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
-  dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
-
-#ifdef __GNUC__
-__inline
-#else
-#ifdef __cplusplus
-inline
-#endif
-#endif
-static const char *
-dcnpgettext_expr (const char *domain,
-                 const char *msgctxt, const char *msgid,
-                 const char *msgid_plural, unsigned long int n,
-                 int category)
-{
-  size_t msgctxt_len = strlen (msgctxt) + 1;
-  size_t msgid_len = strlen (msgid) + 1;
-  const char *translation;
-#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
-  char msg_ctxt_id[msgctxt_len + msgid_len];
-#else
-  char buf[1024];
-  char *msg_ctxt_id =
-    (msgctxt_len + msgid_len <= sizeof (buf)
-     ? buf
-     : (char *) malloc (msgctxt_len + msgid_len));
-  if (msg_ctxt_id != NULL)
-#endif
-    {
-      memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
-      msg_ctxt_id[msgctxt_len - 1] = '\004';
-      memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
-      translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
-#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
-      if (msg_ctxt_id != buf)
-       free (msg_ctxt_id);
-#endif
-      if (!(translation == msg_ctxt_id || translation == msgid_plural))
-       return translation;
-    }
-  return (n == 1 ? msgid : msgid_plural);
-}
-
 #endif /* _LIBGETTEXT_H */
diff --git a/lib/gl/override/lib/gettext.h.diff b/lib/gl/override/lib/gettext.h.diff
new file mode 100644 (file)
index 0000000..ec8f03f
--- /dev/null
@@ -0,0 +1,112 @@
+--- lib/gl/gettext.h.orig      2008-11-17 17:11:58.000000000 +0100
++++ lib/gl/gettext.h   2008-11-17 17:12:03.000000000 +0100
+@@ -162,109 +162,4 @@
+     return translation;
+ }
+-/* The same thing extended for non-constant arguments.  Here MSGCTXT and MSGID
+-   can be arbitrary expressions.  But for string literals these macros are
+-   less efficient than those above.  */
+-
+-#include <string.h>
+-
+-#define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS \
+-  (((__GNUC__ >= 3 || __GNUG__ >= 2) && !__STRICT_ANSI__) \
+-   /* || __STDC_VERSION__ >= 199901L */ )
+-
+-#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+-#include <stdlib.h>
+-#endif
+-
+-#define pgettext_expr(Msgctxt, Msgid) \
+-  dcpgettext_expr (NULL, Msgctxt, Msgid, LC_MESSAGES)
+-#define dpgettext_expr(Domainname, Msgctxt, Msgid) \
+-  dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES)
+-
+-#ifdef __GNUC__
+-__inline
+-#else
+-#ifdef __cplusplus
+-inline
+-#endif
+-#endif
+-static const char *
+-dcpgettext_expr (const char *domain,
+-               const char *msgctxt, const char *msgid,
+-               int category)
+-{
+-  size_t msgctxt_len = strlen (msgctxt) + 1;
+-  size_t msgid_len = strlen (msgid) + 1;
+-  const char *translation;
+-#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+-  char msg_ctxt_id[msgctxt_len + msgid_len];
+-#else
+-  char buf[1024];
+-  char *msg_ctxt_id =
+-    (msgctxt_len + msgid_len <= sizeof (buf)
+-     ? buf
+-     : (char *) malloc (msgctxt_len + msgid_len));
+-  if (msg_ctxt_id != NULL)
+-#endif
+-    {
+-      memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
+-      msg_ctxt_id[msgctxt_len - 1] = '\004';
+-      memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
+-      translation = dcgettext (domain, msg_ctxt_id, category);
+-#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+-      if (msg_ctxt_id != buf)
+-      free (msg_ctxt_id);
+-#endif
+-      if (translation != msg_ctxt_id)
+-      return translation;
+-    }
+-  return msgid;
+-}
+-
+-#define npgettext_expr(Msgctxt, Msgid, MsgidPlural, N) \
+-  dcnpgettext_expr (NULL, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
+-#define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
+-  dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
+-
+-#ifdef __GNUC__
+-__inline
+-#else
+-#ifdef __cplusplus
+-inline
+-#endif
+-#endif
+-static const char *
+-dcnpgettext_expr (const char *domain,
+-                const char *msgctxt, const char *msgid,
+-                const char *msgid_plural, unsigned long int n,
+-                int category)
+-{
+-  size_t msgctxt_len = strlen (msgctxt) + 1;
+-  size_t msgid_len = strlen (msgid) + 1;
+-  const char *translation;
+-#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+-  char msg_ctxt_id[msgctxt_len + msgid_len];
+-#else
+-  char buf[1024];
+-  char *msg_ctxt_id =
+-    (msgctxt_len + msgid_len <= sizeof (buf)
+-     ? buf
+-     : (char *) malloc (msgctxt_len + msgid_len));
+-  if (msg_ctxt_id != NULL)
+-#endif
+-    {
+-      memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
+-      msg_ctxt_id[msgctxt_len - 1] = '\004';
+-      memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
+-      translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
+-#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+-      if (msg_ctxt_id != buf)
+-      free (msg_ctxt_id);
+-#endif
+-      if (!(translation == msg_ctxt_id || translation == msgid_plural))
+-      return translation;
+-    }
+-  return (n == 1 ? msgid : msgid_plural);
+-}
+-
+ #endif /* _LIBGETTEXT_H */
index 5ae4e6b1ebfb3deec0b76e5fd5f2d8ca23ef88d5..e55ae541e2c7600f8c6da9a2bb4dd032b7dee132 100644 (file)
@@ -531,9 +531,9 @@ ssl3_md5 (int i, opaque * secret, int secret_len,
 }
 
 int
-_gnutls_ssl3_hash_md5 (void *first, int first_len,
-                      void *second, int second_len, int ret_len,
-                      opaque * ret)
+_gnutls_ssl3_hash_md5 (const void *first, int first_len,
+                      const void *second, int second_len,
+                      int ret_len, opaque * ret)
 {
   opaque digest[MAX_HASH_SIZE];
   digest_hd_st td;
index 8606642e43a2e8af0249d4b4b62b27a9a463d45f..8017d12f9af3b141f0167f0281fbf065cf3a3937 100644 (file)
@@ -83,8 +83,9 @@ int _gnutls_hash_fast( gnutls_digest_algorithm_t algorithm,
 int _gnutls_ssl3_generate_random (void *secret, int secret_len,
                                  void *rnd, int random_len, int bytes,
                                  opaque * ret);
-int _gnutls_ssl3_hash_md5 (void *first, int first_len, void *second,
-                          int second_len, int ret_len, opaque * ret);
+int _gnutls_ssl3_hash_md5 (const void *first, int first_len,
+                          const void *second, int second_len,
+                          int ret_len, opaque * ret);
 
 void _gnutls_mac_deinit_ssl3_handshake (digest_hd_st* handle, void *digest,
                                        opaque * key, uint32_t key_size);
index e42d2f66c4e0a1a2a621a05bd638f1559758a59f..3817ccbbc6057d1b4aab69711a2f0c81d2c90242 100644 (file)
 #include <gnutls_algorithms.h>
 #include <gnutls_rsa_export.h>
 
+/* These should really be static, but src/tests.c calls them.  Make
+   them public functions?  */
+void
+_gnutls_record_set_default_version (gnutls_session_t session,
+                                   unsigned char major, unsigned char minor);
+void
+_gnutls_rsa_pms_set_version (gnutls_session_t session,
+                            unsigned char major, unsigned char minor);
+
 void
 _gnutls_session_cert_type_set (gnutls_session_t session,
                               gnutls_certificate_type_t ct)
index b5eb31948c245f7ac8ea2e7f443bc52ec3f435cf..6b84fcae64ea7e867f659c4303413136df9e7f36 100644 (file)
@@ -55,7 +55,17 @@ int _gnutls_string_copy_str (gnutls_string * dest, const char *src);
 int _gnutls_string_append_str (gnutls_string *, const char *str);
 int _gnutls_string_append_data (gnutls_string *, const void *data,
                                size_t data_size);
-int _gnutls_string_append_printf (gnutls_string * dest, const char *fmt, ...);
+
+
+#ifndef __attribute__
+/* This feature is available in gcc versions 2.5 and later.  */
+# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
+#  define __attribute__(Spec)  /* empty */
+# endif
+#endif
+
+int _gnutls_string_append_printf (gnutls_string * dest, const char *fmt, ...)
+  __attribute__ ((format (printf, 2, 3)));
 
 typedef gnutls_string gnutls_buffer;
 
index 027f27ce06e62eaa7af8695471946aa825230e31..617cf77e834ac04a39a4679f2ba86f97baa65543 100644 (file)
@@ -186,9 +186,9 @@ print_key_times (gnutls_string * str, gnutls_openpgp_crt_t cert, int idx)
     struct tm t;
 
     if (gmtime_r (&tim, &t) == NULL)
-      addf (str, "error: gmtime_r (%d)\n", t);
+      addf (str, "error: gmtime_r (%ld)\n", (unsigned long) tim);
     else if (strftime (s, max, "%a %b %e %H:%M:%S UTC %Y", &t) == 0)
-      addf (str, "error: strftime (%d)\n", t);
+      addf (str, "error: strftime (%ld)\n", (unsigned long) tim);
     else
       addf (str, _("\t\tCreation: %s\n"), s);
   }
@@ -204,14 +204,14 @@ print_key_times (gnutls_string * str, gnutls_openpgp_crt_t cert, int idx)
 
     if (tim == 0)
       {
-       addf (str, _("\t\tExpiration: Never\n"), s);
+       addf (str, _("\t\tExpiration: Never\n"));
       }
     else
       {
        if (gmtime_r (&tim, &t) == NULL)
-         addf (str, "error: gmtime_r (%d)\n", t);
+         addf (str, "error: gmtime_r (%ld)\n", (unsigned long) tim);
        else if (strftime (s, max, "%a %b %e %H:%M:%S UTC %Y", &t) == 0)
-         addf (str, "error: strftime (%d)\n", t);
+         addf (str, "error: strftime (%ld)\n", (unsigned long) tim);
        else
          addf (str, _("\t\tExpiration: %s\n"), s);
       }
index d0337b2459736b49864a01a8f8a047b19e6ea4f8..42039db7c965bc00d7a7f1df74a3a8116a9d6475 100644 (file)
@@ -18,8 +18,8 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
 # USA
 
+AM_CFLAGS = $(WARN_CFLAGS)
 AM_CPPFLAGS = \
-       $(WARN_CFLAGS)                  \
        -I$(srcdir)/../gl               \
        -I$(builddir)/../gl             \
        -I$(srcdir)/../includes         \
index c8d99594a0731107d7794ef55f04096e99cd32fe..e714b3298e26a913649e57a272c0ad9892bae9fe 100644 (file)
@@ -673,7 +673,7 @@ _gnutls_x509_encode_and_write_attribute (const char *given_oid,
 
   if ((result = _gnutls_x509_oid_data_choice (given_oid)) > 0)
     {
-      char *string_type;
+      const char *string_type;
       int i;
 
       string_type = "printableString";
index 08f51f33396578e5b8436c3ee2ab2b69970f14e9..a8e40c94be6b435931e52a4d89a1d0002bcee683 100644 (file)
@@ -41,7 +41,7 @@
 #define addf _gnutls_string_append_printf
 #define adds _gnutls_string_append_str
 
-#define ERROR_STR "(error)"
+#define ERROR_STR (char*) "(error)"
 
 static void
 hexdump (gnutls_string * str, const char *data, size_t len, const char *spc)
@@ -940,9 +940,9 @@ print_cert (gnutls_string * str, gnutls_x509_crt_t cert, int notsigned)
       struct tm t;
 
       if (gmtime_r (&tim, &t) == NULL)
-       addf (str, "error: gmtime_r (%d)\n", t);
+       addf (str, "error: gmtime_r (%ld)\n", (unsigned long) tim);
       else if (strftime (s, max, "%a %b %d %H:%M:%S UTC %Y", &t) == 0)
-       addf (str, "error: strftime (%d)\n", t);
+       addf (str, "error: strftime (%ld)\n", (unsigned long) tim);
       else
        addf (str, _("\t\tNot Before: %s\n"), s);
     }
@@ -954,9 +954,9 @@ print_cert (gnutls_string * str, gnutls_x509_crt_t cert, int notsigned)
       struct tm t;
 
       if (gmtime_r (&tim, &t) == NULL)
-       addf (str, "error: gmtime_r (%d)\n", t);
+       addf (str, "error: gmtime_r (%ld)\n", (unsigned long) tim);
       else if (strftime (s, max, "%a %b %d %H:%M:%S UTC %Y", &t) == 0)
-       addf (str, "error: strftime (%d)\n", t);
+       addf (str, "error: strftime (%ld)\n", (unsigned long) tim);
       else
        addf (str, _("\t\tNot After: %s\n"), s);
     }
@@ -1233,9 +1233,9 @@ print_oneline (gnutls_string * str, gnutls_x509_crt_t cert)
       struct tm t;
 
       if (gmtime_r (&tim, &t) == NULL)
-       addf (str, "unknown activation (%d), ", t);
+       addf (str, "unknown activation (%ld), ", (unsigned long) tim);
       else if (strftime (s, max, "%Y-%m-%d %H:%M:%S UTC", &t) == 0)
-       addf (str, "failed activation (%d), ", t);
+       addf (str, "failed activation (%ld), ", (unsigned long) tim);
       else
        addf (str, "activated `%s', ", s);
     }
@@ -1247,9 +1247,9 @@ print_oneline (gnutls_string * str, gnutls_x509_crt_t cert)
       struct tm t;
 
       if (gmtime_r (&tim, &t) == NULL)
-       addf (str, "unknown expiry (%d), ", t);
+       addf (str, "unknown expiry (%ld), ", (unsigned long) tim);
       else if (strftime (s, max, "%Y-%m-%d %H:%M:%S UTC", &t) == 0)
-       addf (str, "failed expiry (%d), ", t);
+       addf (str, "failed expiry (%ld), ", (unsigned long) tim);
       else
        addf (str, "expires `%s', ", s);
     }
@@ -1405,9 +1405,9 @@ print_crl (gnutls_string * str, gnutls_x509_crl_t crl, int notsigned)
       struct tm t;
 
       if (gmtime_r (&tim, &t) == NULL)
-       addf (str, "error: gmtime_r (%d)\n", t);
+       addf (str, "error: gmtime_r (%ld)\n", (unsigned long) tim);
       else if (strftime (s, max, "%a %b %d %H:%M:%S UTC %Y", &t) == 0)
-       addf (str, "error: strftime (%d)\n", t);
+       addf (str, "error: strftime (%ld)\n", (unsigned long) tim);
       else
        addf (str, _("\t\tIssued: %s\n"), s);
     }
@@ -1421,9 +1421,9 @@ print_crl (gnutls_string * str, gnutls_x509_crl_t crl, int notsigned)
       if (tim == -1)
        addf (str, "\t\tNo next update time.\n");
       else if (gmtime_r (&tim, &t) == NULL)
-       addf (str, "error: gmtime_r (%d)\n", t);
+       addf (str, "error: gmtime_r (%ld)\n", (unsigned long) tim);
       else if (strftime (s, max, "%a %b %d %H:%M:%S UTC %Y", &t) == 0)
-       addf (str, "error: strftime (%d)\n", t);
+       addf (str, "error: strftime (%ld)\n", (unsigned long) tim);
       else
        addf (str, _("\t\tNext at: %s\n"), s);
     }
@@ -1582,9 +1582,9 @@ print_crl (gnutls_string * str, gnutls_x509_crl_t crl, int notsigned)
            adds (str, "\n");
 
            if (gmtime_r (&tim, &t) == NULL)
-             addf (str, "error: gmtime_r (%d)\n", t);
+             addf (str, "error: gmtime_r (%ld)\n", (unsigned long) tim);
            else if (strftime (s, max, "%a %b %d %H:%M:%S UTC %Y", &t) == 0)
-             addf (str, "error: strftime (%d)\n", t);
+             addf (str, "error: strftime (%ld)\n", (unsigned long) tim);
            else
              addf (str, _("\t\tRevoked at: %s\n"), s);
          }
index 53e2f28b7de2cd14a0d992f6cfaed13e73355450..3e5c75f5f01be273a471910be50f8ecf589ffc2b 100644 (file)
@@ -684,7 +684,7 @@ gnutls_x509_privkey_export (gnutls_x509_privkey_t key,
                            gnutls_x509_crt_fmt_t format, void *output_data,
                            size_t * output_data_size)
 {
-  char *msg;
+  const char *msg;
   int ret;
 
   if (key == NULL)
index 114c396fd58acc2052349af36d980af092c43a27..43939c82b166c2f01c8b4ace2d40ae882cf046ac 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <gnutls_int.h>
 #include <gnutls/crypto.h>
+#include <gnutls/extra.h>
 
 #include <md5.h>
 #include <hmac.h>
index 5b60e02186a3cb1bf8d0ec737838fe37c94c8d90..5a81a59b0168286e150f65452b45623e46e81fe8 100644 (file)
@@ -34,6 +34,7 @@
 #  include <lzo1x.h>
 # endif
 #endif
+#include <gnutls/extra.h>
 
 #ifdef USE_LZO
 #include <gnutls_compress.h>
index cbf928c0e5e568b82f3bb0e675f33d65c0bf6b2a..b079088f3916ffa66d12d08848d7931242598b7d 100644 (file)
@@ -849,7 +849,7 @@ SSL_CIPHER_description (SSL_CIPHER * cipher, char *buf, int size)
     {
       if (local_alloc)
        free (tmpbuf);
-      return "Buffer too small";
+      return (char*) "Buffer too small";
     }
 
   return tmpbuf;
index 0bc02b4ee083867a5a9feed6b6334fad61ec4e4d..19811bb0721e6648cabd9639a7630778e5f2fd9e 100644 (file)
@@ -21,14 +21,14 @@ EXTRA_DIST = README README.srptool
 
 SUBDIRS = cfg
 
-INCS = \
+AM_CFLAGS = $(WARN_CFLAGS)
+AM_CPPFLAGS = \
        -I$(srcdir)/../gl                       \
        -I$(builddir)/../gl                     \
        -I$(builddir)/../lib/includes           \
        -I$(srcdir)/../lib/includes             \
        -I$(srcdir)/../libextra/includes        \
        -I$(srcdir)/cfg
-AM_CPPFLAGS = $(WARN_CFLAGS) $(INCS)
 
 bin_PROGRAMS = gnutls-serv gnutls-cli psktool gnutls-cli-debug
 if ENABLE_PKI
@@ -38,43 +38,65 @@ if ENABLE_SRP
 bin_PROGRAMS += srptool
 endif
 
-gnutls_serv_SOURCES = serv.gaa serv-gaa.h serv-gaa.c list.h serv.c     \
-       common.h common.c certtool-common.h
+noinst_LTLIBRARIES =
+
+gnutls_serv_SOURCES = list.h serv.c common.h common.c certtool-common.h
 gnutls_serv_LDADD = ../lib/libgnutls.la ../libextra/libgnutls-extra.la \
-       ../gl/libgnu.la
+       ../gl/libgnu.la libcmd-serv.la
+noinst_LTLIBRARIES += libcmd-serv.la
+libcmd_serv_la_CFLAGS =
+libcmd_serv_la_SOURCES = serv.gaa serv-gaa.h serv-gaa.c
 
 if ENABLE_SRP
-srptool_SOURCES = crypt.gaa crypt-gaa.h crypt-gaa.c crypt.c
-srptool_LDADD = ../lib/libgnutls.la ../gl/libgnu.la ../lib/gl/liblgnu.la
+srptool_SOURCES = crypt.c
+srptool_LDADD = ../lib/libgnutls.la ../gl/libgnu.la ../lib/gl/liblgnu.la \
+       libcmd-srp.la
+noinst_LTLIBRARIES += libcmd-srp.la
+libcmd_srp_la_CFLAGS =
+libcmd_srp_la_SOURCES = crypt.gaa crypt-gaa.h crypt-gaa.c
 endif
 
-psktool_SOURCES = psk.gaa psk-gaa.h psk-gaa.c psk.c
-psktool_LDADD = ../lib/libgnutls.la ../gl/libgnu.la ../lib/gl/liblgnu.la
+psktool_SOURCES = psk.c
+psktool_LDADD = ../lib/libgnutls.la ../gl/libgnu.la ../lib/gl/liblgnu.la \
+       libcmd-psk.la
+noinst_LTLIBRARIES += libcmd-psk.la
+libcmd_psk_la_CFLAGS =
+libcmd_psk_la_SOURCES = psk.gaa psk-gaa.h psk-gaa.c
 
-gnutls_cli_SOURCES = cli.gaa cli-gaa.h cli-gaa.c cli.c common.h        \
-       common.c
+gnutls_cli_SOURCES = cli.c common.h common.c
 gnutls_cli_LDADD = ../lib/libgnutls.la ../libextra/libgnutls-extra.la \
-       ../gl/libgnu.la
+       ../gl/libgnu.la libcmd-cli.la
+noinst_LTLIBRARIES += libcmd-cli.la
+libcmd_cli_la_CFLAGS =
+libcmd_cli_la_SOURCES = cli.gaa cli-gaa.h cli-gaa.c
 
-gnutls_cli_debug_SOURCES = tls_test.gaa tls_test-gaa.h tls_test-gaa.c  \
-       tls_test.c tests.h tests.c common.h common.c
-gnutls_cli_debug_LDADD = ../lib/libgnutls.la ../gl/libgnu.la
+gnutls_cli_debug_SOURCES = tls_test.c tests.h tests.c common.h common.c
+gnutls_cli_debug_LDADD = ../lib/libgnutls.la ../gl/libgnu.la \
+       libcmd-cli-debug.la
+noinst_LTLIBRARIES += libcmd-cli-debug.la
+libcmd_cli_debug_la_CFLAGS =
+libcmd_cli_debug_la_SOURCES = tls_test.gaa tls_test-gaa.h tls_test-gaa.c
 
-certtool_SOURCES = certtool.gaa certtool-gaa.h certtool-cfg.h  \
-       certtool-gaa.c certtool.c prime.c certtool-cfg.c
-certtool_LDADD = ../lib/libgnutls.la ../libextra/libgnutls-extra.la \
-       ../gl/libgnu.la ../lib/gl/liblgnu.la @LTLIBREADLINE@
+certtool_SOURCES = certtool.c prime.c
+certtool_LDADD = ../lib/libgnutls.la ../libextra/libgnutls-extra.la    \
+       ../gl/libgnu.la ../lib/gl/liblgnu.la @LTLIBREADLINE@            \
+       libcmd-certtool.la
 if HAVE_LIBCFG
 certtool_LDADD += -lcfg+
 else
-noinst_LTLIBRARIES = libcfg.la
-libcfg_la_CPPFLAGS = $(INCS)
+noinst_LTLIBRARIES += libcfg.la
+libcfg_la_CFLAGS =
 libcfg_la_SOURCES = cfg/cfg+.c cfg/cfgfile.c cfg/cmdline.c cfg/parse.c \
        cfg/props.c cfg/shared.c cfg/platon/str/dynfgets.c              \
        cfg/platon/str/strctype.c cfg/platon/str/strdyn.c               \
        cfg/platon/str/strplus.c
 certtool_LDADD += libcfg.la
 endif
+noinst_LTLIBRARIES += libcmd-certtool.la
+libcmd_certtool_la_CFLAGS =
+libcmd_certtool_la_SOURCES = certtool.gaa certtool-gaa.h       \
+       certtool-gaa.c certtool-cfg.h certtool-cfg.c
+libcmd_certtool_la_LIBADD = ../gl/libgnu.la 
 
 noinst_PROGRAMS = errcodes printlist
 errcodes_SOURCES = errcodes.c
index cea711b1b7c18f85fbb78ba5f08c3ac9c4b088f8..0f0ea6e8839fb3ababc45fdf70557675d1c427ed 100644 (file)
--- a/src/cli.c
+++ b/src/cli.c
@@ -54,7 +54,7 @@
 
 /* global stuff here */
 int resume, starttls, insecure;
-char *hostname = NULL;
+const char *hostname = NULL;
 char *service;
 int record_max_size;
 int fingerprint;
@@ -895,6 +895,8 @@ gaa_parser (int argc, char **argv)
   parse_comp (info.comp, info.ncomp, comp_priority);
 }
 
+void cli_version (void);
+
 void
 cli_version (void)
 {
index 01e0fa5cc4f5e4c136210f26938913b2de5f105a..d209655986289443df7c450baba73028fcbb8a4c 100644 (file)
 # include <winbase.h>
 #endif
 
+#ifndef __attribute__
+# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
+#  define __attribute__(Spec)  /* empty */
+# endif
+#endif
+
 /* the number of elements in the priority structures.
  */
 #define PRI_MAX 16
index c36230a1d099f4eb4fe66eea38093bcac5f10fe8..8c53a01259f791af5aff49f20b39212a9a151aa9 100644 (file)
@@ -57,7 +57,6 @@ static int _verify_passwd_int (const char *username, const char *passwd,
                               const gnutls_datum_t * g,
                               const gnutls_datum_t * n);
 
-
 static void
 print_num (const char *msg, const gnutls_datum_t * num)
 {
@@ -419,9 +418,9 @@ main (int argc, char **argv)
     }
 
   if (info.passwd == NULL)
-    info.passwd = KPASSWD;
+    info.passwd = (char*) KPASSWD;
   if (info.passwd_conf == NULL)
-    info.passwd_conf = KPASSWD_CONF;
+    info.passwd_conf = (char*) KPASSWD_CONF;
 
   if (info.username == NULL)
     {
@@ -710,6 +709,8 @@ read_conf_values (gnutls_datum_t * g, gnutls_datum_t * n, char *str)
   return index;
 }
 
+extern void srptool_version(void);
+
 void
 srptool_version (void)
 {
index 213f31287e8ed3ece3c79dd82ce232ec60c0fe2e..9b07f95b9c908aed496c6a30a97905c93ea609ab 100644 (file)
@@ -39,6 +39,8 @@ extern const int buffer_size;
 
 static int cparams = 0;
 
+int generate_prime (int bits, int how);
+
 /* If how is zero then the included parameters are used.
  */
 int
index 7ce6b1b9d79915cb74c8141d5f52b3444950faa9..1ae05d01ffc7e8fd9b90ebae53c9b2922a5665ad 100644 (file)
--- a/src/psk.c
+++ b/src/psk.c
@@ -89,7 +89,7 @@ main (int argc, char **argv)
     }
 
   if (info.passwd == NULL)
-    info.passwd = KPASSWD;
+    info.passwd = (char*) KPASSWD;
 
   if (info.username == NULL)
     {
@@ -300,6 +300,8 @@ write_key (const char *username, const char *key, int key_size,
 
 #endif /* ENABLE_PSK */
 
+void psktool_version (void);
+
 void
 psktool_version (void)
 {
index dbd76c225e6533ff8e65c2cfc5191736a09162ba..e650998654517c87ab77f804dd883fda297d6457 100644 (file)
@@ -742,6 +742,8 @@ unimplemented:
   *response_length = ((*response) ? strlen (*response) : 0);
 }
 
+static void terminate (int sig) __attribute__ ((noreturn));
+
 static void
 terminate (int sig)
 {
@@ -1433,6 +1435,8 @@ gaa_parser (int argc, char **argv)
   parse_comp (info.comp, info.ncomp, comp_priority);
 }
 
+extern void serv_version(void);
+
 void
 serv_version (void)
 {
index 0f5d50151e417e6620ada5e80fe48a6f0ac25803..48c31e0114e6e969401ee380aa2a7c8ebae17418 100644 (file)
@@ -40,7 +40,7 @@
 
 /* global stuff here */
 int resume;
-char *hostname = NULL;
+const char *hostname = NULL;
 int port;
 int record_max_size;
 int fingerprint;
@@ -69,11 +69,11 @@ typedef test_code_t (*TEST_FUNC) (gnutls_session_t);
 
 typedef struct
 {
-  char *test_name;
+  const char *test_name;
   TEST_FUNC func;
-  char *suc_str;
-  char *fail_str;
-  char *unsure_str;
+  const char *suc_str;
+  const char *fail_str;
+  const char *unsure_str;
 } TLS_TEST;
 
 static const TLS_TEST tls_tests[] = {
@@ -326,6 +326,8 @@ gaa_parser (int argc, char **argv)
 
 }
 
+void tls_test_version (void);
+
 void
 tls_test_version (void)
 {
index c34a9dd83073b1078861db1b55b309b741684d74..da9e5d2277a8678fbbdc0df25a96be7c606afdaa 100644 (file)
@@ -28,8 +28,8 @@ endif
 
 EXTRA_DIST = libgcrypt.supp hostname-check.README
 
+AM_CFLAGS = $(WARN_CFLAGS)
 AM_CPPFLAGS = \
-       $(WARN_CFLAGS)                          \
        -I$(top_srcdir)/gl                      \
        -I$(top_builddir)/gl                    \
        -I$(top_srcdir)/lib/includes            \
index d2286bdb2a230f5449b81d15b4718719cf300674..2819becd54edeeca0de53315da0f40105e3043e0 100644 (file)
@@ -37,6 +37,8 @@
 #include <unistd.h>
 #include <gnutls/gnutls.h>
 
+#include "tcp.c"
+
 #include "utils.h"
 
 static void
@@ -51,46 +53,7 @@ tls_log_func (int level, const char *str)
 #define MAX_BUF 1024
 #define MSG "Hello TLS"
 
-/* Connects to the peer and returns a socket
- * descriptor.
- */
-int
-tcp_connect (void)
-{
-  const char *PORT = "5556";
-  const char *SERVER = "127.0.0.1";
-  int err, sd;
-  struct sockaddr_in sa;
-
-  /* connects to server
-   */
-  sd = socket (AF_INET, SOCK_STREAM, 0);
-
-  memset (&sa, '\0', sizeof (sa));
-  sa.sin_family = AF_INET;
-  sa.sin_port = htons (atoi (PORT));
-  inet_pton (AF_INET, SERVER, &sa.sin_addr);
-
-  err = connect (sd, (struct sockaddr *) &sa, sizeof (sa));
-  if (err < 0)
-    {
-      fprintf (stderr, "Connect error\n");
-      exit (1);
-    }
-
-  return sd;
-}
-
-/* closes the given socket descriptor.
- */
-void
-tcp_close (int sd)
-{
-  shutdown (sd, SHUT_RDWR);    /* no more receptions */
-  close (sd);
-}
-
-void
+static void
 client (void)
 {
   int ret, sd, ii;
@@ -189,7 +152,7 @@ end:
 /* These are global */
 gnutls_anon_server_credentials_t anoncred;
 
-gnutls_session_t
+static gnutls_session_t
 initialize_tls_session (void)
 {
   gnutls_session_t session;
@@ -215,7 +178,7 @@ static gnutls_dh_params_t dh_params;
 static int
 generate_dh_params (void)
 {
-  const gnutls_datum_t p3 = { pkcs3, strlen (pkcs3) };
+  const gnutls_datum_t p3 = { (char*) pkcs3, strlen (pkcs3) };
   /* Generate Diffie Hellman parameters - for use with DHE
    * kx algorithms. These should be discarded and regenerated
    * once a day, once a week or once a month. Depending on the
@@ -235,7 +198,7 @@ gnutls_session_t session;
 char buffer[MAX_BUF + 1];
 int optval = 1;
 
-void
+static void
 server_start (void)
 {
   /* Socket operations
@@ -274,7 +237,7 @@ server_start (void)
   success ("server: ready. Listening to port '%d'.\n", PORT);
 }
 
-void
+static void
 server (void)
 {
   /* this must be called once in the program
index e7fd425f1439d53994cc873eda05673b0217d282..5fd8557dafa7fd6d48344955b810e98ac02811cb 100644 (file)
 #include <gnutls/crypto.h>
 #include "../lib/random.h"
 
-void
-mylogfn (int level, const char *ptr)
-{
-  printf ("Got Logs: ");
-  if (ptr)
-    printf ("%s", ptr);
-}
-
-int
+static int
 rng_init (void **ctx)
 {
   return 0;
 }
 
-int
+static int
 rng_rnd (void *ctx, int level, void *data, size_t datasize)
 {
   memset (data, 1, datasize);
   return 0;
 }
 
-void
+static void
 rng_deinit (void *ctx)
 {
 }
index f0bf5d9d5403ec9deb0599852228912cd5ba6eaa..3d41f24c82663d2de20d0067f17dfb180a4abea5 100644 (file)
@@ -37,6 +37,8 @@
 #include <unistd.h>
 #include <gnutls/gnutls.h>
 
+#include "tcp.c"
+
 #include "utils.h"
 
 /* A very basic TLS client, with PSK authentication.
@@ -51,53 +53,14 @@ tls_log_func (int level, const char *str)
   fprintf (stderr, "|<%d>| %s", level, str);
 }
 
-/* Connects to the peer and returns a socket
- * descriptor.
- */
-int
-tcp_connect (void)
-{
-  const char *PORT = "5556";
-  const char *SERVER = "127.0.0.1";
-  int err, sd;
-  struct sockaddr_in sa;
-
-  /* connects to server
-   */
-  sd = socket (AF_INET, SOCK_STREAM, 0);
-
-  memset (&sa, '\0', sizeof (sa));
-  sa.sin_family = AF_INET;
-  sa.sin_port = htons (atoi (PORT));
-  inet_pton (AF_INET, SERVER, &sa.sin_addr);
-
-  err = connect (sd, (struct sockaddr *) &sa, sizeof (sa));
-  if (err < 0)
-    {
-      fprintf (stderr, "Connect error\n");
-      exit (1);
-    }
-
-  return sd;
-}
-
-/* closes the given socket descriptor.
- */
-void
-tcp_close (int sd)
-{
-  shutdown (sd, SHUT_RDWR);    /* no more receptions */
-  close (sd);
-}
-
-void
+static void
 client (void)
 {
   int ret, sd, ii;
   gnutls_session_t session;
   char buffer[MAX_BUF + 1];
   gnutls_psk_client_credentials_t pskcred;
-  const gnutls_datum_t key = { "DEADBEEF", 8 };
+  const gnutls_datum_t key = { (char*) "DEADBEEF", 8 };
 
   gnutls_global_init ();
 
@@ -183,7 +146,7 @@ end:
 /* These are global */
 gnutls_psk_server_credentials_t server_pskcred;
 
-gnutls_session_t
+static gnutls_session_t
 initialize_tls_session (void)
 {
   gnutls_session_t session;
@@ -205,7 +168,7 @@ static gnutls_dh_params_t dh_params;
 static int
 generate_dh_params (void)
 {
-  const gnutls_datum_t p3 = { pkcs3, strlen (pkcs3) };
+  const gnutls_datum_t p3 = { (char*) pkcs3, strlen (pkcs3) };
   /* Generate Diffie Hellman parameters - for use with DHE
    * kx algorithms. These should be discarded and regenerated
    * once a day, once a week or once a month. Depending on the
@@ -238,7 +201,7 @@ gnutls_session_t session;
 char buffer[MAX_BUF + 1];
 int optval = 1;
 
-void
+static void
 server_start (void)
 {
   success ("Launched, generating DH parameters...\n");
@@ -279,7 +242,7 @@ server_start (void)
   success ("server: ready. Listening to port '%d'.\n", PORT);
 }
 
-void
+static void
 server (void)
 {
   /* this must be called once in the program
index 5528312b98a4fea8db862ab1b7f9bf513dd91afc..abae0776654f8b15e42afb8b76a279b993134029 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006, 2007 Free Software Foundation
+ * Copyright (C) 2006, 2007, 2008 Free Software Foundation
  * Author: Simon Josefsson, Howard Chu
  *
  * This file is part of GNUTLS.
@@ -59,7 +59,7 @@ static char pem[] =
   "bHarWgDg9CKVP1DggVkcD838s//kE1Vl2DReyfAtEQ1agSXLFncgxL+yOi1o3lcq\n"
   "+dmDgpDn168TY1Iug80uVKg7AfkLrA==\n" "-----END CERTIFICATE-----\n";
 
-void
+static void
 print_dn (gnutls_x509_dn_t dn)
 {
   int i, j, ret = 0;
index 4d82cd54030902697f2c1744486dd5315cba3946..5a5810ff4b314f0abf714ee7d1df831ded0aff93 100644 (file)
@@ -46,7 +46,7 @@ size_t to_server_len;
 char *to_client;
 size_t to_client_len;
 
-ssize_t
+static ssize_t
 client_pull (gnutls_transport_ptr_t tr, void *data, size_t len)
 {
   success ("client_pull len %d has %d\n", len, to_client_len);
@@ -65,7 +65,7 @@ client_pull (gnutls_transport_ptr_t tr, void *data, size_t len)
   return len;
 }
 
-ssize_t
+static ssize_t
 client_push (gnutls_transport_ptr_t tr, const void *data, size_t len)
 {
   size_t newlen = to_server_len + len;
@@ -88,7 +88,7 @@ client_push (gnutls_transport_ptr_t tr, const void *data, size_t len)
   return len;
 }
 
-ssize_t
+static ssize_t
 server_pull (gnutls_transport_ptr_t tr, void *data, size_t len)
 {
   success ("server_pull len %d has %d\n", len, to_server_len);
@@ -107,7 +107,7 @@ server_pull (gnutls_transport_ptr_t tr, void *data, size_t len)
   return len;
 }
 
-ssize_t
+static ssize_t
 server_push (gnutls_transport_ptr_t tr, const void *data, size_t len)
 {
   size_t newlen = to_client_len + len;
@@ -131,7 +131,7 @@ server_push (gnutls_transport_ptr_t tr, const void *data, size_t len)
   return len;
 }
 
-void
+static void
 client_finished_callback (gnutls_session_t session,
                          const void *finished, size_t len)
 {
@@ -139,7 +139,7 @@ client_finished_callback (gnutls_session_t session,
   hexprint (finished, len);
 }
 
-void
+static void
 server_finished_callback (gnutls_session_t session,
                          const void *finished, size_t len)
 {
@@ -155,7 +155,7 @@ doit (void)
 {
   /* Server stuff. */
   gnutls_anon_server_credentials_t s_anoncred;
-  const gnutls_datum_t p3 = { pkcs3, strlen (pkcs3) };
+  const gnutls_datum_t p3 = { (char*) pkcs3, strlen (pkcs3) };
   static gnutls_dh_params_t dh_params;
   gnutls_session_t server;
   int sret = GNUTLS_E_AGAIN;
index 777a4a89923a26758b7ce243553165dd3836f988..70c61805253db6ff1841a382b1261c635579ab97 100644 (file)
 #include "../lib/x509/pbkdf2-sha1.h"
 #include "../lib/debug.h"
 
-int
-is_secure_mem (const void *ign)
-{
-  return 0;
-}
-
 void
 doit (void)
 {
index edda9f96b6e7f74238b84d1883b9bda4e6b80527..b64401db62ed7f5326ef1e1f4c5323b57c6c4525 100644 (file)
@@ -44,7 +44,7 @@ size_t to_server_len;
 char *to_client;
 size_t to_client_len;
 
-ssize_t
+static ssize_t
 client_pull (gnutls_transport_ptr_t tr, void *data, size_t len)
 {
   success ("client_pull len %d has %d\n", len, to_client_len);
@@ -63,7 +63,7 @@ client_pull (gnutls_transport_ptr_t tr, void *data, size_t len)
   return len;
 }
 
-ssize_t
+static ssize_t
 client_push (gnutls_transport_ptr_t tr, const void *data, size_t len)
 {
   size_t newlen = to_server_len + len;
@@ -86,7 +86,7 @@ client_push (gnutls_transport_ptr_t tr, const void *data, size_t len)
   return len;
 }
 
-ssize_t
+static ssize_t
 server_pull (gnutls_transport_ptr_t tr, void *data, size_t len)
 {
   success ("server_pull len %d has %d\n", len, to_server_len);
@@ -105,7 +105,7 @@ server_pull (gnutls_transport_ptr_t tr, void *data, size_t len)
   return len;
 }
 
-ssize_t
+static ssize_t
 server_push (gnutls_transport_ptr_t tr, const void *data, size_t len)
 {
   size_t newlen = to_client_len + len;
@@ -137,7 +137,7 @@ doit (void)
 {
   /* Server stuff. */
   gnutls_anon_server_credentials_t s_anoncred;
-  const gnutls_datum_t p3 = { pkcs3, strlen (pkcs3) };
+  const gnutls_datum_t p3 = { (char*) pkcs3, strlen (pkcs3) };
   static gnutls_dh_params_t dh_params;
   gnutls_session_t server;
   int sret = GNUTLS_E_AGAIN;
index b399a111e8efc4e8e11a8dd96e91fc444f546b03..fc802880cb29e5b3254af23cbe434047197bee70 100644 (file)
@@ -42,6 +42,7 @@
 
 #include "ex-session-info.c"
 #include "ex-x509-info.c"
+#include "tcp.c"
 
 pid_t child;
 
@@ -57,45 +58,6 @@ tls_log_func (int level, const char *str)
 #define MAX_BUF 1024
 #define MSG "Hello TLS"
 
-/* Connects to the peer and returns a socket
- * descriptor.
- */
-int
-tcp_connect (void)
-{
-  const char *PORT = "5556";
-  const char *SERVER = "127.0.0.1";
-  int err, sd;
-  struct sockaddr_in sa;
-
-  /* connects to server
-   */
-  sd = socket (AF_INET, SOCK_STREAM, 0);
-
-  memset (&sa, '\0', sizeof (sa));
-  sa.sin_family = AF_INET;
-  sa.sin_port = htons (atoi (PORT));
-  inet_pton (AF_INET, SERVER, &sa.sin_addr);
-
-  err = connect (sd, (struct sockaddr *) &sa, sizeof (sa));
-  if (err < 0)
-    {
-      fprintf (stderr, "Connect error\n");
-      exit (1);
-    }
-
-  return sd;
-}
-
-/* closes the given socket descriptor.
- */
-void
-tcp_close (int sd)
-{
-  shutdown (sd, SHUT_RDWR);    /* no more receptions */
-  close (sd);
-}
-
 static unsigned char cert_txt[] =
   "-----BEGIN PGP PUBLIC KEY BLOCK-----\n"
   "Version: GnuPG v1.0.6 (GNU/Linux)\n"
@@ -139,7 +101,7 @@ static unsigned char key_txt[] =
   "=4M0W\n" "-----END PGP PRIVATE KEY BLOCK-----\n";
 const gnutls_datum_t key = { key_txt, sizeof (key_txt) };
 
-void
+static void
 client (void)
 {
   int ret, sd, ii;
@@ -249,7 +211,7 @@ end:
 /* These are global */
 gnutls_certificate_credentials_t pgp_cred;
 
-gnutls_session_t
+static gnutls_session_t
 initialize_tls_session (void)
 {
   gnutls_session_t session;
@@ -277,7 +239,7 @@ static gnutls_dh_params_t dh_params;
 static int
 generate_dh_params (void)
 {
-  const gnutls_datum_t p3 = { pkcs3, strlen (pkcs3) };
+  const gnutls_datum_t p3 = { (char*) pkcs3, strlen (pkcs3) };
   /* Generate Diffie Hellman parameters - for use with DHE
    * kx algorithms. These should be discarded and regenerated
    * once a day, once a week or once a month. Depending on the
@@ -372,7 +334,7 @@ static unsigned char server_key_txt[] =
   "=mZnW\n" "-----END PGP PRIVATE KEY BLOCK-----\n";
 const gnutls_datum_t server_key = { server_key_txt, sizeof (server_key_txt) };
 
-void
+static void
 server_start (void)
 {
   /* Socket operations
@@ -411,7 +373,7 @@ server_start (void)
   success ("server: ready. Listening to port '%d'.\n", PORT);
 }
 
-void
+static void
 server (void)
 {
   /* this must be called once in the program
index 03d1c66be93844673769672c9c96eb3c4a98c73c..f576137b356dd1834137d07a2e979ce3dca1d9ce 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007 Free Software Foundation
+ * Copyright (C) 2007, 2008 Free Software Foundation
  *
  * Author: Simon Josefsson
  *
@@ -37,10 +37,10 @@ tls_log_func (int level, const char *str)
   fprintf (stderr, "|<%d>| %s", level, str);
 }
 
-char *salt[3] = { "salt1", "ltsa22", "balt33" };
-char *pw[3] = { "secret1", "verysecret2", "veryverysecret3" };
+static const char *salt[3] = { "salt1", "ltsa22", "balt33" };
+static const char *pw[3] = { "secret1", "verysecret2", "veryverysecret3" };
 
-char *values[] = {
+static const char *values[] = {
 /* 1.0 */
   "85a3c676a66f0960f4807144a28c8d61a0001b81846f301a1ac164289879972f",
 /* 1.2 */
index 107b4e43245913f54bbac7ab07509d92e523869b..3fb3c5875abc5183655d5acbd46d1794ee8b6604 100644 (file)
@@ -37,6 +37,8 @@
 #include <unistd.h>
 #include <gnutls/gnutls.h>
 
+#include "tcp.c"
+
 #include "utils.h"
 
 /* A very basic TLS client, with PSK authentication.
 #define MAX_BUF 1024
 #define MSG "Hello TLS"
 
-/* Connects to the peer and returns a socket
- * descriptor.
- */
-int
-tcp_connect (void)
-{
-  const char *PORT = "5556";
-  const char *SERVER = "127.0.0.1";
-  int err, sd;
-  struct sockaddr_in sa;
-
-  /* connects to server
-   */
-  sd = socket (AF_INET, SOCK_STREAM, 0);
-
-  memset (&sa, '\0', sizeof (sa));
-  sa.sin_family = AF_INET;
-  sa.sin_port = htons (atoi (PORT));
-  inet_pton (AF_INET, SERVER, &sa.sin_addr);
-
-  err = connect (sd, (struct sockaddr *) &sa, sizeof (sa));
-  if (err < 0)
-    {
-      fprintf (stderr, "Connect error\n");
-      exit (1);
-    }
-
-  return sd;
-}
-
-/* closes the given socket descriptor.
- */
-void
-tcp_close (int sd)
-{
-  shutdown (sd, SHUT_RDWR);    /* no more receptions */
-  close (sd);
-}
-
-void
+static void
 client (void)
 {
   int ret, sd, ii;
@@ -93,7 +56,7 @@ client (void)
   gnutls_psk_client_credentials_t pskcred;
   /* Need to enable anonymous KX specifically. */
   const int kx_prio[] = { GNUTLS_KX_PSK, 0 };
-  const gnutls_datum_t key = { "DEADBEEF", 8 };
+  const gnutls_datum_t key = { (char*) "DEADBEEF", 8 };
 
   gnutls_global_init ();
 
@@ -181,7 +144,7 @@ end:
 /* These are global */
 gnutls_psk_server_credentials_t server_pskcred;
 
-gnutls_session_t
+static gnutls_session_t
 initialize_tls_session (void)
 {
   gnutls_session_t session;
@@ -223,7 +186,7 @@ gnutls_session_t session;
 char buffer[MAX_BUF + 1];
 int optval = 1;
 
-void
+static void
 server_start (void)
 {
   success ("Launched...\n");
@@ -264,7 +227,7 @@ server_start (void)
   success ("server: ready. Listening to port '%d'.\n", PORT);
 }
 
-void
+static void
 server (void)
 {
   /* this must be called once in the program
index 2dd656fee1164fa33f9d972ff715d775ba5e3555..b70bac444bc8f0c7e3bb6c07913fafefc921d65a 100644 (file)
@@ -37,6 +37,8 @@
 #include <unistd.h>
 #include <gnutls/gnutls.h>
 
+#include "tcp.c"
+
 #include "utils.h"
 
 static void wrap_db_init (void);
@@ -53,46 +55,7 @@ static int wrap_db_delete (void *dbf, gnutls_datum_t key);
 #define MAX_BUF 1024
 #define MSG "Hello TLS"
 
-/* Connects to the peer and returns a socket
- * descriptor.
- */
-int
-tcp_connect (void)
-{
-  const char *PORT = "5556";
-  const char *SERVER = "127.0.0.1";
-  int err, sd;
-  struct sockaddr_in sa;
-
-  /* connects to server
-   */
-  sd = socket (AF_INET, SOCK_STREAM, 0);
-
-  memset (&sa, '\0', sizeof (sa));
-  sa.sin_family = AF_INET;
-  sa.sin_port = htons (atoi (PORT));
-  inet_pton (AF_INET, SERVER, &sa.sin_addr);
-
-  err = connect (sd, (struct sockaddr *) &sa, sizeof (sa));
-  if (err < 0)
-    {
-      fprintf (stderr, "Connect error\n");
-      exit (1);
-    }
-
-  return sd;
-}
-
-/* closes the given socket descriptor.
- */
-void
-tcp_close (int sd)
-{
-  shutdown (sd, SHUT_RDWR);    /* no more receptions */
-  close (sd);
-}
-
-void
+static void
 client (void)
 {
   int ret, sd, ii;
@@ -223,7 +186,7 @@ client (void)
 /* These are global */
 gnutls_anon_server_credentials_t anoncred;
 
-gnutls_session_t
+static gnutls_session_t
 initialize_tls_session (void)
 {
   gnutls_session_t session;
@@ -257,7 +220,7 @@ static gnutls_dh_params_t dh_params;
 static int
 generate_dh_params (void)
 {
-  const gnutls_datum_t p3 = { pkcs3, strlen (pkcs3) };
+  const gnutls_datum_t p3 = { (char*) pkcs3, strlen (pkcs3) };
   /* Generate Diffie Hellman parameters - for use with DHE
    * kx algorithms. These should be discarded and regenerated
    * once a day, once a week or once a month. Depending on the
@@ -277,7 +240,7 @@ gnutls_session_t session;
 char buffer[MAX_BUF + 1];
 int optval = 1;
 
-void
+static void
 global_start (void)
 {
   /* Socket operations
@@ -316,7 +279,7 @@ global_start (void)
   success ("server: ready. Listening to port '%d'.\n", PORT);
 }
 
-void
+static void
 global_stop (void)
 {
   success ("global stop\n");
@@ -328,7 +291,7 @@ global_stop (void)
   gnutls_global_deinit ();
 }
 
-void
+static void
 server (void)
 {
   size_t t;
index c0349a24c3c5673d6413e62072d4a1c1a0b56c8d..ebdf8b111e7f641ef7a631907a941d67083af0b6 100644 (file)
@@ -32,7 +32,7 @@ void
 doit (void)
 {
   gnutls_certificate_credentials_t x509cred;
-  char *file, *password;
+  const char *file, *password;
   int ret;
 
   ret = gnutls_global_init ();
index 80e82be31180170d13b3b77f99655635d3d33b92..3b03b251bcbff2a0f74ae8eb67795a5c8fcb3650 100644 (file)
@@ -40,6 +40,8 @@
 
 #include "utils.h"
 
+#include "tcp.c"
+
 #include <readline.h>
 
 /* A very basic TLS client, with anonymous authentication.
 #define MAX_BUF 1024
 #define MSG "Hello TLS"
 
-/* Connects to the peer and returns a socket
- * descriptor.
- */
-int
-tcp_connect (void)
-{
-  const char *PORT = "5556";
-  const char *SERVER = "127.0.0.1";
-  int err, sd;
-  struct sockaddr_in sa;
-
-  /* connects to server
-   */
-  sd = socket (AF_INET, SOCK_STREAM, 0);
-
-  memset (&sa, '\0', sizeof (sa));
-  sa.sin_family = AF_INET;
-  sa.sin_port = htons (atoi (PORT));
-  inet_pton (AF_INET, SERVER, &sa.sin_addr);
-
-  err = connect (sd, (struct sockaddr *) &sa, sizeof (sa));
-  if (err < 0)
-    {
-      fprintf (stderr, "Connect error\n");
-      exit (1);
-    }
-
-  return sd;
-}
-
-/* closes the given socket descriptor.
- */
-void
-tcp_close (int sd)
-{
-  shutdown (sd, SHUT_RDWR);    /* no more receptions */
-  close (sd);
-}
-
-int
+static int
 client_avp (gnutls_session_t session, void *ptr,
            const char *last, size_t lastlen, char **new, size_t * newlen)
 {
   static int iter = 0;
-  char *p;
+  const char *p;
 
   if (last)
     printf ("client: received %d bytes AVP: `%.*s'\n",
@@ -137,7 +100,7 @@ client_avp (gnutls_session_t session, void *ptr,
   return 0;
 }
 
-void
+static void
 client (void)
 {
   int ret, sd, ii;
@@ -273,7 +236,7 @@ end:
 gnutls_anon_server_credentials_t anoncred;
 gnutls_ia_server_credentials_t iacred;
 
-gnutls_session_t
+static gnutls_session_t
 initialize_tls_session (void)
 {
   gnutls_session_t session;
@@ -299,7 +262,7 @@ static gnutls_dh_params_t dh_params;
 static int
 generate_dh_params (void)
 {
-  const gnutls_datum_t p3 = { pkcs3, strlen (pkcs3) };
+  const gnutls_datum_t p3 = { (char*) pkcs3, strlen (pkcs3) };
   /* Generate Diffie Hellman parameters - for use with DHE
    * kx algorithms. These should be discarded and regenerated
    * once a day, once a week or once a month. Depending on the
@@ -319,12 +282,12 @@ gnutls_session_t session;
 char buffer[MAX_BUF + 1];
 int optval = 1;
 
-int
+static int
 server_avp (gnutls_session_t session, void *ptr,
            const char *last, size_t lastlen, char **new, size_t * newlen)
 {
   static int iter = 0;
-  char *p;
+  const char *p;
 
   if (last)
     printf ("server: received %d bytes AVP: `%.*s'\n",
@@ -397,7 +360,7 @@ server_avp (gnutls_session_t session, void *ptr,
   return 0;
 }
 
-void
+static void
 server_start (void)
 {
   /* Socket operations
@@ -436,7 +399,7 @@ server_start (void)
   success ("server: ready. Listening to port '%d'\n", PORT);
 }
 
-void
+static void
 server (void)
 {
   /* this must be called once in the program
index 3630318bb4e05606e4f9fff0a782f84dfab8d877..441a9d0511ac1cd904d88c7b254f4a2d2fe84e07 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation
  *
  * Author: Simon Josefsson
  *
@@ -33,7 +33,7 @@ int debug = 0;
 int error_count = 0;
 int break_on_error = 0;
 
-char *pkcs3 =
+const char *pkcs3 =
   "-----BEGIN DH PARAMETERS-----\n"
   "MIGGAoGAtkxw2jlsVCsrfLqxrN+IrF/3W8vVFvDzYbLmxi2GQv9s/PQGWP1d9i22\n"
   "P2DprfcJknWt7KhCI1SaYseOQIIIAYP78CfyIpGScW/vS8khrw0rlQiyeCvQgF3O\n"
index 88d100f73d5e323cba73288cdfbb11c899b8afec..cb3c57b6eee88fa6bf11d2eee78575009abe7800 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2004, 2005, 2007 Free Software Foundation
+ * Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation
  *
  * Author: Simon Josefsson
  *
 # include <stdarg.h>
 # include <gnutls/gnutls.h>
 
+#ifndef __attribute__
+# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
+#  define __attribute__(Spec)  /* empty */
+# endif
+#endif
+
 extern int debug;
 extern int error_count;
 extern int break_on_error;
 
-extern char *pkcs3;
+extern const char *pkcs3;
 
-extern void fail (const char *format, ...);
-extern void success (const char *format, ...);
+extern void fail (const char *format, ...)
+  __attribute__ ((format (printf, 1, 2)));
+extern void success (const char *format, ...)
+  __attribute__ ((format (printf, 1, 2)));
 
 extern void escapeprint (const char *str, size_t len);
 extern void hexprint (const char *str, size_t len);
index 9434ee9979a94c03f803832bbdf1182cc715beae..27ad6f1cd43c842b064d005b99df1ab48a0d8199 100644 (file)
@@ -41,6 +41,7 @@
 
 #include "ex-session-info.c"
 #include "ex-x509-info.c"
+#include "tcp.c"
 
 pid_t child;
 
@@ -56,45 +57,6 @@ tls_log_func (int level, const char *str)
 #define MAX_BUF 1024
 #define MSG "Hello TLS"
 
-/* Connects to the peer and returns a socket
- * descriptor.
- */
-int
-tcp_connect (void)
-{
-  const char *PORT = "5556";
-  const char *SERVER = "127.0.0.1";
-  int err, sd;
-  struct sockaddr_in sa;
-
-  /* connects to server
-   */
-  sd = socket (AF_INET, SOCK_STREAM, 0);
-
-  memset (&sa, '\0', sizeof (sa));
-  sa.sin_family = AF_INET;
-  sa.sin_port = htons (atoi (PORT));
-  inet_pton (AF_INET, SERVER, &sa.sin_addr);
-
-  err = connect (sd, (struct sockaddr *) &sa, sizeof (sa));
-  if (err < 0)
-    {
-      fprintf (stderr, "Connect error\n");
-      exit (1);
-    }
-
-  return sd;
-}
-
-/* closes the given socket descriptor.
- */
-void
-tcp_close (int sd)
-{
-  shutdown (sd, SHUT_RDWR);    /* no more receptions */
-  close (sd);
-}
-
 static unsigned char ca_pem[] =
   "-----BEGIN CERTIFICATE-----\n"
   "MIIB5zCCAVKgAwIBAgIERiYdJzALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
@@ -210,7 +172,7 @@ cert_callback (gnutls_session session,
 }
 
 
-void
+static void
 client (void)
 {
   int ret, sd, ii;
@@ -315,7 +277,7 @@ end:
 /* These are global */
 gnutls_certificate_credentials_t x509_cred;
 
-gnutls_session_t
+static gnutls_session_t
 initialize_tls_session (void)
 {
   gnutls_session_t session;
@@ -343,7 +305,7 @@ static gnutls_dh_params_t dh_params;
 static int
 generate_dh_params (void)
 {
-  const gnutls_datum_t p3 = { pkcs3, strlen (pkcs3) };
+  const gnutls_datum_t p3 = { (char*) pkcs3, strlen (pkcs3) };
   /* Generate Diffie Hellman parameters - for use with DHE
    * kx algorithms. These should be discarded and regenerated
    * once a day, once a week or once a month. Depending on the
@@ -405,7 +367,7 @@ const gnutls_datum_t server_key = { server_key_pem,
   sizeof (server_key_pem)
 };
 
-void
+static void
 server_start (void)
 {
   /* Socket operations
@@ -444,7 +406,7 @@ server_start (void)
   success ("server: ready. Listening to port '%d'.\n", PORT);
 }
 
-void
+static void
 server (void)
 {
   /* this must be called once in the program
index 1d6c26e045c342bf8ad07fcdcf11b8a0933a5586..fd951901567af0d6c168e291cdc39fdb3ee63d81 100644 (file)
@@ -41,6 +41,7 @@
 
 #include "ex-session-info.c"
 #include "ex-x509-info.c"
+#include "tcp.c"
 
 pid_t child;
 
@@ -56,45 +57,6 @@ tls_log_func (int level, const char *str)
 #define MAX_BUF 1024
 #define MSG "Hello TLS"
 
-/* Connects to the peer and returns a socket
- * descriptor.
- */
-int
-tcp_connect (void)
-{
-  const char *PORT = "5556";
-  const char *SERVER = "127.0.0.1";
-  int err, sd;
-  struct sockaddr_in sa;
-
-  /* connects to server
-   */
-  sd = socket (AF_INET, SOCK_STREAM, 0);
-
-  memset (&sa, '\0', sizeof (sa));
-  sa.sin_family = AF_INET;
-  sa.sin_port = htons (atoi (PORT));
-  inet_pton (AF_INET, SERVER, &sa.sin_addr);
-
-  err = connect (sd, (struct sockaddr *) &sa, sizeof (sa));
-  if (err < 0)
-    {
-      fprintf (stderr, "Connect error\n");
-      exit (1);
-    }
-
-  return sd;
-}
-
-/* closes the given socket descriptor.
- */
-void
-tcp_close (int sd)
-{
-  shutdown (sd, SHUT_RDWR);    /* no more receptions */
-  close (sd);
-}
-
 static unsigned char ca_pem[] =
   "-----BEGIN CERTIFICATE-----\n"
   "MIIB5zCCAVKgAwIBAgIERiYdJzALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
@@ -144,7 +106,7 @@ static unsigned char key_pem[] =
   "-----END RSA PRIVATE KEY-----\n";
 const gnutls_datum_t key = { key_pem, sizeof (key_pem) };
 
-void
+static void
 client (void)
 {
   int ret, sd, ii;
@@ -249,7 +211,7 @@ end:
 /* These are global */
 gnutls_certificate_credentials_t x509_cred;
 
-gnutls_session_t
+static gnutls_session_t
 initialize_tls_session (void)
 {
   gnutls_session_t session;
@@ -277,7 +239,7 @@ static gnutls_dh_params_t dh_params;
 static int
 generate_dh_params (void)
 {
-  const gnutls_datum_t p3 = { pkcs3, strlen (pkcs3) };
+  const gnutls_datum_t p3 = { (char*) pkcs3, strlen (pkcs3) };
   /* Generate Diffie Hellman parameters - for use with DHE
    * kx algorithms. These should be discarded and regenerated
    * once a day, once a week or once a month. Depending on the
@@ -339,7 +301,7 @@ const gnutls_datum_t server_key = { server_key_pem,
   sizeof (server_key_pem)
 };
 
-void
+static void
 server_start (void)
 {
   /* Socket operations
@@ -378,7 +340,7 @@ server_start (void)
   success ("server: ready. Listening to port '%d'.\n", PORT);
 }
 
-void
+static void
 server (void)
 {
   /* this must be called once in the program
index 7920cc6f00364ce4f46846f3c9687dec81dc983d..7b1586a1493e5930aa7aa9de20b562fb220f0c2c 100644 (file)
@@ -40,7 +40,7 @@
 
 #include "ex-session-info.c"
 #include "ex-x509-info.c"
-extern int print_info (gnutls_session_t session);
+#include "tcp.c"
 
 #include "utils.h"
 
@@ -58,45 +58,6 @@ tls_log_func (int level, const char *str)
 #define MAX_BUF 1024
 #define MSG "Hello TLS"
 
-/* Connects to the peer and returns a socket
- * descriptor.
- */
-int
-tcp_connect (void)
-{
-  const char *PORT = "5556";
-  const char *SERVER = "127.0.0.1";
-  int err, sd;
-  struct sockaddr_in sa;
-
-  /* connects to server
-   */
-  sd = socket (AF_INET, SOCK_STREAM, 0);
-
-  memset (&sa, '\0', sizeof (sa));
-  sa.sin_family = AF_INET;
-  sa.sin_port = htons (atoi (PORT));
-  inet_pton (AF_INET, SERVER, &sa.sin_addr);
-
-  err = connect (sd, (struct sockaddr *) &sa, sizeof (sa));
-  if (err < 0)
-    {
-      fprintf (stderr, "Connect error\n");
-      exit (1);
-    }
-
-  return sd;
-}
-
-/* closes the given socket descriptor.
- */
-void
-tcp_close (int sd)
-{
-  shutdown (sd, SHUT_RDWR);    /* no more receptions */
-  close (sd);
-}
-
 static char ca_pem[] =
   "-----BEGIN CERTIFICATE-----\n"
   "MIIB5zCCAVKgAwIBAgIERiYdJzALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
@@ -128,7 +89,7 @@ static char cert_pem[] =
   "dc8Siq5JojruiMizAf0pA7in\n" "-----END CERTIFICATE-----\n";
 const gnutls_datum_t cert = { cert_pem, sizeof (cert_pem) };
 
-int
+static int
 sign_func (gnutls_session_t session,
           void *userdata,
           gnutls_certificate_type_t cert_type,
@@ -174,7 +135,7 @@ done:
   return ret;
 }
 
-void
+static void
 client (void)
 {
   int ret, sd, ii;
@@ -282,7 +243,7 @@ end:
 /* These are global */
 gnutls_certificate_credentials_t x509_cred;
 
-gnutls_session_t
+static gnutls_session_t
 initialize_tls_session (void)
 {
   gnutls_session_t session;
@@ -310,7 +271,7 @@ static gnutls_dh_params_t dh_params;
 static int
 generate_dh_params (void)
 {
-  const gnutls_datum_t p3 = { pkcs3, strlen (pkcs3) };
+  const gnutls_datum_t p3 = { (char*) pkcs3, strlen (pkcs3) };
   /* Generate Diffie Hellman parameters - for use with DHE
    * kx algorithms. These should be discarded and regenerated
    * once a day, once a week or once a month. Depending on the
@@ -371,7 +332,7 @@ const gnutls_datum_t server_key = { server_key_pem,
   sizeof (server_key_pem)
 };
 
-void
+static void
 server_start (void)
 {
   /* Socket operations
@@ -410,7 +371,7 @@ server_start (void)
   success ("server: ready. Listening to port '%d'.\n", PORT);
 }
 
-void
+static void
 server (void)
 {
   /* this must be called once in the program