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

Function xmlTextWriterStartDTD

ThirdParty/libxml2/vtklibxml2/xmlwriter.c:2821–2948  ·  view source on GitHub ↗

* xmlTextWriterStartDTD: * @writer: the xmlTextWriterPtr * @name: the name of the DTD * @pubid: the public identifier, which is an alternative to the system identifier * @sysid: the system identifier, which is the URI of the DTD * * Start an xml DTD. * * Returns the bytes written (may be 0 because of buffering) or -1 in case of error */

Source from the content-addressed store, hash-verified

2819 * Returns the bytes written (may be 0 because of buffering) or -1 in case of error
2820 */
2821int
2822xmlTextWriterStartDTD(xmlTextWriterPtr writer,
2823 const xmlChar * name,
2824 const xmlChar * pubid, const xmlChar * sysid)
2825{
2826 int count;
2827 int sum;
2828 xmlLinkPtr lk;
2829 xmlTextWriterStackEntry *p;
2830
2831 if (writer == NULL || name == NULL || *name == '\0')
2832 return -1;
2833
2834 sum = 0;
2835 lk = xmlListFront(writer->nodes);
2836 if ((lk != NULL) && (xmlLinkGetData(lk) != NULL)) {
2837 xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR,
2838 "xmlTextWriterStartDTD : DTD allowed only in prolog!\n");
2839 return -1;
2840 }
2841
2842 p = (xmlTextWriterStackEntry *)
2843 xmlMalloc(sizeof(xmlTextWriterStackEntry));
2844 if (p == 0) {
2845 xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY,
2846 "xmlTextWriterStartDTD : out of memory!\n");
2847 return -1;
2848 }
2849
2850 p->name = xmlStrdup(name);
2851 if (p->name == 0) {
2852 xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY,
2853 "xmlTextWriterStartDTD : out of memory!\n");
2854 xmlFree(p);
2855 return -1;
2856 }
2857 p->state = XML_TEXTWRITER_DTD;
2858
2859 xmlListPushFront(writer->nodes, p);
2860
2861 count = xmlOutputBufferWriteString(writer->out, "<!DOCTYPE ");
2862 if (count < 0)
2863 return -1;
2864 sum += count;
2865 count = xmlOutputBufferWriteString(writer->out, (const char *) name);
2866 if (count < 0)
2867 return -1;
2868 sum += count;
2869
2870 if (pubid != 0) {
2871 if (sysid == 0) {
2872 xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR,
2873 "xmlTextWriterStartDTD : system identifier needed!\n");
2874 return -1;
2875 }
2876
2877 if (writer->indent)
2878 count = xmlOutputBufferWrite(writer->out, 1, "\n");

Callers 1

xmlTextWriterWriteDTDFunction · 0.85

Calls 7

xmlListFrontFunction · 0.85
xmlLinkGetDataFunction · 0.85
xmlWriterErrMsgFunction · 0.85
xmlStrdupFunction · 0.85
xmlListPushFrontFunction · 0.85
xmlOutputBufferWriteFunction · 0.85

Tested by

no test coverage detected