static guint32 firstsec, firstusec;
static guint32 prevsec, prevusec;
static GString *comp_info_str, *runtime_info_str;
-static gboolean quiet;
static gboolean print_packet_info; /* TRUE if we're to print packet information */
/*
static print_stream_t *print_stream;
#ifdef HAVE_LIBPCAP
+/*
+ * TRUE if we're to print packet counts to keep track of captured packets.
+ */
+static gboolean print_packet_counts;
+
typedef struct _loop_data {
gboolean go; /* TRUE as long as we're supposed to keep capturing */
gint linktype;
#else
gboolean capture_option_specified = FALSE;
#endif
+ gboolean quiet = FALSE;
gchar *save_file = NULL;
int out_file_type = WTAP_FILE_PCAP;
gchar *cf_name = NULL, *rfilter = NULL;
break;
case 'r': /* Read capture file xxx */
cf_name = g_strdup(optarg);
- quiet = TRUE; /* We're not capturing, so don't print packet counts */
break;
case 'R': /* Read file filter */
rfilter = optarg;
exit(0);
}
+ if (!quiet) {
+ /*
+ * The user didn't ask us not to print a count of packets as
+ * they arrive, so do so.
+ */
+ print_packet_counts = TRUE;
+ }
+
capture(save_file, out_file_type);
if (capture_opts.ringbuffer_on) {
if (cnd_ring_timeout != NULL)
cnd_delete(cnd_ring_timeout);
- if ((save_file != NULL) && !quiet) {
- /* We're saving to a file, which means we're printing packet counts
- to stderr if we are not running silent and deep.
+ if (print_packet_counts) {
+ /* We're printing packet counts to stderr.
Send a newline so that we move to the line after the packet count. */
fprintf(stderr, "\n");
}
if (!process_packet(&cfile, ldat->pdh, 0, &whdr, &pseudo_header, pd, &err)) {
/* Error writing to a capture file */
- if (!quiet) {
- /* We're capturing packets, so (if -q not specified) we're printing
- a count of packets captured; move to the line after the count. */
+ if (print_packet_counts) {
+ /* We're printing counts of packets captured; move to the line after
+ the count. */
fprintf(stderr, "\n");
}
show_capture_file_io_error(ldat->save_file, err, FALSE);
signal(SIGINFO, report_counts_siginfo);
#endif /* SIGINFO */
- if (quiet || print_packet_info) {
+ if (!print_packet_counts) {
/* Report the count only if we aren't printing a packet count
as packets arrive. */
fprintf(stderr, "%u packets captured\n", ld.packet_count);
if (!wtap_dump(pdh, whdr, pseudo_header, pd, err))
return FALSE;
#ifdef HAVE_LIBPCAP
- /* Report packet capture count if not quiet */
- if (!quiet && !print_packet_info) {
- /* Don't print a packet count if we were asked not to with "-q"
- or if we're also printing packet info. */
+ if (print_packet_counts) {
+ /* We're printing packet counts. */
if (ld.packet_count != 0) {
fprintf(stderr, "\r%u ", ld.packet_count);
/* stderr could be line buffered */