diff options
author | Takashi Iwai <tiwai@suse.de> | 2000-09-14 10:19:45 +0000 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2000-09-14 10:19:45 +0000 |
commit | e0847b4af87f144b67e62e98f8d3a4879151946f (patch) | |
tree | ec55d4dfdd89f20b93965f922e99e758f98cc7a0 /seq/aseqnet | |
parent | d57f1ef1663a12e94fce93cf72450101bc95577a (diff) | |
download | alsa-utils-e0847b4af87f144b67e62e98f8d3a4879151946f.tar.gz |
Accept the client name as address argument of aconnect and aseqnet.
You may use aconnect like this:
% aconnect External:0 Emu8000:1
Diffstat (limited to 'seq/aseqnet')
-rw-r--r-- | seq/aseqnet/aseqnet.c | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/seq/aseqnet/aseqnet.c b/seq/aseqnet/aseqnet.c index 8eab330..9640195 100644 --- a/seq/aseqnet/aseqnet.c +++ b/seq/aseqnet/aseqnet.c @@ -169,18 +169,42 @@ static void init_buf(void) } /* - * parse client:port argument + * parse command line to client:port + * NB: the given string will be broken. */ -static int parse_addr(snd_seq_addr_t *addr, char *arg) +static int parse_address(snd_seq_t *seq, snd_seq_addr_t *addr, char *arg) { char *p; + int client, port; - if (! isdigit(*arg)) - return -1; if ((p = strpbrk(arg, ":.")) == NULL) return -1; - addr->client = atoi(arg); - addr->port = atoi(p + 1); + if ((port = atoi(p + 1)) < 0) + return -1; + addr->port = port; + if (isdigit(*arg)) { + client = atoi(arg); + if (client < 0) + return -1; + addr->client = client; + } else { + /* convert from the name */ + snd_seq_client_info_t cinfo; + int len; + + *p = 0; + len = strlen(arg); + if (len <= 0) + return -1; + cinfo.client = -1; + while (snd_seq_query_next_client(seq, &cinfo) >= 0) { + if (! strncmp(cinfo.name, arg, len)) { + addr->client = cinfo.client; + return 0; + } + } + return -1; /* not found */ + } return 0; } @@ -240,7 +264,7 @@ static void init_seq(char *source, char *dest) /* explicit subscriptions */ if (source) { /* read subscription */ - if (parse_addr(&addr, source) < 0) { + if (parse_address(handle, &addr, source) < 0) { fprintf(stderr, "invalid source address %s\n", source); exit(1); } @@ -251,7 +275,7 @@ static void init_seq(char *source, char *dest) } if (dest) { /* write subscription */ - if (parse_addr(&addr, dest) < 0) { + if (parse_address(handle, &addr, dest) < 0) { fprintf(stderr, "invalid destination address %s\n", dest); exit(1); } |