aboutsummaryrefslogtreecommitdiffstats
path: root/libav
diff options
context:
space:
mode:
authorFabrice Bellard <fabrice@bellard.org>2002-07-24 18:04:50 +0000
committerFabrice Bellard <fabrice@bellard.org>2002-07-24 18:04:50 +0000
commita9a721da7ce859250b57041746f6aef921ee6a93 (patch)
tree644000b73342e8703760e3d771f406a16fac943d /libav
parentbdd7d518480f0eb8ad0262eefb60c67dbce85ffb (diff)
downloadffmpeg-a9a721da7ce859250b57041746f6aef921ee6a93.tar.gz
added url_split()
Originally committed as revision 800 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libav')
-rw-r--r--libav/utils.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/libav/utils.c b/libav/utils.c
index e8e62e8ac8..bae52c73d7 100644
--- a/libav/utils.c
+++ b/libav/utils.c
@@ -1092,3 +1092,54 @@ void av_hex_dump(UINT8 *buf, int size)
}
}
+void url_split(char *proto, int proto_size,
+ char *hostname, int hostname_size,
+ int *port_ptr,
+ char *path, int path_size,
+ const char *url)
+{
+ const char *p;
+ char *q;
+ int port;
+
+ port = -1;
+
+ p = url;
+ q = proto;
+ while (*p != ':' && *p != '\0') {
+ if ((q - proto) < proto_size - 1)
+ *q++ = *p;
+ p++;
+ }
+ if (proto_size > 0)
+ *q = '\0';
+ if (*p == '\0') {
+ if (proto_size > 0)
+ proto[0] = '\0';
+ if (hostname_size > 0)
+ hostname[0] = '\0';
+ p = url;
+ } else {
+ p++;
+ if (*p == '/')
+ p++;
+ if (*p == '/')
+ p++;
+ q = hostname;
+ while (*p != ':' && *p != '/' && *p != '?' && *p != '\0') {
+ if ((q - hostname) < hostname_size - 1)
+ *q++ = *p;
+ p++;
+ }
+ if (hostname_size > 0)
+ *q = '\0';
+ if (*p == ':') {
+ p++;
+ port = strtoul(p, (char **)&p, 10);
+ }
+ }
+ if (port_ptr)
+ *port_ptr = port;
+ pstrcpy(path, path_size, p);
+}
+