ongrep

A cleaned up fork of ngrep for OpenBSD
git clone git://git.sgregoratto.me/ongrep
Log | Files | Refs | README | LICENSE

commit 06f52fd923cf7f1fe59915fae69d5c6a7a830dd1
parent 68bc6968ab9865e76110b44619cf938094d3e93b
Author: Jordan Ritter <jpr5@darkridge.com>
Date:   Mon, 31 Dec 2001 21:44:04 +0000

MacOS X compile support

Diffstat:
MMakefile.in | 5+++--
Mconfigure | 173++++++++++++++++++++++++++++++++++++++++++-------------------------------------
Mconfigure.in | 9+++++++++
Mngrep.c | 4++++
4 files changed, 109 insertions(+), 82 deletions(-)

diff --git a/Makefile.in b/Makefile.in @@ -12,6 +12,7 @@ INCLUDES=-I@srcdir@ @PCAP_INCLUDE@ CFLAGS=@CFLAGS@ @DEFS@ LDFLAGS=@LDFLAGS@ @PCAP_LINK@ LIBS=-lpcap @EXTRA_LIBS@ +STRIPFLAG=@STRIP@ SRC=ngrep.c OBJS=ngrep.o @@ -29,13 +30,13 @@ REGEX_OBJS=@REGEX_OBJS@ all: $(TARGET) $(TARGET): $(REGEX_TARGET) $(OBJS) - $(CC) $(CFLAGS) $(LDFLAGS) -s -o $(TARGET) $(OBJS) $(REGEX_OBJS) $(LIBS) + $(CC) $(CFLAGS) $(LDFLAGS) $(STRIPFLAG) -o $(TARGET) $(OBJS) $(REGEX_OBJS) $(LIBS) debug: $(OBJS) $(CC) $(CFLAGS) $(LDFLAGS) -g -o $(TARGET) $(OBJS) $(REGEX_OBJS) $(LIBS) static: $(OBJS) - $(CC) $(CFLAGS) $(LDFLAGS) -s -o $(TARGET).static -static $(OBJS) $(REGEX_OBJS) $(LIBS) + $(CC) $(CFLAGS) $(LDFLAGS) $(STRIPFLAG) -o $(TARGET).static -static $(OBJS) $(REGEX_OBJS) $(LIBS) install: $(TARGET) $(INSTALL) -c -m 0755 $(TARGET) $(BINDEST) diff --git a/configure b/configure @@ -12,6 +12,8 @@ ac_help= ac_default_prefix=/usr/local # Any additions from configure.in: ac_help="$ac_help + --with-pcap-includes specify the pcap include directory" +ac_help="$ac_help --with-pcre use libnet build directory" ac_help="$ac_help --with-restart use libpcap restart func" @@ -573,7 +575,7 @@ else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } fi echo $ac_n "checking host system type""... $ac_c" 1>&6 -echo "configure:577: checking host system type" >&5 +echo "configure:579: checking host system type" >&5 host_alias=$host case "$host_alias" in @@ -594,7 +596,7 @@ host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` echo "$ac_t""$host" 1>&6 echo $ac_n "checking target system type""... $ac_c" 1>&6 -echo "configure:598: checking target system type" >&5 +echo "configure:600: checking target system type" >&5 target_alias=$target case "$target_alias" in @@ -612,7 +614,7 @@ target_os=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` echo "$ac_t""$target" 1>&6 echo $ac_n "checking build system type""... $ac_c" 1>&6 -echo "configure:616: checking build system type" >&5 +echo "configure:618: checking build system type" >&5 build_alias=$build case "$build_alias" in @@ -638,7 +640,7 @@ test "$host_alias" != "$target_alias" && # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:642: checking for $ac_word" >&5 +echo "configure:644: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -668,7 +670,7 @@ if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:672: checking for $ac_word" >&5 +echo "configure:674: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -719,7 +721,7 @@ fi # Extract the first word of "cl", so it can be a program name with args. set dummy cl; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:723: checking for $ac_word" >&5 +echo "configure:725: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -751,7 +753,7 @@ fi fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:755: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 +echo "configure:757: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. @@ -762,12 +764,12 @@ cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext << EOF -#line 766 "configure" +#line 768 "configure" #include "confdefs.h" main(){return(0);} EOF -if { (eval echo configure:771: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:773: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then ac_cv_prog_cc_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then @@ -793,12 +795,12 @@ if test $ac_cv_prog_cc_works = no; then { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:797: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "configure:799: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 cross_compiling=$ac_cv_prog_cc_cross echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:802: checking whether we are using GNU C" >&5 +echo "configure:804: checking whether we are using GNU C" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -807,7 +809,7 @@ else yes; #endif EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:811: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:813: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no @@ -826,7 +828,7 @@ ac_test_CFLAGS="${CFLAGS+set}" ac_save_CFLAGS="$CFLAGS" CFLAGS= echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -echo "configure:830: checking whether ${CC-cc} accepts -g" >&5 +echo "configure:832: checking whether ${CC-cc} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -862,7 +864,7 @@ echo $ac_n "checking for prefix by $ac_c" 1>&6 # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:866: checking for $ac_word" >&5 +echo "configure:868: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_GCC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -901,7 +903,7 @@ fi echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -echo "configure:905: checking how to run the C preprocessor" >&5 +echo "configure:907: checking how to run the C preprocessor" >&5 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= @@ -916,13 +918,13 @@ else # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext <<EOF -#line 920 "configure" +#line 922 "configure" #include "confdefs.h" #include <assert.h> Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:926: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:928: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -933,13 +935,13 @@ else rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext <<EOF -#line 937 "configure" +#line 939 "configure" #include "confdefs.h" #include <assert.h> Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:943: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:945: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -950,13 +952,13 @@ else rm -rf conftest* CPP="${CC-cc} -nologo -E" cat > conftest.$ac_ext <<EOF -#line 954 "configure" +#line 956 "configure" #include "confdefs.h" #include <assert.h> Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:960: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:962: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -981,12 +983,12 @@ fi echo "$ac_t""$CPP" 1>&6 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 -echo "configure:985: checking for ANSI C header files" >&5 +echo "configure:987: checking for ANSI C header files" >&5 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 990 "configure" +#line 992 "configure" #include "confdefs.h" #include <stdlib.h> #include <stdarg.h> @@ -994,7 +996,7 @@ else #include <float.h> EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:998: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1000: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -1011,7 +1013,7 @@ rm -f conftest* if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat > conftest.$ac_ext <<EOF -#line 1015 "configure" +#line 1017 "configure" #include "confdefs.h" #include <string.h> EOF @@ -1029,7 +1031,7 @@ fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat > conftest.$ac_ext <<EOF -#line 1033 "configure" +#line 1035 "configure" #include "confdefs.h" #include <stdlib.h> EOF @@ -1050,7 +1052,7 @@ if test "$cross_compiling" = yes; then : else cat > conftest.$ac_ext <<EOF -#line 1054 "configure" +#line 1056 "configure" #include "confdefs.h" #include <ctype.h> #define ISLOWER(c) ('a' <= (c) && (c) <= 'z') @@ -1061,7 +1063,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); exit (0); } EOF -if { (eval echo configure:1065: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1067: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then : else @@ -1085,12 +1087,12 @@ EOF fi echo $ac_n "checking for working const""... $ac_c" 1>&6 -echo "configure:1089: checking for working const" >&5 +echo "configure:1091: checking for working const" >&5 if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 1094 "configure" +#line 1096 "configure" #include "confdefs.h" int main() { @@ -1139,7 +1141,7 @@ ccp = (char const *const *) p; ; return 0; } EOF -if { (eval echo configure:1143: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1145: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_const=yes else @@ -1160,12 +1162,12 @@ EOF fi echo $ac_n "checking for size_t""... $ac_c" 1>&6 -echo "configure:1164: checking for size_t" >&5 +echo "configure:1166: checking for size_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 1169 "configure" +#line 1171 "configure" #include "confdefs.h" #include <sys/types.h> #if STDC_HEADERS @@ -1193,12 +1195,12 @@ EOF fi echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6 -echo "configure:1197: checking return type of signal handlers" >&5 +echo "configure:1199: checking return type of signal handlers" >&5 if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 1202 "configure" +#line 1204 "configure" #include "confdefs.h" #include <sys/types.h> #include <signal.h> @@ -1215,7 +1217,7 @@ int main() { int i; ; return 0; } EOF -if { (eval echo configure:1219: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1221: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_type_signal=void else @@ -1236,19 +1238,19 @@ EOF # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works # for constant arguments. Useless! echo $ac_n "checking for working alloca.h""... $ac_c" 1>&6 -echo "configure:1240: checking for working alloca.h" >&5 +echo "configure:1242: checking for working alloca.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_alloca_h'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 1245 "configure" +#line 1247 "configure" #include "confdefs.h" #include <alloca.h> int main() { char *p = alloca(2 * sizeof(int)); ; return 0; } EOF -if { (eval echo configure:1252: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1254: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_header_alloca_h=yes else @@ -1269,12 +1271,12 @@ EOF fi echo $ac_n "checking for alloca""... $ac_c" 1>&6 -echo "configure:1273: checking for alloca" >&5 +echo "configure:1275: checking for alloca" >&5 if eval "test \"`echo '$''{'ac_cv_func_alloca_works'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 1278 "configure" +#line 1280 "configure" #include "confdefs.h" #ifdef __GNUC__ @@ -1302,7 +1304,7 @@ int main() { char *p = (char *) alloca(1); ; return 0; } EOF -if { (eval echo configure:1306: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1308: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_func_alloca_works=yes else @@ -1334,12 +1336,12 @@ EOF echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6 -echo "configure:1338: checking whether alloca needs Cray hooks" >&5 +echo "configure:1340: checking whether alloca needs Cray hooks" >&5 if eval "test \"`echo '$''{'ac_cv_os_cray'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 1343 "configure" +#line 1345 "configure" #include "confdefs.h" #if defined(CRAY) && ! defined(CRAY2) webecray @@ -1364,12 +1366,12 @@ echo "$ac_t""$ac_cv_os_cray" 1>&6 if test $ac_cv_os_cray = yes; then for ac_func in _getb67 GETB67 getb67; do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:1368: checking for $ac_func" >&5 +echo "configure:1370: 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 1373 "configure" +#line 1375 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func(); below. */ @@ -1392,7 +1394,7 @@ $ac_func(); ; return 0; } EOF -if { (eval echo configure:1396: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1398: \"$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 @@ -1419,7 +1421,7 @@ done fi echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6 -echo "configure:1423: checking stack direction for C alloca" >&5 +echo "configure:1425: checking stack direction for C alloca" >&5 if eval "test \"`echo '$''{'ac_cv_c_stack_direction'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1427,7 +1429,7 @@ else ac_cv_c_stack_direction=0 else cat > conftest.$ac_ext <<EOF -#line 1431 "configure" +#line 1433 "configure" #include "confdefs.h" find_stack_direction () { @@ -1446,7 +1448,7 @@ main () exit (find_stack_direction() < 0); } EOF -if { (eval echo configure:1450: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1452: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_c_stack_direction=1 else @@ -1470,17 +1472,17 @@ fi ac_safe=`echo "strings.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for strings.h""... $ac_c" 1>&6 -echo "configure:1474: checking for strings.h" >&5 +echo "configure:1476: checking for strings.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 1479 "configure" +#line 1481 "configure" #include "confdefs.h" #include <strings.h> EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1484: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1486: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -1504,17 +1506,17 @@ fi ac_safe=`echo "netinet/if_ether.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for netinet/if_ether.h""... $ac_c" 1>&6 -echo "configure:1508: checking for netinet/if_ether.h" >&5 +echo "configure:1510: checking for netinet/if_ether.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 1513 "configure" +#line 1515 "configure" #include "confdefs.h" #include <netinet/if_ether.h> EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1518: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1520: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -1541,14 +1543,25 @@ fi echo $ac_n "checking for a complete set of pcap headers""... $ac_c" 1>&6 -echo "configure:1545: checking for a complete set of pcap headers" >&5 +echo "configure:1547: checking for a complete set of pcap headers" >&5 + possible_dirs="`eval echo -n ${includedir}` \ /usr/include /usr/include/pcap \ /usr/local/include /usr/local/include/pcap \ /usr/share/include /usr/share/include/pcap" + +# Check whether --with-pcap-includes or --without-pcap-includes was given. +if test "${with_pcap_includes+set}" = set; then + withval="$with_pcap_includes" + PCAP_DIR=$withval +else + PCAP_DIR=$possible_dirs +fi + + pcap_dir="" -for dir in $possible_dirs ; do +for dir in $PCAP_DIR ; do if test -d $dir -a -r "$dir/pcap.h" -a \ -r "$dir/net/bpf.h" ; then if test -n "$pcap_dir" -a "$pcap_dir" != "$dir"; then @@ -1577,7 +1590,7 @@ else echo $ac_n "checking for usable bpf.h""... $ac_c" 1>&6 -echo "configure:1581: checking for usable bpf.h" >&5 +echo "configure:1594: checking for usable bpf.h" >&5 if test -n "`grep DLT_RAW $pcap_dir/net/bpf.h`" ; then echo yep else @@ -1644,9 +1657,9 @@ EOF echo $ac_n "checking for a dumb udphdr declaration""... $ac_c" 1>&6 -echo "configure:1648: checking for a dumb udphdr declaration" >&5 +echo "configure:1661: checking for a dumb udphdr declaration" >&5 cat > conftest.$ac_ext <<EOF -#line 1650 "configure" +#line 1663 "configure" #include "confdefs.h" int main() { @@ -1665,7 +1678,7 @@ unsigned short bar = foo.uh_sport; ; return 0; } EOF -if { (eval echo configure:1669: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1682: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo nope else @@ -1696,7 +1709,7 @@ EOF echo $ac_n "checking for socket in -lsocket""... $ac_c" 1>&6 -echo "configure:1700: checking for socket in -lsocket" >&5 +echo "configure:1713: checking for socket in -lsocket" >&5 ac_lib_var=`echo socket'_'socket | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1704,7 +1717,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lsocket $LIBS" cat > conftest.$ac_ext <<EOF -#line 1708 "configure" +#line 1721 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -1715,7 +1728,7 @@ int main() { socket() ; return 0; } EOF -if { (eval echo configure:1719: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1732: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1744,7 +1757,7 @@ echo no socket in -lsocket\?; exit fi echo $ac_n "checking for gethostbyname in -lnsl""... $ac_c" 1>&6 -echo "configure:1748: checking for gethostbyname in -lnsl" >&5 +echo "configure:1761: checking for gethostbyname in -lnsl" >&5 ac_lib_var=`echo nsl'_'gethostbyname | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1752,7 +1765,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lnsl $LIBS" cat > conftest.$ac_ext <<EOF -#line 1756 "configure" +#line 1769 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -1763,7 +1776,7 @@ int main() { gethostbyname() ; return 0; } EOF -if { (eval echo configure:1767: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1780: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1837,7 +1850,7 @@ esac echo $ac_n "checking for pcap_open_live in -lpcap""... $ac_c" 1>&6 -echo "configure:1841: checking for pcap_open_live in -lpcap" >&5 +echo "configure:1854: checking for pcap_open_live in -lpcap" >&5 ac_lib_var=`echo pcap'_'pcap_open_live | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1845,7 +1858,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lpcap $LIBS" cat > conftest.$ac_ext <<EOF -#line 1849 "configure" +#line 1862 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -1856,7 +1869,7 @@ int main() { pcap_open_live() ; return 0; } EOF -if { (eval echo configure:1860: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1873: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1913,7 +1926,7 @@ fi if test "$need_restart" = "yes" ; then echo $ac_n "checking for pcap_restart in -lpcap""... $ac_c" 1>&6 -echo "configure:1917: checking for pcap_restart in -lpcap" >&5 +echo "configure:1930: checking for pcap_restart in -lpcap" >&5 ac_lib_var=`echo pcap'_'pcap_restart | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1921,7 +1934,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lpcap $LIBS" cat > conftest.$ac_ext <<EOF -#line 1925 "configure" +#line 1938 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -1932,7 +1945,7 @@ int main() { pcap_restart() ; return 0; } EOF -if { (eval echo configure:1936: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1949: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1954,7 +1967,7 @@ EOF else echo "$ac_t""no" 1>&6 echo $ac_n "checking for pcap_yyrestart in -lpcap""... $ac_c" 1>&6 -echo "configure:1958: checking for pcap_yyrestart in -lpcap" >&5 +echo "configure:1971: checking for pcap_yyrestart in -lpcap" >&5 ac_lib_var=`echo pcap'_'pcap_yyrestart | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1962,7 +1975,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lpcap $LIBS" cat > conftest.$ac_ext <<EOF -#line 1966 "configure" +#line 1979 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -1973,7 +1986,7 @@ int main() { pcap_yyrestart() ; return 0; } EOF -if { (eval echo configure:1977: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1990: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1995,7 +2008,7 @@ EOF else echo "$ac_t""no" 1>&6 echo $ac_n "checking for yyrestart in -lpcap""... $ac_c" 1>&6 -echo "configure:1999: checking for yyrestart in -lpcap" >&5 +echo "configure:2012: checking for yyrestart in -lpcap" >&5 ac_lib_var=`echo pcap'_'yyrestart | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2003,7 +2016,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lpcap $LIBS" cat > conftest.$ac_ext <<EOF -#line 2007 "configure" +#line 2020 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -2014,7 +2027,7 @@ int main() { yyrestart() ; return 0; } EOF -if { (eval echo configure:2018: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2031: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else diff --git a/configure.in b/configure.in @@ -114,6 +114,8 @@ dnl OS-specific options dnl AC_DEFINE(_BSD_SOURCE) AC_DEFINE(__FAVOR_BSD) +STRIPFLAG="-s" + case "$target_os" in @@ -176,6 +178,12 @@ unsigned short bar = foo.uh_sport; ;; +*darwin*) + AC_DEFINE(MACOSX) + STRIPFLAG="" + + ;; + *) AC_MSG_WARN(Your OS ($target_os) is not supported yet. Try\ playing with the build host and target options.) @@ -184,6 +192,7 @@ unsigned short bar = foo.uh_sport; esac +AC_SUBST(STRIPFLAG) AC_CHECK_LIB(pcap, pcap_open_live,,echo need pcap lib; exit) diff --git a/ngrep.c b/ngrep.c @@ -731,7 +731,11 @@ int strishex(char *str) { void print_time_absolute(struct pcap_pkthdr *h) { +#ifdef MACOSX + struct tm *t = localtime((const time_t *)&h->ts.tv_sec); +#else struct tm *t = localtime(&h->ts.tv_sec); +#endif printf("%02d/%02d/%02d %02d:%02d:%02d.%06d ", t->tm_year+1900, t->tm_mon+1, t->tm_mday, t->tm_hour,