MCPcopy Create free account
hub / github.com/Kitware/VTK / xmlShellPwd

Function xmlShellPwd

ThirdParty/libxml2/vtklibxml2/debugXML.c:2755–2781  ·  view source on GitHub ↗

* xmlShellPwd: * @ctxt: the shell context * @buffer: the output buffer * @node: a node * @node2: unused * * Implements the XML shell function "pwd" * Show the full path from the root to the node, if needed building * thumblers when similar elements exists at a given ancestor level. * The output is compatible with XPath commands. * * Returns 0 or -1 in case of error */

Source from the content-addressed store, hash-verified

2753 * Returns 0 or -1 in case of error
2754 */
2755int
2756xmlShellPwd(xmlShellCtxtPtr ctxt ATTRIBUTE_UNUSED, char *buffer,
2757 xmlNodePtr node, xmlNodePtr node2 ATTRIBUTE_UNUSED)
2758{
2759 xmlChar *path;
2760
2761 if ((node == NULL) || (buffer == NULL))
2762 return (-1);
2763
2764 path = xmlGetNodePath(node);
2765 if (path == NULL)
2766 return (-1);
2767
2768 /*
2769 * This test prevents buffer overflow, because this routine
2770 * is only called by xmlShell, in which the second argument is
2771 * 500 chars long.
2772 * It is a dirty hack before a cleaner solution is found.
2773 * Documentation should mention that the second argument must
2774 * be at least 500 chars long, and could be stripped if too long.
2775 */
2776 snprintf(buffer, 499, "%s", path);
2777 buffer[499] = '0';
2778 xmlFree(path);
2779
2780 return (0);
2781}
2782
2783/**
2784 * xmlShell:

Callers 1

xmlShellFunction · 0.85

Calls 1

xmlGetNodePathFunction · 0.85

Tested by

no test coverage detected