From Morro Roberto:
[obnox/wireshark/wip.git] / tshark.c
index 1163ac57c60b2880bbd8c00cd3a9344b19854e84..aba91572393b936957cb147c3dc2a4be31e83d82 100644 (file)
--- a/tshark.c
+++ b/tshark.c
@@ -221,7 +221,7 @@ print_usage(gboolean print_ver)
         "See http://www.wireshark.org for more information.\n"
         "\n"
         "%s",
-       svnversion, get_copyright_info());
+       wireshark_svnversion, get_copyright_info());
   } else {
     output = stderr;
   }
@@ -273,9 +273,10 @@ print_usage(gboolean print_ver)
   fprintf(output, "  -F <output file type>    set the output file type, default is libpcap\n");
   fprintf(output, "                           an empty \"-F\" option will list the file types\n");
   fprintf(output, "  -V                       add output of packet tree        (Packet Details)\n");
+  fprintf(output, "  -S                       display packets even when writing to a file\n");
   fprintf(output, "  -x                       add output of hex and ASCII dump (Packet Bytes)\n");
   fprintf(output, "  -T pdml|ps|psml|text     output format of text output (def: text)\n");
-  fprintf(output, "  -t ad|a|r|d              output format of time stamps (def: r: rel. to first)\n");
+  fprintf(output, "  -t ad|a|r|d|e            output format of time stamps (def: r: rel. to first)\n");
   fprintf(output, "  -l                       flush output after each packet\n");
   fprintf(output, "  -q                       be more quiet on stdout (e.g. when using statistics)\n");
   fprintf(output, "  -X <key>:<value>         eXtension options, see the man page for details\n");
@@ -693,8 +694,9 @@ main(int argc, char *argv[])
   char                 badopt;
   GLogLevelFlags       log_flags;
   int                  status;
+  int                  optind_initial;
 
-#define OPTSTRING_INIT "a:b:c:d:Df:F:hi:lLnN:o:pqr:R:s:St:T:vVw:xX:y:z:"
+#define OPTSTRING_INIT "a:b:c:d:Df:F:G:hi:lLnN:o:pqr:R:s:St:T:vVw:xX:y:z:"
 #ifdef HAVE_LIBPCAP
 #ifdef _WIN32
 #define OPTSTRING_WIN32 "B:"
@@ -721,15 +723,37 @@ main(int argc, char *argv[])
    */
   get_credential_info();
 
+  /*
+   * Now attempt to get the pathname of the plugins.
+   */
+  init_plugin_dir();
+
+  /*
+   * In order to have the -X opts assigned before the wslua machine starts
+   * we need to call getopts before epan_init() gets called.
+   */
+  opterr = 0;
+  optind_initial = optind;
+  
+  while ((opt = getopt(argc, argv, optstring)) != -1) {
+         switch (opt) {
+                 case 'X':
+                         ex_opt_add(optarg);
+                         break;
+                 default:
+                         break;
+         }
+  }
+  
+  optind = optind_initial;
+  opterr = 1;
+
   /* nothing more than the standard GLib handler, but without a warning */
   log_flags =
-                   G_LOG_LEVEL_ERROR|
-                   G_LOG_LEVEL_CRITICAL|
                    G_LOG_LEVEL_WARNING|
                    G_LOG_LEVEL_MESSAGE|
                    G_LOG_LEVEL_INFO|
-                   G_LOG_LEVEL_DEBUG|
-                   G_LOG_FLAG_FATAL|G_LOG_FLAG_RECURSION;
+                   G_LOG_LEVEL_DEBUG;
 
   g_log_set_handler(NULL,
                    log_flags,
@@ -751,8 +775,8 @@ main(int argc, char *argv[])
      "-G" flag, as the "-G" flag dumps information registered by the
      dissectors, and we must do it before we read the preferences, in
      case any dissectors register preferences. */
-  epan_init(PLUGIN_DIR,register_all_protocols,register_all_protocol_handoffs,
-            failure_message,open_failure_message,read_failure_message);
+  epan_init(register_all_protocols, register_all_protocol_handoffs,
+            failure_message, open_failure_message, read_failure_message);
 
   /* Register all tap listeners; we do this before we parse the arguments,
      as the "-z" argument can specify a registered tap. */
@@ -1010,6 +1034,8 @@ main(int argc, char *argv[])
           timestamp_set_type(TS_ABSOLUTE_WITH_DATE);
         else if (strcmp(optarg, "d") == 0)
           timestamp_set_type(TS_DELTA);
+        else if (strcmp(optarg, "e") == 0)
+          timestamp_set_type(TS_EPOCH);
         else {
           cmdarg_err("Invalid time stamp type \"%s\"",
             optarg);
@@ -1045,7 +1071,7 @@ main(int argc, char *argv[])
                "%s"
                "\n"
                "%s",
-               svnversion, get_copyright_info(), comp_info_str->str,
+               wireshark_svnversion, get_copyright_info(), comp_info_str->str,
                runtime_info_str->str);
         exit(0);
         break;
@@ -1056,7 +1082,6 @@ main(int argc, char *argv[])
           print_hex = TRUE;
           break;
       case 'X':
-          ex_opt_add(optarg);
           break;
       case 'z':
         /* We won't call the init function for the stat this soon
@@ -1112,6 +1137,7 @@ main(int argc, char *argv[])
     }
   }
 
+#ifdef HAVE_LIBPCAP
   if (!capture_opts.saving_to_file) {
     /* We're not saving the capture to a file; if "-q" wasn't specified,
        we should print packet information */
@@ -1129,6 +1155,12 @@ main(int argc, char *argv[])
       exit(1);
     }
   }
+#else
+  /* We're not saving the capture to a file; if "-q" wasn't specified,
+     we should print packet information */
+  if (!quiet)
+    print_packet_info = TRUE;
+#endif
 
 #ifndef HAVE_LIBPCAP
   if (capture_option_specified)
@@ -1430,7 +1462,11 @@ main(int argc, char *argv[])
     }
 
     /* Process the packets in the file */
+#ifdef HAVE_LIBPCAP
     err = load_cap_file(&cfile, capture_opts.save_file, out_file_type);
+#else
+    err = load_cap_file(&cfile, NULL, out_file_type);
+#endif
     if (err != 0) {
       epan_cleanup();
       exit(2);
@@ -2999,7 +3035,7 @@ cmdarg_err_cont(const char *fmt, ...)
 
 /** Report a new capture file having been opened. */
 void
-report_new_capture_file(const char *filename)
+report_new_capture_file(const char *filename _U_)
 {
     /* shouldn't happen */
     g_assert_not_reached();
@@ -3007,7 +3043,7 @@ report_new_capture_file(const char *filename)
 
 /** Report a number of new packets captured. */
 void
-report_packet_count(int packet_count)
+report_packet_count(int packet_count _U_)
 {
     /* shouldn't happen */
     g_assert_not_reached();
@@ -3015,7 +3051,7 @@ report_packet_count(int packet_count)
 
 /** Report the packet drops once the capture finishes. */
 void
-report_packet_drops(int drops)
+report_packet_drops(int drops _U_)
 {
     /* shouldn't happen */
     g_assert_not_reached();