summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile12
-rw-r--r--glcddrivers/Makefile4
-rw-r--r--glcdgraphics/Makefile2
-rw-r--r--glcdskin/Makefile4
-rw-r--r--glcdskin/function.c3
-rw-r--r--glcdskin/parser.c41
-rw-r--r--glcdskin/parser.h3
-rw-r--r--glcdskin/xml.c24
-rw-r--r--glcdskin/xml.h1
9 files changed, 67 insertions, 27 deletions
diff --git a/Makefile b/Makefile
index a659568..2ece39f 100644
--- a/Makefile
+++ b/Makefile
@@ -3,46 +3,36 @@
#
PROJECT = graphlcd-base
-VERSION = 0.1.6
+VERSION = 0.3.0
ARCHIVE = $(PROJECT)-$(VERSION)
PACKAGE = $(ARCHIVE)
TMPDIR = /tmp
-INCLUDE_SKINS=1
-
### Targets:
all:
@$(MAKE) -C glcdgraphics all
@$(MAKE) -C glcddrivers all
-ifdef INCLUDE_SKINS
@$(MAKE) -C glcdskin all
-endif
@$(MAKE) -C tools all
install:
@$(MAKE) -C glcdgraphics install
@$(MAKE) -C glcddrivers install
-ifdef INCLUDE_SKINS
@$(MAKE) -C glcdskin install
-endif
@$(MAKE) -C tools install
uninstall:
@$(MAKE) -C glcdgraphics uninstall
@$(MAKE) -C glcddrivers uninstall
-ifdef INCLUDE_SKINS
@$(MAKE) -C glcdskin uninstall
-endif
@$(MAKE) -C tools uninstall
clean:
@-rm -f *.tgz
@$(MAKE) -C glcdgraphics clean
@$(MAKE) -C glcddrivers clean
-ifdef INCLUDE_SKINS
@$(MAKE) -C glcdskin clean
-endif
@$(MAKE) -C tools clean
dist: clean
diff --git a/glcddrivers/Makefile b/glcddrivers/Makefile
index 331c829..72776d8 100644
--- a/glcddrivers/Makefile
+++ b/glcddrivers/Makefile
@@ -6,8 +6,8 @@
CXXFLAGS += -fPIC
-VERMAJOR = 1
-VERMINOR = 0
+VERMAJOR = 2
+VERMINOR = 1
VERMICRO = 0
BASENAME = libglcddrivers.so
diff --git a/glcdgraphics/Makefile b/glcdgraphics/Makefile
index 27f6b33..0a10190 100644
--- a/glcdgraphics/Makefile
+++ b/glcdgraphics/Makefile
@@ -18,7 +18,7 @@ endif
CXXFLAGS += -fPIC
VERMAJOR = 2
-VERMINOR = 0
+VERMINOR = 1
VERMICRO = 0
BASENAME = libglcdgraphics.so
diff --git a/glcdskin/Makefile b/glcdskin/Makefile
index c67582c..1c1b04e 100644
--- a/glcdskin/Makefile
+++ b/glcdskin/Makefile
@@ -7,8 +7,8 @@
CXXFLAGS += -fPIC
-VERMAJOR = 1
-VERMINOR = 0
+VERMAJOR = 2
+VERMINOR = 1
VERMICRO = 0
BASENAME = libglcdskin.so
diff --git a/glcdskin/function.c b/glcdskin/function.c
index 9815073..c6089bc 100644
--- a/glcdskin/function.c
+++ b/glcdskin/function.c
@@ -128,7 +128,8 @@ bool cSkinFunction::Parse(const std::string & Text)
int num = strtol(ptr, &end, 10);
if (end == ptr || *end != '\0')
{
- syslog(LOG_ERR, "ERROR: Invalid numeric value\n");
+ // don't log this because when parsing a string starting with a digit (eg: 0%) this may result in a load of false positives
+ //syslog(LOG_ERR, "ERROR: Invalid numeric value (%s)\n", Text.c_str());
return false;
}
diff --git a/glcdskin/parser.c b/glcdskin/parser.c
index a06ebc4..411c832 100644
--- a/glcdskin/parser.c
+++ b/glcdskin/parser.c
@@ -143,6 +143,17 @@ static uint32_t oindex = 0;
static std::string errorDetail = "";
static std::string condblock_cond = "";
+// support for including files (templates, ...) in the skin definition
+// max. depth supported for file inclusion (-> detect recursive inclusions)
+#define MAX_INCLUDEDEPTH 5
+static int includeDepth = 0;
+static std::string subErrorDetail = "";
+
+bool StartElem(const std::string & name, std::map<std::string,std::string> & attrs);
+bool CharData(const std::string & text);
+bool EndElem(const std::string & name);
+
+
static bool CheckSkinVersion(const std::string & version) {
float currv;
@@ -186,6 +197,36 @@ bool StartElem(const std::string & name, std::map<std::string,std::string> & att
else
TAG_ERR_REMAIN("document");
}
+ else if (name == "include")
+ {
+ if (includeDepth + 1 < MAX_INCLUDEDEPTH) {
+ cSkinObject* tmpobj = new cSkinObject(new cSkinDisplay(skin));
+ cSkinString* path = new cSkinString(tmpobj, false);
+ ATTRIB_MAN_FUNC("path", path->Parse);
+ std::string strpath = path->Evaluate();
+ // is path relative? -> prepend skinpath
+ if (strpath[0] != '/') {
+ strpath = skin->Config().SkinPath() + "/" + strpath;
+ }
+ path = NULL;
+ tmpobj = NULL;
+
+ includeDepth++;
+ cXML incxml(strpath, skin->Config().CharSet());
+ incxml.SetNodeStartCB(StartElem);
+ incxml.SetNodeEndCB(EndElem);
+ incxml.SetCDataCB(CharData);
+ if (incxml.Parse() != 0) {
+ errorDetail = "error when parsing included xml file '"+strpath+"'"+ ( (subErrorDetail == "") ? "" : " ("+subErrorDetail+")");
+ syslog(LOG_ERR, "ERROR: graphlcd/skin: %s", errorDetail.c_str());
+ return false;
+ }
+ includeDepth--;
+ } else {
+ subErrorDetail = "max. include depth reached";
+ return false;
+ }
+ }
else if (name == "condblock")
{
int i = context.size() - 1;
diff --git a/glcdskin/parser.h b/glcdskin/parser.h
index f8b2a2e..855c626 100644
--- a/glcdskin/parser.h
+++ b/glcdskin/parser.h
@@ -16,7 +16,8 @@
#include <string>
-#define GLCDSKIN_SKIN_VERSION 1.1
+// max. version of skin definitions supported by the parser
+#define GLCDSKIN_SKIN_VERSION 1.2
namespace GLCD
diff --git a/glcdskin/xml.c b/glcdskin/xml.c
index 1ed927d..a3ad976 100644
--- a/glcdskin/xml.c
+++ b/glcdskin/xml.c
@@ -70,18 +70,21 @@ cXML::cXML(const std::string & file, const std::string sysCharset)
if (!f.is_open())
{
syslog(LOG_ERR, "ERROR: skin file %s not found\n", file.c_str());
- }
- size = f.tellg();
+ validFile = false;
+ } else {
+ validFile = true;
+ size = f.tellg();
#if (__GNUC__ < 3)
- f.seekg(0, std::ios::beg);
+ f.seekg(0, std::ios::beg);
#else
- f.seekg(0, std::ios_base::beg);
+ f.seekg(0, std::ios_base::beg);
#endif
- buffer = new char[size];
- f.read(buffer, size);
- f.close();
- data.assign(buffer, size);
- delete[] buffer;
+ buffer = new char[size];
+ f.read(buffer, size);
+ f.close();
+ data.assign(buffer, size);
+ delete[] buffer;
+ }
}
#if 0
@@ -135,6 +138,9 @@ int cXML::Parse(void)
uint32_t c, c_tmp;
unsigned int i_old;
int l, char_size;
+
+ if (!validFile)
+ return -1;
state = LOOK4START;
linenr = 1;
diff --git a/glcdskin/xml.h b/glcdskin/xml.h
index 30210cc..0978cf4 100644
--- a/glcdskin/xml.h
+++ b/glcdskin/xml.h
@@ -34,6 +34,7 @@ void (*CB)(int percent)
class cXML
{
private:
+ bool validFile;
bool skipping;
int state;
int linenr;