From Albert Chin <china@thewrittenword.com>: on platforms that lack
"snprintf()", include one in libpcap with the name "pcap_snprintf()", so applications don't have to supply their own "snprintf()" on those platforms in order to use libpcap.
This commit is contained in:
parent
026542c235
commit
fcadc89577
1
CREDITS
1
CREDITS
|
@ -12,6 +12,7 @@ Additional people who have contributed patches:
|
||||||
|
|
||||||
Alan Bawden <Alan@LCS.MIT.EDU>
|
Alan Bawden <Alan@LCS.MIT.EDU>
|
||||||
Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
|
Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
|
||||||
|
Albert Chin <china@thewrittenword.com>
|
||||||
Andrew Brown <atatat@atatdot.net>
|
Andrew Brown <atatat@atatdot.net>
|
||||||
Antti Kantee <pooka@netbsd.org>
|
Antti Kantee <pooka@netbsd.org>
|
||||||
Arkadiusz Miskiewicz <misiek@pld.org.pl>
|
Arkadiusz Miskiewicz <misiek@pld.org.pl>
|
||||||
|
|
1
FILES
1
FILES
|
@ -76,6 +76,7 @@ ppp.h
|
||||||
savefile.c
|
savefile.c
|
||||||
scanner.l
|
scanner.l
|
||||||
sll.h
|
sll.h
|
||||||
|
snprintf.c
|
||||||
sunatmpos.h
|
sunatmpos.h
|
||||||
Win32/Include/Gnuc.h
|
Win32/Include/Gnuc.h
|
||||||
Win32/Include/addrinfo.h
|
Win32/Include/addrinfo.h
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
@(#) $Header: /tcpdump/master/libpcap/INSTALL.txt,v 1.7 2003-07-24 08:02:34 guy Exp $ (LBL)
|
@(#) $Header: /tcpdump/master/libpcap/INSTALL.txt,v 1.8 2003-12-15 01:35:03 guy Exp $ (LBL)
|
||||||
|
|
||||||
To build libpcap, run "./configure" (a shell script). The configure
|
To build libpcap, run "./configure" (a shell script). The configure
|
||||||
script will determine your system attributes and generate an
|
script will determine your system attributes and generate an
|
||||||
|
@ -365,5 +365,6 @@ ppp.h - Point to Point Protocol definitions
|
||||||
savefile.c - offline support
|
savefile.c - offline support
|
||||||
scanner.l - filter string scanner
|
scanner.l - filter string scanner
|
||||||
sll.h - definitions for Linux cooked mode fake link-layer header
|
sll.h - definitions for Linux cooked mode fake link-layer header
|
||||||
|
snprintf.c - snprintf and vsnprintf for platforms that lack them
|
||||||
sunatmpos.h - definitions for SunATM capturing
|
sunatmpos.h - definitions for SunATM capturing
|
||||||
Win32 - headers and routines for building on Win32 systems
|
Win32 - headers and routines for building on Win32 systems
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||||
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
#
|
#
|
||||||
# @(#) $Header: /tcpdump/master/libpcap/Makefile.in,v 1.98 2003-11-30 22:46:13 guy Exp $ (LBL)
|
# @(#) $Header: /tcpdump/master/libpcap/Makefile.in,v 1.99 2003-12-15 01:35:03 guy Exp $ (LBL)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Various configurable paths (remember to edit Makefile.in, not Makefile)
|
# Various configurable paths (remember to edit Makefile.in, not Makefile)
|
||||||
|
@ -83,7 +83,7 @@ SRC = $(PSRC) $(FSRC) $(CSRC) $(SSRC) $(GENSRC)
|
||||||
|
|
||||||
# We would like to say "OBJ = $(SRC:.c=.o)" but Ultrix's make cannot
|
# We would like to say "OBJ = $(SRC:.c=.o)" but Ultrix's make cannot
|
||||||
# hack the extra indirection
|
# hack the extra indirection
|
||||||
OBJ = $(PSRC:.c=.o) $(FSRC:.c=.o) $(CSRC:.c=.o) $(SSRC:.c=.o) $(GENSRC:.c=.o) # $(LIBOBJS)
|
OBJ = $(PSRC:.c=.o) $(FSRC:.c=.o) $(CSRC:.c=.o) $(SSRC:.c=.o) $(GENSRC:.c=.o) $(LIBOBJS)
|
||||||
HDR = pcap.h pcap-int.h pcap-namedb.h pcap-nit.h pcap-pf.h \
|
HDR = pcap.h pcap-int.h pcap-namedb.h pcap-nit.h pcap-pf.h \
|
||||||
ethertype.h gencode.h gnuc.h
|
ethertype.h gencode.h gnuc.h
|
||||||
GENHDR = \
|
GENHDR = \
|
||||||
|
@ -145,8 +145,8 @@ grammar.o: grammar.c
|
||||||
version.o: version.c
|
version.o: version.c
|
||||||
$(CC) $(CFLAGS) -c version.c
|
$(CC) $(CFLAGS) -c version.c
|
||||||
|
|
||||||
snprintf.o: $(srcdir)/../tcpdump/missing/snprintf.c
|
snprintf.o: $(srcdir)/missing/snprintf.c
|
||||||
$(CC) $(CFLAGS) -o $@ -c $(srcdir)/../tcpdump/missing/snprintf.c
|
$(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/snprintf.c
|
||||||
|
|
||||||
version.c: $(srcdir)/VERSION
|
version.c: $(srcdir)/VERSION
|
||||||
@rm -f $@
|
@rm -f $@
|
||||||
|
|
|
@ -14,12 +14,18 @@
|
||||||
/* Define if you have the ether_hostton function. */
|
/* Define if you have the ether_hostton function. */
|
||||||
#undef HAVE_ETHER_HOSTTON
|
#undef HAVE_ETHER_HOSTTON
|
||||||
|
|
||||||
|
/* Define if you have the snprintf function. */
|
||||||
|
#undef HAVE_SNPRINTF
|
||||||
|
|
||||||
/* Define if you have the strerror function. */
|
/* Define if you have the strerror function. */
|
||||||
#undef HAVE_STRERROR
|
#undef HAVE_STRERROR
|
||||||
|
|
||||||
/* Define if you have the strlcpy function. */
|
/* Define if you have the strlcpy function. */
|
||||||
#undef HAVE_STRLCPY
|
#undef HAVE_STRLCPY
|
||||||
|
|
||||||
|
/* Define if you have the vsnprintf function. */
|
||||||
|
#undef HAVE_VSNPRINTF
|
||||||
|
|
||||||
/* Define if you have the <ifaddrs.h> header file. */
|
/* Define if you have the <ifaddrs.h> header file. */
|
||||||
#undef HAVE_IFADDRS_H
|
#undef HAVE_IFADDRS_H
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
|
|
||||||
# From configure.in Revision: 1.103
|
# From configure.in Revision: 1.104
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1575,8 +1575,71 @@ fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
|
needsnprintf=no
|
||||||
|
LIBOBJS=
|
||||||
|
for ac_func in vsnprintf snprintf
|
||||||
|
do
|
||||||
|
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
|
||||||
|
echo "configure:1584: checking for $ac_func" >&5
|
||||||
|
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
|
||||||
|
echo $ac_n "(cached) $ac_c" 1>&6
|
||||||
|
else
|
||||||
|
cat > conftest.$ac_ext <<EOF
|
||||||
|
#line 1589 "configure"
|
||||||
|
#include "confdefs.h"
|
||||||
|
/* System header to define __stub macros and hopefully few prototypes,
|
||||||
|
which can conflict with char $ac_func(); below. */
|
||||||
|
#include <assert.h>
|
||||||
|
/* Override any gcc2 internal prototype to avoid an error. */
|
||||||
|
/* We use char because int might match the return type of a gcc2
|
||||||
|
builtin and then its argument prototype would still apply. */
|
||||||
|
char $ac_func();
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
|
||||||
|
/* The GNU C library defines this for functions which it implements
|
||||||
|
to always fail with ENOSYS. Some functions are actually named
|
||||||
|
something starting with __ and the normal name is an alias. */
|
||||||
|
#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
|
||||||
|
choke me
|
||||||
|
#else
|
||||||
|
$ac_func();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
; return 0; }
|
||||||
|
EOF
|
||||||
|
if { (eval echo configure:1612: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||||
|
rm -rf conftest*
|
||||||
|
eval "ac_cv_func_$ac_func=yes"
|
||||||
|
else
|
||||||
|
echo "configure: failed program was:" >&5
|
||||||
|
cat conftest.$ac_ext >&5
|
||||||
|
rm -rf conftest*
|
||||||
|
eval "ac_cv_func_$ac_func=no"
|
||||||
|
fi
|
||||||
|
rm -f conftest*
|
||||||
|
fi
|
||||||
|
|
||||||
|
if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
|
||||||
|
echo "$ac_t""yes" 1>&6
|
||||||
|
ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
|
||||||
|
cat >> confdefs.h <<EOF
|
||||||
|
#define $ac_tr_func 1
|
||||||
|
EOF
|
||||||
|
|
||||||
|
else
|
||||||
|
echo "$ac_t""no" 1>&6
|
||||||
|
needsnprintf=yes
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if test $needsnprintf = yes; then
|
||||||
|
LIBOBJS="$LIBOBJS snprintf.o"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
echo $ac_n "checking if --disable-protochain option is specified""... $ac_c" 1>&6
|
echo $ac_n "checking if --disable-protochain option is specified""... $ac_c" 1>&6
|
||||||
echo "configure:1580: checking if --disable-protochain option is specified" >&5
|
echo "configure:1643: checking if --disable-protochain option is specified" >&5
|
||||||
# Check whether --enable-protochain or --disable-protochain was given.
|
# Check whether --enable-protochain or --disable-protochain was given.
|
||||||
if test "${enable_protochain+set}" = set; then
|
if test "${enable_protochain+set}" = set; then
|
||||||
enableval="$enable_protochain"
|
enableval="$enable_protochain"
|
||||||
|
@ -1607,7 +1670,7 @@ if test "${with_pcap+set}" = set; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo $ac_n "checking packet capture type""... $ac_c" 1>&6
|
echo $ac_n "checking packet capture type""... $ac_c" 1>&6
|
||||||
echo "configure:1611: checking packet capture type" >&5
|
echo "configure:1674: checking packet capture type" >&5
|
||||||
if test ! -z "$with_pcap" ; then
|
if test ! -z "$with_pcap" ; then
|
||||||
V_PCAP="$withval"
|
V_PCAP="$withval"
|
||||||
elif test -r /dev/bpf0 ; then
|
elif test -r /dev/bpf0 ; then
|
||||||
|
@ -1645,12 +1708,12 @@ fi
|
||||||
echo "$ac_t""$V_PCAP" 1>&6
|
echo "$ac_t""$V_PCAP" 1>&6
|
||||||
|
|
||||||
echo $ac_n "checking for getifaddrs""... $ac_c" 1>&6
|
echo $ac_n "checking for getifaddrs""... $ac_c" 1>&6
|
||||||
echo "configure:1649: checking for getifaddrs" >&5
|
echo "configure:1712: checking for getifaddrs" >&5
|
||||||
if eval "test \"`echo '$''{'ac_cv_func_getifaddrs'+set}'`\" = set"; then
|
if eval "test \"`echo '$''{'ac_cv_func_getifaddrs'+set}'`\" = set"; then
|
||||||
echo $ac_n "(cached) $ac_c" 1>&6
|
echo $ac_n "(cached) $ac_c" 1>&6
|
||||||
else
|
else
|
||||||
cat > conftest.$ac_ext <<EOF
|
cat > conftest.$ac_ext <<EOF
|
||||||
#line 1654 "configure"
|
#line 1717 "configure"
|
||||||
#include "confdefs.h"
|
#include "confdefs.h"
|
||||||
/* System header to define __stub macros and hopefully few prototypes,
|
/* System header to define __stub macros and hopefully few prototypes,
|
||||||
which can conflict with char getifaddrs(); below. */
|
which can conflict with char getifaddrs(); below. */
|
||||||
|
@ -1673,7 +1736,7 @@ getifaddrs();
|
||||||
|
|
||||||
; return 0; }
|
; return 0; }
|
||||||
EOF
|
EOF
|
||||||
if { (eval echo configure:1677: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
if { (eval echo configure:1740: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||||
rm -rf conftest*
|
rm -rf conftest*
|
||||||
eval "ac_cv_func_getifaddrs=yes"
|
eval "ac_cv_func_getifaddrs=yes"
|
||||||
else
|
else
|
||||||
|
@ -1711,12 +1774,12 @@ else
|
||||||
# or it might be some other OS, with just SIOCGIFCONF.
|
# or it might be some other OS, with just SIOCGIFCONF.
|
||||||
#
|
#
|
||||||
echo $ac_n "checking whether we have SIOCGLIFCONF""... $ac_c" 1>&6
|
echo $ac_n "checking whether we have SIOCGLIFCONF""... $ac_c" 1>&6
|
||||||
echo "configure:1715: checking whether we have SIOCGLIFCONF" >&5
|
echo "configure:1778: checking whether we have SIOCGLIFCONF" >&5
|
||||||
if eval "test \"`echo '$''{'ac_cv_lbl_have_siocglifconf'+set}'`\" = set"; then
|
if eval "test \"`echo '$''{'ac_cv_lbl_have_siocglifconf'+set}'`\" = set"; then
|
||||||
echo $ac_n "(cached) $ac_c" 1>&6
|
echo $ac_n "(cached) $ac_c" 1>&6
|
||||||
else
|
else
|
||||||
cat > conftest.$ac_ext <<EOF
|
cat > conftest.$ac_ext <<EOF
|
||||||
#line 1720 "configure"
|
#line 1783 "configure"
|
||||||
#include "confdefs.h"
|
#include "confdefs.h"
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/file.h>
|
#include <sys/file.h>
|
||||||
|
@ -1727,7 +1790,7 @@ int main() {
|
||||||
ioctl(0, SIOCGLIFCONF, (char *)0);
|
ioctl(0, SIOCGLIFCONF, (char *)0);
|
||||||
; return 0; }
|
; return 0; }
|
||||||
EOF
|
EOF
|
||||||
if { (eval echo configure:1731: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
if { (eval echo configure:1794: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||||
rm -rf conftest*
|
rm -rf conftest*
|
||||||
ac_cv_lbl_have_siocglifconf=yes
|
ac_cv_lbl_have_siocglifconf=yes
|
||||||
else
|
else
|
||||||
|
@ -1769,7 +1832,7 @@ fi
|
||||||
|
|
||||||
|
|
||||||
echo $ac_n "checking if --enable-ipv6 option is specified""... $ac_c" 1>&6
|
echo $ac_n "checking if --enable-ipv6 option is specified""... $ac_c" 1>&6
|
||||||
echo "configure:1773: checking if --enable-ipv6 option is specified" >&5
|
echo "configure:1836: checking if --enable-ipv6 option is specified" >&5
|
||||||
# Check whether --enable-ipv6 or --disable-ipv6 was given.
|
# Check whether --enable-ipv6 or --disable-ipv6 was given.
|
||||||
if test "${enable_ipv6+set}" = set; then
|
if test "${enable_ipv6+set}" = set; then
|
||||||
enableval="$enable_ipv6"
|
enableval="$enable_ipv6"
|
||||||
|
@ -1785,7 +1848,7 @@ fi
|
||||||
echo "$ac_t""${enable_ipv6-no}" 1>&6
|
echo "$ac_t""${enable_ipv6-no}" 1>&6
|
||||||
|
|
||||||
echo $ac_n "checking whether to build optimizer debugging code""... $ac_c" 1>&6
|
echo $ac_n "checking whether to build optimizer debugging code""... $ac_c" 1>&6
|
||||||
echo "configure:1789: checking whether to build optimizer debugging code" >&5
|
echo "configure:1852: checking whether to build optimizer debugging code" >&5
|
||||||
# Check whether --enable-optimizer-dbg or --disable-optimizer-dbg was given.
|
# Check whether --enable-optimizer-dbg or --disable-optimizer-dbg was given.
|
||||||
if test "${enable_optimizer_dbg+set}" = set; then
|
if test "${enable_optimizer_dbg+set}" = set; then
|
||||||
enableval="$enable_optimizer_dbg"
|
enableval="$enable_optimizer_dbg"
|
||||||
|
@ -1801,7 +1864,7 @@ fi
|
||||||
echo "$ac_t""${enable_optimizer_dbg-no}" 1>&6
|
echo "$ac_t""${enable_optimizer_dbg-no}" 1>&6
|
||||||
|
|
||||||
echo $ac_n "checking whether to build parser debugging code""... $ac_c" 1>&6
|
echo $ac_n "checking whether to build parser debugging code""... $ac_c" 1>&6
|
||||||
echo "configure:1805: checking whether to build parser debugging code" >&5
|
echo "configure:1868: checking whether to build parser debugging code" >&5
|
||||||
# Check whether --enable-yydebug or --disable-yydebug was given.
|
# Check whether --enable-yydebug or --disable-yydebug was given.
|
||||||
if test "${enable_yydebug+set}" = set; then
|
if test "${enable_yydebug+set}" = set; then
|
||||||
enableval="$enable_yydebug"
|
enableval="$enable_yydebug"
|
||||||
|
@ -1823,17 +1886,17 @@ dlpi)
|
||||||
do
|
do
|
||||||
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
|
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
|
||||||
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
|
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
|
||||||
echo "configure:1827: checking for $ac_hdr" >&5
|
echo "configure:1890: checking for $ac_hdr" >&5
|
||||||
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
|
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
|
||||||
echo $ac_n "(cached) $ac_c" 1>&6
|
echo $ac_n "(cached) $ac_c" 1>&6
|
||||||
else
|
else
|
||||||
cat > conftest.$ac_ext <<EOF
|
cat > conftest.$ac_ext <<EOF
|
||||||
#line 1832 "configure"
|
#line 1895 "configure"
|
||||||
#include "confdefs.h"
|
#include "confdefs.h"
|
||||||
#include <$ac_hdr>
|
#include <$ac_hdr>
|
||||||
EOF
|
EOF
|
||||||
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
|
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
|
||||||
{ (eval echo configure:1837: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
{ (eval echo configure:1900: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||||
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
|
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
|
||||||
if test -z "$ac_err"; then
|
if test -z "$ac_err"; then
|
||||||
rm -rf conftest*
|
rm -rf conftest*
|
||||||
|
@ -1860,7 +1923,7 @@ fi
|
||||||
done
|
done
|
||||||
|
|
||||||
echo $ac_n "checking for /dev/dlpi device""... $ac_c" 1>&6
|
echo $ac_n "checking for /dev/dlpi device""... $ac_c" 1>&6
|
||||||
echo "configure:1864: checking for /dev/dlpi device" >&5
|
echo "configure:1927: checking for /dev/dlpi device" >&5
|
||||||
if test -c /dev/dlpi ; then
|
if test -c /dev/dlpi ; then
|
||||||
echo "$ac_t""yes" 1>&6
|
echo "$ac_t""yes" 1>&6
|
||||||
cat >> confdefs.h <<\EOF
|
cat >> confdefs.h <<\EOF
|
||||||
|
@ -1871,7 +1934,7 @@ EOF
|
||||||
echo "$ac_t""no" 1>&6
|
echo "$ac_t""no" 1>&6
|
||||||
dir="/dev/dlpi"
|
dir="/dev/dlpi"
|
||||||
echo $ac_n "checking for $dir directory""... $ac_c" 1>&6
|
echo $ac_n "checking for $dir directory""... $ac_c" 1>&6
|
||||||
echo "configure:1875: checking for $dir directory" >&5
|
echo "configure:1938: checking for $dir directory" >&5
|
||||||
if test -d $dir ; then
|
if test -d $dir ; then
|
||||||
echo "$ac_t""yes" 1>&6
|
echo "$ac_t""yes" 1>&6
|
||||||
cat >> confdefs.h <<EOF
|
cat >> confdefs.h <<EOF
|
||||||
|
@ -1886,7 +1949,7 @@ EOF
|
||||||
|
|
||||||
linux)
|
linux)
|
||||||
echo $ac_n "checking Linux kernel version""... $ac_c" 1>&6
|
echo $ac_n "checking Linux kernel version""... $ac_c" 1>&6
|
||||||
echo "configure:1890: checking Linux kernel version" >&5
|
echo "configure:1953: checking Linux kernel version" >&5
|
||||||
if test "$cross_compiling" = yes; then
|
if test "$cross_compiling" = yes; then
|
||||||
if eval "test \"`echo '$''{'ac_cv_linux_vers'+set}'`\" = set"; then
|
if eval "test \"`echo '$''{'ac_cv_linux_vers'+set}'`\" = set"; then
|
||||||
echo $ac_n "(cached) $ac_c" 1>&6
|
echo $ac_n "(cached) $ac_c" 1>&6
|
||||||
|
@ -1911,12 +1974,12 @@ fi
|
||||||
{ echo "configure: error: version 2 or higher required; see the INSTALL doc for more info" 1>&2; exit 1; }
|
{ echo "configure: error: version 2 or higher required; see the INSTALL doc for more info" 1>&2; exit 1; }
|
||||||
fi
|
fi
|
||||||
echo $ac_n "checking if if_packet.h has tpacket_stats defined""... $ac_c" 1>&6
|
echo $ac_n "checking if if_packet.h has tpacket_stats defined""... $ac_c" 1>&6
|
||||||
echo "configure:1915: checking if if_packet.h has tpacket_stats defined" >&5
|
echo "configure:1978: checking if if_packet.h has tpacket_stats defined" >&5
|
||||||
if eval "test \"`echo '$''{'ac_cv_lbl_tpacket_stats'+set}'`\" = set"; then
|
if eval "test \"`echo '$''{'ac_cv_lbl_tpacket_stats'+set}'`\" = set"; then
|
||||||
echo $ac_n "(cached) $ac_c" 1>&6
|
echo $ac_n "(cached) $ac_c" 1>&6
|
||||||
else
|
else
|
||||||
cat > conftest.$ac_ext <<EOF
|
cat > conftest.$ac_ext <<EOF
|
||||||
#line 1920 "configure"
|
#line 1983 "configure"
|
||||||
#include "confdefs.h"
|
#include "confdefs.h"
|
||||||
|
|
||||||
# include <linux/if_packet.h>
|
# include <linux/if_packet.h>
|
||||||
|
@ -1924,7 +1987,7 @@ int main() {
|
||||||
struct tpacket_stats stats
|
struct tpacket_stats stats
|
||||||
; return 0; }
|
; return 0; }
|
||||||
EOF
|
EOF
|
||||||
if { (eval echo configure:1928: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
if { (eval echo configure:1991: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||||
rm -rf conftest*
|
rm -rf conftest*
|
||||||
ac_cv_lbl_tpacket_stats=yes
|
ac_cv_lbl_tpacket_stats=yes
|
||||||
else
|
else
|
||||||
|
@ -1957,7 +2020,7 @@ null)
|
||||||
esac
|
esac
|
||||||
|
|
||||||
echo $ac_n "checking whether we have /proc/net/dev""... $ac_c" 1>&6
|
echo $ac_n "checking whether we have /proc/net/dev""... $ac_c" 1>&6
|
||||||
echo "configure:1961: checking whether we have /proc/net/dev" >&5
|
echo "configure:2024: checking whether we have /proc/net/dev" >&5
|
||||||
if test -r /proc/net/dev ; then
|
if test -r /proc/net/dev ; then
|
||||||
ac_cv_lbl_proc_net_dev=yes
|
ac_cv_lbl_proc_net_dev=yes
|
||||||
else
|
else
|
||||||
|
@ -2022,7 +2085,7 @@ esac
|
||||||
|
|
||||||
if test "$with_dag" != no; then
|
if test "$with_dag" != no; then
|
||||||
echo $ac_n "checking whether we have DAG API""... $ac_c" 1>&6
|
echo $ac_n "checking whether we have DAG API""... $ac_c" 1>&6
|
||||||
echo "configure:2026: checking whether we have DAG API" >&5
|
echo "configure:2089: checking whether we have DAG API" >&5
|
||||||
|
|
||||||
if test -z "$dag_root"; then
|
if test -z "$dag_root"; then
|
||||||
dag_root=$srcdir/../dag
|
dag_root=$srcdir/../dag
|
||||||
|
@ -2094,7 +2157,7 @@ do
|
||||||
# Extract the first word of "$ac_prog", so it can be a program name with args.
|
# Extract the first word of "$ac_prog", so it can be a program name with args.
|
||||||
set dummy $ac_prog; ac_word=$2
|
set dummy $ac_prog; ac_word=$2
|
||||||
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
|
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
|
||||||
echo "configure:2098: checking for $ac_word" >&5
|
echo "configure:2161: checking for $ac_word" >&5
|
||||||
if eval "test \"`echo '$''{'ac_cv_prog_V_LEX'+set}'`\" = set"; then
|
if eval "test \"`echo '$''{'ac_cv_prog_V_LEX'+set}'`\" = set"; then
|
||||||
echo $ac_n "(cached) $ac_c" 1>&6
|
echo $ac_n "(cached) $ac_c" 1>&6
|
||||||
else
|
else
|
||||||
|
@ -2128,7 +2191,7 @@ test -n "$V_LEX" || V_LEX="lex"
|
||||||
if test "$V_LEX" = flex ; then
|
if test "$V_LEX" = flex ; then
|
||||||
# The -V flag was added in 2.4
|
# The -V flag was added in 2.4
|
||||||
echo $ac_n "checking for flex 2.4 or higher""... $ac_c" 1>&6
|
echo $ac_n "checking for flex 2.4 or higher""... $ac_c" 1>&6
|
||||||
echo "configure:2132: checking for flex 2.4 or higher" >&5
|
echo "configure:2195: checking for flex 2.4 or higher" >&5
|
||||||
if eval "test \"`echo '$''{'ac_cv_lbl_flex_v24'+set}'`\" = set"; then
|
if eval "test \"`echo '$''{'ac_cv_lbl_flex_v24'+set}'`\" = set"; then
|
||||||
echo $ac_n "(cached) $ac_c" 1>&6
|
echo $ac_n "(cached) $ac_c" 1>&6
|
||||||
else
|
else
|
||||||
|
@ -2154,7 +2217,7 @@ do
|
||||||
# Extract the first word of "$ac_prog", so it can be a program name with args.
|
# Extract the first word of "$ac_prog", so it can be a program name with args.
|
||||||
set dummy $ac_prog; ac_word=$2
|
set dummy $ac_prog; ac_word=$2
|
||||||
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
|
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
|
||||||
echo "configure:2158: checking for $ac_word" >&5
|
echo "configure:2221: checking for $ac_word" >&5
|
||||||
if eval "test \"`echo '$''{'ac_cv_prog_V_YACC'+set}'`\" = set"; then
|
if eval "test \"`echo '$''{'ac_cv_prog_V_YACC'+set}'`\" = set"; then
|
||||||
echo $ac_n "(cached) $ac_c" 1>&6
|
echo $ac_n "(cached) $ac_c" 1>&6
|
||||||
else
|
else
|
||||||
|
@ -2201,7 +2264,7 @@ if test "$V_LEX" = lex ; then
|
||||||
# Some versions of lex can't handle the definitions section of scanner.l .
|
# Some versions of lex can't handle the definitions section of scanner.l .
|
||||||
# Try lexing it and complain if it can't deal.
|
# Try lexing it and complain if it can't deal.
|
||||||
echo $ac_n "checking for capable lex""... $ac_c" 1>&6
|
echo $ac_n "checking for capable lex""... $ac_c" 1>&6
|
||||||
echo "configure:2205: checking for capable lex" >&5
|
echo "configure:2268: checking for capable lex" >&5
|
||||||
if eval "test \"`echo '$''{'tcpdump_cv_capable_lex'+set}'`\" = set"; then
|
if eval "test \"`echo '$''{'tcpdump_cv_capable_lex'+set}'`\" = set"; then
|
||||||
echo $ac_n "(cached) $ac_c" 1>&6
|
echo $ac_n "(cached) $ac_c" 1>&6
|
||||||
else
|
else
|
||||||
|
@ -2253,19 +2316,19 @@ EOF
|
||||||
|
|
||||||
sinix*)
|
sinix*)
|
||||||
echo $ac_n "checking if SINIX compiler defines sinix""... $ac_c" 1>&6
|
echo $ac_n "checking if SINIX compiler defines sinix""... $ac_c" 1>&6
|
||||||
echo "configure:2257: checking if SINIX compiler defines sinix" >&5
|
echo "configure:2320: checking if SINIX compiler defines sinix" >&5
|
||||||
if eval "test \"`echo '$''{'ac_cv_cc_sinix_defined'+set}'`\" = set"; then
|
if eval "test \"`echo '$''{'ac_cv_cc_sinix_defined'+set}'`\" = set"; then
|
||||||
echo $ac_n "(cached) $ac_c" 1>&6
|
echo $ac_n "(cached) $ac_c" 1>&6
|
||||||
else
|
else
|
||||||
cat > conftest.$ac_ext <<EOF
|
cat > conftest.$ac_ext <<EOF
|
||||||
#line 2262 "configure"
|
#line 2325 "configure"
|
||||||
#include "confdefs.h"
|
#include "confdefs.h"
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
int i = sinix;
|
int i = sinix;
|
||||||
; return 0; }
|
; return 0; }
|
||||||
EOF
|
EOF
|
||||||
if { (eval echo configure:2269: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
if { (eval echo configure:2332: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||||
rm -rf conftest*
|
rm -rf conftest*
|
||||||
ac_cv_cc_sinix_defined=yes
|
ac_cv_cc_sinix_defined=yes
|
||||||
else
|
else
|
||||||
|
@ -2301,7 +2364,7 @@ esac
|
||||||
# Extract the first word of "ranlib", so it can be a program name with args.
|
# Extract the first word of "ranlib", so it can be a program name with args.
|
||||||
set dummy ranlib; ac_word=$2
|
set dummy ranlib; ac_word=$2
|
||||||
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
|
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
|
||||||
echo "configure:2305: checking for $ac_word" >&5
|
echo "configure:2368: checking for $ac_word" >&5
|
||||||
if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
|
if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
|
||||||
echo $ac_n "(cached) $ac_c" 1>&6
|
echo $ac_n "(cached) $ac_c" 1>&6
|
||||||
else
|
else
|
||||||
|
@ -2369,12 +2432,12 @@ EOF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo $ac_n "checking if sockaddr struct has sa_len member""... $ac_c" 1>&6
|
echo $ac_n "checking if sockaddr struct has sa_len member""... $ac_c" 1>&6
|
||||||
echo "configure:2373: checking if sockaddr struct has sa_len member" >&5
|
echo "configure:2436: checking if sockaddr struct has sa_len member" >&5
|
||||||
if eval "test \"`echo '$''{'ac_cv_lbl_sockaddr_has_sa_len'+set}'`\" = set"; then
|
if eval "test \"`echo '$''{'ac_cv_lbl_sockaddr_has_sa_len'+set}'`\" = set"; then
|
||||||
echo $ac_n "(cached) $ac_c" 1>&6
|
echo $ac_n "(cached) $ac_c" 1>&6
|
||||||
else
|
else
|
||||||
cat > conftest.$ac_ext <<EOF
|
cat > conftest.$ac_ext <<EOF
|
||||||
#line 2378 "configure"
|
#line 2441 "configure"
|
||||||
#include "confdefs.h"
|
#include "confdefs.h"
|
||||||
|
|
||||||
# include <sys/types.h>
|
# include <sys/types.h>
|
||||||
|
@ -2383,7 +2446,7 @@ int main() {
|
||||||
u_int i = sizeof(((struct sockaddr *)0)->sa_len)
|
u_int i = sizeof(((struct sockaddr *)0)->sa_len)
|
||||||
; return 0; }
|
; return 0; }
|
||||||
EOF
|
EOF
|
||||||
if { (eval echo configure:2387: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
if { (eval echo configure:2450: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||||
rm -rf conftest*
|
rm -rf conftest*
|
||||||
ac_cv_lbl_sockaddr_has_sa_len=yes
|
ac_cv_lbl_sockaddr_has_sa_len=yes
|
||||||
else
|
else
|
||||||
|
@ -2404,12 +2467,12 @@ EOF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo $ac_n "checking if sockaddr_storage struct exists""... $ac_c" 1>&6
|
echo $ac_n "checking if sockaddr_storage struct exists""... $ac_c" 1>&6
|
||||||
echo "configure:2408: checking if sockaddr_storage struct exists" >&5
|
echo "configure:2471: checking if sockaddr_storage struct exists" >&5
|
||||||
if eval "test \"`echo '$''{'ac_cv_lbl_has_sockaddr_storage'+set}'`\" = set"; then
|
if eval "test \"`echo '$''{'ac_cv_lbl_has_sockaddr_storage'+set}'`\" = set"; then
|
||||||
echo $ac_n "(cached) $ac_c" 1>&6
|
echo $ac_n "(cached) $ac_c" 1>&6
|
||||||
else
|
else
|
||||||
cat > conftest.$ac_ext <<EOF
|
cat > conftest.$ac_ext <<EOF
|
||||||
#line 2413 "configure"
|
#line 2476 "configure"
|
||||||
#include "confdefs.h"
|
#include "confdefs.h"
|
||||||
|
|
||||||
# include <sys/types.h>
|
# include <sys/types.h>
|
||||||
|
@ -2418,7 +2481,7 @@ int main() {
|
||||||
u_int i = sizeof (struct sockaddr_storage)
|
u_int i = sizeof (struct sockaddr_storage)
|
||||||
; return 0; }
|
; return 0; }
|
||||||
EOF
|
EOF
|
||||||
if { (eval echo configure:2422: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
if { (eval echo configure:2485: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||||
rm -rf conftest*
|
rm -rf conftest*
|
||||||
ac_cv_lbl_has_sockaddr_storage=yes
|
ac_cv_lbl_has_sockaddr_storage=yes
|
||||||
else
|
else
|
||||||
|
@ -2439,12 +2502,12 @@ EOF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo $ac_n "checking if dl_hp_ppa_info_t struct has dl_module_id_1 member""... $ac_c" 1>&6
|
echo $ac_n "checking if dl_hp_ppa_info_t struct has dl_module_id_1 member""... $ac_c" 1>&6
|
||||||
echo "configure:2443: checking if dl_hp_ppa_info_t struct has dl_module_id_1 member" >&5
|
echo "configure:2506: checking if dl_hp_ppa_info_t struct has dl_module_id_1 member" >&5
|
||||||
if eval "test \"`echo '$''{'ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1'+set}'`\" = set"; then
|
if eval "test \"`echo '$''{'ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1'+set}'`\" = set"; then
|
||||||
echo $ac_n "(cached) $ac_c" 1>&6
|
echo $ac_n "(cached) $ac_c" 1>&6
|
||||||
else
|
else
|
||||||
cat > conftest.$ac_ext <<EOF
|
cat > conftest.$ac_ext <<EOF
|
||||||
#line 2448 "configure"
|
#line 2511 "configure"
|
||||||
#include "confdefs.h"
|
#include "confdefs.h"
|
||||||
|
|
||||||
# include <sys/types.h>
|
# include <sys/types.h>
|
||||||
|
@ -2454,7 +2517,7 @@ int main() {
|
||||||
u_int i = sizeof(((dl_hp_ppa_info_t *)0)->dl_module_id_1)
|
u_int i = sizeof(((dl_hp_ppa_info_t *)0)->dl_module_id_1)
|
||||||
; return 0; }
|
; return 0; }
|
||||||
EOF
|
EOF
|
||||||
if { (eval echo configure:2458: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
if { (eval echo configure:2521: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||||
rm -rf conftest*
|
rm -rf conftest*
|
||||||
ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1=yes
|
ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1=yes
|
||||||
else
|
else
|
||||||
|
@ -2475,7 +2538,7 @@ EOF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo $ac_n "checking if unaligned accesses fail""... $ac_c" 1>&6
|
echo $ac_n "checking if unaligned accesses fail""... $ac_c" 1>&6
|
||||||
echo "configure:2479: checking if unaligned accesses fail" >&5
|
echo "configure:2542: checking if unaligned accesses fail" >&5
|
||||||
if eval "test \"`echo '$''{'ac_cv_lbl_unaligned_fail'+set}'`\" = set"; then
|
if eval "test \"`echo '$''{'ac_cv_lbl_unaligned_fail'+set}'`\" = set"; then
|
||||||
echo $ac_n "(cached) $ac_c" 1>&6
|
echo $ac_n "(cached) $ac_c" 1>&6
|
||||||
else
|
else
|
||||||
|
@ -2596,7 +2659,7 @@ ln -s ${srcdir}/bpf/net net
|
||||||
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
|
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
|
||||||
# ./install, which can be erroneously created by make from ./install.sh.
|
# ./install, which can be erroneously created by make from ./install.sh.
|
||||||
echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
|
echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
|
||||||
echo "configure:2600: checking for a BSD compatible install" >&5
|
echo "configure:2663: checking for a BSD compatible install" >&5
|
||||||
if test -z "$INSTALL"; then
|
if test -z "$INSTALL"; then
|
||||||
if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
|
if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
|
||||||
echo $ac_n "(cached) $ac_c" 1>&6
|
echo $ac_n "(cached) $ac_c" 1>&6
|
||||||
|
@ -2802,6 +2865,7 @@ s%@build_os@%$build_os%g
|
||||||
s%@SHLICC2@%$SHLICC2%g
|
s%@SHLICC2@%$SHLICC2%g
|
||||||
s%@CC@%$CC%g
|
s%@CC@%$CC%g
|
||||||
s%@CPP@%$CPP%g
|
s%@CPP@%$CPP%g
|
||||||
|
s%@LIBOBJS@%$LIBOBJS%g
|
||||||
s%@V_LEX@%$V_LEX%g
|
s%@V_LEX@%$V_LEX%g
|
||||||
s%@V_YACC@%$V_YACC%g
|
s%@V_YACC@%$V_YACC%g
|
||||||
s%@RANLIB@%$RANLIB%g
|
s%@RANLIB@%$RANLIB%g
|
||||||
|
|
13
configure.in
13
configure.in
|
@ -1,4 +1,4 @@
|
||||||
dnl @(#) $Header: /tcpdump/master/libpcap/configure.in,v 1.103 2003-12-10 09:30:57 guy Exp $ (LBL)
|
dnl @(#) $Header: /tcpdump/master/libpcap/configure.in,v 1.104 2003-12-15 01:35:04 guy Exp $ (LBL)
|
||||||
dnl
|
dnl
|
||||||
dnl Copyright (c) 1994, 1995, 1996, 1997
|
dnl Copyright (c) 1994, 1995, 1996, 1997
|
||||||
dnl The Regents of the University of California. All rights reserved.
|
dnl The Regents of the University of California. All rights reserved.
|
||||||
|
@ -6,7 +6,7 @@ dnl
|
||||||
dnl Process this file with autoconf to produce a configure script.
|
dnl Process this file with autoconf to produce a configure script.
|
||||||
dnl
|
dnl
|
||||||
|
|
||||||
AC_REVISION($Revision: 1.103 $)
|
AC_REVISION($Revision: 1.104 $)
|
||||||
AC_INIT(pcap.c)
|
AC_INIT(pcap.c)
|
||||||
|
|
||||||
AC_CANONICAL_SYSTEM
|
AC_CANONICAL_SYSTEM
|
||||||
|
@ -31,6 +31,15 @@ AC_LBL_FIXINCLUDES
|
||||||
|
|
||||||
AC_CHECK_FUNCS(ether_hostton strerror strlcpy)
|
AC_CHECK_FUNCS(ether_hostton strerror strlcpy)
|
||||||
|
|
||||||
|
needsnprintf=no
|
||||||
|
LIBOBJS=
|
||||||
|
AC_CHECK_FUNCS(vsnprintf snprintf,,
|
||||||
|
[needsnprintf=yes])
|
||||||
|
if test $needsnprintf = yes; then
|
||||||
|
LIBOBJS="$LIBOBJS snprintf.o"
|
||||||
|
fi
|
||||||
|
AC_SUBST(LIBOBJS)
|
||||||
|
|
||||||
dnl to pacify those who hate protochain insn
|
dnl to pacify those who hate protochain insn
|
||||||
AC_MSG_CHECKING(if --disable-protochain option is specified)
|
AC_MSG_CHECKING(if --disable-protochain option is specified)
|
||||||
AC_ARG_ENABLE(protochain, [ --disable-protochain disable \"protochain\" insn])
|
AC_ARG_ENABLE(protochain, [ --disable-protochain disable \"protochain\" insn])
|
||||||
|
|
14
pcap-int.h
14
pcap-int.h
|
@ -30,7 +30,7 @@
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @(#) $Header: /tcpdump/master/libpcap/pcap-int.h,v 1.58 2003-11-21 10:19:34 guy Exp $ (LBL)
|
* @(#) $Header: /tcpdump/master/libpcap/pcap-int.h,v 1.59 2003-12-15 01:35:04 guy Exp $ (LBL)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef pcap_int_h
|
#ifndef pcap_int_h
|
||||||
|
@ -237,6 +237,18 @@ int pcap_read(pcap_t *, int cnt, pcap_handler, u_char *);
|
||||||
strlen((y)))
|
strlen((y)))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
#if !defined(HAVE_SNPRINTF)
|
||||||
|
#define snprintf pcap_snprintf
|
||||||
|
extern int snprintf (char *, size_t, const char *, ...);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(HAVE_VSNPRINTF)
|
||||||
|
#define vsnprintf pcap_vsnprintf
|
||||||
|
extern int vsnprintf (char *, size_t, const char *, va_list ap);
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Routines that most pcap implementations can use for non-blocking mode.
|
* Routines that most pcap implementations can use for non-blocking mode.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -0,0 +1,632 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1995-1999 Kungliga Tekniska Högskolan
|
||||||
|
* (Royal Institute of Technology, Stockholm, Sweden).
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* 3. Neither the name of the Institute nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* $Id: snprintf.c,v 1.1 2003-12-15 01:35:05 guy Exp $ */
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef lint
|
||||||
|
static const char rcsid[] _U_ =
|
||||||
|
"@(#) $Header: /tcpdump/master/libpcap/Attic/snprintf.c,v 1.1 2003-12-15 01:35:05 guy Exp $";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <pcap-int.h>
|
||||||
|
|
||||||
|
enum format_flags {
|
||||||
|
minus_flag = 1,
|
||||||
|
plus_flag = 2,
|
||||||
|
space_flag = 4,
|
||||||
|
alternate_flag = 8,
|
||||||
|
zero_flag = 16
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Common state
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct state {
|
||||||
|
unsigned char *str;
|
||||||
|
unsigned char *s;
|
||||||
|
unsigned char *theend;
|
||||||
|
size_t sz;
|
||||||
|
size_t max_sz;
|
||||||
|
int (*append_char)(struct state *, unsigned char);
|
||||||
|
int (*reserve)(struct state *, size_t);
|
||||||
|
/* XXX - methods */
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifndef HAVE_VSNPRINTF
|
||||||
|
static int
|
||||||
|
sn_reserve (struct state *state, size_t n)
|
||||||
|
{
|
||||||
|
return state->s + n > state->theend;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
sn_append_char (struct state *state, unsigned char c)
|
||||||
|
{
|
||||||
|
if (sn_reserve (state, 1)) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
*state->s++ = c;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
static int
|
||||||
|
as_reserve (struct state *state, size_t n)
|
||||||
|
{
|
||||||
|
if (state->s + n > state->theend) {
|
||||||
|
int off = state->s - state->str;
|
||||||
|
unsigned char *tmp;
|
||||||
|
|
||||||
|
if (state->max_sz && state->sz >= state->max_sz)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
state->sz = max(state->sz * 2, state->sz + n);
|
||||||
|
if (state->max_sz)
|
||||||
|
state->sz = min(state->sz, state->max_sz);
|
||||||
|
tmp = realloc (state->str, state->sz);
|
||||||
|
if (tmp == NULL)
|
||||||
|
return 1;
|
||||||
|
state->str = tmp;
|
||||||
|
state->s = state->str + off;
|
||||||
|
state->theend = state->str + state->sz - 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
as_append_char (struct state *state, unsigned char c)
|
||||||
|
{
|
||||||
|
if(as_reserve (state, 1))
|
||||||
|
return 1;
|
||||||
|
else {
|
||||||
|
*state->s++ = c;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static int
|
||||||
|
append_number(struct state *state,
|
||||||
|
unsigned long num, unsigned base, char *rep,
|
||||||
|
int width, int prec, int flags, int minusp)
|
||||||
|
{
|
||||||
|
int len = 0;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
/* given precision, ignore zero flag */
|
||||||
|
if(prec != -1)
|
||||||
|
flags &= ~zero_flag;
|
||||||
|
else
|
||||||
|
prec = 1;
|
||||||
|
/* zero value with zero precision -> "" */
|
||||||
|
if(prec == 0 && num == 0)
|
||||||
|
return 0;
|
||||||
|
do{
|
||||||
|
if((*state->append_char)(state, rep[num % base]))
|
||||||
|
return 1;
|
||||||
|
len++;
|
||||||
|
num /= base;
|
||||||
|
}while(num);
|
||||||
|
prec -= len;
|
||||||
|
/* pad with prec zeros */
|
||||||
|
while(prec-- > 0){
|
||||||
|
if((*state->append_char)(state, '0'))
|
||||||
|
return 1;
|
||||||
|
len++;
|
||||||
|
}
|
||||||
|
/* add length of alternate prefix (added later) to len */
|
||||||
|
if(flags & alternate_flag && (base == 16 || base == 8))
|
||||||
|
len += base / 8;
|
||||||
|
/* pad with zeros */
|
||||||
|
if(flags & zero_flag){
|
||||||
|
width -= len;
|
||||||
|
if(minusp || (flags & space_flag) || (flags & plus_flag))
|
||||||
|
width--;
|
||||||
|
while(width-- > 0){
|
||||||
|
if((*state->append_char)(state, '0'))
|
||||||
|
return 1;
|
||||||
|
len++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* add alternate prefix */
|
||||||
|
if(flags & alternate_flag && (base == 16 || base == 8)){
|
||||||
|
if(base == 16)
|
||||||
|
if((*state->append_char)(state, rep[10] + 23)) /* XXX */
|
||||||
|
return 1;
|
||||||
|
if((*state->append_char)(state, '0'))
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
/* add sign */
|
||||||
|
if(minusp){
|
||||||
|
if((*state->append_char)(state, '-'))
|
||||||
|
return 1;
|
||||||
|
len++;
|
||||||
|
} else if(flags & plus_flag) {
|
||||||
|
if((*state->append_char)(state, '+'))
|
||||||
|
return 1;
|
||||||
|
len++;
|
||||||
|
} else if(flags & space_flag) {
|
||||||
|
if((*state->append_char)(state, ' '))
|
||||||
|
return 1;
|
||||||
|
len++;
|
||||||
|
}
|
||||||
|
if(flags & minus_flag)
|
||||||
|
/* swap before padding with spaces */
|
||||||
|
for(i = 0; i < len / 2; i++){
|
||||||
|
char c = state->s[-i-1];
|
||||||
|
state->s[-i-1] = state->s[-len+i];
|
||||||
|
state->s[-len+i] = c;
|
||||||
|
}
|
||||||
|
width -= len;
|
||||||
|
while(width-- > 0){
|
||||||
|
if((*state->append_char)(state, ' '))
|
||||||
|
return 1;
|
||||||
|
len++;
|
||||||
|
}
|
||||||
|
if(!(flags & minus_flag))
|
||||||
|
/* swap after padding with spaces */
|
||||||
|
for(i = 0; i < len / 2; i++){
|
||||||
|
char c = state->s[-i-1];
|
||||||
|
state->s[-i-1] = state->s[-len+i];
|
||||||
|
state->s[-len+i] = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
append_string (struct state *state,
|
||||||
|
unsigned char *arg,
|
||||||
|
int width,
|
||||||
|
int prec,
|
||||||
|
int flags)
|
||||||
|
{
|
||||||
|
if(prec != -1)
|
||||||
|
width -= prec;
|
||||||
|
else
|
||||||
|
width -= strlen((char *)arg);
|
||||||
|
if(!(flags & minus_flag))
|
||||||
|
while(width-- > 0)
|
||||||
|
if((*state->append_char) (state, ' '))
|
||||||
|
return 1;
|
||||||
|
if (prec != -1) {
|
||||||
|
while (*arg && prec--)
|
||||||
|
if ((*state->append_char) (state, *arg++))
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
while (*arg)
|
||||||
|
if ((*state->append_char) (state, *arg++))
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if(flags & minus_flag)
|
||||||
|
while(width-- > 0)
|
||||||
|
if((*state->append_char) (state, ' '))
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
append_char(struct state *state,
|
||||||
|
unsigned char arg,
|
||||||
|
int width,
|
||||||
|
int flags)
|
||||||
|
{
|
||||||
|
while(!(flags & minus_flag) && --width > 0)
|
||||||
|
if((*state->append_char) (state, ' '))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
if((*state->append_char) (state, arg))
|
||||||
|
return 1;
|
||||||
|
while((flags & minus_flag) && --width > 0)
|
||||||
|
if((*state->append_char) (state, ' '))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This can't be made into a function...
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define PARSE_INT_FORMAT(res, arg, unsig) \
|
||||||
|
if (long_flag) \
|
||||||
|
res = (unsig long)va_arg(arg, unsig long); \
|
||||||
|
else if (short_flag) \
|
||||||
|
res = (unsig short)va_arg(arg, unsig int); \
|
||||||
|
else \
|
||||||
|
res = (unsig int)va_arg(arg, unsig int)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* zyxprintf - return 0 or -1
|
||||||
|
*/
|
||||||
|
|
||||||
|
static int
|
||||||
|
xyzprintf (struct state *state, const char *char_format, va_list ap)
|
||||||
|
{
|
||||||
|
const unsigned char *format = (const unsigned char *)char_format;
|
||||||
|
unsigned char c;
|
||||||
|
|
||||||
|
while((c = *format++)) {
|
||||||
|
if (c == '%') {
|
||||||
|
int flags = 0;
|
||||||
|
int width = 0;
|
||||||
|
int prec = -1;
|
||||||
|
int long_flag = 0;
|
||||||
|
int short_flag = 0;
|
||||||
|
|
||||||
|
/* flags */
|
||||||
|
while((c = *format++)){
|
||||||
|
if(c == '-')
|
||||||
|
flags |= minus_flag;
|
||||||
|
else if(c == '+')
|
||||||
|
flags |= plus_flag;
|
||||||
|
else if(c == ' ')
|
||||||
|
flags |= space_flag;
|
||||||
|
else if(c == '#')
|
||||||
|
flags |= alternate_flag;
|
||||||
|
else if(c == '0')
|
||||||
|
flags |= zero_flag;
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if((flags & space_flag) && (flags & plus_flag))
|
||||||
|
flags ^= space_flag;
|
||||||
|
|
||||||
|
if((flags & minus_flag) && (flags & zero_flag))
|
||||||
|
flags ^= zero_flag;
|
||||||
|
|
||||||
|
/* width */
|
||||||
|
if (isdigit(c))
|
||||||
|
do {
|
||||||
|
width = width * 10 + c - '0';
|
||||||
|
c = *format++;
|
||||||
|
} while(isdigit(c));
|
||||||
|
else if(c == '*') {
|
||||||
|
width = va_arg(ap, int);
|
||||||
|
c = *format++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* precision */
|
||||||
|
if (c == '.') {
|
||||||
|
prec = 0;
|
||||||
|
c = *format++;
|
||||||
|
if (isdigit(c))
|
||||||
|
do {
|
||||||
|
prec = prec * 10 + c - '0';
|
||||||
|
c = *format++;
|
||||||
|
} while(isdigit(c));
|
||||||
|
else if (c == '*') {
|
||||||
|
prec = va_arg(ap, int);
|
||||||
|
c = *format++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* size */
|
||||||
|
|
||||||
|
if (c == 'h') {
|
||||||
|
short_flag = 1;
|
||||||
|
c = *format++;
|
||||||
|
} else if (c == 'l') {
|
||||||
|
long_flag = 1;
|
||||||
|
c = *format++;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (c) {
|
||||||
|
case 'c' :
|
||||||
|
if(append_char(state, va_arg(ap, int), width, flags))
|
||||||
|
return -1;
|
||||||
|
break;
|
||||||
|
case 's' :
|
||||||
|
if (append_string(state,
|
||||||
|
va_arg(ap, unsigned char*),
|
||||||
|
width,
|
||||||
|
prec,
|
||||||
|
flags))
|
||||||
|
return -1;
|
||||||
|
break;
|
||||||
|
case 'd' :
|
||||||
|
case 'i' : {
|
||||||
|
long arg;
|
||||||
|
unsigned long num;
|
||||||
|
int minusp = 0;
|
||||||
|
|
||||||
|
PARSE_INT_FORMAT(arg, ap, signed);
|
||||||
|
|
||||||
|
if (arg < 0) {
|
||||||
|
minusp = 1;
|
||||||
|
num = -arg;
|
||||||
|
} else
|
||||||
|
num = arg;
|
||||||
|
|
||||||
|
if (append_number (state, num, 10, "0123456789",
|
||||||
|
width, prec, flags, minusp))
|
||||||
|
return -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'u' : {
|
||||||
|
unsigned long arg;
|
||||||
|
|
||||||
|
PARSE_INT_FORMAT(arg, ap, unsigned);
|
||||||
|
|
||||||
|
if (append_number (state, arg, 10, "0123456789",
|
||||||
|
width, prec, flags, 0))
|
||||||
|
return -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'o' : {
|
||||||
|
unsigned long arg;
|
||||||
|
|
||||||
|
PARSE_INT_FORMAT(arg, ap, unsigned);
|
||||||
|
|
||||||
|
if (append_number (state, arg, 010, "01234567",
|
||||||
|
width, prec, flags, 0))
|
||||||
|
return -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'x' : {
|
||||||
|
unsigned long arg;
|
||||||
|
|
||||||
|
PARSE_INT_FORMAT(arg, ap, unsigned);
|
||||||
|
|
||||||
|
if (append_number (state, arg, 0x10, "0123456789abcdef",
|
||||||
|
width, prec, flags, 0))
|
||||||
|
return -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'X' :{
|
||||||
|
unsigned long arg;
|
||||||
|
|
||||||
|
PARSE_INT_FORMAT(arg, ap, unsigned);
|
||||||
|
|
||||||
|
if (append_number (state, arg, 0x10, "0123456789ABCDEF",
|
||||||
|
width, prec, flags, 0))
|
||||||
|
return -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'p' : {
|
||||||
|
unsigned long arg = (unsigned long)va_arg(ap, void*);
|
||||||
|
|
||||||
|
if (append_number (state, arg, 0x10, "0123456789ABCDEF",
|
||||||
|
width, prec, flags, 0))
|
||||||
|
return -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'n' : {
|
||||||
|
int *arg = va_arg(ap, int*);
|
||||||
|
*arg = state->s - state->str;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case '\0' :
|
||||||
|
--format;
|
||||||
|
/* FALLTHROUGH */
|
||||||
|
case '%' :
|
||||||
|
if ((*state->append_char)(state, c))
|
||||||
|
return -1;
|
||||||
|
break;
|
||||||
|
default :
|
||||||
|
if ( (*state->append_char)(state, '%')
|
||||||
|
|| (*state->append_char)(state, c))
|
||||||
|
return -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
if ((*state->append_char) (state, c))
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef HAVE_SNPRINTF
|
||||||
|
int
|
||||||
|
snprintf (char *str, size_t sz, const char *format, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
va_start(args, format);
|
||||||
|
ret = vsnprintf (str, sz, format, args);
|
||||||
|
|
||||||
|
#ifdef PARANOIA
|
||||||
|
{
|
||||||
|
int ret2;
|
||||||
|
char *tmp;
|
||||||
|
|
||||||
|
tmp = malloc (sz);
|
||||||
|
if (tmp == NULL)
|
||||||
|
abort ();
|
||||||
|
|
||||||
|
ret2 = vsprintf (tmp, format, args);
|
||||||
|
if (ret != ret2 || strcmp(str, tmp))
|
||||||
|
abort ();
|
||||||
|
free (tmp);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
va_end(args);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
#ifndef HAVE_ASPRINTF
|
||||||
|
int
|
||||||
|
asprintf (char **ret, const char *format, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
int val;
|
||||||
|
|
||||||
|
va_start(args, format);
|
||||||
|
val = vasprintf (ret, format, args);
|
||||||
|
|
||||||
|
#ifdef PARANOIA
|
||||||
|
{
|
||||||
|
int ret2;
|
||||||
|
char *tmp;
|
||||||
|
tmp = malloc (val + 1);
|
||||||
|
if (tmp == NULL)
|
||||||
|
abort ();
|
||||||
|
|
||||||
|
ret2 = vsprintf (tmp, format, args);
|
||||||
|
if (val != ret2 || strcmp(*ret, tmp))
|
||||||
|
abort ();
|
||||||
|
free (tmp);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
va_end(args);
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_ASNPRINTF
|
||||||
|
int
|
||||||
|
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);
|
||||||
|
|
||||||
|
#ifdef PARANOIA
|
||||||
|
{
|
||||||
|
int ret2;
|
||||||
|
char *tmp;
|
||||||
|
tmp = malloc (val + 1);
|
||||||
|
if (tmp == NULL)
|
||||||
|
abort ();
|
||||||
|
|
||||||
|
ret2 = vsprintf (tmp, format, 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)
|
||||||
|
{
|
||||||
|
return vasnprintf (ret, 0, format, args);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef HAVE_VASNPRINTF
|
||||||
|
int
|
||||||
|
vasnprintf (char **ret, size_t max_sz, const char *format, va_list args)
|
||||||
|
{
|
||||||
|
int st;
|
||||||
|
size_t len;
|
||||||
|
struct state state;
|
||||||
|
|
||||||
|
state.max_sz = max_sz;
|
||||||
|
state.sz = 1;
|
||||||
|
state.str = malloc(state.sz);
|
||||||
|
if (state.str == NULL) {
|
||||||
|
*ret = NULL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
state.s = state.str;
|
||||||
|
state.theend = state.s + state.sz - 1;
|
||||||
|
state.append_char = as_append_char;
|
||||||
|
state.reserve = as_reserve;
|
||||||
|
|
||||||
|
st = xyzprintf (&state, format, args);
|
||||||
|
if (st) {
|
||||||
|
free (state.str);
|
||||||
|
*ret = NULL;
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
|
char *tmp;
|
||||||
|
|
||||||
|
*state.s = '\0';
|
||||||
|
len = state.s - state.str;
|
||||||
|
tmp = realloc (state.str, len+1);
|
||||||
|
if (tmp == NULL) {
|
||||||
|
free (state.str);
|
||||||
|
*ret = NULL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
*ret = tmp;
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_VSNPRINTF
|
||||||
|
int
|
||||||
|
vsnprintf (char *str, size_t sz, const char *format, va_list args)
|
||||||
|
{
|
||||||
|
struct state state;
|
||||||
|
int ret;
|
||||||
|
unsigned char *ustr = (unsigned char *)str;
|
||||||
|
|
||||||
|
state.max_sz = 0;
|
||||||
|
state.sz = sz;
|
||||||
|
state.str = ustr;
|
||||||
|
state.s = ustr;
|
||||||
|
state.theend = ustr + sz - 1;
|
||||||
|
state.append_char = sn_append_char;
|
||||||
|
state.reserve = sn_reserve;
|
||||||
|
|
||||||
|
ret = xyzprintf (&state, format, args);
|
||||||
|
*state.s = '\0';
|
||||||
|
if (ret)
|
||||||
|
return sz;
|
||||||
|
else
|
||||||
|
return state.s - state.str;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
Reference in New Issue