diff options
-rw-r--r-- | capture_opts.h | 31 | ||||
-rw-r--r-- | dumpcap.c | 8 | ||||
-rw-r--r-- | tshark.c | 4 | ||||
-rw-r--r-- | ui/qt/main.cpp | 6 |
4 files changed, 35 insertions, 14 deletions
diff --git a/capture_opts.h b/capture_opts.h index f9bdf89eb6..a48635d68b 100644 --- a/capture_opts.h +++ b/capture_opts.h @@ -40,15 +40,30 @@ extern "C" { #endif /* __cplusplus */ -/* Attention: - for tshark, we're using a leading - in the optstring to prevent getopt() - from permuting the argv[] entries, in this case, unknown argv[] entries - will be returned as parameters to a dummy-option 1 - in short: we must not use 1 here */ - -/* this does not clash with tshark's -2 option which returns '2' */ -#define LONGOPT_NUM_CAP_COMMENT 2 +/* + * Long options. + * We do not currently have long options corresponding to all short + * options; we should probably pick appropriate option names for them. + * + * 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. + * + * NOTE: + * for tshark, we're using a leading - in the optstring to prevent getopt() + * from permuting the argv[] entries, in this case, unknown argv[] entries + * will be returned as parameters to a dummy-option 1. + * In short: we must not use 1 here, which is another reason to use + * values outside the range of ASCII graphic characters. + */ +#define LONGOPT_NUM_CAP_COMMENT 128 +/* + * Non-capture long-only options should start here, to avoid collision + * with capture options. + */ +#define MIN_NON_CAPTURE_LONGOPT 129 #ifdef HAVE_PCAP_REMOTE /* Type of capture source */ @@ -4176,8 +4176,10 @@ main(int argc, char *argv[]) GString *comp_info_str; GString *runtime_info_str; int opt; - struct option long_options[] = { + static const struct option long_options[] = { {(char *)"capture-comment", required_argument, NULL, LONGOPT_NUM_CAP_COMMENT }, + {(char *)"help", no_argument, NULL, 'h'}, + {(char *)"version", no_argument, NULL, 'v'}, {0, 0, 0, 0 } }; @@ -4525,8 +4527,8 @@ main(int argc, char *argv[]) global_capture_opts.saving_to_file = TRUE; global_capture_opts.has_ring_num_files = TRUE; - /* Pass on capture_child mode for capture_opts */ - global_capture_opts.capture_child = capture_child; + /* Pass on capture_child mode for capture_opts */ + global_capture_opts.capture_child = capture_child; /* Now get our args */ while ((opt = getopt_long(argc, argv, OPTSTRING, long_options, NULL)) != -1) { @@ -922,8 +922,10 @@ main(int argc, char *argv[]) GString *runtime_info_str; char *init_progfile_dir_error; int opt; - struct option long_options[] = { + static const struct option long_options[] = { {(char *)"capture-comment", required_argument, NULL, LONGOPT_NUM_CAP_COMMENT }, + {(char *)"help", no_argument, NULL, 'h'}, + {(char *)"version", no_argument, NULL, 'v'}, {0, 0, 0, 0 } }; gboolean arg_error = FALSE; diff --git a/ui/qt/main.cpp b/ui/qt/main.cpp index 871d0e92a0..c91937e846 100644 --- a/ui/qt/main.cpp +++ b/ui/qt/main.cpp @@ -516,8 +516,10 @@ int main(int argc, char *argv[]) #endif #define OPTSTRING "a:b:" OPTSTRING_B "c:C:Df:g:Hhi:" OPTSTRING_I "jJ:kK:lLm:nN:o:P:pQr:R:Ss:t:u:vw:X:y:z:" - struct option long_options[] = { - {(char *)"read-file", required_argument, NULL, (int)'r' }, + static const struct option long_options[] = { + {(char *)"help", no_argument, NULL, 'h'}, + {(char *)"read-file", required_argument, NULL, 'r' }, + {(char *)"version", no_argument, NULL, 'v'}, {0, 0, 0, 0 } }; static const char optstring[] = OPTSTRING; |