diff options
author | lordjaxom <lordjaxom> | 2004-12-12 19:53:30 +0000 |
---|---|---|
committer | lordjaxom <lordjaxom> | 2004-12-12 19:53:30 +0000 |
commit | 3b0999969632e2820b846ca8adcef6b346ff7441 (patch) | |
tree | 1582ed7db886839ea06c226e228eade0516f60c2 /xml | |
parent | e4c359b5c303cecfc49fb82799805da9fee8dadb (diff) | |
download | vdr-plugin-text2skin-3b0999969632e2820b846ca8adcef6b346ff7441.tar.gz vdr-plugin-text2skin-3b0999969632e2820b846ca8adcef6b346ff7441.tar.bz2 |
1.0-pre3v1.0-pre3
Diffstat (limited to 'xml')
-rw-r--r-- | xml/function.c | 23 | ||||
-rw-r--r-- | xml/function.h | 4 | ||||
-rw-r--r-- | xml/parser.c | 61 | ||||
-rw-r--r-- | xml/string.c | 1 | ||||
-rw-r--r-- | xml/type.c | 5 | ||||
-rw-r--r-- | xml/type.h | 2 | ||||
-rw-r--r-- | xml/xml.c | 32 |
7 files changed, 70 insertions, 58 deletions
diff --git a/xml/function.c b/xml/function.c index f283c2c..3243257 100644 --- a/xml/function.c +++ b/xml/function.c @@ -1,15 +1,16 @@ /* - * $Id: function.c,v 1.4 2004/12/08 18:47:37 lordjaxom Exp $ + * $Id: function.c,v 1.5 2004/12/10 21:46:46 lordjaxom Exp $ */ #include "xml/function.h" #include "render.h" #include "bitmap.h" #include "common.h" +#include <vdr/plugin.h> #include <vdr/tools.h> static const char *Internals[] = { - "not", "and", "or", "equal", "file", "trans", NULL + "not", "and", "or", "equal", "file", "trans", "plugin", NULL }; const std::string cxFunction::False = ""; @@ -129,6 +130,7 @@ bool cxFunction::Parse(const std::string &Text) case fun_eq: ++params; case fun_not: case fun_trans: + case fun_plugin: case fun_file: ++params; default: break; } @@ -161,6 +163,19 @@ const std::string &cxFunction::FunFile(const std::string &Param) const return cText2SkinBitmap::Load(path) ? Param : False; } +std::string cxFunction::FunPlugin(const std::string &Param) const +{ + Dprintf("FunPlugin: Get(%s)\n", Param.c_str()); + cPlugin *p = cPluginManager::GetPlugin(Param.c_str()); + if (p) { + const char *entry = p->MainMenuEntry(); + Dprintf("Entry: |%s|\n", entry); + if (entry) + return entry; + } + return False; +} + std::string cxFunction::Evaluate(void) const { switch (mType) { @@ -185,6 +200,7 @@ std::string cxFunction::Evaluate(void) const return False; case fun_eq: + Dprintf("eq: |%s| <-> |%s|\n", mParams[0]->Evaluate().c_str(), mParams[1]->Evaluate().c_str()); return mParams[0]->Evaluate() == mParams[1]->Evaluate() ? True : False; case fun_file: @@ -192,6 +208,9 @@ std::string cxFunction::Evaluate(void) const case fun_trans: return tr(mParams[0]->Evaluate().c_str()); + + case fun_plugin: + return FunPlugin(mParams[0]->Evaluate()); default: Dprintf("unknown function code\n"); diff --git a/xml/function.h b/xml/function.h index a7d8838..49928af 100644 --- a/xml/function.h +++ b/xml/function.h @@ -27,7 +27,8 @@ public: fun_or = INTERNAL + 3, fun_eq = INTERNAL + 4, fun_file = INTERNAL + 5, - fun_trans = INTERNAL + 6 + fun_trans = INTERNAL + 6, + fun_plugin = INTERNAL + 7 }; static const std::string False; @@ -42,6 +43,7 @@ private: protected: const std::string &FunFile(const std::string &Param) const; + std::string FunPlugin(const std::string &Param) const; public: cxFunction(void); diff --git a/xml/parser.c b/xml/parser.c index 4b957be..8842d19 100644 --- a/xml/parser.c +++ b/xml/parser.c @@ -1,5 +1,5 @@ /* - * $Id: parser.c,v 1.4 2004/12/08 17:13:26 lordjaxom Exp $ + * $Id: parser.c,v 1.5 2004/12/10 21:46:46 lordjaxom Exp $ */ #include "xml/parser.h" @@ -11,49 +11,6 @@ #include <vector> #include <string> -#define STR_SKIN "skin" -#define STR_DISPLAY "display" -#define STR_ID "id" -#define STR_WINDOW "window" -#define STR_X1 "x1" -#define STR_Y1 "y1" -#define STR_X "x" -#define STR_Y "y" -#define STR_X2 "x2" -#define STR_Y2 "y2" -#define STR_BPP "bpp" -#define STR_IMAGE "image" -#define STR_PATH "path" -#define STR_ALPHA "alpha" -#define STR_TEXT "text" -#define STR_CONDITION "condition" -#define STR_NOT "not" -#define STR_FILE "file" -#define STR_COLOR "color" -#define STR_ALIGN "align" -#define STR_RECTANGLE "rectangle" -#define STR_ELLIPSE "ellipse" -#define STR_SLOPE "slope" -#define STR_PROGRESS "progress" -#define STR_BGCOLOR "bgcolor" -#define STR_CURRENT "current" -#define STR_TOTAL "total" -#define STR_VERSION "version" -#define STR_NAME "name" -#define STR_SCREENBASE "screenBase" -#define STR_FONT "font" -#define STR_ARC "arc" - -#define MSG_BADTAG "ERROR: The tag %s was not expected in this context" -#define MSG_BADENDTAG "ERROR: The tag %s was not expected in this context" -#define MSG_BADATTR "ERROR: The attribute %s was not expected in tag %s" -#define MSG_MISSATTR "ERROR: The tag %s lacks the attribute %s" -#define MSG_BADVALUE "ERROR: %s is not allowed for attribute %s" -#define MSG_PARSERR "ERROR: Parser error in %s:%d: %s" -#define MSG_BADCDATA "ERROR: Bad character data" -#define MSG_NOFILE "ERROR: Couldn't read %s: %m" -#define MSG_MANYWINS "ERROR: Too many windows" - #define TAG_ERR_REMAIN(_context) do { \ esyslog("ERROR: Text2Skin: Unexpected tag %s within %s", \ name.c_str(), _context); \ @@ -132,7 +89,7 @@ static cxObject *parent = NULL; static cxObject *object = NULL; bool xStartElem(const std::string &name, std::map<std::string,std::string> &attrs) { - Dprintf("start element: %s\n", name.c_str()); + //Dprintf("start element: %s\n", name.c_str()); if (context.size() == 0) { if (name == "skin") { @@ -227,7 +184,7 @@ bool xStartElem(const std::string &name, std::map<std::string,std::string> &attr bool xCharData(const std::string &text) { int start = 0, end = text.length() - 1; - Dprintf("char data before: %s\n", text.c_str()); + //Dprintf("char data before: %s\n", text.c_str()); while (text[start] == '\012' || text[start] == '\015' || text[start] == ' ' || text[start] == '\t') ++start; @@ -235,22 +192,22 @@ bool xCharData(const std::string &text) { while (text[end] == '\012' || text[end] == '\015' || text[end] == ' ' || text[end] == '\t') --end; - Dprintf("char data after: %s\n", text.substr(start, end - start + 1).c_str()); + //Dprintf("char data after: %s\n", text.substr(start, end - start + 1).c_str()); if (end - start + 1 > 0) { - Dprintf("context: %s\n", context[context.size() - 1].c_str()); + //Dprintf("context: %s\n", context[context.size() - 1].c_str()); if (context[context.size() - 1] == "text" || context[context.size() - 1] == "scrolltext") { if (!object->mText.Parse(text.substr(start, end - start + 1))) return false; } else - esyslog(MSG_BADCDATA); + esyslog("ERROR: Bad character data"); } return true; } bool xEndElem(const std::string &name) { - Dprintf("end element: %s\n", name.c_str()); + //Dprintf("end element: %s\n", name.c_str()); if (context[context.size() - 1] == name) { if (name == "display") { skin->mDisplays[display->Type()] = display; @@ -258,7 +215,7 @@ bool xEndElem(const std::string &name) { } else if (object != NULL || parent != NULL) { if (object == NULL) { - Dprintf("rotating parent to object\n"); + //Dprintf("rotating parent to object\n"); object = parent; parent = NULL; } @@ -275,7 +232,7 @@ bool xEndElem(const std::string &name) { } if (parent != NULL) { - Dprintf("pushing to parent\n"); + //Dprintf("pushing to parent\n"); if (parent->mObjects == NULL) parent->mObjects = new cxObjects(); parent->mObjects->push_back(object); diff --git a/xml/string.c b/xml/string.c index 051a003..269aa0f 100644 --- a/xml/string.c +++ b/xml/string.c @@ -91,6 +91,7 @@ bool cxString::Parse(const std::string &Text) { int pos = -1; txToken &lastToken = mTokens[mTokens.size() - 1]; + Dprintf("assigning attrib: %.*s\n", ptr-last, last); lastToken.Attrib.assign(last, ptr - last); while ((pos = lastToken.Attrib.find('\\', pos + 1)) != -1) { switch (lastToken.Attrib[pos + 1]) { @@ -7,11 +7,12 @@ #include <stdio.h> const std::string &cxType::String(void) { - static char buffer[50]; if (mType == number) { - snprintf(buffer, sizeof(buffer), "%d", mNumber); + char *buffer; + asprintf(&buffer, "%d", mNumber); mString = buffer; mType = string; + free(buffer); } else if (mType == boolean) { mString = mNumber ? cxFunction::True : cxFunction::False; mType = string; @@ -5,6 +5,7 @@ #ifndef VDR_TEXT2SKIN_XML_TYPE_H #define VDR_TEXT2SKIN_XML_TYPE_H +#include <stdio.h> #include <string> class cxType { @@ -26,6 +27,7 @@ public: cxType(int Number): mType(number), mNumber(Number) {} cxType(time_t Number): mType(number), mNumber(Number) {} cxType(bool Value): mType(boolean), mNumber(Value ? 1 : 0) {} + cxType(const cxType &Src): mType(Src.mType), mString(Src.mString), mNumber(Src.mNumber) {} const std::string &String(void); int Number(void) const; @@ -16,6 +16,9 @@ enum { LOOK4START, // looking for first element start LOOK4TAG, // looking for element tag INTAG, // reading tag + INCOMMENT, // reading comment + LOOK4CEND1, // looking for second '-' in --> + LOOK4CEND2, // looking for '>' in --> LOOK4ATTRN, // looking for attr name, > or / INATTRN, // reading attr name LOOK4ATTRV, // looking for attr value @@ -149,7 +152,7 @@ XML::readChar(int c) { } break; } else { - if (c == '?' || c == '!') { + if (c == '?') { skipping = true; break; } @@ -159,6 +162,8 @@ XML::readChar(int c) { state = INTAG; } else if (c == '/') { state = LOOK4CLOSETAG; + } else if (c == '!') { + state = INCOMMENT; } else if (!isspace(c)) { if (parseerrorcb) { parseerrorcb(linenr, "Bogus tag char", c); @@ -183,6 +188,31 @@ XML::readChar(int c) { } break; + // reading comment + case INCOMMENT: + if (c == '-') { + state = LOOK4CEND1; + } + break; + + // looking for second '-' in "-->" + case LOOK4CEND1: + if (c == '-') { + state = LOOK4CEND2; + } else { + state = INCOMMENT; + } + break; + + // looking for '>' in "-->" + case LOOK4CEND2: + if (c == '>') { + state = LOOK4START; + } else if (c != '-') { + state = INCOMMENT; + } + break; + // looking for attr name, > or / case LOOK4ATTRN: if (c == '>') { |