forked from osmocom/wireshark
move global capture_child flag into capture_options
svn path=/trunk/; revision=12855
This commit is contained in:
parent
316569ef2b
commit
d9be4670a7
|
@ -69,11 +69,6 @@
|
|||
#endif
|
||||
#include "ui_util.h"
|
||||
|
||||
/*
|
||||
* Capture options.
|
||||
*/
|
||||
gboolean capture_child; /* if this is the child for "-S" */
|
||||
|
||||
|
||||
/* Win32 needs the O_BINARY flag for open() */
|
||||
#ifndef O_BINARY
|
||||
|
@ -299,7 +294,7 @@ capture_start(capture_options *capture_opts, gboolean *stats_known, struct pcap_
|
|||
* Catch SIGUSR1, so that we exit cleanly if the parent process
|
||||
* kills us with it due to the user selecting "Capture->Stop".
|
||||
*/
|
||||
if (capture_child)
|
||||
if (capture_opts->capture_child)
|
||||
signal(SIGUSR1, stop_capture_signal_handler);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -46,6 +46,7 @@ typedef struct capture_options_tag {
|
|||
gboolean promisc_mode; /**< Capture in promiscuous mode */
|
||||
int linktype; /**< Data link type to use, or -1 for
|
||||
"use default" */
|
||||
gboolean capture_child; /**< True if this is the child for "-S" */
|
||||
|
||||
/* GUI related */
|
||||
gboolean sync_mode; /**< Fork a child to do the capture,
|
||||
|
@ -77,9 +78,6 @@ typedef struct capture_options_tag {
|
|||
gint32 autostop_duration; /**< Maximum capture duration */
|
||||
} capture_options;
|
||||
|
||||
/** True if this is the child for "-S" */
|
||||
extern gboolean capture_child;
|
||||
|
||||
|
||||
/** Open a specified file, or create a temporary file, and start a capture
|
||||
* to the file in question.
|
||||
|
|
|
@ -179,8 +179,9 @@ typedef struct _loop_data {
|
|||
|
||||
static void capture_loop_packet_cb(guchar *user, const struct pcap_pkthdr *phdr,
|
||||
const guchar *pd);
|
||||
static void capture_loop_popup_errmsg(const char *);
|
||||
static void capture_loop_get_errmsg(char *, int, const char *, int, gboolean);
|
||||
static void capture_loop_popup_errmsg(capture_options *capture_opts, const char *errmsg);
|
||||
static void capture_loop_get_errmsg(char *errmsg, int errmsglen, const char *fname,
|
||||
int err, gboolean is_close);
|
||||
|
||||
|
||||
|
||||
|
@ -598,7 +599,7 @@ static int capture_loop_open_input(capture_options *capture_opts, loop_data *ld,
|
|||
mode or fork mode, it shouldn't do any UI stuff until we pop up the
|
||||
capture-progress window, and, since we couldn't start the
|
||||
capture, we haven't popped it up. */
|
||||
if (!capture_child) {
|
||||
if (!capture_opts->capture_child) {
|
||||
main_window_update();
|
||||
}
|
||||
|
||||
|
@ -627,7 +628,7 @@ static int capture_loop_open_input(capture_options *capture_opts, loop_data *ld,
|
|||
* capture-progress window, and, since we couldn't start the
|
||||
* capture, we haven't popped it up.
|
||||
*/
|
||||
if (!capture_child) {
|
||||
if (!capture_opts->capture_child) {
|
||||
main_window_update();
|
||||
}
|
||||
|
||||
|
@ -871,7 +872,7 @@ capture_loop_dispatch(loop_data *ld, char *errmsg, int errmsg_len) {
|
|||
if (sel_ret < 0 && errno != EINTR) {
|
||||
g_snprintf(errmsg, errmsg_len,
|
||||
"Unexpected error from select: %s", strerror(errno));
|
||||
capture_loop_popup_errmsg(errmsg);
|
||||
capture_loop_popup_errmsg(capture_opts, errmsg);
|
||||
ld->go = FALSE;
|
||||
}
|
||||
} else {
|
||||
|
@ -937,7 +938,7 @@ capture_loop_dispatch(loop_data *ld, char *errmsg, int errmsg_len) {
|
|||
if (sel_ret < 0 && errno != EINTR) {
|
||||
g_snprintf(errmsg, errmsg_len,
|
||||
"Unexpected error from select: %s", strerror(errno));
|
||||
capture_loop_popup_errmsg(errmsg);
|
||||
capture_loop_popup_errmsg(capture_opts, errmsg);
|
||||
ld->go = FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -1038,7 +1039,7 @@ capture_loop_start(capture_options *capture_opts, gboolean *stats_known, struct
|
|||
in other places as well - and I don't think that works all the
|
||||
time in any case, due to libpcap bugs. */
|
||||
|
||||
if (capture_child) {
|
||||
if (capture_opts->capture_child) {
|
||||
/* Well, we should be able to start capturing.
|
||||
|
||||
This is the child process for a sync mode capture, so sync out
|
||||
|
@ -1146,7 +1147,7 @@ capture_loop_start(capture_options *capture_opts, gboolean *stats_known, struct
|
|||
/* do sync here */
|
||||
fflush(wtap_dump_file(ld.wtap_pdh));
|
||||
|
||||
if (capture_child) {
|
||||
if (capture_opts->capture_child) {
|
||||
/* This is the child process for a sync mode capture, so send
|
||||
our parent a message saying we've written out "ld.sync_packets"
|
||||
packets to the capture file. */
|
||||
|
@ -1213,11 +1214,11 @@ capture_loop_start(capture_options *capture_opts, gboolean *stats_known, struct
|
|||
if (ld.pcap_err) {
|
||||
g_snprintf(errmsg, sizeof(errmsg), "Error while capturing packets: %s",
|
||||
pcap_geterr(ld.pcap_h));
|
||||
capture_loop_popup_errmsg(errmsg);
|
||||
capture_loop_popup_errmsg(capture_opts, errmsg);
|
||||
}
|
||||
#ifndef _WIN32
|
||||
else if (ld.from_cap_pipe && ld.cap_pipe_err == PIPERR)
|
||||
capture_loop_popup_errmsg(errmsg);
|
||||
capture_loop_popup_errmsg(capture_opts, errmsg);
|
||||
#endif
|
||||
|
||||
/* did we had an error while capturing? */
|
||||
|
@ -1226,7 +1227,7 @@ capture_loop_start(capture_options *capture_opts, gboolean *stats_known, struct
|
|||
} else {
|
||||
capture_loop_get_errmsg(errmsg, sizeof(errmsg), cfile.save_file, ld.err,
|
||||
FALSE);
|
||||
capture_loop_popup_errmsg(errmsg);
|
||||
capture_loop_popup_errmsg(capture_opts, errmsg);
|
||||
write_ok = FALSE;
|
||||
}
|
||||
|
||||
|
@ -1238,7 +1239,7 @@ capture_loop_start(capture_options *capture_opts, gboolean *stats_known, struct
|
|||
if (!close_ok && write_ok) {
|
||||
capture_loop_get_errmsg(errmsg, sizeof(errmsg), cfile.save_file, err_close,
|
||||
TRUE);
|
||||
capture_loop_popup_errmsg(errmsg);
|
||||
capture_loop_popup_errmsg(capture_opts, errmsg);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1257,7 +1258,7 @@ capture_loop_start(capture_options *capture_opts, gboolean *stats_known, struct
|
|||
dropped. */
|
||||
if (pcap_stats(ld.pcap_h, stats) >= 0) {
|
||||
*stats_known = TRUE;
|
||||
if (capture_child) {
|
||||
if (capture_opts->capture_child) {
|
||||
/* Let the parent process know. */
|
||||
sync_pipe_drops_to_parent(stats->ps_drop);
|
||||
}
|
||||
|
@ -1265,7 +1266,7 @@ capture_loop_start(capture_options *capture_opts, gboolean *stats_known, struct
|
|||
g_snprintf(errmsg, sizeof(errmsg),
|
||||
"Can't get packet-drop statistics: %s",
|
||||
pcap_geterr(ld.pcap_h));
|
||||
capture_loop_popup_errmsg(errmsg);
|
||||
capture_loop_popup_errmsg(capture_opts, errmsg);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1290,7 +1291,7 @@ error:
|
|||
g_free(cfile.save_file);
|
||||
}
|
||||
cfile.save_file = NULL;
|
||||
capture_loop_popup_errmsg(errmsg);
|
||||
capture_loop_popup_errmsg(capture_opts, errmsg);
|
||||
|
||||
/* close the input file (pcap or cap_pipe) */
|
||||
capture_loop_close_input(&ld);
|
||||
|
@ -1364,9 +1365,9 @@ capture_loop_get_errmsg(char *errmsg, int errmsglen, const char *fname,
|
|||
}
|
||||
|
||||
static void
|
||||
capture_loop_popup_errmsg(const char *errmsg)
|
||||
capture_loop_popup_errmsg(capture_options *capture_opts, const char *errmsg)
|
||||
{
|
||||
if (capture_child) {
|
||||
if (capture_opts->capture_child) {
|
||||
/* This is the child process for a sync mode capture.
|
||||
Send the error message to our parent, so they can display a
|
||||
dialog box containing it. */
|
||||
|
|
|
@ -51,11 +51,6 @@
|
|||
#include "follow_dlg.h"
|
||||
|
||||
|
||||
/* XXX - use capture.h instead */
|
||||
/*#include "capture.h"*/
|
||||
extern gboolean capture_child;
|
||||
|
||||
|
||||
|
||||
#if GTK_MAJOR_VERSION < 2
|
||||
guint m_font_height, m_font_width;
|
||||
|
@ -715,7 +710,7 @@ static void try_to_get_windows_font_gtk2(void)
|
|||
#endif /* _WIN32 */
|
||||
|
||||
|
||||
void font_init(void)
|
||||
void font_init(gboolean capture_child)
|
||||
{
|
||||
#if GTK_MAJOR_VERSION < 2
|
||||
gchar *bold_font_name;
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
#define __FONT_UTILS_H__
|
||||
|
||||
/** Init the application and user fonts at program start. */
|
||||
extern void font_init(void);
|
||||
extern void font_init(gboolean capture_child);
|
||||
|
||||
/** Return value from font_apply() */
|
||||
typedef enum {
|
||||
|
|
16
gtk/main.c
16
gtk/main.c
|
@ -1622,13 +1622,15 @@ main(int argc, char *argv[])
|
|||
console_log_handler, NULL);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBPCAP
|
||||
#ifndef HAVE_LIBPCAP
|
||||
capture_opts->capture_child = FALSE;
|
||||
#else
|
||||
command_name = get_basename(ethereal_path);
|
||||
/* Set "capture_child" to indicate whether this is going to be a child
|
||||
process for a "-S" capture. */
|
||||
capture_child = (strcmp(command_name, CHILD_NAME) == 0);
|
||||
capture_opts->capture_child = (strcmp(command_name, CHILD_NAME) == 0);
|
||||
/* We want a splash screen only if we're not a child process */
|
||||
if (capture_child) {
|
||||
if (capture_opts->capture_child) {
|
||||
strcat(optstring, OPTSTRING_CHILD);
|
||||
} else
|
||||
#endif
|
||||
|
@ -1784,7 +1786,7 @@ main(int argc, char *argv[])
|
|||
|
||||
Otherwise, set promiscuous mode from the preferences setting. */
|
||||
/* the same applies to other preferences settings as well. */
|
||||
if (capture_child) {
|
||||
if (capture_opts->capture_child) {
|
||||
capture_opts->promisc_mode = TRUE; /* maybe changed by command line below */
|
||||
capture_opts->show_info = TRUE; /* maybe changed by command line below */
|
||||
capture_opts->sync_mode = TRUE; /* always true in child process */
|
||||
|
@ -2277,7 +2279,7 @@ main(int argc, char *argv[])
|
|||
}
|
||||
}
|
||||
|
||||
if (capture_child) {
|
||||
if (capture_opts->capture_child) {
|
||||
if (cfile.save_file_fd == -1) {
|
||||
/* XXX - send this to the standard output as something our parent
|
||||
should put in an error message box? */
|
||||
|
@ -2379,7 +2381,7 @@ main(int argc, char *argv[])
|
|||
rc_file = get_persconffile_path(RC_FILE, FALSE);
|
||||
gtk_rc_parse(rc_file);
|
||||
|
||||
font_init();
|
||||
font_init(capture_opts->capture_child);
|
||||
|
||||
/* close the splash screen, as we are going to open the main window now */
|
||||
splash_destroy(splash_win);
|
||||
|
@ -2388,7 +2390,7 @@ main(int argc, char *argv[])
|
|||
/* Is this a "child" ethereal, which is only supposed to pop up a
|
||||
capture box to let us stop the capture, and run a capture
|
||||
to a file that our parent will read? */
|
||||
if (!capture_child) {
|
||||
if (!capture_opts->capture_child) {
|
||||
#endif
|
||||
/* No. Pop up the main window, and read in a capture file if
|
||||
we were told to. */
|
||||
|
|
Loading…
Reference in New Issue