34 while ((ptr->
prev != NULL) && (ptr->
prev->id != pthread_self())) {
37 if (ptr->
prev == NULL) {
41 to_delete = ptr->
prev;
43 if (to_delete->
next) {
44 to_delete->
prev->next = to_delete->
next;
45 to_delete->
next->prev = to_delete->
prev;
52 to_delete->
prev->next = NULL;
57 for (i = 0; i < to_delete->
occ; i++) {
58 free(((
void **)(to_delete->
ptr))[i]);
70 if (to_delete->
next) {
77 for (i = 0; i < to_delete->
occ; i++) {
78 free(((
void **)(to_delete->
ptr))[i]);
82 to_delete->
ptr = NULL;
87 while ((ptr->
next != NULL) && (ptr->
next->ptr != data)) {
90 if (ptr->
next == NULL) {
94 to_delete = ptr->
next;
95 if (to_delete->
next) {
96 to_delete->
next->prev = ptr;
107 for (i = 0; i < to_delete->
occ; i++) {
108 free(((
void **)(to_delete->
ptr))[i]);
111 free(to_delete->
ptr);
126 char *content = buffer;
141 total += ptr->
end - ptr->
pos;
146 if (content == NULL) {
150 if (content == NULL) {
159 int read_size = ptr->
end - ptr->
pos;
161 if (total + read_size > bufsize - 1) {
162 read_size = bufsize - total - 1;
164 ret_len +=
roxml_read(ptr->
pos, read_size, content + total, ptr);
176 ROXML_GET_BASE_BUFFER(name);
179 name_len = strlen(name);
181 ROXML_PUT_BASE_BUFFER(name);
184 total = target->
end - target->
pos - name_len - 2;
185 spec_offset = target->
pos + name_len + 2;
187 total = target->
end - target->
pos;
188 spec_offset = target->
pos;
190 total = target->
end - target->
pos - 4;
191 spec_offset = target->
pos + 4;
193 total = target->
end - target->
pos - name_len - 3;
194 spec_offset = target->
pos + name_len + 3;
198 spec_offset = target->
pos;
199 total = target->
end - target->
pos;
206 if (content == NULL) {
210 if (content == NULL) {
215 if (read_size > bufsize - 1) {
216 read_size = bufsize - 1;
218 total =
roxml_read(spec_offset, read_size, content, target);
221 content[total] =
'\0';
232 ROXML_GET_BASE_BUFFER(tmp_name);
237 memset(buffer, 0, size *
sizeof(
char));
244 ROXML_PUT_BASE_BUFFER(tmp_name);
248 if (n->
prnt == NULL) {
249 strcpy(tmp_name,
"documentRoot");
258 ROXML_PUT_BASE_BUFFER(tmp_name);
276 while (
ROXML_WHITE(tmp_name[offset]) || tmp_name[offset] ==
'<') {
285 for (; count < total; count++) {
288 }
else if ((tmp_name[count] ==
'?') && (tmp_name[count + 1] ==
'>')) {
293 for (; count < total; count++) {
296 }
else if ((tmp_name[count] ==
'/') && (tmp_name[count + 1] ==
'>')) {
298 }
else if (tmp_name[count] ==
'>') {
303 for (; count < total; count++) {
306 }
else if (tmp_name[count] ==
'=') {
308 }
else if (tmp_name[count] ==
'>') {
310 }
else if ((tmp_name[count] ==
'/') && (tmp_name[count + 1] ==
'>')) {
315 for (; count < total; count++) {
318 }
else if (tmp_name[count] ==
'>') {
323 tmp_name[count] =
'\0';
326 if (buffer == NULL) {
328 strcpy(buffer, tmp_name + offset);
330 if (strlen(tmp_name) - offset < (
unsigned int)size) {
331 size = strlen(tmp_name) - offset;
333 strncpy(buffer, tmp_name + offset, size);
336 ROXML_PUT_BASE_BUFFER(tmp_name);
347 while (root->
prnt != NULL) {
354 fclose(root->
src.fil);
368 if (ptr->
type & type) {
405 while ((ptr->
sibl) && (nth > count)) {
420 while (ptr && (ptr->
sibl) && (nth > count)) {
467 node_t *common_parent = n;
468 while (common_parent && common_parent != ns->
prnt) {
469 common_parent = common_parent->
prnt;
471 if (common_parent != ns->
prnt) {
555 prev = n->
prnt->chld;
556 while (prev && prev != n) {
580 if (n->
prnt == NULL) {
628 while ((first) && (first != n)) {
631 if (strcmp(name, twin) == 0) {
643 node_t *current_node = NULL;
647 file = fdopen(fd,
"r");
658 node_t *current_node = NULL;
659 FILE *file = fopen(filename,
"rb");
670 node_t *current_node = NULL;
671 if (buffer == NULL) {
676 return roxml_load(current_node, NULL, buffer);
684 #if(CONFIG_XML_XPATH_ENGINE==1)
689 char *full_path_to_find;
700 full_path_to_find = strdup(path);
708 free(full_path_to_find);
725 #if(CONFIG_XML_READ_WRITE==1)
745 #if(CONFIG_XML_COMMIT_XML_TREE==1)
753 fout = fopen(dest,
"w");
759 if (fout || buffer) {
762 if ((n->
prnt == NULL) || (n->
prnt && n->
prnt->prnt == NULL)) {
795 #if(CONFIG_XML_READ_WRITE==1)
811 parent = parent->
prnt;
819 content_l = strlen(value);
822 name_l = strlen(name);
827 if (!name || !value) {
836 buffer = (
char *)malloc(
sizeof(
char) * (name_l + content_l + xmlns_l + 4));
837 sprintf(buffer,
"xmlns%s%s=\"%s\"", name_l ?
":" :
"", name, value);
839 buffer = (
char *)malloc(
sizeof(
char) * (name_l + content_l + 4));
840 sprintf(buffer,
"%s=\"%s\"", name, value);
842 content_pos = name_l + 2 + xmlns_l;
843 end_node = name_l + 1 + xmlns_l;
844 end_content = name_l + content_l + 2 + xmlns_l;
849 buffer = (
char *)malloc(
sizeof(
char) * (content_l + 8));
850 sprintf(buffer,
"<!--%s-->", value);
852 end_node = content_l + 4;
853 end_content = content_l + 4;
859 buffer = (
char *)malloc(
sizeof(
char) * (name_l + content_l + 8));
860 sprintf(buffer,
"<?%s %s?>", name, value);
861 end_node = name_l + content_l + 3;
862 end_content = name_l + content_l + 5;
864 buffer = (
char *)malloc(
sizeof(
char) * (name_l + 7));
865 sprintf(buffer,
"<?%s?>", name);
866 end_node = name_l + 2;
867 end_content = name_l + 4;
874 buffer = (
char *)malloc(
sizeof(
char) * (content_l + 1));
875 sprintf(buffer,
"%s", value);
877 end_node = content_l + 1;
878 end_content = content_l + 1;
884 buffer = (
char *)malloc(
sizeof(
char) * (name_l * 2 + content_l + 6));
885 sprintf(buffer,
"<%s>%s</%s>", name, value, name);
886 content_pos = name_l + 2;
887 end_node = name_l + content_l + 2;
888 end_content = end_node;
890 buffer = (
char *)malloc(
sizeof(
char) * (name_l + 5));
891 sprintf(buffer,
"<%s />", name);
898 new_node->
end = end_node;
902 ns->
id = ROXML_NS_ID;
905 strcpy(ns->
alias, name);
909 if (((type & ROXML_ELM_NODE) && content_l) || (type & ROXML_ATTR_NODE)) {
912 new_txt->
end = end_content;
915 if (parent == NULL) {
920 table->
id = ROXML_REQTABLE_ID;
921 table->
ids[ROXML_REQTABLE_ID] = 1;
923 pthread_mutex_init(&table->
mut, NULL);
924 parent->
priv = (
void *)table;
int ROXML_INT roxml_read(int pos, int size, char *buffer, node_t *node)
read xml doc function
void ROXML_INT roxml_free_xpath(xpath_node_t *xpath, int nb)
xpath free function
int ROXML_API roxml_get_txt_nb(node_t *n)
text node number getter function
void ROXML_API roxml_close(node_t *n)
unload function
int ROXML_API roxml_get_nodes_nb(node_t *n, int type)
number of nodes getter function
node_t ROXML_API * roxml_get_txt(node_t *n, int nth)
text node getter function
node_t ROXML_API * roxml_get_ns(node_t *n)
namespace getter function
node_t ROXML_API * roxml_get_parent(node_t *n)
parent getter function
node_t ROXML_API * roxml_get_attr(node_t *n, char *name, int nth)
attribute getter function
node_t ROXML_API * roxml_get_nodes(node_t *n, int type, char *name, int nth)
nodes getter function
node_t ROXML_INT ** roxml_exec_xpath(node_t *root, node_t *n, xpath_node_t *xpath, int index, int *count)
real xpath execution
int ROXML_API roxml_get_chld_nb(node_t *n)
chlds number getter function
int ROXML_API roxml_get_attr_nb(node_t *n)
number of attribute getter function
node_t ROXML_API * roxml_load_doc(char *filename)
load function for files
void ROXML_INT roxml_del_txt_node(node_t *n)
text node deletion function
node_t ROXML_API * roxml_get_chld(node_t *n, char *name, int nth)
chld getter function
int ROXML_INT roxml_parse_xpath(char *path, xpath_node_t **xpath, int context)
xpath parsing function
node_t ROXML_API * roxml_get_pi(node_t *n, int nth)
process-instruction getter function
node_t ROXML_API * roxml_get_prev_sibling(node_t *n)
prev sibling getter function
node_t ROXML_INT * roxml_load(node_t *current_node, FILE *file, char *buffer)
generic load function
#define ROXML_DOCTYPE_NODE
void ROXML_API roxml_del_node(node_t *n)
node deletion function
node_t ROXML_API * roxml_add_node(node_t *parent, int position, int type, char *name, char *value)
add a node to the tree
void ROXML_INT * roxml_malloc(int size, int num, int type)
alloc memory function
int ROXML_API roxml_get_type(node_t *n)
node type function
int ROXML_API roxml_commit_changes(node_t *n, char *dest, char **buffer, int human)
sync function
node_t ROXML_API * roxml_load_fd(int fd)
load function for file descriptors
int ROXML_API roxml_get_node_position(node_t *n)
node get position function
node_t ROXML_INT * roxml_create_node(int pos, void *src, int type)
internal function
char ROXML_API * roxml_get_content(node_t *n, char *buffer, int bufsize, int *size)
content getter function
node_t ROXML_API * roxml_set_ns(node_t *n, node_t *ns)
namespace setter function
void ROXML_API roxml_release(void *data)
memory cleanning function
node_t ROXML_API * roxml_load_buf(char *buffer)
load function for buffers
memory_cell_t head_cell
head of memory manager
node_t ROXML_INT * roxml_append_node(node_t *parent, node_t *n)
node append function
void ROXML_INT roxml_del_tree(node_t *n)
internal function
node_t ROXML_API * roxml_get_root(node_t *n)
root getter function
struct memory_cell * prev
void ROXML_INT roxml_del_arg_node(node_t *n)
attribute node deletion function
void ROXML_INT roxml_free_node(node_t *n)
internal function
int ROXML_API roxml_get_cmt_nb(node_t *n)
comments number getter function
char ROXML_API * roxml_get_name(node_t *n, char *buffer, int size)
name getter function
node_t ROXML_API * roxml_get_cmt(node_t *n, int nth)
comment getter function
struct memory_cell * next
node_t ROXML_INT * roxml_parent_node(node_t *parent, node_t *n, int position)
node relocate function
node_t ROXML_API ** roxml_xpath(node_t *n, char *path, int *nb_ans)
exec path function
int ROXML_API roxml_get_pi_nb(node_t *n)
process-instruction number getter function
void ROXML_INT roxml_write_node(node_t *n, FILE *f, char **buf, int human, int lvl, int *offset, int *len)
tree write function
void ROXML_INT roxml_del_std_node(node_t *n)
node deletion function
internal header for libroxml.so
node_t ROXML_API * roxml_get_next_sibling(node_t *n)
next sibling getter function