aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2011-04-11 00:01:08 +0000
committerGuy Harris <guy@alum.mit.edu>2011-04-11 00:01:08 +0000
commit4ad4d3e6784695420c7e511ed7eaa5c0e49f0e91 (patch)
treecb631a4e1881ed6ce2880d3e29c019f1a69a7604
parentf10a13b748bdafd13ab887437c04d04d325d2ca6 (diff)
Jeff Morris's change to make the autostop file size 64-bit. Fixes bug
5691. svn path=/trunk/; revision=36551
-rw-r--r--capture_opts.c6
-rw-r--r--capture_opts.h2
-rw-r--r--capture_sync.c4
-rw-r--r--clopts_common.c47
-rw-r--r--clopts_common.h4
5 files changed, 56 insertions, 7 deletions
diff --git a/capture_opts.c b/capture_opts.c
index de857ad06c..81aadb85f8 100644
--- a/capture_opts.c
+++ b/capture_opts.c
@@ -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");
diff --git a/capture_opts.h b/capture_opts.h
index 9cd688c32e..c6f55b2478 100644
--- a/capture_opts.h
+++ b/capture_opts.h
@@ -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 */
diff --git a/capture_sync.c b/capture_sync.c
index 68b79f7928..e18161888f 100644
--- a/capture_sync.c
+++ b/capture_sync.c
@@ -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);
}
}
diff --git a/clopts_common.c b/clopts_common.c
index 1c7cea9b16..411c59cce1 100644
--- a/clopts_common.c
+++ b/clopts_common.c
@@ -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;
+}
diff --git a/clopts_common.h b/clopts_common.h
index 3341fd0519..9077ead647 100644
--- a/clopts_common.h
+++ b/clopts_common.h
@@ -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 */