#include <time.h>
#include <signal.h>
#include <getopt.h>
+#include <stdarg.h>
#include <netinet/in.h>
void ev_remove(HOST_ENTRY *h);
void add_cidr(char *);
void add_range(char *, char *);
+void print_warning(char *fmt, ...);
/*** function definitions ***/
if( p->icmp_code > ICMP_UNREACH_MAXTYPE )
{
- fprintf( stderr, "ICMP Unreachable (Invalid Code) from %s for ICMP Echo sent to %s",
+ print_warning("ICMP Unreachable (Invalid Code) from %s for ICMP Echo sent to %s",
inet_ntoa( addr->sin_addr ), h->host );
#else
if( p->icmp6_code > ICMP_UNREACH_MAXTYPE )
{
- fprintf( stderr, "ICMP Unreachable (Invalid Code) from %s for ICMP Echo sent to %s",
+ print_warning("ICMP Unreachable (Invalid Code) from %s for ICMP Echo sent to %s",
addr_ascii, h->host );
#endif
}/* IF */
else
{
- fprintf( stderr, "%s from %s for ICMP Echo sent to %s",
+ print_warning("%s from %s for ICMP Echo sent to %s",
#ifndef IPV6
icmp_unreach_str[p->icmp_code], inet_ntoa( addr->sin_addr ), h->host );
#else
if( inet_addr( h->host ) == -1 )
#ifndef IPV6
- fprintf( stderr, " (%s)", inet_ntoa( h->saddr.sin_addr ) );
+ print_warning(" (%s)", inet_ntoa( h->saddr.sin_addr ) );
#else
- fprintf( stderr, " (%s)", addr_ascii);
+ print_warning(" (%s)", addr_ascii);
#endif
- fprintf( stderr, "\n" );
+ print_warning("\n" );
}/* IF */
if( getnetgrent( &machine, &user_ignored, &domain_ignored ) == 0 )
{
endnetgrent();
- if( !quiet_flag )
- fprintf( stderr, "%s address not found\n", name );
+ print_warning("%s address not found\n", name );
num_noaddress++;
return;
endnetgrent();
return;
#else
- if( !quiet_flag )
- fprintf( stderr, "%s address not found\n", name );
+ print_warning("%s address not found\n", name );
num_noaddress++;
return ;
host_add = ( struct in_addr* )*( host_ent->h_addr_list );
if( host_add == NULL )
{
- if( !quiet_flag )
- fprintf( stderr, "%s has no address data\n", name );
+ print_warning("%s has no address data\n", name );
num_noaddress++;
return;
} /* errno_crash_and_burn() */
+/************************************************************
+
+ Function: print_warning
+
+ Description: fprintf(stderr, ...), unless running with -q
+
+*************************************************************/
+
+void print_warning(char *format, ...) {
+ va_list args;
+ if(!quiet_flag) {
+ va_start(args, format );
+ vfprintf(stderr, format, args);
+ va_end(args);
+ }
+}
+
+
+
/************************************************************
Function: timeval_diff