diff options
author | ume <ume@FreeBSD.org> | 2000-05-20 18:23:51 +0000 |
---|---|---|
committer | ume <ume@FreeBSD.org> | 2000-05-20 18:23:51 +0000 |
commit | 1db238984d198d018ab2fb5b8378275ade79695b (patch) | |
tree | 3dc37a6009bb7c87cd8cd539e6c74083672de8c5 /lib/libfetch/fetch.c | |
parent | 0636bdc7c29eae203c24417dfc4c8cc2dc211813 (diff) | |
download | FreeBSD-src-1db238984d198d018ab2fb5b8378275ade79695b.zip FreeBSD-src-1db238984d198d018ab2fb5b8378275ade79695b.tar.gz |
IPv6 support.
Diffstat (limited to 'lib/libfetch/fetch.c')
-rw-r--r-- | lib/libfetch/fetch.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/libfetch/fetch.c b/lib/libfetch/fetch.c index ecf15b1..ad9932f 100644 --- a/lib/libfetch/fetch.c +++ b/lib/libfetch/fetch.c @@ -286,9 +286,18 @@ fetchParseURL(char *URL) } else p = URL; /* hostname */ - for (i = 0; *p && (*p != '/') && (*p != ':'); p++) - if (i < MAXHOSTNAMELEN) - u->host[i++] = *p; +#ifdef INET6 + if (*p == '[' && (q = strchr(p + 1, ']')) != NULL && + (*++q == '\0' || *q == '/' || *q == ':')) { + if ((i = q - p - 2) > MAXHOSTNAMELEN) + i = MAXHOSTNAMELEN; + strncpy(u->host, ++p, i); + p = q; + } else +#endif + for (i = 0; *p && (*p != '/') && (*p != ':'); p++) + if (i < MAXHOSTNAMELEN) + u->host[i++] = *p; /* port */ if (*p == ':') { |