summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt2
-rw-r--r--Makefile.am1
-rw-r--r--extcap/Makefile.am1
-rw-r--r--randpkt_core/randpkt_core.c64
-rw-r--r--ui/failure_message.c28
5 files changed, 28 insertions, 68 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index dc2b9550e8..fbc7f17709 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -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}
diff --git a/Makefile.am b/Makefile.am
index 83f2e5ce6b..48c7a84568 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -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@ \
diff --git a/extcap/Makefile.am b/extcap/Makefile.am
index 77bd317d8d..491522ad07 100644
--- a/extcap/Makefile.am
+++ b/extcap/Makefile.am
@@ -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@
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 <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);
}
}
diff --git a/ui/failure_message.c b/ui/failure_message.c
index 5a6a0f3d43..7626562987 100644
--- a/ui/failure_message.c
+++ b/ui/failure_message.c
@@ -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);
}