summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfps <mista.tapas@gmx.net>2020-07-09 06:25:15 +0200
committerFilipe Coelho <falktx@falktx.com>2020-07-09 07:05:37 +0200
commitd95c7a6efbc2ba82f09a7b11a6e4debac3d6ad88 (patch)
tree2e71546d32276f5de89bc0acf9fc2362ec46234e
parentc95bd9631f137cb771590db187c34309e4206fc7 (diff)
downloadjack2-d95c7a6efbc2ba82f09a7b11a6e4debac3d6ad88.tar.gz
jack_wait: add client name option -n/--name
-rw-r--r--example-clients/wait.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/example-clients/wait.c b/example-clients/wait.c
index 2d5ff1c6..6e56cae9 100644
--- a/example-clients/wait.c
+++ b/example-clients/wait.c
@@ -17,6 +17,7 @@ show_usage(void)
fprintf(stderr, "Check for jack existence, or wait, until it either quits, or gets started\n");
fprintf(stderr, "options:\n");
fprintf(stderr, " -s, --server <name> Connect to the jack server named <name>\n");
+ fprintf(stderr, " -n, --name <name> Set client name to <name>\n");
fprintf(stderr, " -w, --wait Wait for server to become available\n");
fprintf(stderr, " -q, --quit Wait until server is quit\n");
fprintf(stderr, " -c, --check Check whether server is running\n");
@@ -34,6 +35,7 @@ main(int argc, char *argv[])
int c;
int option_index;
char *server_name = NULL;
+ char *client_name = NULL;
int wait_for_start = 0;
int wait_for_quit = 0;
int just_check = 0;
@@ -44,6 +46,7 @@ main(int argc, char *argv[])
struct option long_options[] = {
{ "server", 1, 0, 's' },
{ "wait", 0, 0, 'w' },
+ { "name", 1, 0, 'n'},
{ "quit", 0, 0, 'q' },
{ "check", 0, 0, 'c' },
{ "timeout", 1, 0, 't' },
@@ -58,13 +61,17 @@ main(int argc, char *argv[])
my_name ++;
}
- while ((c = getopt_long (argc, argv, "s:wqct:hv", long_options, &option_index)) >= 0) {
+ while ((c = getopt_long (argc, argv, "s:n:wqct:hv", long_options, &option_index)) >= 0) {
switch (c) {
case 's':
- server_name = (char *) malloc (sizeof (char) * strlen(optarg));
+ server_name = (char *) malloc (sizeof (char) * (strlen(optarg) + 1));
strcpy (server_name, optarg);
options |= JackServerName;
break;
+ case 'n':
+ client_name = (char *) malloc (sizeof (char) * (strlen(optarg) + 1));
+ strcpy (client_name, optarg);
+ break;
case 'w':
wait_for_start = 1;
break;
@@ -93,7 +100,12 @@ main(int argc, char *argv[])
start_timestamp = time(NULL);
while (1) {
- client = jack_client_open ("wait", options, &status, server_name);
+ if (client_name) {
+ client = jack_client_open (client_name, options, &status, server_name);
+ }
+ else {
+ client = jack_client_open ("wait", options, &status, server_name);
+ }
/* check for some real error and bail out */
if ((client == NULL) && !(status & JackServerFailed)) {
fprintf (stderr, "jack_client_open() failed, "