aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Lamping <ulf.lamping@web.de>2004-12-29 12:37:06 +0000
committerUlf Lamping <ulf.lamping@web.de>2004-12-29 12:37:06 +0000
commitd9be4670a7b136db6e7c7ecfbc9dcc75dd010b63 (patch)
tree7512cc6ef5d8483bfb5e9a534dd33976fbf7bff8
parent316569ef2b5d16fdaeb3085e16c081cb290df7e4 (diff)
move global capture_child flag into capture_options
svn path=/trunk/; revision=12855
-rw-r--r--capture.c7
-rw-r--r--capture.h4
-rw-r--r--capture_loop.c35
-rw-r--r--gtk/font_utils.c7
-rw-r--r--gtk/font_utils.h2
-rw-r--r--gtk/main.c16
6 files changed, 31 insertions, 40 deletions
diff --git a/capture.c b/capture.c
index f247478861..39e8786417 100644
--- a/capture.c
+++ b/capture.c
@@ -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
diff --git a/capture.h b/capture.h
index bd4d5472a5..0b2bec89ed 100644
--- a/capture.h
+++ b/capture.h
@@ -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.
diff --git a/capture_loop.c b/capture_loop.c
index b086dda127..6b4b89e15c 100644
--- a/capture_loop.c
+++ b/capture_loop.c
@@ -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. */
diff --git a/gtk/font_utils.c b/gtk/font_utils.c
index 52d317c465..f3ef5998b8 100644
--- a/gtk/font_utils.c
+++ b/gtk/font_utils.c
@@ -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;
diff --git a/gtk/font_utils.h b/gtk/font_utils.h
index 16dcc15d4e..5ba78981b8 100644
--- a/gtk/font_utils.h
+++ b/gtk/font_utils.h
@@ -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 {
diff --git a/gtk/main.c b/gtk/main.c
index 0b334bce81..b05076a098 100644
--- a/gtk/main.c
+++ b/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. */