]> The Tcpdump Group git mirrors - libpcap/commitdiff
Oops, forgot to add the file with the Windows _snprintf() wrappers.
authorGuy Harris <[email protected]>
Wed, 4 Nov 2015 01:18:38 +0000 (17:18 -0800)
committerGuy Harris <[email protected]>
Wed, 4 Nov 2015 01:18:38 +0000 (17:18 -0800)
missing/win_snprintf.c [new file with mode: 0644]

diff --git a/missing/win_snprintf.c b/missing/win_snprintf.c
new file mode 100644 (file)
index 0000000..6e74d85
--- /dev/null
@@ -0,0 +1,31 @@
+#include <stdio.h>
+#include <stdarg.h>
+
+int
+pcap_vsnprintf(char *str, size_t str_size, const char *format, va_list args)
+{
+       int ret;
+
+       ret = _vsnprintf(str, str_size, format, args);
+
+       /*
+        * XXX - _vsnprintf() and _snprintf() do *not* guarantee
+        * that str is null-terminated, but C99's vsnprintf()
+        * and snprintf() do, and we want to offer C99 behavior,
+        * so forcibly null-terminate the string.
+        */
+       str[str_size - 1] = '\0';
+       return (ret);
+}
+
+int
+pcap_snprintf(char *str, size_t str_size, const char *format, ...)
+{
+       va_list args;
+       int ret;
+
+       va_start(args, format);
+       ret = pcap_vsnprintf(str, str_size, format, args);
+       va_end(args);
+       return (ret);
+}