24 { .code =
'"', .escape =
""" },
25 { .code =
'\'', .escape =
"'" },
26 { .code =
'<', .escape =
"<"},
27 { .code =
'>', .escape =
">"},
28 { .code =
'&', .escape =
"&"}
35 for (; i < strlen(buf); ) {
38 if (decode && (strncmp(specials[s].escape, buf+i, strlen(specials[s].escape)) == 0)) {
40 out[l] = specials[s].code;
42 i += strlen(specials[s].escape);
44 }
else if (!decode && (buf[i] == specials[s].code)) {
46 strcpy(out+l, specials[s].escape);
47 l += strlen(specials[s].escape);
74ROXML_STATIC ROXML_INT
inline int roxml_read(
int pos,
int size,
char *buffer,
node_t *node)
78 if (size > 0 && buffer) {
88ROXML_STATIC ROXML_INT
inline int roxml_content_size(
node_t *n,
int *offset)
101 total += ptr->
end - ptr->
pos;
106 total = n->
chld->end - n->
chld->pos;
107 *offset = n->
chld->pos;
112 ROXML_GET_BASE_BUFFER(name);
115 name_len = strlen(name);
117 ROXML_PUT_BASE_BUFFER(name);
128 total = n->
end - n->
pos - name_len;
129 *offset = n->
pos + name_len;
134ROXML_STATIC ROXML_INT
inline char *roxml_prepare_buffer(
node_t *n,
char *buffer,
int contentsize,
int size)
138 memset(buffer, 0, size);
143 memset(buffer, 0, size);
158 content_size = roxml_content_size(n, &content_offset);
159 content = roxml_prepare_buffer(n, buffer, content_size, bufsize);
161 if (buffer != content)
162 bufsize = content_size + 1;
163 if (content_size > bufsize - 1)
164 content_size = bufsize - 1;
165 if (content == NULL) {
177 int read_size = ptr->
end - ptr->
pos;
179 if (total + read_size > bufsize - 1)
180 read_size = bufsize - total - 1;
181 len +=
roxml_read(ptr->
pos, read_size, content + total, ptr);
191 total =
roxml_read(content_offset, content_size, content, target);
194 content[total] =
'\0';
200ROXML_STATIC ROXML_INT
inline int roxml_name_size(
node_t *n,
int size,
int *offset)
234 content_size = roxml_name_size(n, size, &content_offset);
235 content = roxml_prepare_buffer(n, buffer, content_size, size);
237 if (buffer != content)
238 size = content_size + 1;
239 if (content_size > size - 1)
240 content_size = size - 1;
243 if (content_size == 0)
246 memset(content, 0, content_size);
248 if (n->
prnt == NULL) {
249 strcpy(content,
"documentRoot");
253 strncpy(content, ns->
alias, size);
259 char *begin = content;
261 total =
roxml_read(content_offset, content_size, content, n);
267 for (; count < total; count++) {
270 else if ((begin[count] ==
'?') && (begin[count + 1] ==
'>'))
274 for (; count < total; count++) {
277 else if ((begin[count] ==
'/') && (begin[count + 1] ==
'>'))
279 else if (begin[count] ==
'>')
283 for (; count < total; count++) {
286 else if (begin[count] ==
'=')
288 else if (begin[count] ==
'>')
290 else if ((begin[count] ==
'/') && (begin[count + 1] ==
'>'))
294 for (; count < total; count++) {
297 else if (begin[count] ==
'>')
301 begin[count++] =
'\0';
302 memmove(content, begin, count);
320 if (ptr->
type & type)
336ROXML_STATIC ROXML_INT
inline node_t *roxml_get_nodes_by_name(
node_t *n,
int type,
char *name)
357ROXML_STATIC ROXML_INT
inline node_t *roxml_get_nodes_by_nth(
node_t *n,
int type,
int nth)
370 while ((ptr->
sibl) && (nth > count)) {
383 while (ptr && (ptr->
sibl) && (nth > count)) {
398 else if (name == NULL)
399 return roxml_get_nodes_by_nth(n, type, nth);
401 return roxml_get_nodes_by_name(n, type, name);
483 while ((first) && (first != n)) {
487 if (strcmp(name, twin) == 0)
#define ROXML_INVALID_DOC
ROXML_API void roxml_release(void *data)
memory cleanning function
#define ROXML_INVALID_NODE
#define ROXML_DOCTYPE_NODE
ROXML_INT int roxml_read_buff(int pos, int size, char *buffer, node_t *node)
read xml doc function
buffer XML document backend
ROXML_API int roxml_get_pi_nb(node_t *n)
process-instruction number getter function
ROXML_API node_t * roxml_get_pi(node_t *n, int nth)
process-instruction getter function
ROXML_API int roxml_get_chld_nb(node_t *n)
chlds number getter function
ROXML_API node_t * roxml_get_txt(node_t *n, int nth)
text node getter function
ROXML_API int roxml_get_cmt_nb(node_t *n)
comments number getter function
ROXML_API node_t * roxml_get_chld(node_t *n, char *name, int nth)
chld getter function
ROXML_API int roxml_get_txt_nb(node_t *n)
text node number getter function
ROXML_API node_t * roxml_get_attr(node_t *n, char *name, int nth)
attribute getter function
ROXML_API int roxml_get_nodes_nb(node_t *n, int type)
number of nodes getter function
ROXML_API int roxml_get_type(node_t *n)
node type function
ROXML_API int roxml_get_node_position(node_t *n)
node get position function
ROXML_API int roxml_get_attr_nb(node_t *n)
number of attribute getter function
ROXML_API char * roxml_get_content(node_t *n, char *buffer, int bufsize, int *size)
content getter function
ROXML_API node_t * roxml_get_ns(node_t *n)
namespace getter function
ROXML_API char * roxml_get_name(node_t *n, char *buffer, int size)
name getter function
ROXML_API int roxml_escape(const char *buf, int decode, char *out)
XML encoding/decoding function.
ROXML_STATIC ROXML_INT int roxml_read(int pos, int size, char *buffer, node_t *node)
read xml doc function
ROXML_API node_t * roxml_get_cmt(node_t *n, int nth)
comment getter function
ROXML_API node_t * roxml_get_nodes(node_t *n, int type, char *name, int nth)
nodes getter function
ROXML_INT int roxml_read_file(int pos, int size, char *buffer, node_t *node)
read xml doc function
File XML document backend.
ROXML_INT void * roxml_malloc(int size, int num, int type)
alloc memory function
XML internal memory management module.