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 */
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 }
};
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) {
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;
#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;