|
@ -45,14 +45,20 @@ void free_addr(addr_t *addr) |
|
|
|
|
|
|
|
|
void parse_addr(const char *str, addr_t *addr) |
|
|
void parse_addr(const char *str, addr_t *addr) |
|
|
{ |
|
|
{ |
|
|
int ret = -1; |
|
|
|
|
|
|
|
|
int ret = -1, n = 0; |
|
|
char *pch; |
|
|
char *pch; |
|
|
pch = strchr(str, ':'); |
|
|
pch = strchr(str, ':'); |
|
|
while (pch != NULL) |
|
|
while (pch != NULL) |
|
|
{ |
|
|
{ |
|
|
|
|
|
n++; |
|
|
ret = pch - str; |
|
|
ret = pch - str; |
|
|
pch = strchr(pch + 1, ':'); |
|
|
pch = strchr(pch + 1, ':'); |
|
|
} |
|
|
} |
|
|
|
|
|
if (n > 1) { |
|
|
|
|
|
if (strcmp(str+ret, "]") != 0) { |
|
|
|
|
|
ret = -1; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
if (ret == -1) |
|
|
if (ret == -1) |
|
|
{ |
|
|
{ |
|
|
addr->host = strdup(str); |
|
|
addr->host = strdup(str); |
|
|