diff options
Diffstat (limited to 'ui')
-rw-r--r-- | ui/CMakeLists.txt | 1 | ||||
-rw-r--r-- | ui/clopts_common.c | 108 | ||||
-rw-r--r-- | ui/clopts_common.h | 54 | ||||
-rw-r--r-- | ui/commandline.c | 2 | ||||
-rw-r--r-- | ui/dissect_opts.c | 2 | ||||
-rw-r--r-- | ui/logray/logray_main.cpp | 2 | ||||
-rw-r--r-- | ui/qt/main.cpp | 2 |
7 files changed, 4 insertions, 167 deletions
diff --git a/ui/CMakeLists.txt b/ui/CMakeLists.txt index 59fdd64054..92de384004 100644 --- a/ui/CMakeLists.txt +++ b/ui/CMakeLists.txt @@ -11,7 +11,6 @@ set(NONGENERATED_UI_SRC alert_box.c capture.c capture_ui_utils.c - clopts_common.c commandline.c decode_as_utils.c dissect_opts.c diff --git a/ui/clopts_common.c b/ui/clopts_common.c deleted file mode 100644 index 8145bfb8b5..0000000000 --- a/ui/clopts_common.c +++ /dev/null @@ -1,108 +0,0 @@ -/* clopts_common.c - * Handle command-line arguments common to various programs - * - * Wireshark - Network traffic analyzer - * By Gerald Combs <gerald@wireshark.org> - * Copyright 1998 Gerald Combs - * - * SPDX-License-Identifier: GPL-2.0-or-later - */ - -#include "config.h" - -#include <stdlib.h> -#include <errno.h> - -#include <wsutil/strtoi.h> -#include <wsutil/cmdarg_err.h> - -#include "clopts_common.h" - -int -get_natural_int(const char *string, const char *name) -{ - gint32 number; - - if (!ws_strtoi32(string, NULL, &number)) { - if (errno == EINVAL) { - 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); - } - cmdarg_err("The specified %s \"%s\" is too large (greater than %d)", - name, string, number); - exit(1); - } - if (number < 0) { - cmdarg_err("The specified %s \"%s\" is a negative number", name, string); - exit(1); - } - return (int)number; -} - -int -get_positive_int(const char *string, const char *name) -{ - int number; - - number = get_natural_int(string, name); - - if (number == 0) { - cmdarg_err("The specified %s is zero", name); - exit(1); - } - - return number; -} - -guint32 -get_guint32(const char *string, const char *name) -{ - guint32 number; - - if (!ws_strtou32(string, NULL, &number)) { - if (errno == EINVAL) { - cmdarg_err("The specified %s \"%s\" isn't a decimal number", name, string); - exit(1); - } - cmdarg_err("The specified %s \"%s\" is too large (greater than %d)", - name, string, number); - exit(1); - } - return number; -} - -guint32 -get_nonzero_guint32(const char *string, const char *name) -{ - guint32 number; - - number = get_guint32(string, name); - - if (number == 0) { - cmdarg_err("The specified %s is zero", name); - exit(1); - } - - return number; -} - -double -get_positive_double(const char *string, const char *name) -{ - double number = g_ascii_strtod(string, NULL); - - if (errno == EINVAL) { - cmdarg_err("The specified %s \"%s\" isn't a floating point number", name, string); - exit(1); - } - if (number < 0.0) { - cmdarg_err("The specified %s \"%s\" is a negative number", name, string); - exit(1); - } - - return number; -} diff --git a/ui/clopts_common.h b/ui/clopts_common.h deleted file mode 100644 index 04ff5ed56c..0000000000 --- a/ui/clopts_common.h +++ /dev/null @@ -1,54 +0,0 @@ -/** @file - * - * Handle command-line arguments common to various programs - * - * Wireshark - Network traffic analyzer - * By Gerald Combs <gerald@wireshark.org> - * Copyright 1998 Gerald Combs - * - * SPDX-License-Identifier: GPL-2.0-or-later - */ - -#ifndef __UI_CLOPTS_COMMON_H__ -#define __UI_CLOPTS_COMMON_H__ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* - * Long options. - * For long options with no corresponding short options, we define values - * outside the range of ASCII graphic characters, make that the last - * component of the entry for the long option, and have a case for that - * option in the switch statement. - */ -// Base value for capture related long options -#define LONGOPT_BASE_CAPTURE 1000 -// Base value for dissector related long options -#define LONGOPT_BASE_DISSECTOR 2000 -// Base value for application specific long options -#define LONGOPT_BASE_APPLICATION 3000 -// Base value for GUI specific long options -#define LONGOPT_BASE_GUI 4000 - -extern int -get_natural_int(const char *string, const char *name); - -extern int -get_positive_int(const char *string, const char *name); - -extern guint32 -get_guint32(const char *string, const char *name); - -extern guint32 -get_nonzero_guint32(const char *string, const char *name); - -extern double -get_positive_double(const char *string, const char *name); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __UI_CLOPTS_COMMON_H__ */ diff --git a/ui/commandline.c b/ui/commandline.c index fe0da010fd..73cbc27de8 100644 --- a/ui/commandline.c +++ b/ui/commandline.c @@ -21,7 +21,7 @@ #include <wsutil/version_info.h> -#include <ui/clopts_common.h> +#include <wsutil/clopts_common.h> #include <wsutil/cmdarg_err.h> #include <wsutil/filesystem.h> #include <wsutil/ws_assert.h> diff --git a/ui/dissect_opts.c b/ui/dissect_opts.c index f03ae281fa..23564a5983 100644 --- a/ui/dissect_opts.c +++ b/ui/dissect_opts.c @@ -30,7 +30,7 @@ #include <epan/dissectors/read_keytab_file.h> #endif -#include <ui/clopts_common.h> +#include <wsutil/clopts_common.h> #include <wsutil/cmdarg_err.h> #include <wsutil/file_util.h> #include <wsutil/ws_assert.h> diff --git a/ui/logray/logray_main.cpp b/ui/logray/logray_main.cpp index edccee9aab..4a30a8e431 100644 --- a/ui/logray/logray_main.cpp +++ b/ui/logray/logray_main.cpp @@ -23,7 +23,7 @@ #endif #include <ws_exit_codes.h> -#include <ui/clopts_common.h> +#include <wsutil/clopts_common.h> #include <wsutil/cmdarg_err.h> #include <ui/urls.h> #include <wsutil/filesystem.h> diff --git a/ui/qt/main.cpp b/ui/qt/main.cpp index 0a0165ba48..b52635fb08 100644 --- a/ui/qt/main.cpp +++ b/ui/qt/main.cpp @@ -23,7 +23,7 @@ #endif #include <ws_exit_codes.h> -#include <ui/clopts_common.h> +#include <wsutil/clopts_common.h> #include <wsutil/cmdarg_err.h> #include <ui/urls.h> #include <wsutil/filesystem.h> |