summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorphintuka <phintuka>2010-02-03 11:23:11 +0000
committerphintuka <phintuka>2010-02-03 11:23:11 +0000
commit425c0a91bd8e79270ec7ef0e662f7c43b7a404ad (patch)
tree3814cfdf85cb80840ed095922f3d4b2b0c023f4b
parentff42ea107855c06e30e143bfd52897a69d803e90 (diff)
downloadxineliboutput-425c0a91bd8e79270ec7ef0e662f7c43b7a404ad.tar.gz
xineliboutput-425c0a91bd8e79270ec7ef0e662f7c43b7a404ad.tar.bz2
Added BuildMrl
(obsoletes EscapeMrl)
-rw-r--r--tools/playlist.c57
-rw-r--r--tools/playlist.h5
2 files changed, 57 insertions, 5 deletions
diff --git a/tools/playlist.c b/tools/playlist.c
index d025c01b..01e032f1 100644
--- a/tools/playlist.c
+++ b/tools/playlist.c
@@ -4,7 +4,7 @@
* See the main source file 'xineliboutput.c' for copyright information and
* how to reach the author.
*
- * $Id: playlist.c,v 1.24 2009-10-31 19:59:50 phintuka Exp $
+ * $Id: playlist.c,v 1.25 2010-02-03 11:23:11 phintuka Exp $
*
*/
@@ -917,6 +917,56 @@ bool cPlaylist::Read(const char *PlaylistFile, bool Recursive)
return Result;
}
+static cString EscapeString(const char *s)
+{
+ static const uint8_t hex[16] = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
+ const uint8_t *fn = (const uint8_t*)s;
+ int size = strlen(s) + 16;
+ char *buf = (char *)malloc(size);
+ int i = 0;
+ LOGVERBOSE("cPlaylist::EscapeMrl('%s')", fn);
+
+ while (*fn) {
+ if(size-7 < i)
+ buf = (char *)realloc(buf, (size=size+16));
+ switch (*fn) {
+ case 1 ... ' ':
+ case 127 ... 255:
+ case '#':
+ case '%':
+ case '?':
+ case ':':
+ case ';':
+ case '\'':
+ case '\"':
+ case '(':
+ case ')':
+ buf[i++] = '%';
+ buf[i++] = hex[(*fn & 0xf0)>>4];
+ buf[i++] = hex[(*fn & 0x0f)];
+ break;
+ default:
+ buf[i++] = *fn;
+ break;
+ }
+ fn++;
+ }
+
+ buf[i] = 0;
+ LOGVERBOSE(" --> '%s'", buf);
+ return cString(buf, true);
+}
+
+cString cPlaylist::BuildMrl(const char *proto, const char *s1, const char *s2, const char *s3, const char *s4)
+{
+ return cString::sprintf("%s:%s%s%s%s",
+ proto,
+ s1 ? *EscapeString(s1) : "",
+ s2 ? *EscapeString(s2) : "",
+ s3 ? *EscapeString(s3) : "",
+ s4 ? *EscapeString(s4) : "");
+}
+
cString cPlaylist::EscapeMrl(const char *mrl)
{
static const uint8_t hex[16] = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
@@ -924,7 +974,7 @@ cString cPlaylist::EscapeMrl(const char *mrl)
int size = strlen(mrl) + 16;
char *buf = (char *)malloc(size);
int i = 0, found = 0;
- LOGDBG("cPlaylist::EscapeMrl('%s')", fn);
+ LOGVERBOSE("cPlaylist::EscapeMrl('%s')", fn);
// Wait for first '/' (do not escape mrl start dvd:/, http://a@b/, ...)
if (*fn == '/')
@@ -974,13 +1024,12 @@ cString cPlaylist::EscapeMrl(const char *mrl)
}
buf[i] = 0;
- LOGDBG(" --> '%s'", buf);
+ LOGVERBOSE(" --> '%s'", buf);
return cString(buf, true);
}
cString cPlaylist::GetEntry(cPlaylistItem *i, bool isPlaylist, bool isCurrent)
{
-
cString Entry = "";
if ((*i->Artist && xc.playlist_artist) || (*i->Album && xc.playlist_album)) {
Entry = cString::sprintf("%s%s%s%s%s%s(%s%s%s)",
diff --git a/tools/playlist.h b/tools/playlist.h
index 7420643b..947bb9c7 100644
--- a/tools/playlist.h
+++ b/tools/playlist.h
@@ -4,7 +4,7 @@
* See the main source file 'xineliboutput.c' for copyright information and
* how to reach the author.
*
- * $Id: playlist.h,v 1.10 2009-10-31 19:59:50 phintuka Exp $
+ * $Id: playlist.h,v 1.11 2010-02-03 11:23:11 phintuka Exp $
*
*/
@@ -124,7 +124,10 @@ class cPlaylist : protected cList<cPlaylistItem>
cPlaylistItem *Next(void);
cPlaylistItem *Prev(void);
+ static cString BuildMrl(const char *proto, const char *s1,
+ const char *s2 = NULL, const char *s3 = NULL, const char *s4 = NULL);
static cString EscapeMrl(const char *name);
+
static cString GetEntry(cPlaylistItem *i, bool isPlaylist = false, bool isCurrent = false);
};