X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/0b1de8f73d9b1484095a5ba484e83021ef7bc7ae..0845bc813c1cc48b18cdefff0b387c110647463c:/print.c diff --git a/print.c b/print.c index c7381c0a..0d831daa 100644 --- a/print.c +++ b/print.c @@ -311,10 +311,12 @@ get_print_info(netdissect_options *ndo, int type) if (printinfo.printer == NULL) { dltname = pcap_datalink_val_to_name(type); if (dltname != NULL) - error("packet printing is not supported for link type %s: use -w", - dltname); + (*ndo->ndo_error)(ndo, + "packet printing is not supported for link type %s: use -w", + dltname); else - error("packet printing is not supported for link type %d: use -w", type); + (*ndo->ndo_error)(ndo, + "packet printing is not supported for link type %d: use -w", type); } return (printinfo); } @@ -420,11 +422,12 @@ ndo_default_print(netdissect_options *ndo, const u_char *bp, u_int length) /* VARARGS */ static void -ndo_error(netdissect_options *ndo _U_, const char *fmt, ...) +ndo_error(netdissect_options *ndo, const char *fmt, ...) { va_list ap; - (void)fprintf(stderr, "%s: ", program_name); + if(ndo->program_name) + (void)fprintf(stderr, "%s: ", ndo->program_name); va_start(ap, fmt); (void)vfprintf(stderr, fmt, ap); va_end(ap); @@ -439,11 +442,13 @@ ndo_error(netdissect_options *ndo _U_, const char *fmt, ...) /* VARARGS */ static void -ndo_warning(netdissect_options *ndo _U_, const char *fmt, ...) +ndo_warning(netdissect_options *ndo, const char *fmt, ...) { va_list ap; - (void)fprintf(stderr, "%s: WARNING: ", program_name); + if(ndo->program_name) + (void)fprintf(stderr, "%s: ", ndo->program_name); + (void)fprintf(stderr, "WARNING: "); va_start(ap, fmt); (void)vfprintf(stderr, fmt, ap); va_end(ap);