From 596aff3843f074b0c7102dd7a52b4e6ffde3ed93 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 29 Aug 2008 20:03:02 +0000 Subject: removing useless code --- src/daemon/https/lgl/Makefile.am | 9 +---- src/daemon/https/lgl/asprintf.c | 39 ------------------ src/daemon/https/lgl/memmem.c | 61 ---------------------------- src/daemon/https/lgl/memmove.c | 26 ------------ src/daemon/https/lgl/vasnprintf.h | 84 --------------------------------------- src/daemon/https/lgl/vasprintf.c | 56 -------------------------- src/daemon/https/tls/gnutls_str.c | 12 ++++-- 7 files changed, 10 insertions(+), 277 deletions(-) delete mode 100644 src/daemon/https/lgl/asprintf.c delete mode 100644 src/daemon/https/lgl/memmem.c delete mode 100644 src/daemon/https/lgl/memmove.c delete mode 100644 src/daemon/https/lgl/vasnprintf.h delete mode 100644 src/daemon/https/lgl/vasprintf.c diff --git a/src/daemon/https/lgl/Makefile.am b/src/daemon/https/lgl/Makefile.am index ff8d1856..f14c7acc 100644 --- a/src/daemon/https/lgl/Makefile.am +++ b/src/daemon/https/lgl/Makefile.am @@ -12,7 +12,6 @@ liblgl_la_LDFLAGS = -lgcrypt # liblgl_la_LIBADD = ./gc-libgcrypt.lo liblgl_la_SOURCES = \ -asnprintf.c \ sha1.c \ gc-libgcrypt.c \ time_r.c \ @@ -23,16 +22,10 @@ rijndael-alg-fst.c \ hmac-md5.c \ hmac-sha1.c \ realloc.c \ -memmem.c \ -memmove.c \ memxor.c \ printf-args.c \ strverscmp.c \ -snprintf.c \ -asprintf.c \ -vasprintf.c \ -vasnprintf.c \ md5.c \ printf-parse.c \ des.c - \ No newline at end of file + diff --git a/src/daemon/https/lgl/asprintf.c b/src/daemon/https/lgl/asprintf.c deleted file mode 100644 index 04e3c58c..00000000 --- a/src/daemon/https/lgl/asprintf.c +++ /dev/null @@ -1,39 +0,0 @@ -/* Formatted output to strings. - Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation; either version 2.1, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License along - with this program; if not, write to the Free Software Foundation, - Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - -#include "MHD_config.h" - -/* Specification. */ -#ifdef IN_LIBASPRINTF -# include "vasprintf.h" -#else -# include -#endif - -#include - -int -asprintf (char **resultp, const char *format, ...) -{ - va_list args; - int result; - - va_start (args, format); - result = vasprintf (resultp, format, args); - va_end (args); - return result; -} diff --git a/src/daemon/https/lgl/memmem.c b/src/daemon/https/lgl/memmem.c deleted file mode 100644 index 9a0e67d2..00000000 --- a/src/daemon/https/lgl/memmem.c +++ /dev/null @@ -1,61 +0,0 @@ -/* Copyright (C) 1991,92,93,94,96,97,98,2000,2004,2007 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation; either version 2.1, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License along - with this program; if not, write to the Free Software Foundation, - Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - -#ifndef _LIBC -#include "MHD_config.h" -#endif - -#include -#include - -#ifndef _LIBC -# define __builtin_expect(expr, val) (expr) -#endif - -#undef memmem - -/* Return the first occurrence of NEEDLE in HAYSTACK. */ -void * -memmem (haystack, haystack_len, needle, needle_len) - const void *haystack; - size_t haystack_len; - const void *needle; - size_t needle_len; -{ - const char *begin; - const char *const last_possible = (const char *) haystack + haystack_len - - needle_len; - - if (needle_len == 0) - /* The first occurrence of the empty string is deemed to occur at - the beginning of the string. */ - return (void *) haystack; - - /* Sanity check, otherwise the loop might search through the whole - memory. */ - if (__builtin_expect (haystack_len < needle_len, 0)) - return NULL; - - for (begin = (const char *) haystack; begin <= last_possible; ++begin) - if (begin[0] == ((const char *) needle)[0] - && !memcmp ((const void *) &begin[1], - (const void *) ((const char *) needle + 1), - needle_len - 1)) - return (void *) begin; - - return NULL; -} diff --git a/src/daemon/https/lgl/memmove.c b/src/daemon/https/lgl/memmove.c deleted file mode 100644 index c37d6923..00000000 --- a/src/daemon/https/lgl/memmove.c +++ /dev/null @@ -1,26 +0,0 @@ -/* memmove.c -- copy memory. - Copy LENGTH bytes from SOURCE to DEST. Does not null-terminate. - In the public domain. - By David MacKenzie . */ - -#include "MHD_config.h" - -#include - -void * -memmove (void *dest0, void const *source0, size_t length) -{ - char *dest = dest0; - char const *source = source0; - if (source < dest) - /* Moving from low mem to hi mem; start at end. */ - for (source += length, dest += length; length; --length) - *--dest = *--source; - else if (source != dest) - { - /* Moving from hi mem to low mem; start at beginning. */ - for (; length; --length) - *dest++ = *source++; - } - return dest0; -} diff --git a/src/daemon/https/lgl/vasnprintf.h b/src/daemon/https/lgl/vasnprintf.h deleted file mode 100644 index e4c57f5b..00000000 --- a/src/daemon/https/lgl/vasnprintf.h +++ /dev/null @@ -1,84 +0,0 @@ -/* vsprintf with automatic memory allocation. - Copyright (C) 2002-2004, 2007 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation; either version 2.1, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License along - with this program; if not, write to the Free Software Foundation, - Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - -#ifndef _VASNPRINTF_H -#define _VASNPRINTF_H - -/* Get va_list. */ -#include - -/* Get size_t. */ -#include - -#ifndef __attribute__ -/* This feature is available in gcc versions 2.5 and later. */ -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__ -# define __attribute__(Spec) /* empty */ -# endif -/* The __-protected variants of `format' and `printf' attributes - are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */ -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) -# define __format__ format -# define __printf__ printf -# endif -#endif - -#ifdef __cplusplus -extern "C" -{ -#endif - -/* Write formatted output to a string dynamically allocated with malloc(). - You can pass a preallocated buffer for the result in RESULTBUF and its - size in *LENGTHP; otherwise you pass RESULTBUF = NULL. - If successful, return the address of the string (this may be = RESULTBUF - if no dynamic memory allocation was necessary) and set *LENGTHP to the - number of resulting bytes, excluding the trailing NUL. Upon error, set - errno and return NULL. - - When dynamic memory allocation occurs, the preallocated buffer is left - alone (with possibly modified contents). This makes it possible to use - a statically allocated or stack-allocated buffer, like this: - - char buf[100]; - size_t len = sizeof (buf); - char *output = vasnprintf (buf, &len, format, args); - if (output == NULL) - ... error handling ...; - else - { - ... use the output string ...; - if (output != buf) - free (output); - } - */ -#if REPLACE_VASNPRINTF -# define asnprintf rpl_asnprintf -# define vasnprintf rpl_vasnprintf -#endif - extern char *asnprintf (char *resultbuf, size_t * lengthp, - const char *format, ...) - __attribute__ ((__format__ (__printf__, 3, 4))); - extern char *vasnprintf (char *resultbuf, size_t * lengthp, - const char *format, va_list args) - __attribute__ ((__format__ (__printf__, 3, 0))); - -#ifdef __cplusplus -} -#endif - -#endif /* _VASNPRINTF_H */ diff --git a/src/daemon/https/lgl/vasprintf.c b/src/daemon/https/lgl/vasprintf.c deleted file mode 100644 index 9348b5bd..00000000 --- a/src/daemon/https/lgl/vasprintf.c +++ /dev/null @@ -1,56 +0,0 @@ -/* Formatted output to strings. - Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation; either version 2.1, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License along - with this program; if not, write to the Free Software Foundation, - Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - -#include "MHD_config.h" - -/* Specification. */ -#ifdef IN_LIBASPRINTF -# include "vasprintf.h" -#else -# include -#endif - -#include -#include -#include - -#include "vasnprintf.h" - -/* Some systems, like OSF/1 4.0 and Woe32, don't have EOVERFLOW. */ -#ifndef EOVERFLOW -# define EOVERFLOW E2BIG -#endif - -int -vasprintf (char **resultp, const char *format, va_list args) -{ - size_t length; - char *result = vasnprintf (NULL, &length, format, args); - if (result == NULL) - return -1; - - if (length > INT_MAX) - { - free (result); - errno = EOVERFLOW; - return -1; - } - - *resultp = result; - /* Return the number of resulting bytes, excluding the trailing NUL. */ - return length; -} diff --git a/src/daemon/https/tls/gnutls_str.c b/src/daemon/https/tls/gnutls_str.c index 22f949d6..d5e95366 100644 --- a/src/daemon/https/tls/gnutls_str.c +++ b/src/daemon/https/tls/gnutls_str.c @@ -236,12 +236,18 @@ mhd_gtls_string_append_printf (mhd_gtls_string * dest, const char *fmt, ...) char *str; va_start (args, fmt); - len = vasprintf (&str, fmt, args); + len = vsnprintf (NULL, 0, fmt, args); va_end (args); - - if (len < 0 || !str) + if (len < 0) + return -1; + str = malloc(len + 1); + if (! str) return -1; + va_start (args, fmt); + len = vsprintf (str, fmt, args); + va_end (args); + len = mhd_gtls_string_append_str (dest, str); free (str); -- cgit v1.2.3