MCPcopy Create free account
hub / github.com/KhronosGroup/OpenCOLLADA / xmlShellPwd

Function xmlShellPwd

Externals/LibXML/debugXML.c:2759–2785  ·  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

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

Callers 2

test_xmlShellPwdFunction · 0.85
xmlShellFunction · 0.85

Calls 1

xmlGetNodePathFunction · 0.85

Tested by 1

test_xmlShellPwdFunction · 0.68