* htmlSaveFile: * @filename: the filename (or URL) * @cur: the document * * Dump an HTML document to a file. If @filename is "-" the stdout file is * used. * returns: the number of byte written or -1 in case of failure. */
| 1049 | * returns: the number of byte written or -1 in case of failure. |
| 1050 | */ |
| 1051 | int |
| 1052 | htmlSaveFile(const char *filename, xmlDocPtr cur) { |
| 1053 | xmlOutputBufferPtr buf; |
| 1054 | xmlCharEncodingHandlerPtr handler = NULL; |
| 1055 | const char *encoding; |
| 1056 | int ret; |
| 1057 | |
| 1058 | if ((cur == NULL) || (filename == NULL)) |
| 1059 | return(-1); |
| 1060 | |
| 1061 | xmlInitParser(); |
| 1062 | |
| 1063 | encoding = (const char *) htmlGetMetaEncoding(cur); |
| 1064 | handler = htmlFindOutputEncoder(encoding); |
| 1065 | buf = xmlOutputBufferCreateFilename(filename, handler, cur->compression); |
| 1066 | if (buf == NULL) { |
| 1067 | xmlCharEncCloseFunc(handler); |
| 1068 | return(0); |
| 1069 | } |
| 1070 | |
| 1071 | htmlDocContentDumpOutput(buf, cur, NULL); |
| 1072 | |
| 1073 | ret = xmlOutputBufferClose(buf); |
| 1074 | return(ret); |
| 1075 | } |
| 1076 | |
| 1077 | /** |
| 1078 | * htmlSaveFileFormat: |
no test coverage detected