Add long-opts support to qtshark. Take -r or --read-file to open a capture file
immediately from the CLI. Get rid of the comment concerning multi-pass parsing of the options, it only applied to the GTK version. svn path=/trunk/; revision=51640
This commit is contained in:
parent
72b18b1b8e
commit
ae176260e5
@ -496,6 +496,7 @@ int main(int argc, char *argv[])
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
QString locale = QLocale::system().name();
|
QString locale = QLocale::system().name();
|
||||||
|
QString *capture_file = NULL;
|
||||||
|
|
||||||
g_log(NULL, G_LOG_LEVEL_DEBUG, "Translator %s", locale.toStdString().c_str());
|
g_log(NULL, G_LOG_LEVEL_DEBUG, "Translator %s", locale.toStdString().c_str());
|
||||||
QTranslator translator;
|
QTranslator translator;
|
||||||
@ -543,6 +544,11 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
#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:"
|
#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' },
|
||||||
|
{0, 0, 0, 0 }
|
||||||
|
};
|
||||||
|
|
||||||
static const char optstring[] = OPTSTRING;
|
static const char optstring[] = OPTSTRING;
|
||||||
|
|
||||||
/* Assemble the compile-time version information string */
|
/* Assemble the compile-time version information string */
|
||||||
@ -648,20 +654,7 @@ int main(int argc, char *argv[])
|
|||||||
rf_path, strerror(rf_open_errno));
|
rf_path, strerror(rf_open_errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* "pre-scan" the command line parameters, if we have "console only"
|
while ((opt = getopt_long(argc, argv, optstring, long_options, NULL)) != -1) {
|
||||||
parameters. We do this so we don't start GTK+ if we're only showing
|
|
||||||
command-line help or version information.
|
|
||||||
|
|
||||||
XXX - this pre-scan is done before we start GTK+, so we haven't
|
|
||||||
run gtk_init() on the arguments. That means that GTK+ arguments
|
|
||||||
have not been removed from the argument list; those arguments
|
|
||||||
begin with "--", and will be treated as an error by getopt().
|
|
||||||
|
|
||||||
We thus ignore errors - *and* set "opterr" to 0 to suppress the
|
|
||||||
error messages. */
|
|
||||||
opterr = 0;
|
|
||||||
// optind_initial = optind;
|
|
||||||
while ((opt = getopt(argc, argv, optstring)) != -1) {
|
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'C': /* Configuration Profile */
|
case 'C': /* Configuration Profile */
|
||||||
if (profile_exists (optarg, FALSE)) {
|
if (profile_exists (optarg, FALSE)) {
|
||||||
@ -728,6 +721,9 @@ int main(int argc, char *argv[])
|
|||||||
#endif
|
#endif
|
||||||
exit(0);
|
exit(0);
|
||||||
break;
|
break;
|
||||||
|
case 'r':
|
||||||
|
capture_file = new QString(optarg);
|
||||||
|
break;
|
||||||
case 'X':
|
case 'X':
|
||||||
/*
|
/*
|
||||||
* Extension command line options have to be processed before
|
* Extension command line options have to be processed before
|
||||||
@ -736,7 +732,9 @@ int main(int argc, char *argv[])
|
|||||||
*/
|
*/
|
||||||
ex_opt_add(optarg);
|
ex_opt_add(optarg);
|
||||||
break;
|
break;
|
||||||
case '?': /* Ignore errors - the "real" scan will catch them. */
|
case '?':
|
||||||
|
print_usage(TRUE);
|
||||||
|
exit(0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -922,6 +920,10 @@ int main(int argc, char *argv[])
|
|||||||
wsApp->allSystemsGo();
|
wsApp->allSystemsGo();
|
||||||
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_INFO, "Wireshark is up and ready to go");
|
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_INFO, "Wireshark is up and ready to go");
|
||||||
|
|
||||||
|
if (capture_file != NULL) {
|
||||||
|
main_w->openCaptureFile(*capture_file);
|
||||||
|
}
|
||||||
|
|
||||||
g_main_loop_new(NULL, FALSE);
|
g_main_loop_new(NULL, FALSE);
|
||||||
return wsApp->exec();
|
return wsApp->exec();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user