* xmlTextWriterEndPI: * @writer: the xmlTextWriterPtr * * End the current xml PI. * * Returns the bytes written (may be 0 because of buffering) or -1 in case of error */
| 2460 | * Returns the bytes written (may be 0 because of buffering) or -1 in case of error |
| 2461 | */ |
| 2462 | int |
| 2463 | xmlTextWriterEndPI(xmlTextWriterPtr writer) |
| 2464 | { |
| 2465 | int count; |
| 2466 | int sum; |
| 2467 | xmlLinkPtr lk; |
| 2468 | xmlTextWriterStackEntry *p; |
| 2469 | |
| 2470 | if (writer == NULL) |
| 2471 | return -1; |
| 2472 | |
| 2473 | lk = xmlListFront(writer->nodes); |
| 2474 | if (lk == 0) |
| 2475 | return 0; |
| 2476 | |
| 2477 | p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk); |
| 2478 | if (p == 0) |
| 2479 | return 0; |
| 2480 | |
| 2481 | sum = 0; |
| 2482 | switch (p->state) { |
| 2483 | case XML_TEXTWRITER_PI: |
| 2484 | case XML_TEXTWRITER_PI_TEXT: |
| 2485 | count = xmlOutputBufferWriteString(writer->out, "?>"); |
| 2486 | if (count < 0) |
| 2487 | return -1; |
| 2488 | sum += count; |
| 2489 | break; |
| 2490 | default: |
| 2491 | return -1; |
| 2492 | } |
| 2493 | |
| 2494 | if (writer->indent) { |
| 2495 | count = xmlOutputBufferWriteString(writer->out, "\n"); |
| 2496 | if (count < 0) |
| 2497 | return -1; |
| 2498 | sum += count; |
| 2499 | } |
| 2500 | |
| 2501 | xmlListPopFront(writer->nodes); |
| 2502 | return sum; |
| 2503 | } |
| 2504 | |
| 2505 | /** |
| 2506 | * xmlTextWriterWriteFormatPI: |
no test coverage detected