mirror of
https://git.gnunet.org/libmicrohttpd.git
synced 2026-09-27 04:09:31 +03:00
removing useless code
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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 <stdio.h>
|
||||
#endif
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -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 <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
#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;
|
||||
}
|
||||
@@ -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 <djm@gnu.ai.mit.edu>. */
|
||||
|
||||
#include "MHD_config.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -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 <stdarg.h>
|
||||
|
||||
/* Get size_t. */
|
||||
#include <stddef.h>
|
||||
|
||||
#ifndef __attribute__
|
||||
/* This feature is available in gcc versions 2.5 and later. */
|
||||
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
|
||||
# define __attribute__(Spec) /* empty */
|
||||
# endif
|
||||
/* The __-protected variants of `format' and `printf' attributes
|
||||
are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
|
||||
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
|
||||
# define __format__ format
|
||||
# define __printf__ printf
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#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 */
|
||||
@@ -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 <stdio.h>
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#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;
|
||||
}
|
||||
@@ -236,11 +236,17 @@ 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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user