Move "get_natural_int()" and "get_positive_int()" from "capture_opts.c"
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Sun, 27 Feb 2005 21:15:30 +0000 (21:15 +0000)
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Sun, 27 Feb 2005 21:15:30 +0000 (21:15 +0000)
to "clopts_common.c", make them not static, and use them in "gtk/main.c".

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

capture_opts.c
clopts_common.c
clopts_common.h
gtk/main.c

index cf3e87629c05021b61085f7d0b7568f183c8bfe0..f2bdc06900e65e8984dcf6b1e6c77dcaa2c05d25 100644 (file)
@@ -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
index 487dbd5bf3baed031ed54b58e9858daf67d04ffc..12227c44850b434adb07931c7b919efec8f24c11 100644 (file)
@@ -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;
+}
index 2584cd662b431a106bc31c0e2095fbc1db2e3fdc..376ddcc9c3bb15b1a4d767135df1e52a3ef009df 100644 (file)
@@ -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 */
index 7b09832b84aa3f7883c3b0f8a18ed43796919692..283519be5edcb91b2add14de8c0ec0e8295dd536 100644 (file)
@@ -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();