Commit 64a56049 authored by Markus Seeber's avatar Markus Seeber Committed by Stéphane Letz
Browse files

Avoid side effects from parsing of "version" option in jackd (#245)

* detect version option before all other oprion parsing

jackd now checks its arguments for "-V" and "--version" before all other
option parsing happens.

* remove some dead code from option parsing

Version options are detected before optparse runs, the removed code
paths thus became obsolete.

* remove rest of version option from optparse

Detection of the version option is now handled outside of optparse, thus
left over stings and variables are removed.

* switch to string comparison for detection version option

Demanding an exact match for the option strings reflects the original
behavior more closely than a search for substrings.
parent a96111a7
...@@ -241,6 +241,15 @@ static void usage(FILE* file, jackctl_server_t *server, bool full = true) ...@@ -241,6 +241,15 @@ static void usage(FILE* file, jackctl_server_t *server, bool full = true)
// Prototype to be found in libjackserver // Prototype to be found in libjackserver
extern "C" void silent_jack_error_callback(const char *desc); extern "C" void silent_jack_error_callback(const char *desc);
void print_version()
{
printf( "jackdmp version " VERSION " tmpdir "
jack_server_dir " protocol %d" "\n",
JACK_PROTOCOL_VERSION);
exit(-1);
}
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
jackctl_server_t * server_ctl; jackctl_server_t * server_ctl;
...@@ -249,7 +258,13 @@ int main(int argc, char** argv) ...@@ -249,7 +258,13 @@ int main(int argc, char** argv)
jackctl_driver_t * master_driver_ctl; jackctl_driver_t * master_driver_ctl;
jackctl_driver_t * loopback_driver_ctl = NULL; jackctl_driver_t * loopback_driver_ctl = NULL;
int replace_registry = 0; int replace_registry = 0;
const char *options = "-d:X:I:P:uvshVrRL:STFl:t:mn:p:"
for(int a = 1; a < argc; ++a) {
if( !strcmp(argv[a], "--version") || !strcmp(argv[a], "-V") ) {
print_version();
}
}
const char *options = "-d:X:I:P:uvshrRL:STFl:t:mn:p:"
"a:" "a:"
#ifdef __linux__ #ifdef __linux__
"c:" "c:"
...@@ -277,7 +292,6 @@ int main(int argc, char** argv) ...@@ -277,7 +292,6 @@ int main(int argc, char** argv)
{ "realtime-priority", 1, 0, 'P' }, { "realtime-priority", 1, 0, 'P' },
{ "timeout", 1, 0, 't' }, { "timeout", 1, 0, 't' },
{ "temporary", 0, 0, 'T' }, { "temporary", 0, 0, 'T' },
{ "version", 0, 0, 'V' },
{ "silent", 0, 0, 's' }, { "silent", 0, 0, 's' },
{ "sync", 0, 0, 'S' }, { "sync", 0, 0, 'S' },
{ "autoconnect", 1, 0, 'a' }, { "autoconnect", 1, 0, 'a' },
...@@ -290,7 +304,6 @@ int main(int argc, char** argv) ...@@ -290,7 +304,6 @@ int main(int argc, char** argv)
char** master_driver_args = NULL; char** master_driver_args = NULL;
int master_driver_nargs = 1; int master_driver_nargs = 1;
int loopback = 0; int loopback = 0;
bool show_version = false;
jackctl_sigmask_t * sigmask; jackctl_sigmask_t * sigmask;
jackctl_parameter_t* param; jackctl_parameter_t* param;
union jackctl_parameter_value value; union jackctl_parameter_value value;
...@@ -469,10 +482,6 @@ int main(int argc, char** argv) ...@@ -469,10 +482,6 @@ int main(int argc, char** argv)
} }
break; break;
case 'V':
show_version = true;
break;
default: default:
fprintf(stderr, "unknown option character %c\n", optopt); fprintf(stderr, "unknown option character %c\n", optopt);
/*fallthru*/ /*fallthru*/
...@@ -490,14 +499,6 @@ int main(int argc, char** argv) ...@@ -490,14 +499,6 @@ int main(int argc, char** argv)
jackctl_parameter_set_value(param, &value); jackctl_parameter_set_value(param, &value);
} }
if (show_version) {
printf( "jackdmp version " VERSION
" tmpdir " jack_server_dir
" protocol %d"
"\n", JACK_PROTOCOL_VERSION);
return -1;
}
if (!master_driver_name) { if (!master_driver_name) {
usage(stderr, server_ctl, false); usage(stderr, server_ctl, false);
goto destroy_server; goto destroy_server;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment