forked from osmocom/wireshark
Add a new header defining commonly-used exit codes.
"Commonly-used" meaning "used by more than one source file". Clean up the exit codes, combining some duplicates with different names, and using some instead of raw numbers in some places.
This commit is contained in:
parent
20b662b01d
commit
9b70baac96
|
@ -69,6 +69,7 @@
|
|||
#include <wiretap/wtap.h>
|
||||
|
||||
#include <ui/cmdarg_err.h>
|
||||
#include <ui/exit_codes.h>
|
||||
#include <wsutil/filesystem.h>
|
||||
#include <wsutil/privileges.h>
|
||||
#include <cli_main.h>
|
||||
|
@ -87,9 +88,6 @@
|
|||
|
||||
#include "ui/failure_message.h"
|
||||
|
||||
#define INVALID_OPTION 1
|
||||
#define BAD_FLAG 1
|
||||
|
||||
/*
|
||||
* By default capinfos now continues processing
|
||||
* the next filename if and when wiretap detects
|
||||
|
@ -1792,7 +1790,7 @@ main(int argc, char *argv[])
|
|||
|
||||
case '?': /* Bad flag - print usage message */
|
||||
print_usage(stderr);
|
||||
overall_error_status = BAD_FLAG;
|
||||
overall_error_status = INVALID_OPTION;
|
||||
goto exit;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -70,6 +70,7 @@
|
|||
|
||||
#include <ui/clopts_common.h>
|
||||
#include <ui/cmdarg_err.h>
|
||||
#include <ui/exit_codes.h>
|
||||
#include <wsutil/filesystem.h>
|
||||
#include <wsutil/file_util.h>
|
||||
#include <wsutil/wsgcrypt.h>
|
||||
|
@ -88,11 +89,11 @@
|
|||
|
||||
#include "ringbuffer.h" /* For RINGBUFFER_MAX_NUM_FILES */
|
||||
|
||||
#define INVALID_OPTION 1
|
||||
#define INVALID_FILE 2
|
||||
/* Additional exit codes */
|
||||
#define CANT_EXTRACT_PREFIX 2
|
||||
#define WRITE_ERROR 2
|
||||
#define DUMP_ERROR 2
|
||||
#define WRITE_ERROR 2
|
||||
#define DUMP_ERROR 2
|
||||
|
||||
#define NANOSECS_PER_SEC 1000000000
|
||||
|
||||
/*
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include <ui/clopts_common.h>
|
||||
#include <ui/failure_message.h>
|
||||
#include <ui/cmdarg_err.h>
|
||||
#include <ui/exit_codes.h>
|
||||
#include <wsutil/file_util.h>
|
||||
#include <wsutil/filesystem.h>
|
||||
#include <wsutil/privileges.h>
|
||||
|
@ -44,9 +45,9 @@
|
|||
|
||||
#include "randpkt_core/randpkt_core.h"
|
||||
|
||||
#define INVALID_OPTION 1
|
||||
/* Additional exit codes */
|
||||
#define INVALID_TYPE 2
|
||||
#define CLOSE_ERROR 2
|
||||
#define CLOSE_ERROR 2
|
||||
|
||||
/*
|
||||
* Report an error in command-line arguments.
|
||||
|
|
11
rawshark.c
11
rawshark.c
|
@ -52,6 +52,7 @@
|
|||
#include <epan/epan.h>
|
||||
|
||||
#include <ui/cmdarg_err.h>
|
||||
#include <ui/exit_codes.h>
|
||||
#include <wsutil/filesystem.h>
|
||||
#include <wsutil/file_util.h>
|
||||
#include <wsutil/socket.h>
|
||||
|
@ -111,11 +112,9 @@
|
|||
static const gchar decode_as_arg_template[] = "<layer_type>==<selector>,<decode_as_protocol>";
|
||||
#endif
|
||||
|
||||
#define INVALID_OPTION 1
|
||||
#define INIT_ERROR 2
|
||||
/* Additional exit codes */
|
||||
#define INVALID_DFILTER 2
|
||||
#define OPEN_ERROR 2
|
||||
#define FORMAT_ERROR 2
|
||||
#define FORMAT_ERROR 2
|
||||
|
||||
capture_file cfile;
|
||||
|
||||
|
@ -531,7 +530,7 @@ main(int argc, char *argv[])
|
|||
dissectors, and we must do it before we read the preferences, in
|
||||
case any dissectors register preferences. */
|
||||
if (!epan_init(NULL, NULL, TRUE)) {
|
||||
ret = INIT_ERROR;
|
||||
ret = INIT_FAILED;
|
||||
goto clean_exit;
|
||||
}
|
||||
|
||||
|
@ -757,7 +756,7 @@ main(int argc, char *argv[])
|
|||
cmdarg_err("%s", err_msg);
|
||||
g_free(err_msg);
|
||||
cmdarg_err_cont("%s", please_report_bug());
|
||||
ret = INIT_ERROR;
|
||||
ret = INIT_FAILED;
|
||||
goto clean_exit;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include <wiretap/wtap.h>
|
||||
|
||||
#include <ui/cmdarg_err.h>
|
||||
#include <ui/exit_codes.h>
|
||||
#include <wsutil/filesystem.h>
|
||||
#include <wsutil/file_util.h>
|
||||
#include <wsutil/privileges.h>
|
||||
|
@ -46,8 +47,7 @@
|
|||
|
||||
#include "ui/failure_message.h"
|
||||
|
||||
#define INVALID_OPTION 1
|
||||
#define OPEN_ERROR 2
|
||||
/* Additional exit codes */
|
||||
#define OUTPUT_FILE_ERROR 1
|
||||
|
||||
/* Show command-line usage */
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
|
||||
#include <ui/clopts_common.h>
|
||||
#include <ui/cmdarg_err.h>
|
||||
#include <ui/exit_codes.h>
|
||||
#include <ui/urls.h>
|
||||
#include <wsutil/filesystem.h>
|
||||
#include <wsutil/file_util.h>
|
||||
|
@ -80,11 +81,8 @@
|
|||
#include <wsutil/plugins.h>
|
||||
#endif
|
||||
|
||||
#define INVALID_OPTION 1
|
||||
/* Additional exit codes */
|
||||
#define NO_FILE_SPECIFIED 1
|
||||
#define INIT_ERROR 2
|
||||
#define INVALID_FILTER 2
|
||||
#define OPEN_ERROR 2
|
||||
|
||||
capture_file cfile;
|
||||
|
||||
|
|
19
tshark.c
19
tshark.c
|
@ -48,6 +48,7 @@
|
|||
|
||||
#include <ui/clopts_common.h>
|
||||
#include <ui/cmdarg_err.h>
|
||||
#include <ui/exit_codes.h>
|
||||
#include <ui/urls.h>
|
||||
#include <wsutil/filesystem.h>
|
||||
#include <wsutil/file_util.h>
|
||||
|
@ -128,18 +129,10 @@
|
|||
#include <wsutil/plugins.h>
|
||||
#endif
|
||||
|
||||
/* Exit codes */
|
||||
#define INVALID_OPTION 1
|
||||
#define INVALID_INTERFACE 2
|
||||
#define INVALID_FILE 2
|
||||
#define INVALID_FILTER 2
|
||||
#define INVALID_EXPORT 2
|
||||
#define INVALID_CAPABILITY 2
|
||||
#define INVALID_TAP 2
|
||||
#define INVALID_DATA_LINK 2
|
||||
#define INVALID_TIMESTAMP_TYPE 2
|
||||
#define INVALID_CAPTURE 2
|
||||
#define INIT_FAILED 2
|
||||
/* Additional exit codes */
|
||||
#define INVALID_EXPORT 2
|
||||
#define INVALID_TAP 2
|
||||
#define INVALID_CAPTURE 2
|
||||
|
||||
#define LONGOPT_EXPORT_OBJECTS LONGOPT_BASE_APPLICATION+1
|
||||
#define LONGOPT_COLOR LONGOPT_BASE_APPLICATION+2
|
||||
|
@ -2221,7 +2214,7 @@ main(int argc, char *argv[])
|
|||
}
|
||||
if ((if_caps_queries & CAPS_QUERY_LINK_TYPES) && caps->data_link_types == NULL) {
|
||||
cmdarg_err("The capture device \"%s\" has no data link types.", interface_opts->name);
|
||||
exit_status = INVALID_DATA_LINK;
|
||||
exit_status = IFACE_HAS_NO_LINK_TYPES;
|
||||
goto clean_exit;
|
||||
}
|
||||
if ((if_caps_queries & CAPS_QUERY_TIMESTAMP_TYPES) && caps->timestamp_types == NULL) {
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
|
||||
#include <ui/clopts_common.h>
|
||||
#include <ui/cmdarg_err.h>
|
||||
#include <ui/exit_codes.h>
|
||||
#include <wsutil/filesystem.h>
|
||||
|
||||
#include <epan/ex-opt.h>
|
||||
|
@ -280,7 +281,7 @@ void commandline_early_options(int argc, char *argv[])
|
|||
cmdarg_err("%s", err_str);
|
||||
g_free(err_str);
|
||||
}
|
||||
exit(2);
|
||||
exit(INVALID_INTERFACE);
|
||||
}
|
||||
#ifdef _WIN32
|
||||
create_console();
|
||||
|
@ -290,14 +291,14 @@ void commandline_early_options(int argc, char *argv[])
|
|||
#ifdef _WIN32
|
||||
destroy_console();
|
||||
#endif /* _WIN32 */
|
||||
exit(0);
|
||||
exit(EXIT_SUCCESS);
|
||||
#else /* HAVE_LIBPCAP */
|
||||
capture_option_specified = TRUE;
|
||||
#endif /* HAVE_LIBPCAP */
|
||||
break;
|
||||
case 'h': /* Print help and exit */
|
||||
commandline_print_usage(TRUE);
|
||||
exit(0);
|
||||
exit(EXIT_SUCCESS);
|
||||
break;
|
||||
#ifdef _WIN32
|
||||
case 'i':
|
||||
|
@ -308,7 +309,7 @@ void commandline_early_options(int argc, char *argv[])
|
|||
case 'P': /* Personal file directory path settings - change these before the Preferences and alike are processed */
|
||||
if (!persfilepath_opt(opt, optarg)) {
|
||||
cmdarg_err("-P flag \"%s\" failed (hint: is it quoted and existing?)", optarg);
|
||||
exit(2);
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
break;
|
||||
case 'v': /* Show version and exit */
|
||||
|
@ -319,7 +320,7 @@ void commandline_early_options(int argc, char *argv[])
|
|||
#ifdef _WIN32
|
||||
destroy_console();
|
||||
#endif
|
||||
exit(0);
|
||||
exit(EXIT_SUCCESS);
|
||||
break;
|
||||
case 'X':
|
||||
/*
|
||||
|
@ -338,7 +339,7 @@ void commandline_early_options(int argc, char *argv[])
|
|||
if (capture_option_specified) {
|
||||
print_no_capture_support_error();
|
||||
commandline_print_usage(FALSE);
|
||||
exit(1);
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
/* exit_codes.h
|
||||
* Definition of exit codes for programs.
|
||||
*
|
||||
* Wireshark - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@wireshark.org>
|
||||
* Copyright 1998 Gerald Combs
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef __EXIT_CODES_H__
|
||||
#define __EXIT_CODES_H__
|
||||
|
||||
/* Exit codes */
|
||||
#define INVALID_OPTION 1
|
||||
#define INVALID_INTERFACE 2
|
||||
#define INVALID_FILE 2
|
||||
#define INVALID_FILTER 2
|
||||
#define INVALID_CAPABILITY 2
|
||||
#define IFACE_HAS_NO_LINK_TYPES 2
|
||||
#define INVALID_TIMESTAMP_TYPE 2
|
||||
#define INIT_FAILED 2
|
||||
#define OPEN_ERROR 2
|
||||
|
||||
#endif /* __EXIT_CODES_H__ */
|
||||
|
||||
/*
|
||||
* Editor modelines - https://www.wireshark.org/tools/modelines.html
|
||||
*
|
||||
* Local Variables:
|
||||
* c-basic-offset: 4
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*
|
||||
* vi: set shiftwidth=4 tabstop=8 expandtab:
|
||||
* :indentSize=4:tabSize=8:noTabs=true:
|
||||
*/
|
|
@ -36,6 +36,7 @@
|
|||
|
||||
#include <ui/clopts_common.h>
|
||||
#include <ui/cmdarg_err.h>
|
||||
#include <ui/exit_codes.h>
|
||||
#include <ui/urls.h>
|
||||
#include <wsutil/filesystem.h>
|
||||
#include <wsutil/privileges.h>
|
||||
|
@ -127,11 +128,6 @@
|
|||
|
||||
#include <ui/qt/utils/qt_ui_utils.h>
|
||||
|
||||
#define INVALID_OPTION 1
|
||||
#define INIT_FAILED 2
|
||||
#define INVALID_CAPABILITY 2
|
||||
#define INVALID_LINK_TYPE 2
|
||||
|
||||
//#define DEBUG_STARTUP_TIME 1
|
||||
/*
|
||||
# Log level
|
||||
|
@ -911,7 +907,7 @@ int main(int argc, char *qt_argv[])
|
|||
}
|
||||
if (caps->data_link_types == NULL) {
|
||||
cmdarg_err("The capture device \"%s\" has no data link types.", device->name);
|
||||
ret_val = INVALID_LINK_TYPE;
|
||||
ret_val = IFACE_HAS_NO_LINK_TYPES;
|
||||
goto clean_exit;
|
||||
}
|
||||
#ifdef _WIN32
|
||||
|
|
Loading…
Reference in New Issue