]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Use minmax.h from gnulib instead of GMIN/GMAX.
authorSimon Josefsson <simon@josefsson.org>
Tue, 17 Aug 2004 08:45:00 +0000 (08:45 +0000)
committerSimon Josefsson <simon@josefsson.org>
Tue, 17 Aug 2004 08:45:00 +0000 (08:45 +0000)
17 files changed:
configure.in
gl/Makefile.am
gl/m4/gnulib.m4
gl/minmax.h [new file with mode: 0644]
lib/Makefile.am
lib/auth_srp_passwd.c
lib/ext_srp.c
lib/gnutls_buffers.c
lib/gnutls_num.h
lib/gnutls_pk.c
lib/gnutls_str.c
lib/x509/dn.c
lib/x509/pkcs12.c
lib/x509/privkey_pkcs8.c
lib/x509/sign.c
lib/x509/verify.c
libextra/Makefile.am

index 262e1625676a436e0cf4fe4fd93cceb781fd6589..30dbf91de6598b6eae685d52cc9e1450c4cfa2ba 100644 (file)
@@ -608,7 +608,7 @@ AC_MSG_RESULT([***
 
 gl_SOURCE_BASE(gl)
 gl_M4_BASE(gl/m4)
-gl_MODULES(getline error exit progname getpass-gnu)
+gl_MODULES(getline error exit progname getpass-gnu minmax)
 gl_INIT
 
 AC_MSG_RESULT([***
index b20d924c29f0eedf30deb336dec730d68a2a517d..f59ed59af8981e9d86f2507501cfc23f74ac04af 100644 (file)
@@ -10,7 +10,7 @@
 # Generated by gnulib-tool.
 #
 # Invoked as: gnulib-tool --import
-# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --libtool error exit extensions getline getpass-gnu gettext progname stdbool unlocked-io
+# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --libtool error exit extensions getline getpass-gnu gettext minmax progname stdbool unlocked-io
 
 AUTOMAKE_OPTIONS = 1.8 gnits
 
@@ -36,6 +36,8 @@ libgnu_la_SOURCES += getpass.h
 
 libgnu_la_SOURCES += gettext.h
 
+libgnu_la_SOURCES += minmax.h
+
 libgnu_la_SOURCES += progname.h progname.c
 
 BUILT_SOURCES += $(STDBOOL_H)
index 9992333439835cf2196e4e0a621a2f3288a5bd1a..fe1625e28af1a73ef6be7a2d7f6427f0516a181c 100644 (file)
@@ -8,7 +8,7 @@
 # Generated by gnulib-tool.
 #
 # Invoked as: gnulib-tool --import
-# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --libtool error exit extensions getline getpass-gnu gettext progname stdbool unlocked-io
+# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --libtool error exit extensions getline getpass-gnu gettext minmax progname stdbool unlocked-io
 
 AC_DEFUN([gl_EARLY],
 [
diff --git a/gl/minmax.h b/gl/minmax.h
new file mode 100644 (file)
index 0000000..0e50510
--- /dev/null
@@ -0,0 +1,53 @@
+/* MIN, MAX macros.
+   Copyright (C) 1995, 1998, 2001, 2003 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+
+#ifndef _MINMAX_H
+#define _MINMAX_H
+
+/* Note: MIN, MAX are also defined in <sys/param.h> on some systems
+   (glibc, IRIX, HP-UX, OSF/1).  Therefore you might get warnings about
+   MIN, MAX macro redefinitions on some systems; the workaround is to
+   #include this file as the last one among the #include list.  */
+
+/* Before we define the following symbols we get the <limits.h> file
+   since otherwise we get redefinitions on some systems.  */
+#include <limits.h>
+
+/* Note: MIN and MAX should be used with two arguments of the
+   same type.  They might not return the minimum and maximum of their two
+   arguments, if the arguments have different types or have unusual
+   floating-point values.  For example, on a typical host with 32-bit 'int',
+   64-bit 'long long', and 64-bit IEEE 754 'double' types:
+
+     MAX (-1, 2147483648) returns 4294967295.
+     MAX (9007199254740992.0, 9007199254740993) returns 9007199254740992.0.
+     MAX (NaN, 0.0) returns 0.0.
+     MAX (+0.0, -0.0) returns -0.0.
+
+   and in each case the answer is in some sense bogus.  */
+
+/* MAX(a,b) returns the maximum of A and B.  */
+#ifndef MAX
+# define MAX(a,b) ((a) > (b) ? (a) : (b))
+#endif
+
+/* MIN(a,b) returns the minimum of A and B.  */
+#ifndef MIN
+# define MIN(a,b) ((a) < (b) ? (a) : (b))
+#endif
+
+#endif /* _MINMAX_H */
index 4614a06b89a7a31b8b5c89894f09be341a1feef2..ced732377873d529b8507213a53f3f5d10833916 100644 (file)
@@ -1,4 +1,4 @@
-INCLUDES = -I$(top_srcdir)/crypto -I$(top_srcdir)/libextra -I$(srcdir)/minitasn1 -I$(top_srcdir)/libextra/openpgp/ -I$(top_srcdir)/libextra/opencdk -I$(srcdir)/x509 -I$(top_srcdir)/includes $(LIBOPENCDK_CFLAGS) $(LIBTASN1_CFLAGS) $(LIBGCRYPT_CFLAGS)
+INCLUDES = -I$(top_srcdir)/crypto -I$(top_srcdir)/gl -I$(top_srcdir)/libextra -I$(srcdir)/minitasn1 -I$(top_srcdir)/libextra/openpgp/ -I$(top_srcdir)/libextra/opencdk -I$(srcdir)/x509 -I$(top_srcdir)/includes $(LIBOPENCDK_CFLAGS) $(LIBTASN1_CFLAGS) $(LIBGCRYPT_CFLAGS)
 bin_SCRIPTS = libgnutls-config
 
 m4datadir = $(datadir)/aclocal
index 56af4f0d8523424c4eff1dc3899b8debd3ab0dd0..1e547dd0b10bb4eda44a1030481dcf2e0cbc116b 100644 (file)
@@ -210,7 +210,7 @@ static int pwd_read_conf(const char *pconf_file, SRP_PWD_ENTRY * entry,
        while ((line[i] != ':') && (line[i] != '\0') && (i < sizeof(line))) {
            i++;
        }
-       if (strncmp(indexstr, line, GMAX(i, len)) == 0) {
+       if (strncmp(indexstr, line, MAX(i, len)) == 0) {
            if ((index = pwd_put_values2(entry, line)) >= 0)
                return 0;
            else {
@@ -304,7 +304,7 @@ int _gnutls_srp_pwd_read_entry(gnutls_session_t state, char *username,
            i++;
        }
 
-       if (strncmp(username, line, GMAX(i, len)) == 0) {
+       if (strncmp(username, line, MAX(i, len)) == 0) {
            if ((index = pwd_put_values(entry, line)) >= 0) {
                /* Keep the last index in memory, so we can retrieve fake parameters (g,n)
                 * when the user does not exist.
index 8bb1cbc7de6daa344194ecd141e159e7508e589e..50f8668df1d058c5f4418a42356de03f726d0bc9 100644 (file)
@@ -100,7 +100,7 @@ int _gnutls_srp_send_params(gnutls_session_t session, opaque * data,
            return 0;
 
        if (cred->username != NULL) {   /* send username */
-           len = GMIN(strlen(cred->username), 255);
+           len = MIN(strlen(cred->username), 255);
 
            if (data_size < len + 1) {
                gnutls_assert();
@@ -129,7 +129,7 @@ int _gnutls_srp_send_params(gnutls_session_t session, opaque * data,
                return 0;
            }
 
-           len = GMIN(strlen(username), 255);
+           len = MIN(strlen(username), 255);
 
            if (data_size < len + 1) {
                gnutls_free(username);
index ec4850511837182a4ad2514adbfaddd01608da8d..d22722db5c1ac92605a92520afd7e60fd4b13638 100644 (file)
@@ -392,7 +392,7 @@ ssize_t _gnutls_io_read_buffered(gnutls_session_t session, opaque ** iptr,
     /* calculate the actual size, ie. get the minimum of the
      * buffered data and the requested data.
      */
-    min = GMIN(session->internals.record_recv_buffer.length, sizeOfPtr);
+    min = MIN(session->internals.record_recv_buffer.length, sizeOfPtr);
     if (min > 0) {
        /* if we have enough buffered data
         * then just return them.
@@ -485,7 +485,7 @@ ssize_t _gnutls_io_read_buffered(gnutls_session_t session, opaque ** iptr,
     if (ret < 0 || ret2 < 0) {
        gnutls_assert();
        /* that's because they are initialized to 0 */
-       return GMIN(ret, ret2);
+       return MIN(ret, ret2);
     }
 
     ret += ret2;
index 2c49ddb50faeea01233e45d37b67bebd12cd72cf..e14c829d54a343836d22eec96e1cace8e8b12a32 100644 (file)
@@ -1,4 +1,5 @@
 /*
+ *  Copyright (C) 2004 Simon Josefsson
  *  Copyright (C) 2000,2003 Nikos Mavroyanopoulos
  *
  *  This file is part of GNUTLS.
@@ -20,8 +21,7 @@
 
 #include <gnutls_int.h>
 
-#define GMIN(x,y) ((x<y)?x:y)
-#define GMAX(x,y) ((x>y)?x:y)
+#include <minmax.h>
 
 #define rotl32(x,n)   (((x) << ((uint16)(n))) | ((x) >> (32 - (uint16)(n))))
 #define rotr32(x,n)   (((x) >> ((uint16)(n))) | ((x) << (32 - (uint16)(n))))
index c853ae79f7d30b404d4edd65190ba8c0085c9238..d11af60349e8af3fb11087a03cd98c2348b0a49f 100644 (file)
@@ -129,7 +129,7 @@ int _gnutls_pkcs1_rsa_encrypt(gnutls_datum_t * ciphertext,
                if (i < 2)
                    ps[i] = rnd[i];
                else
-                   ps[i] = GMAX(rnd[2] + ps[i - 1] + ps[i - 2], rnd[1]);
+                   ps[i] = MAX(rnd[2] + ps[i - 1] + ps[i - 2], rnd[1]);
            }
        }
        break;
index ad30a94799584ee17bf54b7f922b7703ab7dbe4a..48a84b985fabb68ab53a8a0c37fd9e861ac37635 100644 (file)
@@ -123,12 +123,12 @@ int _gnutls_string_copy_str(gnutls_string * dest, const char *src)
        return src_len;
     } else {
        dest->data =
-           dest->realloc_func(dest->data, GMAX(src_len, MIN_CHUNK));
+           dest->realloc_func(dest->data, MAX(src_len, MIN_CHUNK));
        if (dest->data == NULL) {
            gnutls_assert();
            return GNUTLS_E_MEMORY_ERROR;
        }
-       dest->max_length = GMAX(MIN_CHUNK, src_len);
+       dest->max_length = MAX(MIN_CHUNK, src_len);
 
        memcpy(dest->data, src, src_len);
        dest->length = src_len;
@@ -149,7 +149,7 @@ int _gnutls_string_append_str(gnutls_string * dest, const char *src)
        return tot_len;
     } else {
        size_t new_len =
-           GMAX(src_len, MIN_CHUNK) + GMAX(dest->max_length, MIN_CHUNK);
+           MAX(src_len, MIN_CHUNK) + MAX(dest->max_length, MIN_CHUNK);
 
        dest->data = dest->realloc_func(dest->data, new_len);
        if (dest->data == NULL) {
@@ -177,7 +177,7 @@ int _gnutls_string_append_data(gnutls_string * dest, const void *data,
        return tot_len;
     } else {
        size_t new_len =
-           GMAX(data_size, MIN_CHUNK) + GMAX(dest->max_length, MIN_CHUNK);
+           MAX(data_size, MIN_CHUNK) + MAX(dest->max_length, MIN_CHUNK);
 
        dest->data = dest->realloc_func(dest->data, new_len);
        if (dest->data == NULL) {
index 184dcf318ff28db610772304dab650860d1c084f..ff7493b24c209033383f6a2492637c440866f512 100644 (file)
@@ -58,7 +58,7 @@ static char *str_escape(char *str, char *buffer, unsigned int buffer_size)
     if (str == NULL || buffer == NULL)
        return NULL;
 
-    str_length = GMIN(strlen(str), buffer_size - 1);
+    str_length = MIN(strlen(str), buffer_size - 1);
 
     for (i = j = 0; i < str_length; i++) {
        if (str[i] == ',' || str[i] == '+' || str[i] == '"'
index 3bd761bd4ca7e1b7b81dcc5aba007cee7e9da970..68fcbae08be69ccf931be90796cdec7b4b739bc9 100644 (file)
@@ -345,7 +345,7 @@ _pkcs12_decode_safe_contents(const gnutls_datum_t * content,
        goto cleanup;
     }
 
-    bag->bag_elements = GMIN(MAX_BAG_ELEMENTS, count);
+    bag->bag_elements = MIN(MAX_BAG_ELEMENTS, count);
 
     for (i = 0; i < bag->bag_elements; i++) {
 
index c83054a4de71f0cd26f2b9ee5c5c8a590a74cea7..b2109649371822f92fc906cb95555bc9f26e275c 100644 (file)
@@ -1483,7 +1483,7 @@ static int generate_key(schema_id schema,
 
     if (schema == PBES2)
        kdf_params->salt_size =
-           GMIN(sizeof(kdf_params->salt), (uint) (10 + (rnd[1] % 10)));
+           MIN(sizeof(kdf_params->salt), (uint) (10 + (rnd[1] % 10)));
     else
        kdf_params->salt_size = 8;
 
index 2cce692920ac6db8c0e70df72bf43aaf128bfda9..d63d4b8015f7beb54d4a2b67b0936cd1f3edace1 100644 (file)
@@ -32,7 +32,7 @@
 #include <gnutls_cert.h>
 #include <libtasn1.h>
 #include <gnutls_global.h>
-#include <gnutls_num.h>                /* GMAX */
+#include <gnutls_num.h>                /* MAX */
 #include <gnutls_sig.h>
 #include <gnutls_str.h>
 #include <gnutls_datum.h>
index b6f08b32a62d4a5b67cb9be2ce3ea74d83e1d5e1..f924987dc55033d8882dc2d0e0d6f442d0ade6b4 100644 (file)
@@ -29,7 +29,7 @@
 #include <gnutls_cert.h>
 #include <libtasn1.h>
 #include <gnutls_global.h>
-#include <gnutls_num.h>                /* GMAX */
+#include <gnutls_num.h>                /* MAX */
 #include <gnutls_sig.h>
 #include <gnutls_str.h>
 #include <gnutls_datum.h>
index 7a3c62bbcbd73ba2717d8cfbc6fd73428cccf4a9..740a6c47f315325255b5bcafe1c521662d73c8a5 100644 (file)
@@ -1,4 +1,4 @@
-INCLUDES = -I$(top_srcdir)/crypto -I$(top_srcdir)/lib -I$(top_srcdir)/includes -I$(top_srcdir)/lib/minitasn1 $(LIBOPENCDK_CFLAGS) $(LIBGCRYPT_CFLAGS) $(LIBTASN1_CFLAGS) -I$(srcdir)/opencdk -I$(srcdir)/openpgp
+INCLUDES = -I$(top_srcdir)/crypto -I$(top_srcdir)/gl -I$(top_srcdir)/lib -I$(top_srcdir)/includes -I$(top_srcdir)/lib/minitasn1 $(LIBOPENCDK_CFLAGS) $(LIBGCRYPT_CFLAGS) $(LIBTASN1_CFLAGS) -I$(srcdir)/opencdk -I$(srcdir)/openpgp
 AM_CFLAGS = -DVERSION=\"gnutls/opencdk\"
 bin_SCRIPTS = libgnutls-extra-config
 DIST_SUBDIRS = openpgp opencdk