1 #include <stdio.h>
2 #include <stdarg.h>
3
4 int
pcap_vsnprintf(char * str,size_t str_size,const char * format,va_list args)5 pcap_vsnprintf(char *str, size_t str_size, const char *format, va_list args)
6 {
7 int ret;
8
9 ret = _vsnprintf_s(str, str_size, _TRUNCATE, format, args);
10
11 /*
12 * XXX - _vsnprintf() and _snprintf() do *not* guarantee
13 * that str is null-terminated, but C99's vsnprintf()
14 * and snprintf() do, and we want to offer C99 behavior,
15 * so forcibly null-terminate the string.
16 */
17 str[str_size - 1] = '\0';
18 return (ret);
19 }
20
21 int
pcap_snprintf(char * str,size_t str_size,const char * format,...)22 pcap_snprintf(char *str, size_t str_size, const char *format, ...)
23 {
24 va_list args;
25 int ret;
26
27 va_start(args, format);
28 ret = pcap_vsnprintf(str, str_size, format, args);
29 va_end(args);
30 return (ret);
31 }
32