From 2de2b602227153cdff241bb237bc3370982dcf28 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 22 Dec 2013 23:05:37 +0100 Subject: path: add function to split URL into prefix and path Used in the following commit. --- options/path.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'options/path.c') diff --git a/options/path.c b/options/path.c index d38aa060af..94b599803e 100644 --- a/options/path.c +++ b/options/path.c @@ -231,6 +231,17 @@ bool mp_is_url(bstr path) return true; } +// Return the protocol part of path, e.g. "http" if path is "http://...". +// On success, out_url (if not NULL) is set to the part after the "://". +bstr mp_split_proto(bstr path, bstr *out_url) +{ + if (!mp_is_url(path)) + return (bstr){0}; + bstr r; + bstr_split_tok(path, "://", &r, out_url ? out_url : &(bstr){0}); + return r; +} + void mp_mk_config_dir(struct mpv_global *global, char *subdir) { void *tmp = talloc_new(NULL); -- cgit v1.2.3