static void dumpNodes(int level, xmlNode * a_node, xml2lpc_context *ctx) { xmlNode *cur_node = NULL; for (cur_node = a_node; cur_node; cur_node = cur_node->next) { if (cur_node->type == XML_ELEMENT_NODE) { xml2lpc_log(ctx, XML2LPC_DEBUG, "node level: %d type: Element, name: %s", level, cur_node->name); } else { xml2lpc_log(ctx, XML2LPC_DEBUG, "node level: %d type: %d, name: %s", level, cur_node->type, cur_node->name); } dumpNodes(level + 1, cur_node->children, ctx); } }
/* --- dumpNodes() --- * Recursively print a text representation of the node subtree starting at the * node poined to by $node$, using an indentationlevel of $level$. */ void FHeap::dumpNodes(FHeapNode *node, int level) { #if FHEAP_DUMP FHeapNode *childNode, *partner; int i, childCount; /* Print leading whitespace for this level. */ for(i = 0; i < level; i++) printf(" "); printf("%d(%ld)[%d]\n", node->item, node->key, node->rank); if((childNode = node->child)) { childNode = node->child->right; childCount = 0; do { dumpNodes(childNode, level+1); if(childNode->dim > node->dim) { for(i = 0; i < level+1; i++) printf(" "); printf("error(dim)\n"); exit(1); } if(childNode->parent != node) { for(i = 0; i < level+1; i++) printf(" "); printf("error(parent)\n"); } childNode = childNode->right; childCount++; } while(childNode != node->child->right); if(childCount != node->dim) { for(i = 0; i < level; i++) printf(" "); printf("error(childCount)\n"); exit(1); } } else { if(node->dim != 0) { for(i = 0; i < level; i++) printf(" "); printf("error(dim)\n"); exit(1); } } #endif }
/* --- dump() --- * Print a text representation of the heap to the standard output. */ void FHeap::dump() const { #if FHEAP_DUMP int i; FHeapNode *node; printf("\n"); printf("treeSum = %d\n", treeSum); printf("array entries 0..maxTrees ="); for(i = 0; i < maxTrees; i++) { printf(" %d", trees[i] ? 1 : 0 ); } printf("\n\n"); for(i = 0; i < maxTrees; i++) { if((node = trees[i])) { printf("tree %d\n\n", i); dumpNodes(node, 0); printf("\n"); } } fflush(stdout); #endif }