From 804d3f62454895c1560a690728b859f68ee35bf6 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Thu, 20 Apr 2017 14:07:06 -0700 Subject: Use cfile_write_failure_message() in the randpkt code. Change-Id: I32ef7ff85f854782e5dd02c3e7f12436a120bc13 Reviewed-on: https://code.wireshark.org/review/21259 Reviewed-by: Guy Harris --- randpkt_core/randpkt_core.c | 64 +++++---------------------------------------- 1 file changed, 6 insertions(+), 58 deletions(-) (limited to 'randpkt_core/randpkt_core.c') diff --git a/randpkt_core/randpkt_core.c b/randpkt_core/randpkt_core.c index d9f4a1b1f2..10afdf9e17 100644 --- a/randpkt_core/randpkt_core.c +++ b/randpkt_core/randpkt_core.c @@ -29,9 +29,11 @@ #include #include #include -#include "wsutil/file_util.h" +#include #include +#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); } } -- cgit v1.2.1