• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/ap/gpl/iserver/mxml-2.7/

Lines Matching refs:node

2  * "$Id: mxml-node.c 436 2011-01-22 01:02:05Z mike $"
18 * mxmlAdd() - Add a node to a tree.
19 * mxmlDelete() - Delete a node and all of its children.
20 * mxmlGetRefCount() - Get the current reference (use) count for a node.
21 * mxmlNewCDATA() - Create a new CDATA node.
22 * mxmlNewCustom() - Create a new custom data node.
23 * mxmlNewElement() - Create a new element node.
24 * mxmlNewInteger() - Create a new integer node.
26 * mxmlNewReal() - Create a new real number node.
27 * mxmlNewText() - Create a new text fragment node.
28 * mxmlNewTextf() - Create a new formatted text fragment node.
29 * mxmlRemove() - Remove a node from its parent.
31 * mxmlRelease() - Release a node.
32 * mxmlRetain() - Retain a node.
33 * mxml_new() - Create a new node.
52 * 'mxmlAdd()' - Add a node to a tree.
54 * Adds the specified node to the parent. If the child argument is not
55 * NULL, puts the new node before or after the specified child depending
57 * puts the new node at the beginning of the child list (MXML_ADD_BEFORE)
63 mxmlAdd(mxml_node_t *parent, /* I - Parent node */
65 mxml_node_t *child, /* I - Child node for where or MXML_ADD_TO_PARENT */
66 mxml_node_t *node) /* I - Node to add */
69 fprintf(stderr, "mxmlAdd(parent=%p, where=%d, child=%p, node=%p)\n", parent,
70 where, child, node);
77 if (!parent || !node)
81 fprintf(stderr, " BEFORE: node->parent=%p\n", node->parent);
92 * Remove the node from any existing parent...
95 if (node->parent)
96 mxmlRemove(node);
102 node->parent = parent;
110 * Insert as first node under parent...
113 node->next = parent->child;
116 parent->child->prev = node;
118 parent->last_child = node;
120 parent->child = node;
125 * Insert node before this child...
128 node->next = child;
129 node->prev = child->prev;
132 child->prev->next = node;
134 parent->child = node;
136 child->prev = node;
144 * Insert as last node under parent...
147 node->parent = parent;
148 node->prev = parent->last_child;
151 parent->last_child->next = node;
153 parent->child = node;
155 parent->last_child = node;
160 * Insert node after this child...
163 node->prev = child;
164 node->next = child->next;
167 child->next->prev = node;
169 parent->last_child = node;
171 child->next = node;
177 fprintf(stderr, " AFTER: node->parent=%p\n", node->parent);
190 * 'mxmlDelete()' - Delete a node and all of its children.
192 * If the specified node has a parent, this function first removes the
193 * node from its parent using the mxmlRemove() function.
197 mxmlDelete(mxml_node_t *node) /* I - Node to delete */
203 fprintf(stderr, "mxmlDelete(node=%p)\n", node);
210 if (!node)
214 * Remove the node from its parent, if any...
217 mxmlRemove(node);
223 while (node->child)
224 mxmlDelete(node->child);
227 * Now delete any node data...
230 switch (node->type)
233 if (node->value.element.name)
234 free(node->value.element.name);
236 if (node->value.element.num_attrs)
238 for (i = 0; i < node->value.element.num_attrs; i ++)
240 if (node->value.element.attrs[i].name)
241 free(node->value.element.attrs[i].name);
242 if (node->value.element.attrs[i].value)
243 free(node->value.element.attrs[i].value);
246 free(node->value.element.attrs);
253 if (node->value.opaque)
254 free(node->value.opaque);
260 if (node->value.text.string)
261 free(node->value.text.string);
264 if (node->value.custom.data &&
265 node->value.custom.destroy)
266 (*(node->value.custom.destroy))(node->value.custom.data);
273 * Free this node...
276 free(node);
281 * 'mxmlGetRefCount()' - Get the current reference (use) count for a node.
284 * and @link mxmlRelease@ functions to increment and decrement a node's
291 mxmlGetRefCount(mxml_node_t *node) /* I - Node */
297 if (!node)
304 return (node->ref_count);
309 * 'mxmlNewCDATA()' - Create a new CDATA node.
311 * The new CDATA node is added to the end of the specified parent's child
313 * CDATA node has no parent. The data string must be nul-terminated and
314 * is copied into the new node. CDATA nodes use the MXML_ELEMENT type.
319 mxml_node_t * /* O - New node */
320 mxmlNewCDATA(mxml_node_t *parent, /* I - Parent node or MXML_NO_PARENT */
323 mxml_node_t *node; /* New node */
339 * Create the node and set the name value...
342 if ((node = mxml_new(parent, MXML_ELEMENT)) != NULL)
343 node->value.element.name = _mxml_strdupf("![CDATA[%s]]", data);
345 return (node);
350 * 'mxmlNewCustom()' - Create a new custom data node.
352 * The new custom node is added to the end of the specified parent's child
354 * element node has no parent. NULL can be passed when the data in the
355 * node is not dynamically allocated or is separately managed.
360 mxml_node_t * /* O - New node */
362 mxml_node_t *parent, /* I - Parent node or MXML_NO_PARENT */
366 mxml_node_t *node; /* New node */
375 * Create the node and set the value...
378 if ((node = mxml_new(parent, MXML_CUSTOM)) != NULL)
380 node->value.custom.data = data;
381 node->value.custom.destroy = destroy;
384 return (node);
389 * 'mxmlNewElement()' - Create a new element node.
391 * The new element node is added to the end of the specified parent's child
393 * element node has no parent.
396 mxml_node_t * /* O - New node */
397 mxmlNewElement(mxml_node_t *parent, /* I - Parent node or MXML_NO_PARENT */
400 mxml_node_t *node; /* New node */
416 * Create the node and set the element name...
419 if ((node = mxml_new(parent, MXML_ELEMENT)) != NULL)
420 node->value.element.name = strdup(name);
422 return (node);
427 * 'mxmlNewInteger()' - Create a new integer node.
429 * The new integer node is added to the end of the specified parent's child
431 * integer node has no parent.
434 mxml_node_t * /* O - New node */
435 mxmlNewInteger(mxml_node_t *parent, /* I - Parent node or MXML_NO_PARENT */
438 mxml_node_t *node; /* New node */
446 * Create the node and set the element name...
449 if ((node = mxml_new(parent, MXML_INTEGER)) != NULL)
450 node->value.integer = integer;
452 return (node);
459 * The new opaque node is added to the end of the specified parent's child
461 * opaque node has no parent. The opaque string must be nul-terminated and
462 * is copied into the new node.
465 mxml_node_t * /* O - New node */
466 mxmlNewOpaque(mxml_node_t *parent, /* I - Parent node or MXML_NO_PARENT */
469 mxml_node_t *node; /* New node */
485 * Create the node and set the element name...
488 if ((node = mxml_new(parent, MXML_OPAQUE)) != NULL)
489 node->value.opaque = strdup(opaque);
491 return (node);
496 * 'mxmlNewReal()' - Create a new real number node.
498 * The new real number node is added to the end of the specified parent's
500 * the new real number node has no parent.
503 mxml_node_t * /* O - New node */
504 mxmlNewReal(mxml_node_t *parent, /* I - Parent node or MXML_NO_PARENT */
507 mxml_node_t *node; /* New node */
515 * Create the node and set the element name...
518 if ((node = mxml_new(parent, MXML_REAL)) != NULL)
519 node->value.real = real;
521 return (node);
526 * 'mxmlNewText()' - Create a new text fragment node.
528 * The new text node is added to the end of the specified parent's child
530 * text node has no parent. The whitespace parameter is used to specify
531 * whether leading whitespace is present before the node. The text
532 * string must be nul-terminated and is copied into the new node.
535 mxml_node_t * /* O - New node */
536 mxmlNewText(mxml_node_t *parent, /* I - Parent node or MXML_NO_PARENT */
540 mxml_node_t *node; /* New node */
556 * Create the node and set the text value...
559 if ((node = mxml_new(parent, MXML_TEXT)) != NULL)
561 node->value.text.whitespace = whitespace;
562 node->value.text.string = strdup(string);
565 return (node);
570 * 'mxmlNewTextf()' - Create a new formatted text fragment node.
572 * The new text node is added to the end of the specified parent's child
574 * text node has no parent. The whitespace parameter is used to specify
575 * whether leading whitespace is present before the node. The format
576 * string must be nul-terminated and is formatted into the new node.
579 mxml_node_t * /* O - New node */
580 mxmlNewTextf(mxml_node_t *parent, /* I - Parent node or MXML_NO_PARENT */
585 mxml_node_t *node; /* New node */
602 * Create the node and set the text value...
605 if ((node = mxml_new(parent, MXML_TEXT)) != NULL)
609 node->value.text.whitespace = whitespace;
610 node->value.text.string = _mxml_vstrdupf(format, ap);
615 return (node);
620 * 'mxmlRemove()' - Remove a node from its parent.
622 * Does not free memory used by the node - use mxmlDelete() for that.
623 * This function does nothing if the node has no parent.
627 mxmlRemove(mxml_node_t *node) /* I - Node to remove */
630 fprintf(stderr, "mxmlRemove(node=%p)\n", node);
637 if (!node || !node->parent)
645 fprintf(stderr, " BEFORE: node->parent=%p\n", node->parent);
646 if (node->parent)
648 fprintf(stderr, " BEFORE: node->parent->child=%p\n", node->parent->child);
649 fprintf(stderr, " BEFORE: node->parent->last_child=%p\n", node->parent->last_child);
651 fprintf(stderr, " BEFORE: node->child=%p\n", node->child);
652 fprintf(stderr, " BEFORE: node->last_child=%p\n", node->last_child);
653 fprintf(stderr, " BEFORE: node->prev=%p\n", node->prev);
654 fprintf(stderr, " BEFORE: node->next=%p\n", node->next);
657 if (node->prev)
658 node->prev->next = node->next;
660 node->parent->child = node->next;
662 if (node->next)
663 node->next->prev = node->prev;
665 node->parent->last_child = node->prev;
667 node->parent = NULL;
668 node->prev = NULL;
669 node->next = NULL;
672 fprintf(stderr, " AFTER: node->parent=%p\n", node->parent);
673 if (node->parent)
675 fprintf(stderr, " AFTER: node->parent->child=%p\n", node->parent->child);
676 fprintf(stderr, " AFTER: node->parent->last_child=%p\n", node->parent->last_child);
678 fprintf(stderr, " AFTER: node->child=%p\n", node->child);
679 fprintf(stderr, " AFTER: node->last_child=%p\n", node->last_child);
680 fprintf(stderr, " AFTER: node->prev=%p\n", node->prev);
681 fprintf(stderr, " AFTER: node->next=%p\n", node->next);
690 * ?xml element node. If NULL, version 1.0 is assumed.
695 mxml_node_t * /* O - New ?xml node */
709 * 'mxmlRelease()' - Release a node.
711 * When the reference count reaches zero, the node (and any children)
718 mxmlRelease(mxml_node_t *node) /* I - Node */
720 if (node)
722 if ((-- node->ref_count) <= 0)
724 mxmlDelete(node);
728 return (node->ref_count);
736 * 'mxmlRetain()' - Retain a node.
742 mxmlRetain(mxml_node_t *node) /* I - Node */
744 if (node)
745 return (++ node->ref_count);
752 * 'mxml_new()' - Create a new node.
755 static mxml_node_t * /* O - New node */
756 mxml_new(mxml_node_t *parent, /* I - Parent node */
759 mxml_node_t *node; /* New node */
767 * Allocate memory for the node...
770 if ((node = calloc(1, sizeof(mxml_node_t))) == NULL)
780 fprintf(stderr, " returning %p\n", node);
784 * Set the node type...
787 node->type = type;
788 node->ref_count = 1;
795 mxmlAdd(parent, MXML_ADD_AFTER, MXML_ADD_TO_PARENT, node);
798 * Return the new node...
801 return (node);
806 * End of "$Id: mxml-node.c 436 2011-01-22 01:02:05Z mike $".