* htmlSaveFileFormat: * @filename: the filename * @cur: the document * @format: should formatting spaces been added * @encoding: the document encoding * * Dump an HTML document to a file using a given encoding. * * returns: the number of byte written or -1 in case of failure. */
| 1086 | * returns: the number of byte written or -1 in case of failure. |
| 1087 | */ |
| 1088 | int |
| 1089 | htmlSaveFileFormat(const char *filename, xmlDocPtr cur, |
| 1090 | const char *encoding, int format) { |
| 1091 | xmlOutputBufferPtr buf; |
| 1092 | xmlCharEncodingHandlerPtr handler = NULL; |
| 1093 | int ret; |
| 1094 | |
| 1095 | if ((cur == NULL) || (filename == NULL)) |
| 1096 | return(-1); |
| 1097 | |
| 1098 | xmlInitParser(); |
| 1099 | |
| 1100 | handler = htmlFindOutputEncoder(encoding); |
| 1101 | if (handler != NULL) |
| 1102 | htmlSetMetaEncoding(cur, (const xmlChar *) handler->name); |
| 1103 | else |
| 1104 | htmlSetMetaEncoding(cur, (const xmlChar *) "UTF-8"); |
| 1105 | |
| 1106 | /* |
| 1107 | * save the content to a temp buffer. |
| 1108 | */ |
| 1109 | buf = xmlOutputBufferCreateFilename(filename, handler, 0); |
| 1110 | if (buf == NULL) { |
| 1111 | xmlCharEncCloseFunc(handler); |
| 1112 | return(0); |
| 1113 | } |
| 1114 | |
| 1115 | htmlDocContentDumpFormatOutput(buf, cur, encoding, format); |
| 1116 | |
| 1117 | ret = xmlOutputBufferClose(buf); |
| 1118 | return(ret); |
| 1119 | } |
| 1120 | |
| 1121 | /** |
| 1122 | * htmlSaveFileEnc: |
no test coverage detected