[FFmpeg-devel] [PATCH] url_split() ipv6 support
Ronald S. Bultje
rsbultje
Thu Sep 27 20:16:59 CEST 2007
Hi,
On 9/27/07, Michael Niedermayer <michaelni at gmx.at> wrote:
>
> On Thu, Sep 27, 2007 at 10:04:51AM -0400, Ronald S. Bultje wrote:
> > Index: utils.c
> > ===================================================================
> > --- utils.c (revision 9789)
> > +++ utils.c (working copy)
> > @@ -2793,68 +2793,51 @@
> > char *path, int path_size,
> > const char *url)
> > {
> > + const char *p, *ls;
> >
> > + if (authorization_size > 0) authorization[0] = '\0';
> > + if (hostname_size > 0) hostname[0] = '\0';
>
> these can be vertically aligned and 0 is enough no '\0' needed
Fixed
> + /* parse protocol */
> > + if ((p = strchr(url, ':'))) {
> > p++;
> > + av_strlcpy(proto, url, FFMIN(proto_size, p - url));
> > + if (*p == '/') p++;
> > + if (*p == '/') p++;
> > } else {
> > + /* no protocol means plain filename */
>
> > + if (proto_size > 0) proto[0] = '\0';
>
> this can be placed below the other 2 = 0 above
>
>
> > + av_strlcpy(path, url, path_size);
> > + return;
> > + }
> >
> > + /* separate path from hostname */
> > + if ((ls = strchr(p, '/')))
> > + av_strlcpy(path, ls, path_size);
> > + else {
> > + ls = &p[strlen(p)]; // XXX
>
> > + if (path_size > 0) path[0] = '\0';
>
> this can as well be placed at the top
Both fixed.
> + }
> >
> > + /* the rest is hostname, use that to parse auth/port */
> > + if (ls != p) {
>
> > + const char *at, *col;
>
> these can be merged with the char * at the top
Fixed.
> + /* authorization (user[:pass]@hostname) */
> > + if ((at = strchr(p, '@')) && at < ls) {
>
> > + at++;
> > + av_strlcpy(authorization, p, FFMIN(authorization_size, at -
> p));
>
> at + 1 - p
>
>
> > + p = at;
> > }
> > +
> > + /* port */
> > + if ((col = strchr(p, ':')) && col < ls) {
> > + ls = col;
>
> > + if (port_ptr) *port_ptr = atoi(&col[1]);
>
> col+1
OK, all (where appliccable) use +1 now. New version attached.
except these this looks very nice, and can be commited as soon as the ones
> above are fixed and it works
$ ./test-url_split "test.avi"-> "" :// "" @ "" : "0" / "test.avi"
"/tmp/test.mp3"-> "" :// "" @ "" : "0" / "/tmp/test.mp3"
"file:///tmp/test.mp3"-> "file" :// "" @ "" : "0" / "/tmp/test.mp3"
"http://www.address.com"-> "http" :// "" @ "www.address.com" : "0" / ""
"http://www.address.com/"-> "http" :// "" @ "www.address.com" : "0" / "/"
"http://www.address.com:80"-> "http" :// "" @ "www.address.com" : "80" / ""
"http://www.address.com:80/"-> "http" :// "" @ "www.address.com" : "80" /
"/"
"http://www.address.com:80/test.mp3"-> "http" :// "" @ "www.address.com" :
"80" / "/test.mp3"
"http://1.2.3.4:80/test.mp4"-> "http" :// "" @ "1.2.3.4" : "80" /
"/test.mp4"
"http://:::80/test.mp5"-> "http" :// "" @ "" : "0" / "/test.mp5"
"http://[::1]:80/test.mp6"-> "http" :// "" @ "[" : "0" / "/test.mp6"
"http://[host.address]:80/test.mp3"-> "http" :// "" @ "[host.address]" :
"80" / "/test.mp3"
"file:///[pat]h/to/file.mp3"-> "file" :// "" @ "" : "0" /
"/[pat]h/to/file.mp3"
"http://1:2:3:4:5:6:7:8:80/test.mp3"-> "http" :// "" @ "1" : "2" /
"/test.mp3"
"http://me@:::80/test.mp3"-> "http" :// "me" @ "" : "0" / "/test.mp3"
"http://me:x@:::80/test.mp3"-> "http" :// "me:x" @ "" : "0" / "/test.mp3"
Appears to work as before, the ipv6 ones fail, the rest works. Once in, the
next patch will again fix the ipv6 ones.
Ronald
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ffmpeg-url_split-simplify.patch
Type: application/octet-stream
Size: 3428 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070927/fe1fb5d5/attachment.obj>
More information about the ffmpeg-devel
mailing list