* 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 */
| 2753 | * Returns 0 or -1 in case of error |
| 2754 | */ |
| 2755 | int |
| 2756 | xmlShellPwd(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: |
no test coverage detected