summaryrefslogtreecommitdiff
path: root/missing
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2015-11-03 15:59:38 -0800
committerGuy Harris <guy@alum.mit.edu>2015-11-03 15:59:38 -0800
commit735f1f9d3318693f0096be4198d34e9ac0985777 (patch)
tree3c2c26fc4df90474fad17f135dcec92748e77406 /missing
parent17e43dfad4f2923adc1a6c396b4e8e30a6a1dbb9 (diff)
downloadlibpcap-735f1f9d3318693f0096be4198d34e9ac0985777.tar.gz
Use pcap_snprintf() instead of snprintf().
On UN*Xes with snprintf(), we just #define pcap_snprintf to snprintf. On UN*Xes without snprintf(), we provide our own, but call it pcap_snprintf(). On Windows, we have a routine that wraps _snprintf(), with C99 semantics (ensuring null termination if the string won't fit), called pcap_snprintf(), and use that.
Diffstat (limited to 'missing')
-rw-r--r--missing/getopt.c2
-rw-r--r--missing/snprintf.c20
2 files changed, 12 insertions, 10 deletions
diff --git a/missing/getopt.c b/missing/getopt.c
index 14cd6a32..cc798e1d 100644
--- a/missing/getopt.c
+++ b/missing/getopt.c
@@ -39,6 +39,8 @@ static char sccsid[] = "@(#)getopt.c 8.3 (Berkeley) 4/27/95";
#include <stdlib.h>
#include <string.h>
+#include "getopt.h"
+
int opterr = 1, /* if error message should be printed */
optind = 1, /* index into parent argv vector */
optopt, /* character checked for validity */
diff --git a/missing/snprintf.c b/missing/snprintf.c
index 9b63f8b1..99f0bdfc 100644
--- a/missing/snprintf.c
+++ b/missing/snprintf.c
@@ -456,13 +456,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 +473,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 +518,13 @@ 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);
#ifdef PARANOIA
{
@@ -534,7 +534,7 @@ asnprintf (char **ret, size_t max_sz, const char *format, ...)
if (tmp == NULL)
abort ();
- ret2 = vsprintf (tmp, format, args);
+ ret2 = pcap_vsprintf (tmp, format, args);
if (val != ret2 || strcmp(*ret, tmp))
abort ();
free (tmp);
@@ -548,16 +548,16 @@ asnprintf (char **ret, size_t max_sz, const char *format, ...)
#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 +600,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;