comparison 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
comparison
equal deleted inserted replaced
510:133287132e1d 511:056991ab9f10
61 const char *p; 61 const char *p;
62 fd_set wfds; 62 fd_set wfds;
63 int fd_max, ret; 63 int fd_max, ret;
64 struct timeval tv; 64 struct timeval tv;
65 socklen_t optlen; 65 socklen_t optlen;
66 char proto[1024],path[1024],tmp[1024]; // PETR: protocol and path strings
67
68 url_split(proto, sizeof(proto), NULL, 0, hostname, sizeof(hostname),
69 &port, path, sizeof(path), uri); // PETR: use url_split
70 if (strcmp(proto,"tcp")) goto fail; // PETR: check protocol
71 if ((q = strchr(hostname,'@'))) { strcpy(tmp,q+1); strcpy(hostname,tmp); } // PETR: take only the part after '@' for tcp protocol
66 72
67 s = av_malloc(sizeof(TCPContext)); 73 s = av_malloc(sizeof(TCPContext));
68 if (!s) 74 if (!s)
69 return -ENOMEM; 75 return -ENOMEM;
70 h->priv_data = s; 76 h->priv_data = s;
71 p = uri; 77
72 if (!strstart(p, "tcp://", &p))
73 goto fail;
74 q = hostname;
75 while (*p != ':' && *p != '/' && *p != '\0') {
76 if ((q - hostname) < sizeof(hostname) - 1)
77 *q++ = *p;
78 p++;
79 }
80 *q = '\0';
81 if (*p != ':')
82 goto fail;
83 p++;
84 port = strtoul(p, (char **)&p, 10);
85 if (port <= 0 || port >= 65536) 78 if (port <= 0 || port >= 65536)
86 goto fail; 79 goto fail;
87 80
88 dest_addr.sin_family = AF_INET; 81 dest_addr.sin_family = AF_INET;
89 dest_addr.sin_port = htons(port); 82 dest_addr.sin_port = htons(port);