A program that use the library should set it. Done for tcpdump.
ndo_error() and ndo_warning() print now 'ndo->program_name'.
Moreover:
Fix indent
int ndo_Hflag; /* dissect 802.11s draft mesh standard */
int ndo_packet_number; /* print a packet number in the beginning of line */
int ndo_suppress_default_print; /* don't use default_print() for unknown packet types */
- int ndo_tstamp_precision; /* requested time stamp precision */
+ int ndo_tstamp_precision; /* requested time stamp precision */
const char *ndo_dltname;
+ const char *program_name; /* Name of the program using the library */
char *ndo_espsecret;
struct sa_list *ndo_sa_list_head; /* used by print-esp.c */
struct sa_list *ndo_sa_default;
- char *ndo_sigsecret; /* Signature verification secret key */
+ char *ndo_sigsecret; /* Signature verification secret key */
int ndo_packettype; /* as specified by -T */
/* pointer to void function to output stuff */
void (*ndo_default_print)(netdissect_options *,
- register const u_char *bp, register u_int length);
+ register const u_char *bp, register u_int length);
/* pointer to function to do regular output */
int (*ndo_printf)(netdissect_options *,
/* 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);
/* 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);
WFileName = NULL;
dlt = -1;
if ((cp = strrchr(argv[0], '/')) != NULL)
- program_name = cp + 1;
+ ndo->program_name = program_name = cp + 1;
else
- program_name = argv[0];
+ ndo->program_name = program_name = argv[0];
/*
* On platforms where the CPU doesn't support unaligned loads,