aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/utils.c
diff options
context:
space:
mode:
authorRonald S. Bultje <rsbultje@gmail.com>2007-09-29 14:35:52 +0000
committerAndreas Ă–man <andreas@lonelycoder.com>2007-09-29 14:35:52 +0000
commitf8f88a42cf5444dd078d591fa367c21516b57a98 (patch)
tree21597fbd062a1a80d40ebf1f44064c162a98db62 /libavformat/utils.c
parenta449faeacb64f3a973c2adb960471e0525ac9d0d (diff)
downloadffmpeg-f8f88a42cf5444dd078d591fa367c21516b57a98.tar.gz
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
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r--libavformat/utils.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 8cd34c8e48..0892513dd8 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2878,7 +2878,7 @@ void url_split(char *proto, int proto_size,
char *path, int path_size,
const char *url)
{
- const char *p, *ls, *at, *col;
+ const char *p, *ls, *at, *col, *brk;
if (port_ptr) *port_ptr = -1;
if (proto_size > 0) proto[0] = 0;
@@ -2913,13 +2913,19 @@ void url_split(char *proto, int proto_size,
p = at + 1; /* skip '@' */
}
- /* port */
- if ((col = strchr(p, ':')) && col < ls) {
- ls = col;
- if (port_ptr) *port_ptr = atoi(col + 1); /* skip ':' */
- }
-
- av_strlcpy(hostname, p, FFMIN(1 + ls - p, hostname_size));
+ if (*p == '[' && (brk = strchr(p, ']')) && brk < ls) {
+ /* [host]:port */
+ av_strlcpy(hostname, p + 1,
+ FFMIN(hostname_size, brk - p));
+ if (brk[1] == ':' && port_ptr)
+ *port_ptr = atoi(brk + 2);
+ } 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));
}
}