forked from osmocom/wireshark
Use cfile_write_failure_message() in the randpkt code.
Change-Id: I32ef7ff85f854782e5dd02c3e7f12436a120bc13 Reviewed-on: https://code.wireshark.org/review/21259 Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
parent
64ec2b2e5e
commit
804d3f6245
|
@ -2362,6 +2362,7 @@ endif()
|
|||
if(BUILD_randpkt)
|
||||
set(randpkt_LIBS
|
||||
randpkt_core
|
||||
ui
|
||||
wiretap
|
||||
wsutil
|
||||
${M_LIBRARIES}
|
||||
|
@ -2686,6 +2687,7 @@ endif()
|
|||
if(ENABLE_EXTCAP AND BUILD_randpktdump)
|
||||
set(randpktdump_LIBS
|
||||
randpkt_core
|
||||
ui
|
||||
wiretap
|
||||
${GLIB2_LIBRARIES}
|
||||
${CMAKE_DL_LIBS}
|
||||
|
|
|
@ -698,6 +698,7 @@ randpkt_CPPFLAGS = $(AM_CPPFLAGS) $(GLIB_CFLAGS)
|
|||
# Libraries with which to link randpkt.
|
||||
randpkt_LDADD = \
|
||||
randpkt_core/librandpkt_core.a \
|
||||
ui/libui.a \
|
||||
wiretap/libwiretap.la \
|
||||
wsutil/libwsutil.la \
|
||||
@GLIB_LIBS@ \
|
||||
|
|
|
@ -67,6 +67,7 @@ endif
|
|||
# Libraries and plugin flags with which to link randpktdump.
|
||||
randpktdump_LDADD = \
|
||||
../randpkt_core/librandpkt_core.a \
|
||||
../ui/libui.a \
|
||||
../wiretap/libwiretap.la \
|
||||
../wsutil/libwsutil.la \
|
||||
@GLIB_LIBS@
|
||||
|
|
|
@ -29,9 +29,11 @@
|
|||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "wsutil/file_util.h"
|
||||
#include <wsutil/file_util.h>
|
||||
#include <wiretap/wtap_opttypes.h>
|
||||
|
||||
#include "ui/failure_message.h"
|
||||
|
||||
#define array_length(x) (sizeof x / sizeof x[0])
|
||||
|
||||
#define INVALID_LEN 1
|
||||
|
@ -623,63 +625,9 @@ void randpkt_loop(randpkt_example* example, guint64 produce_count)
|
|||
}
|
||||
|
||||
if (!wtap_dump(example->dump, pkthdr, buffer, &err, &err_info)) {
|
||||
fprintf(stderr, "randpkt: Error writing to %s: %s\n",
|
||||
example->filename, wtap_strerror(err));
|
||||
switch (err) {
|
||||
|
||||
case WTAP_ERR_UNWRITABLE_ENCAP:
|
||||
/*
|
||||
* This is a problem with the particular
|
||||
* frame we're writing and the file type
|
||||
* and subtype we're writing; note that,
|
||||
* and report the file type/subtype.
|
||||
*/
|
||||
fprintf(stderr,
|
||||
"Frame has a network type that can't be saved in a \"%s\" file.\n",
|
||||
wtap_file_type_subtype_short_string(WTAP_FILE_TYPE_SUBTYPE_PCAP));
|
||||
break;
|
||||
|
||||
case WTAP_ERR_PACKET_TOO_LARGE:
|
||||
/*
|
||||
* This is a problem with the particular
|
||||
* frame we're writing and the file type
|
||||
* and subtype we're writing; note that,
|
||||
* and report the file type/subtype.
|
||||
*/
|
||||
fprintf(stderr,
|
||||
"Frame is too large for a \"%s\" file.\n",
|
||||
wtap_file_type_subtype_short_string(WTAP_FILE_TYPE_SUBTYPE_PCAP));
|
||||
break;
|
||||
|
||||
case WTAP_ERR_UNWRITABLE_REC_TYPE:
|
||||
/*
|
||||
* This is a problem with the particular
|
||||
* record we're writing and the file type
|
||||
* and subtype we're writing; note that,
|
||||
* and report the file type/subtype.
|
||||
*/
|
||||
fprintf(stderr,
|
||||
"Record has a record type that can't be saved in a \"%s\" file.\n",
|
||||
wtap_file_type_subtype_short_string(WTAP_FILE_TYPE_SUBTYPE_PCAP));
|
||||
break;
|
||||
|
||||
case WTAP_ERR_UNWRITABLE_REC_DATA:
|
||||
/*
|
||||
* This is a problem with the particular
|
||||
* record we're writing and the file type
|
||||
* and subtype we're writing; note that,
|
||||
* and report the file type/subtype.
|
||||
*/
|
||||
fprintf(stderr,
|
||||
"Record has data that can't be saved in a \"%s\" file.\n(%s)\n",
|
||||
wtap_file_type_subtype_short_string(WTAP_FILE_TYPE_SUBTYPE_PCAP),
|
||||
err_info != NULL ? err_info : "no information supplied");
|
||||
g_free(err_info);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
cfile_write_failure_message("randpkt", NULL,
|
||||
example->filename, err, err_info, 0,
|
||||
WTAP_FILE_TYPE_SUBTYPE_PCAP);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -292,10 +292,18 @@ cfile_write_failure_message(const char *progname, const char *in_filename,
|
|||
guint32 framenum, int file_type_subtype)
|
||||
{
|
||||
char *in_file_string;
|
||||
char *in_frame_string;
|
||||
char *out_file_string;
|
||||
|
||||
/* Get a string that describes what we're reading from */
|
||||
in_file_string = input_file_description(in_filename);
|
||||
if (in_filename == NULL) {
|
||||
in_frame_string = g_strdup("");
|
||||
} else {
|
||||
in_file_string = input_file_description(in_filename);
|
||||
in_frame_string = g_strdup_printf(" %u of %s", framenum,
|
||||
in_file_string);
|
||||
g_free(in_file_string);
|
||||
}
|
||||
|
||||
/* Get a string that describes what we're writing to */
|
||||
out_file_string = output_file_description(out_filename);
|
||||
|
@ -308,8 +316,8 @@ cfile_write_failure_message(const char *progname, const char *in_filename,
|
|||
* and the file type and subtype we're writing; note that,
|
||||
* and report the frame number and file type/subtype.
|
||||
*/
|
||||
cmdarg_err("Frame %u of %s has a network type that can't be saved in a \"%s\" file.",
|
||||
framenum, in_file_string,
|
||||
cmdarg_err("Frame%s has a network type that can't be saved in a \"%s\" file.",
|
||||
in_frame_string,
|
||||
wtap_file_type_subtype_short_string(file_type_subtype));
|
||||
break;
|
||||
|
||||
|
@ -319,8 +327,8 @@ cfile_write_failure_message(const char *progname, const char *in_filename,
|
|||
* and the file type and subtype we're writing; note that,
|
||||
* and report the frame number and file type/subtype.
|
||||
*/
|
||||
cmdarg_err("Frame %u of %s is larger than %s supports in a \"%s\" file.",
|
||||
framenum, in_file_string, progname,
|
||||
cmdarg_err("Frame%s is larger than %s supports in a \"%s\" file.",
|
||||
in_frame_string, progname,
|
||||
wtap_file_type_subtype_short_string(file_type_subtype));
|
||||
break;
|
||||
|
||||
|
@ -330,8 +338,8 @@ cfile_write_failure_message(const char *progname, const char *in_filename,
|
|||
* and the file type and subtype we're writing; note that,
|
||||
* and report the record number and file type/subtype.
|
||||
*/
|
||||
cmdarg_err("Record %u of %s has a record type that can't be saved in a \"%s\" file.",
|
||||
framenum, in_file_string,
|
||||
cmdarg_err("Record%s has a record type that can't be saved in a \"%s\" file.",
|
||||
in_frame_string,
|
||||
wtap_file_type_subtype_short_string(file_type_subtype));
|
||||
break;
|
||||
|
||||
|
@ -341,9 +349,9 @@ cfile_write_failure_message(const char *progname, const char *in_filename,
|
|||
* and the file type and subtype we're writing; note that,
|
||||
* and report the record number and file type/subtype.
|
||||
*/
|
||||
cmdarg_err("Record %u of %s has data that can't be saved in a \"%s\" file.\n"
|
||||
cmdarg_err("Record%s has data that can't be saved in a \"%s\" file.\n"
|
||||
"(%s)",
|
||||
framenum, in_file_string,
|
||||
in_frame_string,
|
||||
wtap_file_type_subtype_short_string(file_type_subtype),
|
||||
err_info != NULL ? err_info : "no information supplied");
|
||||
g_free(err_info);
|
||||
|
@ -373,7 +381,7 @@ cfile_write_failure_message(const char *progname, const char *in_filename,
|
|||
out_file_string, wtap_strerror(err));
|
||||
break;
|
||||
}
|
||||
g_free(in_file_string);
|
||||
g_free(in_frame_string);
|
||||
g_free(out_file_string);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue