packages/libs/ezxml/patches/200-ezxml_parse_str_d.patch
florian a45d0e5d2c Add ezxml (#4362), thanks Raphael
git-svn-id: svn://svn.openwrt.org/openwrt/packages@13678 3c298f89-4303-0410-b956-a3cf2f4a3e73
2008-12-17 17:16:29 +00:00

39 lines
1.5 KiB
Diff

diff -pruN ezxml-0.8.6.orig/ezxml.c ezxml-0.8.6/ezxml.c
--- ezxml-0.8.6.orig/ezxml.c 2006-06-08 04:33:38.000000000 +0200
+++ ezxml-0.8.6/ezxml.c 2008-02-15 14:35:17.000000000 +0100
@@ -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()
diff -pruN ezxml-0.8.6.orig/ezxml.h ezxml-0.8.6/ezxml.h
--- ezxml-0.8.6.orig/ezxml.h 2006-06-08 03:57:30.000000000 +0200
+++ ezxml-0.8.6/ezxml.h 2008-02-15 14:37:15.000000000 +0100
@@ -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.