summaryrefslogtreecommitdiff
path: root/src/input/http_helper.h
diff options
context:
space:
mode:
authorDiego 'Flameeyes' Pettenò <flameeyes@gmail.com>2008-03-01 03:17:33 +0100
committerDiego 'Flameeyes' Pettenò <flameeyes@gmail.com>2008-03-01 03:17:33 +0100
commit813c609ea30c3201eec34d4bba185566ad48c998 (patch)
treef93ff7fd2604bf9396d5f1712d3eaa2f6d044178 /src/input/http_helper.h
parente728b8f587ee41ff483e46fe50a4cb538c5df9e2 (diff)
parenta1508e2f58d2c4b32d032d798f6f137262717e7f (diff)
downloadxine-lib-813c609ea30c3201eec34d4bba185566ad48c998.tar.gz
xine-lib-813c609ea30c3201eec34d4bba185566ad48c998.tar.bz2
Merge from 1.2 tip.
--HG-- rename : src/combined/ffmpeg/ff_dvaudio_decoder.c => src/audio_dec/ff_dvaudio_decoder.c
Diffstat (limited to 'src/input/http_helper.h')
-rw-r--r--src/input/http_helper.h24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/input/http_helper.h b/src/input/http_helper.h
index 3ce3f2b7c..9baa05235 100644
--- a/src/input/http_helper.h
+++ b/src/input/http_helper.h
@@ -43,6 +43,28 @@ int _x_parse_url (char *url, char **proto, char** host, int *port,
* return:
* the canonicalised URL (caller must free() it)
*/
-char *_x_canonicalise_url (const char *base, const char *url);
+static inline char *_x_canonicalise_url (const char *base, const char *url) {
+
+ size_t base_length;
+ char *cut, *ret;
+
+ if ((cut = strstr (url, "://")))
+ return strdup (url);
+
+ cut = strstr (base, "://");
+ if (url[0] == '/') {
+ /* absolute - base up to first '/' after "://", then url */
+ cut = strchr (cut + 3, '/');
+ }
+ else {
+ /* relative - base up to & inc. last '/', then url */
+ cut = strrchr (cut, '/');
+ if (cut)
+ ++cut;
+ }
+ base_length = cut ? (size_t)(cut - base) : strlen (base);
+ asprintf (&ret, "%.*s%s", (int)base_length, base, url);
+ return ret;
+}
#endif /* HTTP_HELPER_H */