diff tcp.c @ 511:056991ab9f10 libavformat

HTTP Authentication Patch by (Petr Doubek <doubek at vision dot ee dot ethz dot ch>) tested and submitted by (Torsten Spindler <spindler at hbt dot arch dot ethz dot ch>)
author michael
date Thu, 12 Aug 2004 00:09:32 +0000
parents 0fdc96c2f2fe
children 095009fc2f35
line wrap: on
line diff
--- a/tcp.c	Wed Aug 04 20:57:35 2004 +0000
+++ b/tcp.c	Thu Aug 12 00:09:32 2004 +0000
@@ -63,25 +63,18 @@
     int fd_max, ret;
     struct timeval tv;
     socklen_t optlen;
+    char proto[1024],path[1024],tmp[1024];  // PETR: protocol and path strings
+
+    url_split(proto, sizeof(proto), NULL, 0, hostname, sizeof(hostname),
+      &port, path, sizeof(path), uri);  // PETR: use url_split
+    if (strcmp(proto,"tcp")) goto fail; // PETR: check protocol
+    if ((q = strchr(hostname,'@'))) { strcpy(tmp,q+1); strcpy(hostname,tmp); } // PETR: take only the part after '@' for tcp protocol
     
     s = av_malloc(sizeof(TCPContext));
     if (!s)
         return -ENOMEM;
     h->priv_data = s;
-    p = uri;
-    if (!strstart(p, "tcp://", &p))
-        goto fail;
-    q = hostname;
-    while (*p != ':' && *p != '/' && *p != '\0') {
-        if ((q - hostname) < sizeof(hostname) - 1)
-            *q++ = *p;
-        p++;
-    }
-    *q = '\0';
-    if (*p != ':')
-        goto fail;
-    p++;
-    port = strtoul(p, (char **)&p, 10);
+    
     if (port <= 0 || port >= 65536)
         goto fail;