mirror of https://git.ffmpeg.org/ffmpeg.git
Add IPv6 support to url_split()
patch by: Ronald S. Bultje rsbultje a gmail d com thread: "[PATCH] url_split() ipv6 support" at 2007/Sep/23 18:43 Originally committed as revision 10615 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
a449faeacb
commit
f8f88a42cf
|
@ -2878,7 +2878,7 @@ void url_split(char *proto, int proto_size,
|
||||||
char *path, int path_size,
|
char *path, int path_size,
|
||||||
const char *url)
|
const char *url)
|
||||||
{
|
{
|
||||||
const char *p, *ls, *at, *col;
|
const char *p, *ls, *at, *col, *brk;
|
||||||
|
|
||||||
if (port_ptr) *port_ptr = -1;
|
if (port_ptr) *port_ptr = -1;
|
||||||
if (proto_size > 0) proto[0] = 0;
|
if (proto_size > 0) proto[0] = 0;
|
||||||
|
@ -2913,13 +2913,19 @@ void url_split(char *proto, int proto_size,
|
||||||
p = at + 1; /* skip '@' */
|
p = at + 1; /* skip '@' */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* port */
|
if (*p == '[' && (brk = strchr(p, ']')) && brk < ls) {
|
||||||
if ((col = strchr(p, ':')) && col < ls) {
|
/* [host]:port */
|
||||||
ls = col;
|
av_strlcpy(hostname, p + 1,
|
||||||
if (port_ptr) *port_ptr = atoi(col + 1); /* skip ':' */
|
FFMIN(hostname_size, brk - p));
|
||||||
}
|
if (brk[1] == ':' && port_ptr)
|
||||||
|
*port_ptr = atoi(brk + 2);
|
||||||
av_strlcpy(hostname, p, FFMIN(1 + ls - p, hostname_size));
|
} else if ((col = strchr(p, ':')) && col < ls) {
|
||||||
|
av_strlcpy(hostname, p,
|
||||||
|
FFMIN(col + 1 - p, hostname_size));
|
||||||
|
if (port_ptr) *port_ptr = atoi(col + 1);
|
||||||
|
} else
|
||||||
|
av_strlcpy(hostname, p,
|
||||||
|
FFMIN(ls + 1 - p, hostname_size));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue