[xiph-commits] r3124 - liboggplay/trunk/src/liboggplay
tahn at svn.annodex.net
tahn at svn.annodex.net
Thu Jun 28 07:41:21 PDT 2007
Author: tahn
Date: 2007-06-28 07:41:21 -0700 (Thu, 28 Jun 2007)
New Revision: 3124
Modified:
liboggplay/trunk/src/liboggplay/oggplay_tcp_reader.c
Log:
Shane's changes to tcp_reader
Modified: liboggplay/trunk/src/liboggplay/oggplay_tcp_reader.c
===================================================================
--- liboggplay/trunk/src/liboggplay/oggplay_tcp_reader.c 2007-06-28 14:18:05 UTC (rev 3123)
+++ liboggplay/trunk/src/liboggplay/oggplay_tcp_reader.c 2007-06-28 14:41:21 UTC (rev 3124)
@@ -152,12 +152,14 @@
int len;
int has_http;
+ /* no proxy: split the location into host, port and path. */
if (proxy == NULL) {
char *_location;
len = strlen(location);
_location = (char*)malloc(len + 2);
strcpy(_location, location);
+ /* find location of slash and possibly colon (colon -> port) */
if (strncmp(_location, "http://", 7) == 0) {
*path = strchr(_location + 7, '/');
colon = strchr(_location + 7, ':');
@@ -169,27 +171,29 @@
}
*port = 80;
+ /* if there's a colon before the path starts, then override default
+ * port (i.e. if we have http://example.com:22/my/path but not
+ * http://example.com/my:22/path */
if (colon != NULL) {
if (*path == NULL || colon < *path) {
*port = (int)strtol(colon+1, NULL, 10);
if (*path != NULL) {
+ /* move path back a bit so that we copy the correct amount
+ * into host later */
strcpy(colon, location + (*path - _location));
- *path = strdup(colon);
- }
- else {
+ *path = colon;
+ } else {
*colon = '\0';
- *path = NULL;
}
}
}
-
-
+
if (*path == NULL) {
_location[len] = '/';
_location[len + 1] = '\0';
- *path = strdup(_location + len);
+ *path = _location + len;
}
-
+
if (has_http) {
*host = (char*)malloc((*path - _location) - 6);
strncpy(*host, _location + 7, (*path - _location) - 7);
@@ -199,6 +203,14 @@
strncpy(*host, _location, *path - _location);
(*host)[*path - _location] = '\0';
}
+
+ /* create a malloced copy of the path if not null, otherwise
+ * create a path of "/" */
+ if (*path != NULL) {
+ char *tmp = *path;
+ *path = strdup(tmp);
+ }
+
free(_location);
}
else
More information about the commits
mailing list