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

Function xmlTextWriterStartPI

ThirdParty/libxml2/vtklibxml2/xmlwriter.c:2366–2452  ·  view source on GitHub ↗

* xmlTextWriterStartPI: * @writer: the xmlTextWriterPtr * @target: PI target * * Start an xml PI. * * Returns the bytes written (may be 0 because of buffering) or -1 in case of error */

Source from the content-addressed store, hash-verified

2364 * Returns the bytes written (may be 0 because of buffering) or -1 in case of error
2365 */
2366int
2367xmlTextWriterStartPI(xmlTextWriterPtr writer, const xmlChar * target)
2368{
2369 int count;
2370 int sum;
2371 xmlLinkPtr lk;
2372 xmlTextWriterStackEntry *p;
2373
2374 if ((writer == NULL) || (target == NULL) || (*target == '\0'))
2375 return -1;
2376
2377 if (xmlStrcasecmp(target, (const xmlChar *) "xml") == 0) {
2378 xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR,
2379 "xmlTextWriterStartPI : target name [Xx][Mm][Ll] is reserved for xml standardization!\n");
2380 return -1;
2381 }
2382
2383 sum = 0;
2384 lk = xmlListFront(writer->nodes);
2385 if (lk != 0) {
2386 p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk);
2387 if (p != 0) {
2388 switch (p->state) {
2389 case XML_TEXTWRITER_ATTRIBUTE:
2390 count = xmlTextWriterEndAttribute(writer);
2391 if (count < 0)
2392 return -1;
2393 sum += count;
2394 /* fallthrough */
2395 case XML_TEXTWRITER_NAME:
2396 /* Output namespace declarations */
2397 count = xmlTextWriterOutputNSDecl(writer);
2398 if (count < 0)
2399 return -1;
2400 sum += count;
2401 count = xmlOutputBufferWriteString(writer->out, ">");
2402 if (count < 0)
2403 return -1;
2404 sum += count;
2405 p->state = XML_TEXTWRITER_TEXT;
2406 break;
2407 case XML_TEXTWRITER_NONE:
2408 case XML_TEXTWRITER_TEXT:
2409 case XML_TEXTWRITER_DTD:
2410 break;
2411 case XML_TEXTWRITER_PI:
2412 case XML_TEXTWRITER_PI_TEXT:
2413 xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR,
2414 "xmlTextWriterStartPI : nested PI!\n");
2415 return -1;
2416 default:
2417 return -1;
2418 }
2419 }
2420 }
2421
2422 p = (xmlTextWriterStackEntry *)
2423 xmlMalloc(sizeof(xmlTextWriterStackEntry));

Callers 1

xmlTextWriterWritePIFunction · 0.85

Calls 9

xmlStrcasecmpFunction · 0.85
xmlWriterErrMsgFunction · 0.85
xmlListFrontFunction · 0.85
xmlLinkGetDataFunction · 0.85
xmlStrdupFunction · 0.85
xmlListPushFrontFunction · 0.85

Tested by

no test coverage detected