/* Checks that the node has no remaining child nodes or property nodes, * then unlinks the node from the tree which updates pointers and * frees the memory */ void FreeNode(INOUTP ezxml_t Node) { ezxml_t Cur; char *Txt; /* Shouldn't have unprocessed properties */ if(Node->attr[0]) { printf(ERRTAG "[LINE %d] Node '%s' has invalid property %s=\"%s\".\n", Node->line, Node->name, Node->attr[0], Node->attr[1]); exit(1); } /* Shouldn't have non-whitespace text */ Txt = Node->txt; while(*Txt) { if(!IsWhitespace(*Txt)) { printf(ERRTAG "[LINE %d] Node '%s' has unexpected text '%s' within it.\n", Node->line, Node->name, Node->txt); exit(1); } ++Txt; } /* We shouldn't have child items left */ Cur = Node->child; if(Cur) { printf(ERRTAG "[LINE %d] Node '%s' has invalid child node '%s'.\n", Node->line, Node->name, Cur->name); exit(1); } /* Now actually unlink and free the node */ ezxml_remove(Node); }
/* ------------------------------------------------------------------------- */ int Reg_Update(Reg_TRegistry* reg, const ezxml_t items) { ezxml_t new_item; assert(reg); /* sanity check */ if (!(new_item = items->child)) return -EXIT_SUCCESS; while(new_item) { if ('\0' == ezxml_txt(new_item)[0]) return -EXIT_FAILURE; new_item = new_item->ordered; } /* update */ new_item = items->child; while(new_item) { ezxml_t existing_item; if ((existing_item = ezxml_child(reg->m_root, ezxml_name(new_item)))) ezxml_set_txt_d(existing_item, ezxml_txt(new_item)); else { ezxml_t n = ezxml_add_child_d(reg->m_root, ezxml_name(new_item), 0); ezxml_set_txt_d(n, ezxml_txt(new_item)); } ezxml_remove(new_item); new_item = items->child; } if (reg->m_file_name) Reg_ExportToFile(reg, reg->m_file_name); return -EXIT_SUCCESS; }
void clParserRemove(ClParserPtrT xml) { ezxml_remove(xml); }