* htmlBufNodeDumpFormat: * @buf: the xmlBufPtr output * @doc: the document * @cur: the current node * @format: should formatting spaces been added * * Dump an HTML node, recursive behaviour,children are printed too. * * Returns the number of byte written or -1 in case of error */
| 413 | * Returns the number of byte written or -1 in case of error |
| 414 | */ |
| 415 | static size_t |
| 416 | htmlBufNodeDumpFormat(xmlBufPtr buf, xmlDocPtr doc, xmlNodePtr cur, |
| 417 | int format) { |
| 418 | size_t use; |
| 419 | size_t ret; |
| 420 | xmlOutputBufferPtr outbuf; |
| 421 | |
| 422 | if (cur == NULL) { |
| 423 | return ((size_t) -1); |
| 424 | } |
| 425 | if (buf == NULL) { |
| 426 | return ((size_t) -1); |
| 427 | } |
| 428 | outbuf = (xmlOutputBufferPtr) xmlMalloc(sizeof(xmlOutputBuffer)); |
| 429 | if (outbuf == NULL) |
| 430 | return ((size_t) -1); |
| 431 | memset(outbuf, 0, sizeof(xmlOutputBuffer)); |
| 432 | outbuf->buffer = buf; |
| 433 | outbuf->encoder = NULL; |
| 434 | outbuf->writecallback = NULL; |
| 435 | outbuf->closecallback = NULL; |
| 436 | outbuf->context = NULL; |
| 437 | outbuf->written = 0; |
| 438 | |
| 439 | use = xmlBufUse(buf); |
| 440 | htmlNodeDumpFormatOutput(outbuf, doc, cur, NULL, format); |
| 441 | if (outbuf->error) |
| 442 | ret = (size_t) -1; |
| 443 | else |
| 444 | ret = xmlBufUse(buf) - use; |
| 445 | xmlFree(outbuf); |
| 446 | return (ret); |
| 447 | } |
| 448 | |
| 449 | /** |
| 450 | * htmlNodeDump: |
no test coverage detected