]> git.samba.org - obnox/wireshark/wip.git/commitdiff
move global capture_child flag into capture_options
authorulfl <ulfl@f5534014-38df-0310-8fa8-9805f1628bb7>
Wed, 29 Dec 2004 12:37:06 +0000 (12:37 +0000)
committerulfl <ulfl@f5534014-38df-0310-8fa8-9805f1628bb7>
Wed, 29 Dec 2004 12:37:06 +0000 (12:37 +0000)
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@12855 f5534014-38df-0310-8fa8-9805f1628bb7

capture.c
capture.h
capture_loop.c
gtk/font_utils.c
gtk/font_utils.h
gtk/main.c

index f24747886155a608776bcb80477b3e5038a484fd..39e87864178870c7323f49f817ac7aee3e951805 100644 (file)
--- a/capture.c
+++ b/capture.c
 #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
 
index bd4d5472a5eed84865e1ab362158a3ef587b5d53..0b2bec89ed090fdf0debd0a1811afd799d2003f6 100644 (file)
--- 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.  
index b086dda127c9e9cc5e062caef93a2e933a4f01e3..6b4b89e15c2a505bb414a5c1e234025fb8a99b2d 100644 (file)
@@ -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. */
index 52d317c4655f264d88326aaa709b143f0d05964d..f3ef5998b88ffaa5fc8beb75ffb54b11bf357dcd 100644 (file)
 #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;
index 16dcc15d4e168295dab3faa2e7246bce8ba4dedf..5ba78981b868d211060d5f4ec7dbc92dabf798bb 100644 (file)
@@ -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 {
index 0b334bce8181fe4c2e0549c67f2a82d4c3352cc8..b05076a09885e0e87a0c76d54728d7c678392a75 100644 (file)
@@ -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. */