Gnulib sync.
AC_CHECK_HEADERS(math.h limits.h float.h stdarg.h ctype.h)
dnl opencdk
AC_CHECK_HEADERS(netdb.h)
-AC_CHECK_FUNCS(vasprintf isascii memmove strnstr mmap gmtime_r inet_ntop,,)
+AC_CHECK_FUNCS(vasprintf isascii memmove mmap gmtime_r inet_ntop,,)
AC_FUNC_ALLOCA
gl_SOURCE_BASE(gl)
gl_M4_BASE(gl/m4)
-gl_MODULES(getline error exit progname getpass-gnu minmax)
+gl_MODULES(getline error exit progname getpass-gnu minmax strnstr)
gl_INIT
AC_MSG_RESULT([***
# 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 minmax 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 strnstr unlocked-io
AUTOMAKE_OPTIONS = 1.8 gnits
mv $@-t $@
MOSTLYCLEANFILES += stdbool.h stdbool.h-t
+libgnu_la_SOURCES += strnstr.h
+
libgnu_la_SOURCES += unlocked-io.h
# 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 minmax 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 strnstr unlocked-io
AC_DEFUN([gl_EARLY],
[
gl_FUNC_GETPASS_GNU
dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac.
AM_STDBOOL_H
+ gl_FUNC_STRNSTR
gl_FUNC_GLIBC_UNLOCKED_IO
])
dnl Usage: gl_M4_BASE(DIR)
AC_DEFUN([gl_M4_BASE], [])
+dnl Usage: gl_LIB(LIBNAME)
+AC_DEFUN([gl_LIB], [])
+
+dnl Usage: gl_LGPL
+AC_DEFUN([gl_LGPL], [])
+
# gnulib.m4 ends here
--- /dev/null
+# strnstr.m4 serial 1
+dnl Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+dnl This file is free software, distributed under the terms of the GNU
+dnl General Public License. As a special exception to the GNU General
+dnl Public License, this file may be distributed as part of a program
+dnl that contains a configuration script generated by Autoconf, under
+dnl the same distribution terms as the rest of that program.
+
+AC_DEFUN([gl_FUNC_STRNSTR],
+[
+ AC_REPLACE_FUNCS(strnstr)
+ AC_CHECK_DECLS_ONCE(strnstr)
+ gl_PREREQ_STRNSTR
+])
+
+# Prerequisites of lib/strnstr.c.
+AC_DEFUN([gl_PREREQ_STRNSTR], [:])
-/* Copyright (C) 2004 Simon Josefsson
- Copyright (C) 1995,1996,1997,2000,2001,2003 Free Software Foundation, Inc.
+/* MIN, MAX macros.
+ Copyright (C) 1995, 1998, 2001, 2003 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 by the Free Software Foundation; either version 2.1 of
- the License, or (at your option) any later version.
+ 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 file 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.
+ 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 Lesser General Public
- License along with this file; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- USA. */
+ 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
+#ifndef _MINMAX_H
+#define _MINMAX_H
-/* Macros for min/max. */
-#ifndef MIN
-# define MIN(a,b) (((a)<(b))?(a):(b))
-#endif
+/* 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))
+# 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 */
+#endif /* _MINMAX_H */
/* Program name management.
- Copyright (C) 2001-2003 Free Software Foundation, Inc.
+ Copyright (C) 2001-2004 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
argv0 = base + 3;
program_name = argv0;
}
+
+/* Return short program name of the current executable, based on the
+ earlier call to set_program_name. Return NULL if unknown. The
+ short program name is computed by removing all directory names and
+ path separators. */
+const char *
+get_short_program_name (void)
+{
+ const char *slash = NULL;
+ if (program_name)
+ slash = strrchr (program_name, '/');
+ return slash != NULL ? slash + 1 : program_name;
+}
/* Set program_name, based on argv[0]. */
extern void set_program_name (const char *argv0);
+/* Return short program name of the current executable, based on the
+ earlier call to set_program_name. Return NULL if unknown. The
+ short program name is computed by removing all directory names and
+ path separators. */
+extern const char *get_short_program_name (void);
+
#if ENABLE_RELOCATABLE
/* Set program_name, based on argv[0], and original installation prefix and
--- /dev/null
+/*
+ * Copyright (C) 2004 Free Software Foundation
+ * Written by Simon Josefsson
+ *
+ * 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. */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+/* Get MIN. */
+#include <minmax.h>
+
+/* Get strlen, strncmp. */
+#include <string.h>
+
+/* Locate first occurance of zero terminated string LITLE in the first
+ MIN(LEN, strlen(BIG)) characters of the string BIG. Returns
+ pointer to match within BIG, or NULL if no match is found. If
+ LITTLE is the empty string, BIG is returned. */
+char *
+strnstr (const char *big, const char *little, size_t len)
+{
+ size_t searchlen = MIN (len, strlen (big));
+ size_t littlelen = strlen (little);
+ char *p = (char*) big;
+ size_t i;
+
+ if (*little == '\0')
+ return p;
+
+ if (searchlen < littlelen)
+ return NULL;
+
+ for (i = 0; i <= searchlen - littlelen; i++)
+ if (strncmp (&p[i], little, littlelen) == 0)
+ return &p[i];
+
+ return NULL;
+}
--- /dev/null
+/*
+ * Copyright (C) 2004 Free Software Foundation
+ * Written by Simon Josefsson
+ *
+ * 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 STRNSTR_H
+# define STRNSTR_H
+
+/* Get strnstr, if available. */
+# include <string.h>
+
+# if defined HAVE_DECL_STRNSTR && !HAVE_DECL_STRNSTR
+char *strnstr (const char *big, const char *little, size_t len);
+# endif
+
+#endif /* STRNSTR_H */
ext_max_record.c gnutls_alert.c gnutls_int_compat.c \
gnutls_str.c gnutls_state.c gnutls_x509.c ext_cert_type.c \
gnutls_rsa_export.c auth_rsa_export.c ext_server_name.c \
- auth_dh_common.c strnstr.c
+ auth_dh_common.c
HFILES = debug.h gnutls_compress.h defines.h gnutls_cipher.h \
gnutls_buffers.h gnutls_errors.h gnutls_int.h \
/*
- * Copyright (C) 2000,2001,2002 Nikos Mavroyanopoulos
+ * Copyright (C) 2004 Free Software Foundation
+ * Copyright (C) 2000,2001,2002 Nikos Mavroyanopoulos
*
* This file is part of GNUTLS.
*
# include <strings.h>
#endif
-#ifndef HAVE_STRNSTR
-char *strnstr(const char *haystack, const char *needle,
- size_t haystacklen);
-#endif
+#include <strnstr.h>
#ifdef HAVE_STDDEF_H
# include <stddef.h>
+++ /dev/null
-/*
- * Copyright (C) 2003 Nikos Mavroyanopoulos
- * Copyright (C) 2004 Free Software Foundation
- *
- * This file is part of GNUTLS.
- *
- * The GNUTLS library 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 of the License, or (at your option) any later version.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-
-#include <defines.h>
-#ifndef HAVE_STRNSTR
-# include <string.h>
-
-char *strnstr(const char *haystack, const char *needle, size_t haystacklen)
-{
- char *p;
- ssize_t plen;
- ssize_t len = strlen(needle);
-
- if (*needle == '\0') /* everything matches empty string */
- return (char *) haystack;
-
- plen = haystacklen;
- for (p = (char *) haystack; p != NULL;
- p = memchr(p + 1, *needle, plen - 1)) {
- plen = haystacklen - (p - haystack);
-
- if (plen < len)
- return NULL;
-
- if (strncmp(p, needle, len) == 0)
- return (p);
- }
- return NULL;
-}
-
-#endif