Jeff Morris's change to make the autostop file size 64-bit. Fixes bug
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Mon, 11 Apr 2011 00:01:08 +0000 (00:01 +0000)
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Mon, 11 Apr 2011 00:01:08 +0000 (00:01 +0000)
5691.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@36551 f5534014-38df-0310-8fa8-9805f1628bb7

capture_opts.c
capture_opts.h
capture_sync.c
clopts_common.c
clopts_common.h

index de857ad06cc9e1a79e4527d060a1c2cc462da222..81aadb85f8f165e4c9f5b284ea0084c169c90d5c 100644 (file)
@@ -172,7 +172,7 @@ capture_opts_log(const char *log_domain, GLogLevelFlags log_level, capture_optio
 
     g_log(log_domain, log_level, "AutostopFiles   (%u): %u", capture_opts->has_autostop_files, capture_opts->autostop_files);
     g_log(log_domain, log_level, "AutostopPackets (%u): %u", capture_opts->has_autostop_packets, capture_opts->autostop_packets);
-    g_log(log_domain, log_level, "AutostopFilesize(%u): %u (KB)", capture_opts->has_autostop_filesize, capture_opts->autostop_filesize);
+    g_log(log_domain, log_level, "AutostopFilesize(%u): %" G_GINT64_MODIFIER "d (KB)", capture_opts->has_autostop_filesize, capture_opts->autostop_filesize);
     g_log(log_domain, log_level, "AutostopDuration(%u): %u", capture_opts->has_autostop_duration, capture_opts->autostop_duration);
 
     g_log(log_domain, log_level, "ForkChild          : %d", capture_opts->fork_child);
@@ -220,7 +220,7 @@ set_autostop_criterion(capture_options *capture_opts, const char *autostoparg)
     capture_opts->autostop_duration = get_positive_int(p,"autostop duration");
   } else if (strcmp(autostoparg,"filesize") == 0) {
     capture_opts->has_autostop_filesize = TRUE;
-    capture_opts->autostop_filesize = get_positive_int(p,"autostop filesize");
+    capture_opts->autostop_filesize = get_positive_int64(p,"autostop filesize");
   } else if (strcmp(autostoparg,"files") == 0) {
     capture_opts->multi_files_on = TRUE;
     capture_opts->has_autostop_files = TRUE;
@@ -272,7 +272,7 @@ get_ring_arguments(capture_options *capture_opts, const char *arg)
     capture_opts->ring_num_files = get_positive_int(p, "number of ring buffer files");
   } else if (strcmp(arg,"filesize") == 0) {
     capture_opts->has_autostop_filesize = TRUE;
-    capture_opts->autostop_filesize = get_positive_int(p, "ring buffer filesize");
+    capture_opts->autostop_filesize = get_positive_int64(p, "ring buffer filesize");
   } else if (strcmp(arg,"duration") == 0) {
     capture_opts->has_file_duration = TRUE;
     capture_opts->file_duration = get_positive_int(p, "ring buffer duration");
index 9cd688c32e8f71c79af11e638f5ef09bbf6e52f4..c6f55b2478235b6cc799f98f3bb6897c5f61cf0f 100644 (file)
@@ -144,7 +144,7 @@ typedef struct capture_options_tag {
     int autostop_packets;           /**< Maximum packet count */
     gboolean has_autostop_filesize; /**< TRUE if maximum capture file size
                                          is specified */
-    gint32 autostop_filesize;       /**< Maximum capture file size */
+    gint64 autostop_filesize;       /**< Maximum capture file size in KB */
     gboolean has_autostop_duration; /**< TRUE if maximum capture duration
                                          is specified */
     gint32 autostop_duration;       /**< Maximum capture duration */
index 68b79f79280acbc1fad8f0245cf2c084b46792c1..e18161888fe68d1bd8bad83defc5b6964e349909 100644 (file)
@@ -391,7 +391,7 @@ sync_pipe_start(capture_options *capture_opts) {
     if(capture_opts->multi_files_on) {
       if (capture_opts->has_autostop_filesize) {
         argv = sync_pipe_add_arg(argv, &argc, "-b");
-        g_snprintf(sfilesize, ARGV_NUMBER_LEN, "filesize:%d",capture_opts->autostop_filesize);
+        g_snprintf(sfilesize, ARGV_NUMBER_LEN, "filesize:%" G_GINT64_MODIFIER "d",capture_opts->autostop_filesize);
         argv = sync_pipe_add_arg(argv, &argc, sfilesize);
       }
 
@@ -415,7 +415,7 @@ sync_pipe_start(capture_options *capture_opts) {
     } else {
         if (capture_opts->has_autostop_filesize) {
           argv = sync_pipe_add_arg(argv, &argc, "-a");
-          g_snprintf(sautostop_filesize, ARGV_NUMBER_LEN, "filesize:%d",capture_opts->autostop_filesize);
+          g_snprintf(sautostop_filesize, ARGV_NUMBER_LEN, "filesize:%" G_GINT64_MODIFIER "d",capture_opts->autostop_filesize);
           argv = sync_pipe_add_arg(argv, &argc, sautostop_filesize);
         }
     }
index 1c7cea9b16c253d37c4c4b4de20ea407be07f950..411c59cce1c65eb3d7bea9355039a0b197076bb1 100644 (file)
@@ -74,3 +74,50 @@ get_positive_int(const char *string, const char *name)
 
   return number;
 }
+
+gint64
+get_natural_int64(const char *string, const char *name)
+{
+  gint64 number;
+  char *p;
+
+#if GLIB_CHECK_VERSION(2,12,0)
+  number = g_ascii_strtoll(string, &p, 10);
+#elif defined(HAVE_STRTOLL)
+  number = strtoll(string, &p, 10);
+#else
+  /* Punt and grab a 32-bit value */
+  number = strtol(string, &p, 10);
+#endif
+
+  if (p == string || *p != '\0') {
+    cmdarg_err("The specified %s \"%s\" isn't a decimal number", name, string);
+    exit(1);
+  }
+  if (number < 0) {
+    cmdarg_err("The specified %s \"%s\" is a negative number", name, string);
+    exit(1);
+  }
+  if (number > G_MAXINT64) { /* XXX - ??? */
+    cmdarg_err("The specified %s \"%s\" is too large (greater than %" G_GINT64_MODIFIER "d)",
+              name, string, G_MAXINT64);
+    exit(1);
+  }
+  return number;
+}
+
+
+gint64
+get_positive_int64(const char *string, const char *name)
+{
+  gint64 number;
+
+  number = get_natural_int64(string, name);
+
+  if (number == 0) {
+    cmdarg_err("The specified %s is zero", name);
+    exit(1);
+  }
+
+  return number;
+}
index 3341fd05196dc83f4936ebed742d63ed6aa3c113..9077ead647baa5ab95fa73d5fcc45720a080b055 100644 (file)
@@ -30,9 +30,11 @@ extern "C" {
 #endif /* __cplusplus */
 
 int get_natural_int(const char *string, const char *name);
-
 int get_positive_int(const char *string, const char *name);
 
+gint64 get_natural_int64(const char *string, const char *name);
+gint64 get_positive_int64(const char *string, const char *name);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */