33 while((ptr->
prev != NULL)&&(ptr->
prev->id != pthread_self())) { ptr = ptr->
prev; }
34 if(ptr->
prev == NULL) {
return; }
36 to_delete = ptr->
prev;
39 to_delete->
prev->next = to_delete->
next;
40 to_delete->
next->prev = to_delete->
prev;
47 to_delete->
prev->next = NULL;
52 for(i = 0; i < to_delete->
occ; i++) { free(((
void**)(to_delete->
ptr))[i]); }
68 for(i = 0; i < to_delete->
occ; i++) { free(((
void**)(to_delete->
ptr))[i]); }
71 to_delete->
ptr = NULL;
76 while((ptr->
next != NULL)&&(ptr->
next->ptr != data)) { ptr = ptr->
next; }
77 if(ptr->
next == NULL) {
81 to_delete = ptr->
next;
83 to_delete->
next->prev = ptr;
94 for(i = 0; i < to_delete->
occ; i++) { free(((
void**)(to_delete->
ptr))[i]); }
107 char * content = buffer;
122 total += ptr->
end - ptr->
pos;
127 if(content == NULL) {
131 if(content == NULL) {
return NULL; }
138 int read_size = ptr->
end - ptr->
pos;
140 if(total+read_size > bufsize-1) {
141 read_size = bufsize - total - 1;
143 ret_len +=
roxml_read(ptr->
pos, read_size, content+total, ptr);
151 char name[ROXML_BASE_LEN];
157 name_len = strlen(name);
160 total = target->
end - target->
pos - name_len - 2;
161 spec_offset = target->
pos + name_len + 2;
163 total = target->
end - target->
pos;
164 spec_offset = target->
pos;
166 total = target->
end - target->
pos - 4;
167 spec_offset = target->
pos + 4;
169 total = target->
end - target->
pos - name_len - 3;
170 spec_offset = target->
pos + name_len + 3;
174 spec_offset = target->
pos;
175 total = target->
end - target->
pos;
182 if(content == NULL) {
186 if(content == NULL) {
return NULL; }
189 if(read_size > bufsize-1) {
190 read_size = bufsize-1;
192 total =
roxml_read(spec_offset, read_size, content, target);
195 content[total] =
'\0';
211 memset(buffer, 0, size*
sizeof(
char));
221 if(n->
prnt == NULL) {
222 strcpy(tmp_name,
"documentRoot");
226 strcpy(tmp_name, ns->
alias);
247 while(
ROXML_WHITE(tmp_name[offset]) || tmp_name[offset] ==
'<') {
256 }
else if((tmp_name[count] ==
'?')&&(tmp_name[count+1] ==
'>')) {
264 }
else if((tmp_name[count] ==
'/')&&(tmp_name[count+1] ==
'>')) {
266 }
else if(tmp_name[count] ==
'>') {
274 }
else if(tmp_name[count] ==
'=') {
276 }
else if(tmp_name[count] ==
'>') {
278 }
else if((tmp_name[count] ==
'/')&&(tmp_name[count+1] ==
'>')) {
286 }
else if(tmp_name[count] ==
'>') {
291 tmp_name[count] =
'\0';
296 strcpy(buffer, tmp_name+offset);
298 if(strlen(tmp_name)-offset < (
unsigned int)size) {
299 size = strlen(tmp_name)-offset;
301 strncpy(buffer, tmp_name+offset, size);
312 while(root->
prnt != NULL) {
319 fclose(root->
src.fil);
333 if(ptr->
type & type) {
370 while((ptr->
sibl)&&(nth > count)) {
385 while(ptr && (ptr->
sibl) && (nth > count)) {
392 if(nth > count) {
return NULL; }
430 node_t * common_parent = n;
431 while(common_parent && common_parent != ns->
prnt) {
432 common_parent = common_parent->
prnt;
434 if(common_parent != ns->
prnt) {
518 prev = n->
prnt->chld;
519 while(prev && prev != n) {
543 if(n->
prnt == NULL) {
558 while(root->
prnt) root = root->
prnt;
563 node_t * lone_elm_node = 0;
565 if(root->
chld->sibl) {
577 root = lone_elm_node;
599 if(n == NULL) {
return 0; }
609 while((first)&&(first != n)) {
612 if(strcmp(name, twin) == 0) { idx++; }
622 node_t *current_node = NULL;
626 file = fdopen(fd,
"r");
637 node_t *current_node = NULL;
638 FILE* file = fopen(filename,
"rb");
649 node_t *current_node = NULL;
650 if(buffer == NULL) {
return NULL; }
653 return roxml_load(current_node, NULL, buffer);
661 node_t ** node_set = NULL;
663 char * full_path_to_find;
667 if(nb_ans) { *nb_ans = 0; }
673 full_path_to_find = strdup(path);
674 path_to_find = full_path_to_find;
682 free(full_path_to_find);
698 if(n == NULL)
return;
721 len = ROXML_LONG_LEN;
723 fout = fopen(dest,
"w");
726 *buffer = (
char*)malloc(ROXML_LONG_LEN);
727 memset(*buffer, 0, ROXML_LONG_LEN);
730 if((n->
prnt == NULL)||(n->
prnt && n->
prnt->prnt == NULL)) {
746 len -= ROXML_LONG_LEN;
768 char * buffer = NULL;
771 int allow_attrib_child;
780 parent = parent->
prnt;
788 content_l = strlen(value);
791 name_l = strlen(name);
796 if(!name || !value) {
return NULL; }
803 buffer = (
char*)malloc(
sizeof(
char)*(name_l+content_l+xmlns_l+4));
804 sprintf(buffer,
"xmlns%s%s=\"%s\"", name_l?
":":
"", name, value);
806 buffer = (
char*)malloc(
sizeof(
char)*(name_l+content_l+4));
807 sprintf(buffer,
"%s=\"%s\"",name, value);
809 content_pos = name_l + 2 + xmlns_l;
810 end_node = name_l + 1 + xmlns_l;
811 end_content = name_l + content_l + 2 + xmlns_l;
813 if(!value) {
return NULL; }
814 buffer = (
char*)malloc(
sizeof(
char)*(content_l+8));
815 sprintf(buffer,
"<!--%s-->", value);
817 end_node = content_l + 4;
818 end_content = content_l + 4;
820 if(!name) {
return NULL; }
822 buffer = (
char*)malloc(
sizeof(
char)*(name_l+content_l+8));
823 sprintf(buffer,
"<?%s %s?>", name, value);
824 end_node = name_l + content_l + 3;
825 end_content = name_l + content_l + 5;
827 buffer = (
char*)malloc(
sizeof(
char)*(name_l+7));
828 sprintf(buffer,
"<?%s?>", name);
829 end_node = name_l + 2;
830 end_content = name_l + 4;
834 if(!value) {
return NULL; }
835 buffer = (
char*)malloc(
sizeof(
char)*(content_l+1));
836 sprintf(buffer,
"%s", value);
838 end_node = content_l + 1;
839 end_content = content_l + 1;
841 if(!name) {
return NULL; }
843 buffer = (
char*)malloc(
sizeof(
char)*(name_l*2+content_l+6));
844 sprintf(buffer,
"<%s>%s</%s>",name, value, name);
845 content_pos = name_l+2;
846 end_node = name_l + content_l + 2;
847 end_content = end_node;
849 buffer = (
char*)malloc(
sizeof(
char)*(name_l+5));
850 sprintf(buffer,
"<%s />",name);
857 new_node->
end = end_node;
861 ns->
id = ROXML_NS_ID;
863 strcpy(ns->
alias, name);
868 if(((type & ROXML_ELM_NODE) && content_l) || (type & ROXML_ATTR_NODE)) {
871 new_txt->
end = end_content;
879 table->
id = ROXML_REQTABLE_ID;
880 table->
ids[ROXML_REQTABLE_ID] = 1;
882 pthread_mutex_init(&table->
mut, NULL);
883 parent->
priv = (
void*)table;