mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-04 13:30:08 -05:00
Improved parse_address to accept the string without a port number
This commit is contained in:
parent
75cac98f76
commit
f1c0e964dd
1 changed files with 9 additions and 5 deletions
|
|
@ -324,13 +324,18 @@ int snd_seq_parse_address(snd_seq_t *seq, snd_seq_addr_t *addr, const char *arg)
|
||||||
{
|
{
|
||||||
char *p;
|
char *p;
|
||||||
int client, port;
|
int client, port;
|
||||||
|
int len;
|
||||||
|
|
||||||
assert(seq && addr && arg);
|
assert(seq && addr && arg);
|
||||||
|
|
||||||
if ((p = strpbrk(arg, ":.")) == NULL)
|
if ((p = strpbrk(arg, ":.")) != NULL) {
|
||||||
return -EINVAL;
|
if ((port = atoi(p + 1)) < 0)
|
||||||
if ((port = atoi(p + 1)) < 0)
|
return -EINVAL;
|
||||||
return -EINVAL;
|
len = (int)(p - arg); /* length of client name */
|
||||||
|
} else {
|
||||||
|
port = 0;
|
||||||
|
len = strlen(arg);
|
||||||
|
}
|
||||||
addr->port = port;
|
addr->port = port;
|
||||||
if (isdigit(*arg)) {
|
if (isdigit(*arg)) {
|
||||||
client = atoi(arg);
|
client = atoi(arg);
|
||||||
|
|
@ -343,7 +348,6 @@ int snd_seq_parse_address(snd_seq_t *seq, snd_seq_addr_t *addr, const char *arg)
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
*p = 0;
|
*p = 0;
|
||||||
len = (int)(p - arg); /* length of client name */
|
|
||||||
if (len <= 0)
|
if (len <= 0)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
cinfo.client = -1;
|
cinfo.client = -1;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue