17d5efaef57def936ba1c39801d38d890f70e67d
[openwrt/svn-archive/archive.git] / libs / ezxml / patches / 200-ezxml_parse_str_d.patch
1 diff -pruN ezxml-0.8.6.orig/ezxml.c ezxml-0.8.6/ezxml.c
2 --- ezxml-0.8.6.orig/ezxml.c 2006-06-08 04:33:38.000000000 +0200
3 +++ ezxml-0.8.6/ezxml.c 2008-02-15 14:35:17.000000000 +0100
4 @@ -599,6 +599,19 @@ ezxml_t ezxml_parse_str(char *s, size_t
5 else return ezxml_err(root, d, "unclosed tag <%s>", root->cur->name);
6 }
7
8 +// parse the given xml string and return an ezxml structure
9 +ezxml_t ezxml_parse_str_d(char const *_s, size_t len)
10 +{
11 + ezxml_root_t root;
12 + char *s;
13 +
14 + if (! (s = strndup(_s, len))) return NULL;
15 +
16 + root = (ezxml_root_t)ezxml_parse_str(s, strlen(s));
17 + root->len = -1; // so we know to free s in ezxml_free()
18 + return &root->xml;
19 +}
20 +
21 // Wrapper for ezxml_parse_str() that accepts a file stream. Reads the entire
22 // stream into memory and then parses it. For xml files, use ezxml_parse_file()
23 // or ezxml_parse_fd()
24 diff -pruN ezxml-0.8.6.orig/ezxml.h ezxml-0.8.6/ezxml.h
25 --- ezxml-0.8.6.orig/ezxml.h 2006-06-08 03:57:30.000000000 +0200
26 +++ ezxml-0.8.6/ezxml.h 2008-02-15 14:37:15.000000000 +0100
27 @@ -59,6 +59,11 @@ struct ezxml {
28 // pass in the copy. Returns NULL on failure.
29 ezxml_t ezxml_parse_str(char *s, size_t len);
30
31 +// Given a string of xml data and its length, parses it and creates an ezxml
32 +// structure. that strdup()s s
33 +// Returns NULL on failure.
34 +ezxml_t ezxml_parse_str_d(char const *s, size_t len);
35 +
36 // A wrapper for ezxml_parse_str() that accepts a file descriptor. First
37 // attempts to mem map the file. Failing that, reads the file into memory.
38 // Returns NULL on failure.