Lines Matching defs:ctxt
100 * @ctxt: an XML parser context
106 xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
108 if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
109 (ctxt->instate == XML_PARSER_EOF))
111 if (ctxt != NULL) {
112 ctxt->errNo = XML_ERR_NO_MEMORY;
113 ctxt->instate = XML_PARSER_EOF;
114 ctxt->disableSAX = 1;
117 __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER,
122 __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER,
129 * @ctxt: an XML parser context
138 __xmlErrEncoding(xmlParserCtxtPtr ctxt, xmlParserErrors xmlerr,
141 if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
142 (ctxt->instate == XML_PARSER_EOF))
144 if (ctxt != NULL)
145 ctxt->errNo = xmlerr;
147 ctxt, NULL, XML_FROM_PARSER, xmlerr, XML_ERR_FATAL,
150 if (ctxt != NULL) {
151 ctxt->wellFormed = 0;
152 if (ctxt->recovery == 0)
153 ctxt->disableSAX = 1;
159 * @ctxt: an XML parser context
166 xmlErrInternal(xmlParserCtxtPtr ctxt, const char *msg, const xmlChar * str)
168 if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
169 (ctxt->instate == XML_PARSER_EOF))
171 if (ctxt != NULL)
172 ctxt->errNo = XML_ERR_INTERNAL_ERROR;
174 ctxt, NULL, XML_FROM_PARSER, XML_ERR_INTERNAL_ERROR,
177 if (ctxt != NULL) {
178 ctxt->wellFormed = 0;
179 if (ctxt->recovery == 0)
180 ctxt->disableSAX = 1;
186 * @ctxt: an XML parser context
194 xmlErrEncodingInt(xmlParserCtxtPtr ctxt, xmlParserErrors error,
197 if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
198 (ctxt->instate == XML_PARSER_EOF))
200 if (ctxt != NULL)
201 ctxt->errNo = error;
203 ctxt, NULL, XML_FROM_PARSER, error, XML_ERR_FATAL,
205 if (ctxt != NULL) {
206 ctxt->wellFormed = 0;
207 if (ctxt->recovery == 0)
208 ctxt->disableSAX = 1;
442 * @ctxt: the XML parser context
448 xmlNextChar(xmlParserCtxtPtr ctxt)
450 if ((ctxt == NULL) || (ctxt->instate == XML_PARSER_EOF) ||
451 (ctxt->input == NULL))
454 if (ctxt->charset == XML_CHAR_ENCODING_UTF8) {
455 if ((*ctxt->input->cur == 0) &&
456 (xmlParserInputGrow(ctxt->input, INPUT_CHUNK) <= 0) &&
457 (ctxt->instate != XML_PARSER_COMMENT)) {
464 xmlPopInput(ctxt);
475 if (*(ctxt->input->cur) == '\n') {
476 ctxt->input->line++; ctxt->input->col = 1;
478 ctxt->input->col++;
491 cur = ctxt->input->cur;
498 xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
505 xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
510 xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
515 ctxt->input->cur += 4;
522 ctxt->input->cur += 3;
530 xmlErrEncodingInt(ctxt, XML_ERR_INVALID_CHAR,
536 ctxt->input->cur += 2;
539 ctxt->input->cur++;
541 ctxt->nbChars++;
542 if (*ctxt->input->cur == 0)
543 xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
552 if (*(ctxt->input->cur) == '\n') {
553 ctxt->input->line++; ctxt->input->col = 1;
555 ctxt->input->col++;
556 ctxt->input->cur++;
557 ctxt->nbChars++;
558 if (*ctxt->input->cur == 0)
559 xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
561 if ((*ctxt->input->cur == '%') && (!ctxt->html))
562 xmlParserHandlePEReference(ctxt);
563 if ((*ctxt->input->cur == 0) &&
564 (xmlParserInputGrow(ctxt->input, INPUT_CHUNK) <= 0))
565 xmlPopInput(ctxt);
575 if ((ctxt == NULL) || (ctxt->input == NULL) ||
576 (ctxt->input->end - ctxt->input->cur < 4)) {
577 __xmlErrEncoding(ctxt, XML_ERR_INVALID_CHAR,
584 ctxt->input->cur[0], ctxt->input->cur[1],
585 ctxt->input->cur[2], ctxt->input->cur[3]);
586 __xmlErrEncoding(ctxt, XML_ERR_INVALID_CHAR,
590 ctxt->charset = XML_CHAR_ENCODING_8859_1;
591 ctxt->input->cur++;
597 * @ctxt: the XML parser context
614 xmlCurrentChar(xmlParserCtxtPtr ctxt, int *len) {
615 if ((ctxt == NULL) || (len == NULL) || (ctxt->input == NULL)) return(0);
616 if (ctxt->instate == XML_PARSER_EOF)
619 if ((*ctxt->input->cur >= 0x20) && (*ctxt->input->cur <= 0x7F)) {
621 return((int) *ctxt->input->cur);
623 if (ctxt->charset == XML_CHAR_ENCODING_UTF8) {
635 const unsigned char *cur = ctxt->input->cur;
644 xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
649 xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
654 xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
684 xmlErrEncodingInt(ctxt, XML_ERR_INVALID_CHAR,
691 if (*ctxt->input->cur == 0)
692 xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
693 if ((*ctxt->input->cur == 0) &&
694 (ctxt->input->end > ctxt->input->cur)) {
695 xmlErrEncodingInt(ctxt, XML_ERR_INVALID_CHAR,
698 if (*ctxt->input->cur == 0xD) {
699 if (ctxt->input->cur[1] == 0xA) {
700 ctxt->nbChars++;
701 ctxt->input->cur++;
705 return((int) *ctxt->input->cur);
714 if (*ctxt->input->cur == 0xD) {
715 if (ctxt->input->cur[1] == 0xA) {
716 ctxt->nbChars++;
717 ctxt->input->cur++;
721 return((int) *ctxt->input->cur);
728 if (ctxt->input->end - ctxt->input->cur < 4) {
744 ctxt->input->cur[0], ctxt->input->cur[1],
745 ctxt->input->cur[2], ctxt->input->cur[3]);
746 __xmlErrEncoding(ctxt, XML_ERR_INVALID_CHAR,
750 ctxt->charset = XML_CHAR_ENCODING_8859_1;
752 return((int) *ctxt->input->cur);
757 * @ctxt: the XML parser context
768 xmlStringCurrentChar(xmlParserCtxtPtr ctxt, const xmlChar * cur, int *len)
771 if ((ctxt == NULL) || (ctxt->charset == XML_CHAR_ENCODING_UTF8)) {
817 xmlErrEncodingInt(ctxt, XML_ERR_INVALID_CHAR,
841 if ((ctxt == NULL) || (ctxt->input == NULL) ||
842 (ctxt->input->end - ctxt->input->cur < 4)) {
857 ctxt->input->cur[0], ctxt->input->cur[1],
858 ctxt->input->cur[2], ctxt->input->cur[3]);
859 __xmlErrEncoding(ctxt, XML_ERR_INVALID_CHAR,
938 * @ctxt: the parser context
947 xmlSwitchEncoding(xmlParserCtxtPtr ctxt, xmlCharEncoding enc)
951 if (ctxt == NULL) return(-1);
954 __xmlErrEncoding(ctxt, XML_ERR_UNKNOWN_ENCODING,
959 ctxt->charset = XML_CHAR_ENCODING_UTF8;
963 ctxt->charset = XML_CHAR_ENCODING_UTF8;
970 if ((ctxt->input != NULL) &&
971 (ctxt->input->cur[0] == 0xEF) &&
972 (ctxt->input->cur[1] == 0xBB) &&
973 (ctxt->input->cur[2] == 0xBF)) {
974 ctxt->input->cur += 3;
982 *ctxt->input->cur to contain UTF-8 encoded characters.
987 if ((ctxt->input != NULL) && (ctxt->input->cur != NULL) &&
988 (ctxt->input->cur[0] == 0xEF) &&
989 (ctxt->input->cur[1] == 0xBB) &&
990 (ctxt->input->cur[2] == 0xBF)) {
991 ctxt->input->cur += 3;
1005 ctxt->charset = XML_CHAR_ENCODING_UTF8;
1012 __xmlErrEncoding(ctxt, XML_ERR_UNSUPPORTED_ENCODING,
1017 __xmlErrEncoding(ctxt, XML_ERR_UNSUPPORTED_ENCODING,
1022 __xmlErrEncoding(ctxt, XML_ERR_UNSUPPORTED_ENCODING,
1027 __xmlErrEncoding(ctxt, XML_ERR_UNSUPPORTED_ENCODING,
1032 __xmlErrEncoding(ctxt, XML_ERR_UNSUPPORTED_ENCODING,
1037 __xmlErrEncoding(ctxt, XML_ERR_UNSUPPORTED_ENCODING,
1056 if ((ctxt->inputNr == 1) &&
1057 (ctxt->encoding == NULL) &&
1058 (ctxt->input != NULL) &&
1059 (ctxt->input->encoding != NULL)) {
1060 ctxt->encoding = xmlStrdup(ctxt->input->encoding);
1062 ctxt->charset = enc;
1065 __xmlErrEncoding(ctxt, XML_ERR_UNSUPPORTED_ENCODING,
1070 __xmlErrEncoding(ctxt, XML_ERR_UNSUPPORTED_ENCODING,
1075 __xmlErrEncoding(ctxt, XML_ERR_UNSUPPORTED_ENCODING,
1085 ctxt->charset = XML_CHAR_ENCODING_UTF8;
1086 return(xmlSwitchToEncoding(ctxt, handler));
1091 * @ctxt: the parser context
1101 xmlSwitchInputEncoding(xmlParserCtxtPtr ctxt, xmlParserInputPtr input,
1185 if (ctxt->html) {
1204 xmlErrInternal(ctxt,
1220 xmlErrInternal(ctxt, "switching encoding : no input\n", NULL);
1228 * @ctxt: the parser context
1237 xmlSwitchToEncoding(xmlParserCtxtPtr ctxt, xmlCharEncodingHandlerPtr handler)
1242 if (ctxt->input != NULL) {
1243 ret = xmlSwitchInputEncoding(ctxt, ctxt->input, handler);
1245 xmlErrInternal(ctxt, "xmlSwitchToEncoding : no input\n",
1252 ctxt->charset = XML_CHAR_ENCODING_UTF8;
1287 * @ctxt: an XML parser context
1293 xmlNewInputStream(xmlParserCtxtPtr ctxt) {
1299 xmlErrMemory(ctxt, "couldn't allocate a new input stream\n");
1316 * @ctxt: an XML parser context
1326 xmlNewIOInputStream(xmlParserCtxtPtr ctxt, xmlParserInputBufferPtr input,
1333 inputStream = xmlNewInputStream(ctxt);
1343 xmlSwitchEncoding(ctxt, enc);
1351 * @ctxt: an XML parser context
1359 xmlNewEntityInputStream(xmlParserCtxtPtr ctxt, xmlEntityPtr entity) {
1363 xmlErrInternal(ctxt, "xmlNewEntityInputStream entity = NULL\n",
1373 xmlErrInternal(ctxt, "Cannot parse entity %s\n",
1379 (char *) entity->ExternalID, ctxt));
1381 xmlErrInternal(ctxt,
1386 xmlErrInternal(ctxt,
1391 xmlErrInternal(ctxt,
1398 input = xmlNewInputStream(ctxt);
1413 * @ctxt: an XML parser context
1420 xmlNewStringInputStream(xmlParserCtxtPtr ctxt, const xmlChar *buffer) {
1424 xmlErrInternal(ctxt, "xmlNewStringInputStream string = NULL\n",
1431 input = xmlNewInputStream(ctxt);
1433 xmlErrMemory(ctxt, "couldn't allocate a new input stream\n");
1445 * @ctxt: an XML parser context
1453 xmlNewInputFromFile(xmlParserCtxtPtr ctxt, const char *filename) {
1462 if (ctxt == NULL) return(NULL);
1466 __xmlLoaderErr(ctxt,
1470 __xmlLoaderErr(ctxt, "failed to load external entity \"%s\"\n",
1475 inputStream = xmlNewInputStream(ctxt);
1480 inputStream = xmlCheckHTTPInput(ctxt, inputStream);
1497 if ((ctxt->directory == NULL) && (directory != NULL))
1498 ctxt->directory = (char *) xmlStrdup((const xmlChar *) directory);
1510 * @ctxt: an XML parser context
1518 xmlInitParserCtxt(xmlParserCtxtPtr ctxt)
1522 if(ctxt==NULL) {
1529 if (ctxt->dict == NULL)
1530 ctxt->dict = xmlDictCreate();
1531 if (ctxt->dict == NULL) {
1535 if (ctxt->sax == NULL)
1536 ctxt->sax = (xmlSAXHandler *) xmlMalloc(sizeof(xmlSAXHandler));
1537 if (ctxt->sax == NULL) {
1542 xmlSAXVersion(ctxt->sax, 2);
1544 ctxt->maxatts = 0;
1545 ctxt->atts = NULL;
1547 if (ctxt->inputTab == NULL) {
1548 ctxt->inputTab = (xmlParserInputPtr *)
1550 ctxt->inputMax = 5;
1552 if (ctxt->inputTab == NULL) {
1554 ctxt->inputNr = 0;
1555 ctxt->inputMax = 0;
1556 ctxt->input = NULL;
1559 while ((input = inputPop(ctxt)) != NULL) { /* Non consuming */
1562 ctxt->inputNr = 0;
1563 ctxt->input = NULL;
1565 ctxt->version = NULL;
1566 ctxt->encoding = NULL;
1567 ctxt->standalone = -1;
1568 ctxt->hasExternalSubset = 0;
1569 ctxt->hasPErefs = 0;
1570 ctxt->html = 0;
1571 ctxt->external = 0;
1572 ctxt->instate = XML_PARSER_START;
1573 ctxt->token = 0;
1574 ctxt->directory = NULL;
1577 if (ctxt->nodeTab == NULL) {
1578 ctxt->nodeTab = (xmlNodePtr *) xmlMalloc(10 * sizeof(xmlNodePtr));
1579 ctxt->nodeMax = 10;
1581 if (ctxt->nodeTab == NULL) {
1583 ctxt->nodeNr = 0;
1584 ctxt->nodeMax = 0;
1585 ctxt->node = NULL;
1586 ctxt->inputNr = 0;
1587 ctxt->inputMax = 0;
1588 ctxt->input = NULL;
1591 ctxt->nodeNr = 0;
1592 ctxt->node = NULL;
1595 if (ctxt->nameTab == NULL) {
1596 ctxt->nameTab = (const xmlChar **) xmlMalloc(10 * sizeof(xmlChar *));
1597 ctxt->nameMax = 10;
1599 if (ctxt->nameTab == NULL) {
1601 ctxt->nodeNr = 0;
1602 ctxt->nodeMax = 0;
1603 ctxt->node = NULL;
1604 ctxt->inputNr = 0;
1605 ctxt->inputMax = 0;
1606 ctxt->input = NULL;
1607 ctxt->nameNr = 0;
1608 ctxt->nameMax = 0;
1609 ctxt->name = NULL;
1612 ctxt->nameNr = 0;
1613 ctxt->name = NULL;
1616 if (ctxt->spaceTab == NULL) {
1617 ctxt->spaceTab = (int *) xmlMalloc(10 * sizeof(int));
1618 ctxt->spaceMax = 10;
1620 if (ctxt->spaceTab == NULL) {
1622 ctxt->nodeNr = 0;
1623 ctxt->nodeMax = 0;
1624 ctxt->node = NULL;
1625 ctxt->inputNr = 0;
1626 ctxt->inputMax = 0;
1627 ctxt->input = NULL;
1628 ctxt->nameNr = 0;
1629 ctxt->nameMax = 0;
1630 ctxt->name = NULL;
1631 ctxt->spaceNr = 0;
1632 ctxt->spaceMax = 0;
1633 ctxt->space = NULL;
1636 ctxt->spaceNr = 1;
1637 ctxt->spaceMax = 10;
1638 ctxt->spaceTab[0] = -1;
1639 ctxt->space = &ctxt->spaceTab[0];
1640 ctxt->userData = ctxt;
1641 ctxt->myDoc = NULL;
1642 ctxt->wellFormed = 1;
1643 ctxt->nsWellFormed = 1;
1644 ctxt->valid = 1;
1645 ctxt->loadsubset = xmlLoadExtDtdDefaultValue;
1646 ctxt->validate = xmlDoValidityCheckingDefaultValue;
1647 ctxt->pedantic = xmlPedanticParserDefaultValue;
1648 ctxt->linenumbers = xmlLineNumbersDefaultValue;
1649 ctxt->keepBlanks = xmlKeepBlanksDefaultValue;
1650 if (ctxt->keepBlanks == 0)
1651 ctxt->sax->ignorableWhitespace = xmlSAX2IgnorableWhitespace;
1653 ctxt->vctxt.finishDtd = XML_CTXT_FINISH_DTD_0;
1654 ctxt->vctxt.userData = ctxt;
1655 ctxt->vctxt.error = xmlParserValidityError;
1656 ctxt->vctxt.warning = xmlParserValidityWarning;
1657 if (ctxt->validate) {
1659 ctxt
1661 ctxt->vctxt.warning = xmlParserValidityWarning;
1662 ctxt->vctxt.nodeMax = 0;
1664 ctxt->replaceEntities = xmlSubstituteEntitiesDefaultValue;
1665 ctxt->record_info = 0;
1666 ctxt->nbChars = 0;
1667 ctxt->checkIndex = 0;
1668 ctxt->inSubset = 0;
1669 ctxt->errNo = XML_ERR_OK;
1670 ctxt->depth = 0;
1671 ctxt->charset = XML_CHAR_ENCODING_UTF8;
1672 ctxt->catalogs = NULL;
1673 ctxt->nbentities = 0;
1674 xmlInitNodeInfoSeq(&ctxt->node_seq);
1680 * @ctxt: an XML parser context
1683 * document in ctxt->myDoc is not freed.
1687 xmlFreeParserCtxt(xmlParserCtxtPtr ctxt)
1691 if (ctxt == NULL) return;
1693 while ((input = inputPop(ctxt)) != NULL) { /* Non consuming */
1696 if (ctxt->spaceTab != NULL) xmlFree(ctxt->spaceTab);
1697 if (ctxt->nameTab != NULL) xmlFree((xmlChar * *)ctxt->nameTab);
1698 if (ctxt->nodeTab != NULL) xmlFree(ctxt->nodeTab);
1699 if (ctxt->inputTab != NULL) xmlFree(ctxt->inputTab);
1700 if (ctxt->version != NULL) xmlFree((char *) ctxt->version);
1701 if (ctxt->encoding != NULL) xmlFree((char *) ctxt->encoding);
1702 if (ctxt->extSubURI != NULL) xmlFree((char *) ctxt->extSubURI);
1703 if (ctxt->extSubSystem != NULL) xmlFree((char *) ctxt->extSubSystem);
1705 if ((ctxt->sax != NULL) &&
1706 (ctxt->sax != (xmlSAXHandlerPtr) &xmlDefaultSAXHandler))
1708 if (ctxt->sax != NULL)
1710 xmlFree(ctxt->sax);
1711 if (ctxt->directory != NULL) xmlFree((char *) ctxt->directory);
1712 if (ctxt->vctxt.nodeTab != NULL) xmlFree(ctxt->vctxt.nodeTab);
1713 if (ctxt->atts != NULL) xmlFree((xmlChar * *)ctxt->atts);
1714 if (ctxt->dict != NULL) xmlDictFree(ctxt->dict);
1715 if (ctxt->nsTab != NULL) xmlFree((char *) ctxt->nsTab);
1716 if (ctxt->pushTab != NULL) xmlFree(ctxt->pushTab);
1717 if (ctxt->attallocs != NULL) xmlFree(ctxt->attallocs);
1718 if (ctxt->attsDefault != NULL)
1719 xmlHashFree(ctxt->attsDefault, (xmlHashDeallocator) xmlFree);
1720 if (ctxt->attsSpecial != NULL)
1721 xmlHashFree(ctxt->attsSpecial, NULL);
1722 if (ctxt->freeElems != NULL) {
1725 cur = ctxt->freeElems;
1732 if (ctxt->freeAttrs != NULL) {
1735 cur = ctxt->freeAttrs;
1745 if (ctxt->lastError.message != NULL)
1746 xmlFree(ctxt->lastError.message);
1747 if (ctxt->lastError.file != NULL)
1748 xmlFree(ctxt->lastError.file);
1749 if (ctxt->lastError.str1 != NULL)
1750 xmlFree(ctxt->lastError.str1);
1751 if (ctxt->lastError.str2 != NULL)
1752 xmlFree(ctxt->lastError.str2);
1753 if (ctxt->lastError.str3 != NULL)
1754 xmlFree(ctxt->lastError.str3);
1757 if (ctxt->catalogs != NULL)
1758 xmlCatalogFreeLocal(ctxt->catalogs);
1760 xmlFree(ctxt);
1774 xmlParserCtxtPtr ctxt;
1776 ctxt = (xmlParserCtxtPtr) xmlMalloc(sizeof(xmlParserCtxt));
1777 if (ctxt == NULL) {
1781 memset(ctxt, 0, sizeof(xmlParserCtxt));
1782 if (xmlInitParserCtxt(ctxt) < 0) {
1783 xmlFreeParserCtxt(ctxt);
1786 return(ctxt);
1797 * @ctxt: an XML parser context
1803 xmlClearParserCtxt(xmlParserCtxtPtr ctxt)
1805 if (ctxt==NULL)
1807 xmlClearNodeInfoSeq(&ctxt->node_seq);
1808 xmlCtxtReset(ctxt);
1916 * @ctxt: an XML parser context
1922 xmlParserAddNodeInfo(xmlParserCtxtPtr ctxt,
1927 if ((ctxt == NULL) || (info == NULL)) return;
1930 pos = xmlParserFindNodeInfoIndex(&ctxt->node_seq, (xmlNodePtr)
1933 if ((pos < ctxt->node_seq.length) &&
1934 (ctxt->node_seq.buffer != NULL) &&
1935 (ctxt->node_seq.buffer[pos].node == info->node)) {
1936 ctxt->node_seq.buffer[pos] = *info;
1941 if (ctxt->node_seq.length + 1 > ctxt->node_seq.maximum) {
1945 if (ctxt->node_seq.maximum == 0)
1946 ctxt->node_seq.maximum = 2;
1947 byte_size = (sizeof(*ctxt->node_seq.buffer) *
1948 (2 * ctxt->node_seq.maximum));
1950 if (ctxt->node_seq.buffer == NULL)
1954 (xmlParserNodeInfo *) xmlRealloc(ctxt->node_seq.buffer,
1958 xmlErrMemory(ctxt, "failed to allocate buffer\n");
1961 ctxt->node_seq.buffer = tmp_buffer;
1962 ctxt->node_seq.maximum *= 2;
1966 if (pos != ctxt->node_seq.length) {
1969 for (i = ctxt->node_seq.length; i > pos; i--)
1970 ctxt->node_seq.buffer[i] = ctxt->node_seq.buffer[i - 1];
1974 ctxt->node_seq.buffer[pos] = *info;
1975 ctxt->node_seq.length++;