PyObject *xmlsec_NodeSetDebugDump(PyObject *self, PyObject *args) { PyObject *nset_obj, *output_obj; xmlSecNodeSetPtr nset; FILE *output; if (CheckArgs(args, "OO:nodeSetDebugDump")) { if (!PyArg_ParseTuple(args, "OO:nodeSetDebugDump", &nset_obj, &output_obj)) return NULL; } else return NULL; nset = xmlSecNodeSetPtr_get(nset_obj); output = PythonFile_get(output_obj); xmlSecNodeSetDebugDump(nset, output); Py_INCREF(Py_None); return (Py_None); }
/** * xmlSecNodeSetDebugDump: * @nset: the pointer to node set. * @output: the pointer to output FILE. * * Prints information about @nset to the @output. */ EXPORT_C void xmlSecNodeSetDebugDump(xmlSecNodeSetPtr nset, FILE *output) { int i, l; xmlNodePtr cur; xmlSecAssert(nset != NULL); xmlSecAssert(output != NULL); fprintf(output, "== Nodes set "); switch(nset->type) { case xmlSecNodeSetNormal: fprintf(output, "(xmlSecNodeSetNormal)\n"); break; case xmlSecNodeSetInvert: fprintf(output, "(xmlSecNodeSetInvert)\n"); break; case xmlSecNodeSetTree: fprintf(output, "(xmlSecNodeSetTree)\n"); break; case xmlSecNodeSetTreeWithoutComments: fprintf(output, "(xmlSecNodeSetTreeWithoutComments)\n"); break; case xmlSecNodeSetTreeInvert: fprintf(output, "(xmlSecNodeSetTreeInvert)\n"); break; case xmlSecNodeSetTreeWithoutCommentsInvert: fprintf(output, "(xmlSecNodeSetTreeWithoutCommentsInvert)\n"); break; case xmlSecNodeSetList: fprintf(output, "(xmlSecNodeSetList)\n"); fprintf(output, ">>>\n"); xmlSecNodeSetDebugDump(nset->children, output); fprintf(output, "<<<\n"); return; default: fprintf(output, "(unknown=%d)\n", nset->type); xmlSecError(XMLSEC_ERRORS_HERE, NULL, NULL, XMLSEC_ERRORS_R_INVALID_TYPE, "type=%d", nset->type); } l = xmlXPathNodeSetGetLength(nset->nodes); for(i = 0; i < l; ++i) { cur = xmlXPathNodeSetItem(nset->nodes, i); if(cur->type != XML_NAMESPACE_DECL) { fprintf(output, "%d: %s\n", cur->type, (cur->name) ? cur->name : BAD_CAST "null"); } else { xmlNsPtr ns = (xmlNsPtr)cur; fprintf(output, "%d: %s=%s (%s:%s)\n", cur->type, (ns->prefix) ? ns->prefix : BAD_CAST "null", (ns->href) ? ns->href : BAD_CAST "null", (((xmlNodePtr)ns->next)->ns && ((xmlNodePtr)ns->next)->ns->prefix) ? ((xmlNodePtr)ns->next)->ns->prefix : BAD_CAST "null", ((xmlNodePtr)ns->next)->name); } } }