From dc952ca6648f7815e63d1bc648acc16e67f8eb0d Mon Sep 17 00:00:00 2001 From: snar Date: Wed, 4 Apr 2007 15:16:26 +0000 Subject: [PATCH] ok, solaris not works (as expected, though..) --- Makefile.in | 8 +-- bgpq_expander.c | 12 +++- config.h.in | 6 ++ configure | 150 ++++++++++++++++++++++++++++++++++++++++++++++++ configure.in | 3 + 5 files changed, 173 insertions(+), 6 deletions(-) diff --git a/Makefile.in b/Makefile.in index 511f3cb..bea8494 100644 --- a/Makefile.in +++ b/Makefile.in @@ -2,10 +2,10 @@ CC=@CC@ CFLAGS=@CFLAGS@ @DEFS@ -g -Wall -I. -O0 LDADD=@LDFLAGS@ @LIBS@ -OBJECTS=bgpq3.o sx_report.o bgpq_expander.o sx_slentry.o bgpq3_printer.o -OBJECTS+=sx_prefix.o -SRCS=bgpq3.c sx_report.c bgpq_expander.c sx_slentry.c bgpq3_printer.c -SRCS+=sx_prefix.c +OBJECTS=bgpq3.o sx_report.o bgpq_expander.o sx_slentry.o bgpq3_printer.o \ + sx_prefix.o +SRCS=bgpq3.c sx_report.c bgpq_expander.c sx_slentry.c bgpq3_printer.c \ + sx_prefix.c all: bgpq3 diff --git a/bgpq_expander.c b/bgpq_expander.c index a42cb3c..8ac84cf 100644 --- a/bgpq_expander.c +++ b/bgpq_expander.c @@ -150,11 +150,14 @@ bgpq_expand_ripe(FILE* f, int (*callback)(char*, void*), void* udata, va_end(ap); SX_DEBUG(debug_expander,"expander(ripe): sending '%s'\n", request); + fseek(f,0,SEEK_END); fwrite(request,1,strlen(request),f); fflush(f); sawNL=0; + fseek(f,0,SEEK_END); while(fgets(request,sizeof(request),f)) { + fseek(f,0,SEEK_END); if(request[0]=='\n') { if(b->family==AF_INET && otype && !strcmp(otype,"route")) { SX_DEBUG(debug_expander,"expander(ripe): got route: %s\n", @@ -183,7 +186,7 @@ bgpq_expand_ripe(FILE* f, int (*callback)(char*, void*), void* udata, *c=0; otype=strdup(request); c++; - while((isspace(*c))) c++; + while((isspace((int)*c))) c++; object=strdup(c); c=strchr(object,'\n'); if(c) *c=0; @@ -219,6 +222,7 @@ bgpq_expand_radb(FILE* f, int (*callback)(char*, void*), void* udata, SX_DEBUG(debug_expander,"expander: sending '%s'\n", request); ret=fwrite(request,1,strlen(request),f); + fseek(f,0,SEEK_END); if(ret!=strlen(request)) { sx_report(SX_FATAL,"Partial write to radb, only %i bytes written: %s\n", ret,strerror(errno)); @@ -235,7 +239,7 @@ bgpq_expand_radb(FILE* f, int (*callback)(char*, void*), void* udata, exit(1); }; SX_DEBUG(debug_expander>2,"expander: initially got %i bytes, '%s'\n", - ret,request); + strlen(request),request); if(request[0]=='A') { char* eon, *c; long togot=strtoul(request+1,&eon,10); @@ -255,6 +259,8 @@ bgpq_expand_radb(FILE* f, int (*callback)(char*, void*), void* udata, }; exit(1); }; + SX_DEBUG(debug_expander>2,"expander: final reply of %i bytes, '%s'\n", + strlen(recvbuffer),recvbuffer); for(c=recvbuffer; csources && b->sources[0]!=0) { char sources[128]; snprintf(sources,sizeof(sources),"!s%s\n", b->sources); + fseek(f,0,SEEK_END); fwrite(sources,strlen(sources),1,f); }; diff --git a/config.h.in b/config.h.in index 493d850..fd35799 100644 --- a/config.h.in +++ b/config.h.in @@ -1,5 +1,11 @@ /* config.h.in. Generated from configure.in by autoheader. */ +/* Define to 1 if you have the `nsl' library (-lnsl). */ +#undef HAVE_LIBNSL + +/* Define to 1 if you have the `socket' library (-lsocket). */ +#undef HAVE_LIBSOCKET + /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT diff --git a/configure b/configure index 985d068..76295d0 100755 --- a/configure +++ b/configure @@ -2175,6 +2175,156 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $ ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +echo "$as_me:$LINENO: checking for socket in -lsocket" >&5 +echo $ECHO_N "checking for socket in -lsocket... $ECHO_C" >&6 +if test "${ac_cv_lib_socket_socket+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lsocket $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char socket (); +int +main () +{ +socket (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_socket_socket=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_socket_socket=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_socket_socket" >&5 +echo "${ECHO_T}$ac_cv_lib_socket_socket" >&6 +if test $ac_cv_lib_socket_socket = yes; then + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBSOCKET 1 +_ACEOF + + LIBS="-lsocket $LIBS" + +fi + + +echo "$as_me:$LINENO: checking for getaddrinfo in -lnsl" >&5 +echo $ECHO_N "checking for getaddrinfo in -lnsl... $ECHO_C" >&6 +if test "${ac_cv_lib_nsl_getaddrinfo+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lnsl $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char getaddrinfo (); +int +main () +{ +getaddrinfo (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_nsl_getaddrinfo=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_nsl_getaddrinfo=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_nsl_getaddrinfo" >&5 +echo "${ECHO_T}$ac_cv_lib_nsl_getaddrinfo" >&6 +if test $ac_cv_lib_nsl_getaddrinfo = yes; then + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBNSL 1 +_ACEOF + + LIBS="-lnsl $LIBS" + +fi + + ac_config_files="$ac_config_files Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure diff --git a/configure.in b/configure.in index b35bdb8..5363839 100644 --- a/configure.in +++ b/configure.in @@ -2,5 +2,8 @@ AC_INIT(bgpq3.c) AC_CONFIG_HEADER(config.h) AC_PROG_CC +AC_CHECK_LIB(socket,socket) +AC_CHECK_LIB(nsl,getaddrinfo) + AC_OUTPUT(Makefile)