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

Function xmlShellSave

ThirdParty/libxml2/vtklibxml2/debugXML.c:2565–2610  ·  view source on GitHub ↗

* xmlShellSave: * @ctxt: the shell context * @filename: the file name (optional) * @node: unused * @node2: unused * * Implements the XML shell function "save" * Write the current document to the filename, or it's original name * * Returns 0 or -1 in case of error */

Source from the content-addressed store, hash-verified

2563 * Returns 0 or -1 in case of error
2564 */
2565int
2566xmlShellSave(xmlShellCtxtPtr ctxt, char *filename,
2567 xmlNodePtr node ATTRIBUTE_UNUSED,
2568 xmlNodePtr node2 ATTRIBUTE_UNUSED)
2569{
2570 if ((ctxt == NULL) || (ctxt->doc == NULL))
2571 return (-1);
2572 if ((filename == NULL) || (filename[0] == 0))
2573 filename = ctxt->filename;
2574 if (filename == NULL)
2575 return (-1);
2576#ifdef W_OK
2577 if (access((char *) filename, W_OK)) {
2578 fprintf(ctxt->output,
2579 "Cannot save to %s\n", filename);
2580 return (-1);
2581 }
2582#endif
2583 switch (ctxt->doc->type) {
2584 case XML_DOCUMENT_NODE:
2585 if (xmlSaveFile((char *) filename, ctxt->doc) < 0) {
2586 fprintf(ctxt->output,
2587 "Failed to save to %s\n", filename);
2588 }
2589 break;
2590 case XML_HTML_DOCUMENT_NODE:
2591#ifdef LIBXML_HTML_ENABLED
2592 if (htmlSaveFile((char *) filename, ctxt->doc) < 0) {
2593 fprintf(ctxt->output,
2594 "Failed to save to %s\n", filename);
2595 }
2596#else
2597 if (xmlSaveFile((char *) filename, ctxt->doc) < 0) {
2598 fprintf(ctxt->output,
2599 "Failed to save to %s\n", filename);
2600 }
2601#endif /* LIBXML_HTML_ENABLED */
2602 break;
2603 default:
2604 fprintf(ctxt->output,
2605 "To save to subparts of a document use the 'write' command\n");
2606 return (-1);
2607
2608 }
2609 return (0);
2610}
2611#endif /* LIBXML_OUTPUT_ENABLED */
2612
2613#ifdef LIBXML_VALID_ENABLED

Callers 1

xmlShellFunction · 0.85

Calls 4

accessClass · 0.85
fprintfFunction · 0.85
xmlSaveFileFunction · 0.85
htmlSaveFileFunction · 0.85

Tested by

no test coverage detected