aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2005-02-27 21:15:30 +0000
committerGuy Harris <guy@alum.mit.edu>2005-02-27 21:15:30 +0000
commit343810d95a1343a7d3f996827c938fb3109053bc (patch)
tree53cbefe97f297642f74521fd0ed7ffc4a01b91ac
parent36833b76d8b62c3eac22ef0943b9e553e3518bb9 (diff)
Move "get_natural_int()" and "get_positive_int()" from "capture_opts.c"
to "clopts_common.c", make them not static, and use them in "gtk/main.c". svn path=/trunk/; revision=13541
-rw-r--r--capture_opts.c45
-rw-r--r--clopts_common.c42
-rw-r--r--clopts_common.h4
-rw-r--r--gtk/main.c47
4 files changed, 50 insertions, 88 deletions
diff --git a/capture_opts.c b/capture_opts.c
index cf3e87629c..f2bdc06900 100644
--- a/capture_opts.c
+++ b/capture_opts.c
@@ -43,7 +43,7 @@
#include "capture.h"
#include "ringbuffer.h"
-
+#include "clopts_common.h"
void
capture_opts_init(capture_options *capture_opts, void *cfile)
@@ -85,49 +85,6 @@ capture_opts_init(capture_options *capture_opts, void *cfile)
capture_opts->fork_child = -1; /* invalid process handle */
}
-static int
-get_natural_int(const char *appname, const char *string, const char *name)
-{
- long number;
- char *p;
-
- number = strtol(string, &p, 10);
- if (p == string || *p != '\0') {
- fprintf(stderr, "%s: The specified %s \"%s\" isn't a decimal number\n",
- appname, name, string);
- exit(1);
- }
- if (number < 0) {
- fprintf(stderr, "%s: The specified %s \"%s\" is a negative number\n",
- appname, name, string);
- exit(1);
- }
- if (number > INT_MAX) {
- fprintf(stderr, "%s: The specified %s \"%s\" is too large (greater than %d)\n",
- appname, name, string, INT_MAX);
- exit(1);
- }
- return number;
-}
-
-
-static int
-get_positive_int(const char *appname, const char *string, const char *name)
-{
- long number;
-
- number = get_natural_int(appname, string, name);
-
- if (number == 0) {
- fprintf(stderr, "%s: The specified %s is zero\n",
- appname, name);
- exit(1);
- }
-
- return number;
-}
-
-
/*
* Given a string of the form "<autostop criterion>:<value>", as might appear
* as an argument to a "-a" option, parse it and set the criterion in
diff --git a/clopts_common.c b/clopts_common.c
index 487dbd5bf3..12227c4485 100644
--- a/clopts_common.c
+++ b/clopts_common.c
@@ -61,3 +61,45 @@ handle_dashG_option(int argc, char **argv, char *progname)
exit(0);
}
}
+
+int
+get_natural_int(const char *appname, const char *string, const char *name)
+{
+ long number;
+ char *p;
+
+ number = strtol(string, &p, 10);
+ if (p == string || *p != '\0') {
+ fprintf(stderr, "%s: The specified %s \"%s\" isn't a decimal number\n",
+ appname, name, string);
+ exit(1);
+ }
+ if (number < 0) {
+ fprintf(stderr, "%s: The specified %s \"%s\" is a negative number\n",
+ appname, name, string);
+ exit(1);
+ }
+ if (number > INT_MAX) {
+ fprintf(stderr, "%s: The specified %s \"%s\" is too large (greater than %d)\n",
+ appname, name, string, INT_MAX);
+ exit(1);
+ }
+ return number;
+}
+
+
+int
+get_positive_int(const char *appname, const char *string, const char *name)
+{
+ long number;
+
+ number = get_natural_int(appname, string, name);
+
+ if (number == 0) {
+ fprintf(stderr, "%s: The specified %s is zero\n",
+ appname, name);
+ exit(1);
+ }
+
+ return number;
+}
diff --git a/clopts_common.h b/clopts_common.h
index 2584cd662b..376ddcc9c3 100644
--- a/clopts_common.h
+++ b/clopts_common.h
@@ -35,6 +35,10 @@ extern "C" {
*/
void handle_dashG_option(int argc, char **argv, char *progname);
+int get_natural_int(const char *appname, const char *string, const char *name);
+
+int get_positive_int(const char *appname, const char *string, const char *name);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/gtk/main.c b/gtk/main.c
index 7b09832b84..283519be5e 100644
--- a/gtk/main.c
+++ b/gtk/main.c
@@ -1116,47 +1116,6 @@ show_version(void)
comp_info_str->str, runtime_info_str->str);
}
-static int
-get_natural_int(const char *string, const char *name)
-{
- long number;
- char *p;
-
- number = strtol(string, &p, 10);
- if (p == string || *p != '\0') {
- fprintf(stderr, "ethereal: The specified %s \"%s\" isn't a decimal number\n",
- name, string);
- exit(1);
- }
- if (number < 0) {
- fprintf(stderr, "ethereal: The specified %s \"%s\" is a negative number\n",
- name, string);
- exit(1);
- }
- if (number > INT_MAX) {
- fprintf(stderr, "ethereal: The specified %s \"%s\" is too large (greater than %d)\n",
- name, string, INT_MAX);
- exit(1);
- }
- return number;
-}
-
-static int
-get_positive_int(const char *string, const char *name)
-{
- long number;
-
- number = get_natural_int(string, name);
-
- if (number == 0) {
- fprintf(stderr, "ethereal: The specified %s is zero\n",
- name);
- exit(1);
- }
-
- return number;
-}
-
#if defined(_WIN32) || GTK_MAJOR_VERSION < 2 || ! defined USE_THREADS
/*
Once every 3 seconds we get a callback here which we use to update
@@ -1899,7 +1858,7 @@ main(int argc, char *argv[])
/*** all non capture option specific ***/
case 'B': /* Byte view pane height */
- bv_size = get_positive_int(optarg, "byte view pane height");
+ bv_size = get_positive_int("ethereal", optarg, "byte view pane height");
break;
case 'h': /* Print help and exit */
print_usage(TRUE);
@@ -1956,7 +1915,7 @@ main(int argc, char *argv[])
}
break;
case 'P': /* Packet list pane height */
- pl_size = get_positive_int(optarg, "packet list pane height");
+ pl_size = get_positive_int("ethereal", optarg, "packet list pane height");
break;
case 'r': /* Read capture file xxx */
/* We may set "last_open_dir" to "cf_name", and if we change
@@ -1985,7 +1944,7 @@ main(int argc, char *argv[])
}
break;
case 'T': /* Tree view pane height */
- tv_size = get_positive_int(optarg, "tree view pane height");
+ tv_size = get_positive_int("ethereal", optarg, "tree view pane height");
break;
case 'v': /* Show version and exit */
show_version();