From: rhk Date: Mon, 13 Sep 2010 14:53:50 +0000 (+0000) Subject: [packages] ezxml: update PKG_RELEASE and rename patches X-Git-Url: http://207.154.207.93/?a=commitdiff_plain;h=b1a51aa24079ebf42f67289102bc841e51c495e2;p=packages.git [packages] ezxml: update PKG_RELEASE and rename patches git-svn-id: svn://svn.openwrt.org/openwrt/packages@23054 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- diff --git a/libs/ezxml/Makefile b/libs/ezxml/Makefile index 309519a64..8333a6d53 100644 --- a/libs/ezxml/Makefile +++ b/libs/ezxml/Makefile @@ -1,5 +1,5 @@ # -# Copyright (C) 2006-2009 OpenWrt.org +# Copyright (C) 2006-2010 OpenWrt.org # # This is free software, licensed under the GNU General Public License v2. # See /LICENSE for more information. @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=ezxml PKG_VERSION:=0.8.6 -PKG_RELEASE:=2 +PKG_RELEASE:=3 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=@SF/ezxml diff --git a/libs/ezxml/patches/200-ezxml_parse_str.patch b/libs/ezxml/patches/200-ezxml_parse_str.patch new file mode 100644 index 000000000..dd65defb2 --- /dev/null +++ b/libs/ezxml/patches/200-ezxml_parse_str.patch @@ -0,0 +1,36 @@ +--- a/ezxml.c ++++ b/ezxml.c +@@ -599,6 +599,19 @@ ezxml_t ezxml_parse_str(char *s, size_t + else return ezxml_err(root, d, "unclosed tag <%s>", root->cur->name); + } + ++// parse the given xml string and return an ezxml structure ++ezxml_t ezxml_parse_str_d(char const *_s, size_t len) ++{ ++ ezxml_root_t root; ++ char *s; ++ ++ if (! (s = strndup(_s, len))) return NULL; ++ ++ root = (ezxml_root_t)ezxml_parse_str(s, strlen(s)); ++ root->len = -1; // so we know to free s in ezxml_free() ++ return &root->xml; ++} ++ + // Wrapper for ezxml_parse_str() that accepts a file stream. Reads the entire + // stream into memory and then parses it. For xml files, use ezxml_parse_file() + // or ezxml_parse_fd() +--- a/ezxml.h ++++ b/ezxml.h +@@ -59,6 +59,11 @@ struct ezxml { + // pass in the copy. Returns NULL on failure. + ezxml_t ezxml_parse_str(char *s, size_t len); + ++// Given a string of xml data and its length, parses it and creates an ezxml ++// structure. that strdup()s s ++// Returns NULL on failure. ++ezxml_t ezxml_parse_str_d(char const *s, size_t len); ++ + // A wrapper for ezxml_parse_str() that accepts a file descriptor. First + // attempts to mem map the file. Failing that, reads the file into memory. + // Returns NULL on failure. diff --git a/libs/ezxml/patches/200-ezxml_parse_str_d.patch b/libs/ezxml/patches/200-ezxml_parse_str_d.patch deleted file mode 100644 index dd65defb2..000000000 --- a/libs/ezxml/patches/200-ezxml_parse_str_d.patch +++ /dev/null @@ -1,36 +0,0 @@ ---- a/ezxml.c -+++ b/ezxml.c -@@ -599,6 +599,19 @@ ezxml_t ezxml_parse_str(char *s, size_t - else return ezxml_err(root, d, "unclosed tag <%s>", root->cur->name); - } - -+// parse the given xml string and return an ezxml structure -+ezxml_t ezxml_parse_str_d(char const *_s, size_t len) -+{ -+ ezxml_root_t root; -+ char *s; -+ -+ if (! (s = strndup(_s, len))) return NULL; -+ -+ root = (ezxml_root_t)ezxml_parse_str(s, strlen(s)); -+ root->len = -1; // so we know to free s in ezxml_free() -+ return &root->xml; -+} -+ - // Wrapper for ezxml_parse_str() that accepts a file stream. Reads the entire - // stream into memory and then parses it. For xml files, use ezxml_parse_file() - // or ezxml_parse_fd() ---- a/ezxml.h -+++ b/ezxml.h -@@ -59,6 +59,11 @@ struct ezxml { - // pass in the copy. Returns NULL on failure. - ezxml_t ezxml_parse_str(char *s, size_t len); - -+// Given a string of xml data and its length, parses it and creates an ezxml -+// structure. that strdup()s s -+// Returns NULL on failure. -+ezxml_t ezxml_parse_str_d(char const *s, size_t len); -+ - // A wrapper for ezxml_parse_str() that accepts a file descriptor. First - // attempts to mem map the file. Failing that, reads the file into memory. - // Returns NULL on failure. diff --git a/libs/ezxml/patches/201-ezxml_int.patch b/libs/ezxml/patches/201-ezxml_int.patch new file mode 100644 index 000000000..1616bd5f8 --- /dev/null +++ b/libs/ezxml/patches/201-ezxml_int.patch @@ -0,0 +1,123 @@ +--- a/ezxml.c ++++ b/ezxml.c +@@ -25,6 +25,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -72,6 +73,19 @@ ezxml_t ezxml_idx(ezxml_t xml, int idx) + return xml; + } + ++int ezxml_int(ezxml_t xml, int default_value) ++{ ++ int ret; ++ ++ if(!xml) ++ return default_value; ++ ++ errno = 0; ++ ret = strtol(xml->txt, NULL, 10); ++ ++ return (errno == 0 ? ret : default_value); ++} ++ + // returns the value of the requested tag attribute or NULL if not found + const char *ezxml_attr(ezxml_t xml, const char *attr) + { +@@ -89,6 +103,23 @@ const char *ezxml_attr(ezxml_t xml, cons + return (root->attr[i][j]) ? root->attr[i][j + 1] : NULL; // found default + } + ++int ezxml_attr_int(ezxml_t xml, const char *attr, int default_value) ++{ ++ int ret; ++ const char *val = NULL; ++ ++ if(!xml) ++ return default_value; ++ ++ if((val = ezxml_attr(xml, attr)) == NULL) ++ return default_value; ++ ++ errno = 0; ++ ret = strtol(val, NULL, 10); ++ ++ return (errno == 0 ? ret : default_value); ++} ++ + // same as ezxml_get but takes an already initialized va_list + ezxml_t ezxml_vget(ezxml_t xml, va_list ap) + { +@@ -926,6 +957,16 @@ ezxml_t ezxml_set_txt(ezxml_t xml, const + return xml; + } + ++ezxml_t ezxml_set_int(ezxml_t xml, int data) ++{ ++ char *buf = NULL; ++ if (! xml) return NULL; ++ ++ asprintf(&buf, "%d", data); ++ ++ return ezxml_set_flag(ezxml_set_txt(xml, buf), EZXML_TXTM); ++} ++ + // Sets the given tag attribute or adds a new attribute if not found. A value + // of NULL will remove the specified attribute. Returns the tag given. + ezxml_t ezxml_set_attr(ezxml_t xml, const char *name, const char *value) +@@ -968,6 +1009,15 @@ ezxml_t ezxml_set_attr(ezxml_t xml, cons + return xml; + } + ++ezxml_t ezxml_set_attr_int(ezxml_t xml, const char *name, int data) ++{ ++ char *buf = NULL; ++ if (! xml) return NULL; ++ ++ asprintf(&buf, "%d", data); ++ return ezxml_set_attr(ezxml_set_flag(xml, EZXML_DUP), name, buf); ++} ++ + // sets a flag for the given tag and returns the tag + ezxml_t ezxml_set_flag(ezxml_t xml, short flag) + { +--- a/ezxml.h ++++ b/ezxml.h +@@ -95,9 +95,13 @@ ezxml_t ezxml_idx(ezxml_t xml, int idx); + // returns the given tag's character content or empty string if none + #define ezxml_txt(xml) ((xml) ? xml->txt : "") + ++int ezxml_int(ezxml_t xml, int default_value); ++ + // returns the value of the requested tag attribute, or NULL if not found + const char *ezxml_attr(ezxml_t xml, const char *attr); + ++int ezxml_attr_int(ezxml_t xml, const char *attr, int default_value); ++ + // Traverses the ezxml sturcture to retrieve a specific subtag. Takes a + // variable length list of tag names and indexes. The argument list must be + // terminated by either an index of -1 or an empty string tag name. Example: +@@ -137,6 +141,9 @@ ezxml_t ezxml_add_child(ezxml_t xml, con + // sets the character content for the given tag and returns the tag + ezxml_t ezxml_set_txt(ezxml_t xml, const char *txt); + ++// set int value ++ezxml_t ezxml_set_int(ezxml_t xml, int data); ++ + // wrapper for ezxml_set_txt() that strdup()s txt + #define ezxml_set_txt_d(xml, txt) \ + ezxml_set_flag(ezxml_set_txt(xml, strdup(txt)), EZXML_TXTM) +@@ -144,6 +151,9 @@ ezxml_t ezxml_set_txt(ezxml_t xml, const + // Sets the given tag attribute or adds a new attribute if not found. A value + // of NULL will remove the specified attribute. Returns the tag given. + ezxml_t ezxml_set_attr(ezxml_t xml, const char *name, const char *value); ++ ++// set int value for an attr ++ezxml_t ezxml_set_attr_int(ezxml_t xml, const char *name, int data); + + // Wrapper for ezxml_set_attr() that strdup()s name/value. Value cannot be NULL + #define ezxml_set_attr_d(xml, name, value) \ diff --git a/libs/ezxml/patches/202-ezxml_child.patch b/libs/ezxml/patches/202-ezxml_child.patch new file mode 100644 index 000000000..96e30858a --- /dev/null +++ b/libs/ezxml/patches/202-ezxml_child.patch @@ -0,0 +1,20 @@ +--- a/ezxml.h ++++ b/ezxml.h +@@ -175,6 +175,17 @@ ezxml_t ezxml_insert(ezxml_t xml, ezxml_ + // removes a tag along with all its subtags + #define ezxml_remove(xml) ezxml_free(ezxml_cut(xml)) + ++static inline char const * ezxml_child_txt( ezxml_t node, char const *child ) ++{ ++ return ezxml_txt( ezxml_child( node, child ) ); ++} ++ ++static inline ezxml_t ezxml_child_set_txt_d( ezxml_t node, char const *child, ++ char const *value ) ++{ ++ return ezxml_set_txt_d( ezxml_child( node, child ), value ); ++} ++ + #ifdef __cplusplus + } + #endif diff --git a/libs/ezxml/patches/203-ezxml_cut.patch b/libs/ezxml/patches/203-ezxml_cut.patch new file mode 100644 index 000000000..63642dee8 --- /dev/null +++ b/libs/ezxml/patches/203-ezxml_cut.patch @@ -0,0 +1,23 @@ +--- a/ezxml.c ++++ b/ezxml.c +@@ -1042,7 +1042,7 @@ ezxml_t ezxml_cut(ezxml_t xml) + + cur = xml->parent->child; // go back to head of subtag list + if (strcmp(cur->name, xml->name)) { // not in first sibling list +- while (strcmp(cur->sibling->name, xml->name)) ++ while (cur->sibling && strcmp(cur->sibling->name, xml->name)) + cur = cur->sibling; + if (cur->sibling == xml) { // first of a sibling list + cur->sibling = (xml->next) ? xml->next +@@ -1051,8 +1051,9 @@ ezxml_t ezxml_cut(ezxml_t xml) + else cur = cur->sibling; // not first of a sibling list + } + +- while (cur->next && cur->next != xml) cur = cur->next; +- if (cur->next) cur->next = cur->next->next; // patch next list ++ cur = xml->parent->child; // go back to head of subtag list ++ while (cur && cur->next != xml) cur = cur->ordered; ++ if (cur && cur->next) cur->next = cur->next->next; // patch next list + } + } + xml->ordered = xml->sibling = xml->next = NULL; diff --git a/libs/ezxml/patches/300-ezxml_int.patch b/libs/ezxml/patches/300-ezxml_int.patch deleted file mode 100644 index 1616bd5f8..000000000 --- a/libs/ezxml/patches/300-ezxml_int.patch +++ /dev/null @@ -1,123 +0,0 @@ ---- a/ezxml.c -+++ b/ezxml.c -@@ -25,6 +25,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -72,6 +73,19 @@ ezxml_t ezxml_idx(ezxml_t xml, int idx) - return xml; - } - -+int ezxml_int(ezxml_t xml, int default_value) -+{ -+ int ret; -+ -+ if(!xml) -+ return default_value; -+ -+ errno = 0; -+ ret = strtol(xml->txt, NULL, 10); -+ -+ return (errno == 0 ? ret : default_value); -+} -+ - // returns the value of the requested tag attribute or NULL if not found - const char *ezxml_attr(ezxml_t xml, const char *attr) - { -@@ -89,6 +103,23 @@ const char *ezxml_attr(ezxml_t xml, cons - return (root->attr[i][j]) ? root->attr[i][j + 1] : NULL; // found default - } - -+int ezxml_attr_int(ezxml_t xml, const char *attr, int default_value) -+{ -+ int ret; -+ const char *val = NULL; -+ -+ if(!xml) -+ return default_value; -+ -+ if((val = ezxml_attr(xml, attr)) == NULL) -+ return default_value; -+ -+ errno = 0; -+ ret = strtol(val, NULL, 10); -+ -+ return (errno == 0 ? ret : default_value); -+} -+ - // same as ezxml_get but takes an already initialized va_list - ezxml_t ezxml_vget(ezxml_t xml, va_list ap) - { -@@ -926,6 +957,16 @@ ezxml_t ezxml_set_txt(ezxml_t xml, const - return xml; - } - -+ezxml_t ezxml_set_int(ezxml_t xml, int data) -+{ -+ char *buf = NULL; -+ if (! xml) return NULL; -+ -+ asprintf(&buf, "%d", data); -+ -+ return ezxml_set_flag(ezxml_set_txt(xml, buf), EZXML_TXTM); -+} -+ - // Sets the given tag attribute or adds a new attribute if not found. A value - // of NULL will remove the specified attribute. Returns the tag given. - ezxml_t ezxml_set_attr(ezxml_t xml, const char *name, const char *value) -@@ -968,6 +1009,15 @@ ezxml_t ezxml_set_attr(ezxml_t xml, cons - return xml; - } - -+ezxml_t ezxml_set_attr_int(ezxml_t xml, const char *name, int data) -+{ -+ char *buf = NULL; -+ if (! xml) return NULL; -+ -+ asprintf(&buf, "%d", data); -+ return ezxml_set_attr(ezxml_set_flag(xml, EZXML_DUP), name, buf); -+} -+ - // sets a flag for the given tag and returns the tag - ezxml_t ezxml_set_flag(ezxml_t xml, short flag) - { ---- a/ezxml.h -+++ b/ezxml.h -@@ -95,9 +95,13 @@ ezxml_t ezxml_idx(ezxml_t xml, int idx); - // returns the given tag's character content or empty string if none - #define ezxml_txt(xml) ((xml) ? xml->txt : "") - -+int ezxml_int(ezxml_t xml, int default_value); -+ - // returns the value of the requested tag attribute, or NULL if not found - const char *ezxml_attr(ezxml_t xml, const char *attr); - -+int ezxml_attr_int(ezxml_t xml, const char *attr, int default_value); -+ - // Traverses the ezxml sturcture to retrieve a specific subtag. Takes a - // variable length list of tag names and indexes. The argument list must be - // terminated by either an index of -1 or an empty string tag name. Example: -@@ -137,6 +141,9 @@ ezxml_t ezxml_add_child(ezxml_t xml, con - // sets the character content for the given tag and returns the tag - ezxml_t ezxml_set_txt(ezxml_t xml, const char *txt); - -+// set int value -+ezxml_t ezxml_set_int(ezxml_t xml, int data); -+ - // wrapper for ezxml_set_txt() that strdup()s txt - #define ezxml_set_txt_d(xml, txt) \ - ezxml_set_flag(ezxml_set_txt(xml, strdup(txt)), EZXML_TXTM) -@@ -144,6 +151,9 @@ ezxml_t ezxml_set_txt(ezxml_t xml, const - // Sets the given tag attribute or adds a new attribute if not found. A value - // of NULL will remove the specified attribute. Returns the tag given. - ezxml_t ezxml_set_attr(ezxml_t xml, const char *name, const char *value); -+ -+// set int value for an attr -+ezxml_t ezxml_set_attr_int(ezxml_t xml, const char *name, int data); - - // Wrapper for ezxml_set_attr() that strdup()s name/value. Value cannot be NULL - #define ezxml_set_attr_d(xml, name, value) \ diff --git a/libs/ezxml/patches/400-ezxml_child.patch b/libs/ezxml/patches/400-ezxml_child.patch deleted file mode 100644 index 96e30858a..000000000 --- a/libs/ezxml/patches/400-ezxml_child.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/ezxml.h -+++ b/ezxml.h -@@ -175,6 +175,17 @@ ezxml_t ezxml_insert(ezxml_t xml, ezxml_ - // removes a tag along with all its subtags - #define ezxml_remove(xml) ezxml_free(ezxml_cut(xml)) - -+static inline char const * ezxml_child_txt( ezxml_t node, char const *child ) -+{ -+ return ezxml_txt( ezxml_child( node, child ) ); -+} -+ -+static inline ezxml_t ezxml_child_set_txt_d( ezxml_t node, char const *child, -+ char const *value ) -+{ -+ return ezxml_set_txt_d( ezxml_child( node, child ), value ); -+} -+ - #ifdef __cplusplus - } - #endif diff --git a/libs/ezxml/patches/500-ezxml_cut.patch b/libs/ezxml/patches/500-ezxml_cut.patch deleted file mode 100644 index 63642dee8..000000000 --- a/libs/ezxml/patches/500-ezxml_cut.patch +++ /dev/null @@ -1,23 +0,0 @@ ---- a/ezxml.c -+++ b/ezxml.c -@@ -1042,7 +1042,7 @@ ezxml_t ezxml_cut(ezxml_t xml) - - cur = xml->parent->child; // go back to head of subtag list - if (strcmp(cur->name, xml->name)) { // not in first sibling list -- while (strcmp(cur->sibling->name, xml->name)) -+ while (cur->sibling && strcmp(cur->sibling->name, xml->name)) - cur = cur->sibling; - if (cur->sibling == xml) { // first of a sibling list - cur->sibling = (xml->next) ? xml->next -@@ -1051,8 +1051,9 @@ ezxml_t ezxml_cut(ezxml_t xml) - else cur = cur->sibling; // not first of a sibling list - } - -- while (cur->next && cur->next != xml) cur = cur->next; -- if (cur->next) cur->next = cur->next->next; // patch next list -+ cur = xml->parent->child; // go back to head of subtag list -+ while (cur && cur->next != xml) cur = cur->ordered; -+ if (cur && cur->next) cur->next = cur->next->next; // patch next list - } - } - xml->ordered = xml->sibling = xml->next = NULL;