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);
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();
}
* 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();
}
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 {
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;
}
}
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
/* 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. */
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? */
} 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;
}
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);
}
/*
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);
}
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);
}
}
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);
}
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. */
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
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 */
}
}
- 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? */
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);
/* 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. */