diff options
author | Craig Tiller <ctiller@google.com> | 2015-07-20 12:32:58 -0700 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2015-07-20 12:32:58 -0700 |
commit | 698d00c60e91ebf8acf993cf6602d74c0032b5dc (patch) | |
tree | 64dfa6ca60dd053c629e3738fd561b607b723b31 /src/core/support/host_port.c | |
parent | cd329560d33ede65256a926a82279311dcc9b15e (diff) |
Add ipv4:, ipv6: schemes
Diffstat (limited to 'src/core/support/host_port.c')
-rw-r--r-- | src/core/support/host_port.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/core/support/host_port.c b/src/core/support/host_port.c index 0906ebc2a3..a28f04df9c 100644 --- a/src/core/support/host_port.c +++ b/src/core/support/host_port.c @@ -50,7 +50,7 @@ int gpr_join_host_port(char **out, const char *host, int port) { } } -void gpr_split_host_port(const char *name, char **host, char **port) { +int gpr_split_host_port(const char *name, char **host, char **port) { const char *host_start; size_t host_len; const char *port_start; @@ -63,7 +63,7 @@ void gpr_split_host_port(const char *name, char **host, char **port) { const char *rbracket = strchr(name, ']'); if (rbracket == NULL) { /* Unmatched [ */ - return; + return 0; } if (rbracket[1] == '\0') { /* ]<end> */ @@ -73,14 +73,14 @@ void gpr_split_host_port(const char *name, char **host, char **port) { port_start = rbracket + 2; } else { /* ]<invalid> */ - return; + return 0; } host_start = name + 1; host_len = (size_t)(rbracket - host_start); if (memchr(host_start, ':', host_len) == NULL) { /* Require all bracketed hosts to contain a colon, because a hostname or IPv4 address should never use brackets. */ - return; + return 0; } } else { const char *colon = strchr(name, ':'); @@ -105,4 +105,6 @@ void gpr_split_host_port(const char *name, char **host, char **port) { if (port_start != NULL) { *port = gpr_strdup(port_start); } + + return 1; } |