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

Function xmlSaveFormatFileEnc

ThirdParty/libxml2/vtklibxml2/xmlsave.c:2910–2952  ·  view source on GitHub ↗

* xmlSaveFormatFileEnc: * @filename: the filename or URL to output * @cur: the document being saved * @encoding: the name of the encoding to use or NULL. * @format: should formatting spaces be added. * * Dump an XML document to a file or an URL. * * Returns the number of bytes written or -1 in case of error. * Note that @format = 1 provide node indenting only if xmlIndentTreeOutput =

Source from the content-addressed store, hash-verified

2908 * or xmlKeepBlanksDefault(0) was called
2909 */
2910int
2911xmlSaveFormatFileEnc( const char * filename, xmlDocPtr cur,
2912 const char * encoding, int format ) {
2913 xmlSaveCtxt ctxt;
2914 xmlOutputBufferPtr buf;
2915 xmlCharEncodingHandlerPtr handler = NULL;
2916 int ret;
2917
2918 if (cur == NULL)
2919 return(-1);
2920
2921 if (encoding == NULL)
2922 encoding = (const char *) cur->encoding;
2923
2924 if (encoding != NULL) {
2925 int res;
2926
2927 res = xmlOpenCharEncodingHandler(encoding, /* output */ 1, &handler);
2928 if (res != XML_ERR_OK)
2929 return(-1);
2930 }
2931
2932#ifdef LIBXML_ZLIB_ENABLED
2933 if (cur->compression < 0) cur->compression = xmlGetCompressMode();
2934#endif
2935 /*
2936 * save the content to a temp buffer.
2937 */
2938 buf = xmlOutputBufferCreateFilename(filename, handler, cur->compression);
2939 if (buf == NULL) return(-1);
2940 memset(&ctxt, 0, sizeof(ctxt));
2941 ctxt.buf = buf;
2942 ctxt.level = 0;
2943 ctxt.format = format ? 1 : 0;
2944 ctxt.encoding = (const xmlChar *) encoding;
2945 xmlSaveCtxtInit(&ctxt);
2946 ctxt.options |= XML_SAVE_AS_XML;
2947
2948 xmlDocContentDumpOutput(&ctxt, cur);
2949
2950 ret = xmlOutputBufferClose(buf);
2951 return(ret);
2952}
2953
2954
2955/**

Callers 3

xmlSaveFileEncFunction · 0.85
xmlSaveFormatFileFunction · 0.85
xmlSaveFileFunction · 0.85

Calls 6

xmlGetCompressModeFunction · 0.85
xmlSaveCtxtInitFunction · 0.85
xmlDocContentDumpOutputFunction · 0.85
xmlOutputBufferCloseFunction · 0.85

Tested by

no test coverage detected