summaryrefslogtreecommitdiff
path: root/missing/snprintf.c
diff options
context:
space:
mode:
Diffstat (limited to 'missing/snprintf.c')
-rw-r--r--missing/snprintf.c32
1 files changed, 19 insertions, 13 deletions
diff --git a/missing/snprintf.c b/missing/snprintf.c
index 9b63f8b..672aeb8 100644
--- a/missing/snprintf.c
+++ b/missing/snprintf.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995-1999 Kungliga Tekniska Högskolan
+ * Copyright (c) 1995-1999 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -31,6 +31,10 @@
* SUCH DAMAGE.
*/
+/*
+ * We use this for platforms that don't have snprintf() at all.
+ */
+
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
@@ -42,7 +46,7 @@
#include <ctype.h>
#include <sys/types.h>
-#include <pcap-int.h>
+#include "portability.h"
enum format_flags {
minus_flag = 1,
@@ -456,13 +460,13 @@ xyzprintf (struct state *state, const char *char_format, va_list ap)
#ifndef HAVE_SNPRINTF
int
-snprintf (char *str, size_t sz, const char *format, ...)
+pcap_snprintf (char *str, size_t sz, const char *format, ...)
{
va_list args;
int ret;
va_start(args, format);
- ret = vsnprintf (str, sz, format, args);
+ ret = pcap_vsnprintf (str, sz, format, args);
#ifdef PARANOIA
{
@@ -473,7 +477,7 @@ snprintf (char *str, size_t sz, const char *format, ...)
if (tmp == NULL)
abort ();
- ret2 = vsprintf (tmp, format, args);
+ ret2 = pcap_vsprintf (tmp, format, args);
if (ret != ret2 || strcmp(str, tmp))
abort ();
free (tmp);
@@ -518,13 +522,14 @@ asprintf (char **ret, const char *format, ...)
#ifndef HAVE_ASNPRINTF
int
-asnprintf (char **ret, size_t max_sz, const char *format, ...)
+pcap_asnprintf (char **ret, size_t max_sz, const char *format, ...)
{
va_list args;
int val;
va_start(args, format);
- val = vasnprintf (ret, max_sz, format, args);
+ val = pcap_vasnprintf (ret, max_sz, format, args);
+ va_end(args);
#ifdef PARANOIA
{
@@ -534,30 +539,31 @@ asnprintf (char **ret, size_t max_sz, const char *format, ...)
if (tmp == NULL)
abort ();
- ret2 = vsprintf (tmp, format, args);
+ va_start(args, format);
+ ret2 = pcap_vsprintf (tmp, format, args);
+ va_end(args);
if (val != ret2 || strcmp(*ret, tmp))
abort ();
free (tmp);
}
#endif
- va_end(args);
return val;
}
#endif
#ifndef HAVE_VASPRINTF
int
-vasprintf (char **ret, const char *format, va_list args)
+pcap_vasprintf (char **ret, const char *format, va_list args)
{
- return vasnprintf (ret, 0, format, args);
+ return pcap_vasnprintf (ret, 0, format, args);
}
#endif
#ifndef HAVE_VASNPRINTF
int
-vasnprintf (char **ret, size_t max_sz, const char *format, va_list args)
+pcap_vasnprintf (char **ret, size_t max_sz, const char *format, va_list args)
{
int st;
size_t len;
@@ -600,7 +606,7 @@ vasnprintf (char **ret, size_t max_sz, const char *format, va_list args)
#ifndef HAVE_VSNPRINTF
int
-vsnprintf (char *str, size_t sz, const char *format, va_list args)
+pcap_vsnprintf (char *str, size_t sz, const char *format, va_list args)
{
struct state state;
int ret;