Lines Matching refs:parser
7 |_| XML parser
242 static void copy_salt_to_sipkey(XML_Parser parser, struct sipkey *key);
305 A parser reuses these structures, maintaining a list of allocated
428 XML_ACCOUNT_DIRECT, /* bytes directly passed to the Expat parser */
452 typedef enum XML_Error PTRCALL Processor(XML_Parser parser, const char *start,
474 static enum XML_Error handleUnknownEncoding(XML_Parser parser,
476 static enum XML_Error processXmlDecl(XML_Parser parser, int isGeneralTextEntity,
478 static enum XML_Error initializeEncoding(XML_Parser parser);
479 static enum XML_Error doProlog(XML_Parser parser, const ENCODING *enc,
484 static enum XML_Error processInternalEntity(XML_Parser parser, ENTITY *entity,
486 static enum XML_Error doContent(XML_Parser parser, int startTagLevel,
490 static enum XML_Error doCdataSection(XML_Parser parser, const ENCODING *enc,
495 static enum XML_Error doIgnoreSection(XML_Parser parser, const ENCODING *enc,
500 static void freeBindings(XML_Parser parser, BINDING *bindings);
501 static enum XML_Error storeAtts(XML_Parser parser, const ENCODING *enc,
505 static enum XML_Error addBinding(XML_Parser parser, PREFIX *prefix,
510 const XML_Char *value, XML_Parser parser);
511 static enum XML_Error storeAttributeValue(XML_Parser parser,
516 static enum XML_Error appendAttributeValue(XML_Parser parser,
521 static ATTRIBUTE_ID *getAttributeId(XML_Parser parser, const ENCODING *enc,
523 static int setElementTypePrefix(XML_Parser parser, ELEMENT_TYPE *elementType);
525 static enum XML_Error storeEntityValue(XML_Parser parser, const ENCODING *enc,
529 static enum XML_Error storeSelfEntityValue(XML_Parser parser, ENTITY *entity);
531 static int reportProcessingInstruction(XML_Parser parser, const ENCODING *enc,
533 static int reportComment(XML_Parser parser, const ENCODING *enc,
535 static void reportDefault(XML_Parser parser, const ENCODING *enc,
538 static const XML_Char *getContext(XML_Parser parser);
539 static XML_Bool setContext(XML_Parser parser, const XML_Char *context);
552 static NAMED *lookup(XML_Parser parser, HASH_TABLE *table, KEY name,
578 static int FASTCALL nextScaffoldPart(XML_Parser parser);
579 static XML_Content *build_model(XML_Parser parser);
580 static ELEMENT_TYPE *getElementType(XML_Parser parser, const ENCODING *enc,
586 static unsigned long generate_hash_secret_salt(XML_Parser parser);
587 static XML_Bool startParsing(XML_Parser parser);
593 static void parserInit(XML_Parser parser, const XML_Char *encodingName);
609 static void entityTrackingReportStats(XML_Parser parser, ENTITY *entity,
611 static void entityTrackingOnOpen(XML_Parser parser, ENTITY *entity,
613 static void entityTrackingOnClose(XML_Parser parser, ENTITY *entity,
616 static XML_Parser getRootParserOf(XML_Parser parser,
761 #define MALLOC(parser, s) (parser->m_mem.malloc_fcn((s)))
762 #define REALLOC(parser, p, s) (parser->m_mem.realloc_fcn((p), (s)))
763 #define FREE(parser, p) (parser->m_mem.free_fcn((p)))
951 generate_hash_secret_salt(XML_Parser parser) {
953 (void)parser;
994 get_hash_secret_salt(XML_Parser parser) {
995 if (parser->m_parentParser != NULL)
996 return get_hash_secret_salt(parser->m_parentParser);
997 return parser->m_hash_secret_salt;
1001 callProcessor(XML_Parser parser, const char *start, const char *end,
1005 if (parser->m_reparseDeferralEnabled
1006 && ! parser->m_parsingStatus.finalBuffer) {
1009 const size_t had_before = parser->m_partialTokenBytesBefore;
1012 = EXPAT_SAFE_PTR_DIFF(parser->m_bufferPtr, parser->m_buffer);
1017 += EXPAT_SAFE_PTR_DIFF(parser->m_bufferLim, parser->m_bufferEnd);
1021 || ((size_t)parser->m_lastBufferRequestSize > available_buffer);
1031 const enum XML_Error ret = parser->m_processor(parser, start, end, endPtr);
1035 parser->m_partialTokenBytesBefore = have_now;
1037 parser->m_partialTokenBytesBefore = 0;
1043 static XML_Bool /* only valid for root parser */
1044 startParsing(XML_Parser parser) {
1046 if (parser->m_hash_secret_salt == 0)
1047 parser->m_hash_secret_salt = generate_hash_secret_salt(parser);
1048 if (parser->m_ns) {
1049 /* implicit context only set for root parser, since child
1052 return setContext(parser, implicitContext);
1068 XML_Parser parser;
1072 parser = memsuite->malloc_fcn(sizeof(struct XML_ParserStruct));
1073 if (parser != NULL) {
1074 mtemp = (XML_Memory_Handling_Suite *)&(parser->m_mem);
1081 parser = (XML_Parser)malloc(sizeof(struct XML_ParserStruct));
1082 if (parser != NULL) {
1083 mtemp = (XML_Memory_Handling_Suite *)&(parser->m_mem);
1090 if (! parser)
1091 return parser;
1093 parser->m_buffer = NULL;
1094 parser->m_bufferLim = NULL;
1096 parser->m_attsSize = INIT_ATTS_SIZE;
1097 parser->m_atts
1098 = (ATTRIBUTE *)MALLOC(parser, parser->m_attsSize * sizeof(ATTRIBUTE));
1099 if (parser->m_atts == NULL) {
1100 FREE(parser, parser);
1104 parser->m_attInfo = (XML_AttrInfo *)MALLOC(
1105 parser, parser->m_attsSize * sizeof(XML_AttrInfo));
1106 if (parser->m_attInfo == NULL) {
1107 FREE(parser, parser->m_atts);
1108 FREE(parser, parser);
1112 parser->m_dataBuf
1113 = (XML_Char *)MALLOC(parser, INIT_DATA_BUF_SIZE * sizeof(XML_Char));
1114 if (parser->m_dataBuf == NULL) {
1115 FREE(parser, parser->m_atts);
1117 FREE(parser, parser->m_attInfo);
1119 FREE(parser, parser);
1122 parser->m_dataBufEnd = parser->m_dataBuf + INIT_DATA_BUF_SIZE;
1125 parser->m_dtd = dtd;
1127 parser->m_dtd = dtdCreate(&parser->m_mem);
1128 if (parser->m_dtd == NULL) {
1129 FREE(parser, parser->m_dataBuf);
1130 FREE(parser, parser->m_atts);
1132 FREE(parser, parser->m_attInfo);
1134 FREE(parser, parser);
1139 parser->m_freeBindingList = NULL;
1140 parser->m_freeTagList = NULL;
1141 parser->m_freeInternalEntities = NULL;
1143 parser->m_groupSize = 0;
1144 parser->m_groupConnector = NULL;
1146 parser->m_unknownEncodingHandler = NULL;
1147 parser->m_unknownEncodingHandlerData = NULL;
1149 parser->m_namespaceSeparator = ASCII_EXCL;
1150 parser->m_ns = XML_FALSE;
1151 parser->m_ns_triplets = XML_FALSE;
1153 parser->m_nsAtts = NULL;
1154 parser->m_nsAttsVersion = 0;
1155 parser->m_nsAttsPower = 0;
1157 parser->m_protocolEncodingName = NULL;
1159 poolInit(&parser->m_tempPool, &(parser->m_mem));
1160 poolInit(&parser->m_temp2Pool, &(parser->m_mem));
1161 parserInit(parser, encodingName);
1163 if (encodingName && ! parser->m_protocolEncodingName) {
1166 // destroying parser->m_dtd because the DTD is shared with the parent
1167 // parser and the only guard that keeps XML_ParserFree from destroying
1168 // parser->m_dtd is parser->m_isParamEntity but it will be set to
1170 parser->m_dtd = NULL;
1172 XML_ParserFree(parser);
1177 parser->m_ns = XML_TRUE;
1178 parser->m_internalEncoding = XmlGetInternalEncodingNS();
1179 parser->m_namespaceSeparator = *nameSep;
1181 parser->m_internalEncoding = XmlGetInternalEncoding();
1184 return parser;
1188 parserInit(XML_Parser parser, const XML_Char *encodingName) {
1189 parser->m_processor = prologInitProcessor;
1190 XmlPrologStateInit(&parser->m_prologState);
1192 parser->m_protocolEncodingName = copyString(encodingName, &(parser->m_mem));
1194 parser->m_curBase = NULL;
1195 XmlInitEncoding(&parser->m_initEncoding, &parser->m_encoding, 0);
1196 parser->m_userData = NULL;
1197 parser->m_handlerArg = NULL;
1198 parser->m_startElementHandler = NULL;
1199 parser->m_endElementHandler = NULL;
1200 parser->m_characterDataHandler = NULL;
1201 parser->m_processingInstructionHandler = NULL;
1202 parser->m_commentHandler = NULL;
1203 parser->m_startCdataSectionHandler = NULL;
1204 parser->m_endCdataSectionHandler = NULL;
1205 parser->m_defaultHandler = NULL;
1206 parser->m_startDoctypeDeclHandler = NULL;
1207 parser->m_endDoctypeDeclHandler = NULL;
1208 parser->m_unparsedEntityDeclHandler = NULL;
1209 parser->m_notationDeclHandler = NULL;
1210 parser->m_startNamespaceDeclHandler = NULL;
1211 parser->m_endNamespaceDeclHandler = NULL;
1212 parser->m_notStandaloneHandler = NULL;
1213 parser->m_externalEntityRefHandler = NULL;
1214 parser->m_externalEntityRefHandlerArg = parser;
1215 parser->m_skippedEntityHandler = NULL;
1216 parser->m_elementDeclHandler = NULL;
1217 parser->m_attlistDeclHandler = NULL;
1218 parser->m_entityDeclHandler = NULL;
1219 parser->m_xmlDeclHandler = NULL;
1220 parser->m_bufferPtr = parser->m_buffer;
1221 parser->m_bufferEnd = parser->m_buffer;
1222 parser->m_parseEndByteIndex = 0;
1223 parser->m_parseEndPtr = NULL;
1224 parser->m_partialTokenBytesBefore = 0;
1225 parser->m_reparseDeferralEnabled = g_reparseDeferralEnabledDefault;
1226 parser->m_lastBufferRequestSize = 0;
1227 parser->m_declElementType = NULL;
1228 parser->m_declAttributeId = NULL;
1229 parser->m_declEntity = NULL;
1230 parser->m_doctypeName = NULL;
1231 parser->m_doctypeSysid = NULL;
1232 parser->m_doctypePubid = NULL;
1233 parser->m_declAttributeType = NULL;
1234 parser->m_declNotationName = NULL;
1235 parser->m_declNotationPublicId = NULL;
1236 parser->m_declAttributeIsCdata = XML_FALSE;
1237 parser->m_declAttributeIsId = XML_FALSE;
1238 memset(&parser->m_position, 0, sizeof(POSITION));
1239 parser->m_errorCode = XML_ERROR_NONE;
1240 parser->m_eventPtr = NULL;
1241 parser->m_eventEndPtr = NULL;
1242 parser->m_positionPtr = NULL;
1243 parser->m_openInternalEntities = NULL;
1244 parser->m_defaultExpandInternalEntities = XML_TRUE;
1245 parser->m_tagLevel = 0;
1246 parser->m_tagStack = NULL;
1247 parser->m_inheritedBindings = NULL;
1248 parser->m_nSpecifiedAtts = 0;
1249 parser->m_unknownEncodingMem = NULL;
1250 parser->m_unknownEncodingRelease = NULL;
1251 parser->m_unknownEncodingData = NULL;
1252 parser->m_parentParser = NULL;
1253 parser->m_parsingStatus.parsing = XML_INITIALIZED;
1255 parser->m_isParamEntity = XML_FALSE;
1256 parser->m_useForeignDTD = XML_FALSE;
1257 parser->m_paramEntityParsing = XML_PARAM_ENTITY_PARSING_NEVER;
1259 parser->m_hash_secret_salt = 0;
1262 memset(&parser->m_accounting, 0, sizeof(ACCOUNTING));
1263 parser->m_accounting.debugLevel = getDebugLevel("EXPAT_ACCOUNTING_DEBUG", 0u);
1264 parser->m_accounting.maximumAmplificationFactor
1266 parser->m_accounting.activationThresholdBytes
1269 memset(&parser->m_entity_stats, 0, sizeof(ENTITY_STATS));
1270 parser->m_entity_stats.debugLevel = getDebugLevel("EXPAT_ENTITY_DEBUG", 0u);
1276 moveToFreeBindingList(XML_Parser parser, BINDING *bindings) {
1280 b->nextTagBinding = parser->m_freeBindingList;
1281 parser->m_freeBindingList = b;
1286 XML_ParserReset(XML_Parser parser, const XML_Char *encodingName) {
1290 if (parser == NULL)
1293 if (parser->m_parentParser)
1296 tStk = parser->m_tagStack;
1300 tag->parent = parser->m_freeTagList;
1301 moveToFreeBindingList(parser, tag->bindings);
1303 parser->m_freeTagList = tag;
1306 openEntityList = parser->m_openInternalEntities;
1310 openEntity->next = parser->m_freeInternalEntities;
1311 parser->m_freeInternalEntities = openEntity;
1313 moveToFreeBindingList(parser, parser->m_inheritedBindings);
1314 FREE(parser, parser->m_unknownEncodingMem);
1315 if (parser->m_unknownEncodingRelease)
1316 parser->m_unknownEncodingRelease(parser->m_unknownEncodingData);
1317 poolClear(&parser->m_tempPool);
1318 poolClear(&parser->m_temp2Pool);
1319 FREE(parser, (void *)parser->m_protocolEncodingName);
1320 parser->m_protocolEncodingName = NULL;
1321 parserInit(parser, encodingName);
1322 dtdReset(parser->m_dtd, &parser->m_mem);
1327 XML_SetEncoding(XML_Parser parser, const XML_Char *encodingName) {
1328 if (parser == NULL)
1334 if (parser->m_parsingStatus.parsing == XML_PARSING
1335 || parser->m_parsingStatus.parsing == XML_SUSPENDED)
1339 FREE(parser, (void *)parser->m_protocolEncodingName);
1343 parser->m_protocolEncodingName = NULL;
1346 parser->m_protocolEncodingName = copyString(encodingName, &(parser->m_mem));
1347 if (! parser->m_protocolEncodingName)
1356 XML_Parser parser = oldParser;
1390 /* Note that the new parser shares the same hash secret as the old
1391 parser, so that dtdCopy and copyEntityTable can lookup values
1392 from hash tables associated with either parser without us having
1402 /* Stash the original parser contents on the stack */
1403 oldDtd = parser->m_dtd;
1404 oldStartElementHandler = parser->m_startElementHandler;
1405 oldEndElementHandler = parser->m_endElementHandler;
1406 oldCharacterDataHandler = parser->m_characterDataHandler;
1407 oldProcessingInstructionHandler = parser->m_processingInstructionHandler;
1408 oldCommentHandler = parser->m_commentHandler;
1409 oldStartCdataSectionHandler = parser->m_startCdataSectionHandler;
1410 oldEndCdataSectionHandler = parser->m_endCdataSectionHandler;
1411 oldDefaultHandler = parser->m_defaultHandler;
1412 oldUnparsedEntityDeclHandler = parser->m_unparsedEntityDeclHandler;
1413 oldNotationDeclHandler = parser->m_notationDeclHandler;
1414 oldStartNamespaceDeclHandler = parser->m_startNamespaceDeclHandler;
1415 oldEndNamespaceDeclHandler = parser->m_endNamespaceDeclHandler;
1416 oldNotStandaloneHandler = parser->m_notStandaloneHandler;
1417 oldExternalEntityRefHandler = parser->m_externalEntityRefHandler;
1418 oldSkippedEntityHandler = parser->m_skippedEntityHandler;
1419 oldUnknownEncodingHandler = parser->m_unknownEncodingHandler;
1420 oldElementDeclHandler = parser->m_elementDeclHandler;
1421 oldAttlistDeclHandler = parser->m_attlistDeclHandler;
1422 oldEntityDeclHandler = parser->m_entityDeclHandler;
1423 oldXmlDeclHandler = parser->m_xmlDeclHandler;
1424 oldDeclElementType = parser->m_declElementType;
1426 oldUserData = parser->m_userData;
1427 oldHandlerArg = parser->m_handlerArg;
1428 oldDefaultExpandInternalEntities = parser->m_defaultExpandInternalEntities;
1429 oldExternalEntityRefHandlerArg = parser->m_externalEntityRefHandlerArg;
1431 oldParamEntityParsing = parser->m_paramEntityParsing;
1432 oldInEntityValue = parser->m_prologState.inEntityValue;
1434 oldns_triplets = parser->m_ns_triplets;
1435 /* Note that the new parser shares the same hash secret as the old
1436 parser, so that dtdCopy and copyEntityTable can lookup values
1437 from hash tables associated with either parser without us having
1440 oldhash_secret_salt = parser->m_hash_secret_salt;
1441 oldReparseDeferralEnabled = parser->m_reparseDeferralEnabled;
1449 access look more like C++ require that `parser' be overwritten
1453 if (parser->m_ns) {
1454 XML_Char tmp[2] = {parser->m_namespaceSeparator, 0};
1455 parser = parserCreate(encodingName, &parser->m_mem, tmp, newDtd);
1457 parser = parserCreate(encodingName, &parser->m_mem, NULL, newDtd);
1460 if (! parser)
1463 parser->m_startElementHandler = oldStartElementHandler;
1464 parser->m_endElementHandler = oldEndElementHandler;
1465 parser->m_characterDataHandler = oldCharacterDataHandler;
1466 parser->m_processingInstructionHandler = oldProcessingInstructionHandler;
1467 parser->m_commentHandler = oldCommentHandler;
1468 parser->m_startCdataSectionHandler = oldStartCdataSectionHandler;
1469 parser->m_endCdataSectionHandler = oldEndCdataSectionHandler;
1470 parser->m_defaultHandler = oldDefaultHandler;
1471 parser->m_unparsedEntityDeclHandler = oldUnparsedEntityDeclHandler;
1472 parser->m_notationDeclHandler = oldNotationDeclHandler;
1473 parser->m_startNamespaceDeclHandler = oldStartNamespaceDeclHandler;
1474 parser->m_endNamespaceDeclHandler = oldEndNamespaceDeclHandler;
1475 parser->m_notStandaloneHandler = oldNotStandaloneHandler;
1476 parser->m_externalEntityRefHandler = oldExternalEntityRefHandler;
1477 parser->m_skippedEntityHandler = oldSkippedEntityHandler;
1478 parser->m_unknownEncodingHandler = oldUnknownEncodingHandler;
1479 parser->m_elementDeclHandler = oldElementDeclHandler;
1480 parser->m_attlistDeclHandler = oldAttlistDeclHandler;
1481 parser->m_entityDeclHandler = oldEntityDeclHandler;
1482 parser->m_xmlDeclHandler = oldXmlDeclHandler;
1483 parser->m_declElementType = oldDeclElementType;
1484 parser->m_userData = oldUserData;
1486 parser->m_handlerArg = parser->m_userData;
1488 parser->m_handlerArg = parser;
1490 parser->m_externalEntityRefHandlerArg = oldExternalEntityRefHandlerArg;
1491 parser->m_defaultExpandInternalEntities = oldDefaultExpandInternalEntities;
1492 parser->m_ns_triplets = oldns_triplets;
1493 parser->m_hash_secret_salt = oldhash_secret_salt;
1494 parser->m_reparseDeferralEnabled = oldReparseDeferralEnabled;
1495 parser->m_parentParser = oldParser;
1497 parser->m_paramEntityParsing = oldParamEntityParsing;
1498 parser->m_prologState.inEntityValue = oldInEntityValue;
1501 if (! dtdCopy(oldParser, parser->m_dtd, oldDtd, &parser->m_mem)
1502 || ! setContext(parser, context)) {
1503 XML_ParserFree(parser);
1506 parser->m_processor = externalEntityInitProcessor;
1509 /* The DTD instance referenced by parser->m_dtd is shared between the
1510 document's root parser and external PE parsers, therefore one does not
1513 pointers in parser->m_dtd with ones that get destroyed with the external
1514 PE parser. This would leave those prefixes with dangling pointers.
1516 parser->m_isParamEntity = XML_TRUE;
1517 XmlPrologStateInitExternalEntity(&parser->m_prologState);
1518 parser->m_processor = externalParEntInitProcessor;
1521 return parser;
1525 destroyBindings(BINDING *bindings, XML_Parser parser) {
1531 FREE(parser, b->uri);
1532 FREE(parser, b);
1537 XML_ParserFree(XML_Parser parser) {
1540 if (parser == NULL)
1543 tagList = parser->m_tagStack;
1547 if (parser->m_freeTagList == NULL)
1549 tagList = parser->m_freeTagList;
1550 parser->m_freeTagList = NULL;
1554 FREE(parser, p->buf);
1555 destroyBindings(p->bindings, parser);
1556 FREE(parser, p);
1559 entityList = parser->m_openInternalEntities;
1563 if (parser->m_freeInternalEntities == NULL)
1565 entityList = parser->m_freeInternalEntities;
1566 parser->m_freeInternalEntities = NULL;
1570 FREE(parser, openEntity);
1573 destroyBindings(parser->m_freeBindingList, parser);
1574 destroyBindings(parser->m_inheritedBindings, parser);
1575 poolDestroy(&parser->m_tempPool);
1576 poolDestroy(&parser->m_temp2Pool);
1577 FREE(parser, (void *)parser->m_protocolEncodingName);
1580 parser->m_dtd with the root parser, so we must not destroy it
1582 if (! parser->m_isParamEntity && parser->m_dtd)
1584 if (parser->m_dtd)
1586 dtdDestroy(parser->m_dtd, (XML_Bool)! parser->m_parentParser,
1587 &parser->m_mem);
1588 FREE(parser, (void *)parser->m_atts);
1590 FREE(parser, (void *)parser->m_attInfo);
1592 FREE(parser, parser->m_groupConnector);
1593 FREE(parser, parser->m_buffer);
1594 FREE(parser, parser->m_dataBuf);
1595 FREE(parser, parser->m_nsAtts);
1596 FREE(parser, parser->m_unknownEncodingMem);
1597 if (parser->m_unknownEncodingRelease)
1598 parser->m_unknownEncodingRelease(parser->m_unknownEncodingData);
1599 FREE(parser, parser);
1603 XML_UseParserAsHandlerArg(XML_Parser parser) {
1604 if (parser != NULL)
1605 parser->m_handlerArg = parser;
1609 XML_UseForeignDTD(XML_Parser parser, XML_Bool useDTD) {
1610 if (parser == NULL)
1614 if (parser->m_parsingStatus.parsing == XML_PARSING
1615 || parser->m_parsingStatus.parsing == XML_SUSPENDED)
1617 parser->m_useForeignDTD = useDTD;
1626 XML_SetReturnNSTriplet(XML_Parser parser, int do_nst) {
1627 if (parser == NULL)
1630 if (parser->m_parsingStatus.parsing == XML_PARSING
1631 || parser->m_parsingStatus.parsing == XML_SUSPENDED)
1633 parser->m_ns_triplets = do_nst ? XML_TRUE : XML_FALSE;
1637 XML_SetUserData(XML_Parser parser, void *p) {
1638 if (parser == NULL)
1640 if (parser->m_handlerArg == parser->m_userData)
1641 parser->m_handlerArg = parser->m_userData = p;
1643 parser->m_userData = p;
1647 XML_SetBase(XML_Parser parser, const XML_Char *p) {
1648 if (parser == NULL)
1651 p = poolCopyString(&parser->m_dtd->pool, p);
1654 parser->m_curBase = p;
1656 parser->m_curBase = NULL;
1661 XML_GetBase(XML_Parser parser) {
1662 if (parser == NULL)
1664 return parser->m_curBase;
1668 XML_GetSpecifiedAttributeCount(XML_Parser parser) {
1669 if (parser == NULL)
1671 return parser->m_nSpecifiedAtts;
1675 XML_GetIdAttributeIndex(XML_Parser parser) {
1676 if (parser == NULL)
1678 return parser->m_idAttIndex;
1683 XML_GetAttributeInfo(XML_Parser parser) {
1684 if (parser == NULL)
1686 return parser->m_attInfo;
1691 XML_SetElementHandler(XML_Parser parser, XML_StartElementHandler start,
1693 if (parser == NULL)
1695 parser->m_startElementHandler = start;
1696 parser->m_endElementHandler = end;
1700 XML_SetStartElementHandler(XML_Parser parser, XML_StartElementHandler start) {
1701 if (parser != NULL)
1702 parser->m_startElementHandler = start;
1706 XML_SetEndElementHandler(XML_Parser parser, XML_EndElementHandler end) {
1707 if (parser != NULL)
1708 parser->m_endElementHandler = end;
1712 XML_SetCharacterDataHandler(XML_Parser parser,
1714 if (parser != NULL)
1715 parser->m_characterDataHandler = handler;
1719 XML_SetProcessingInstructionHandler(XML_Parser parser,
1721 if (parser != NULL)
1722 parser->m_processingInstructionHandler = handler;
1726 XML_SetCommentHandler(XML_Parser parser, XML_CommentHandler handler) {
1727 if (parser != NULL)
1728 parser->m_commentHandler = handler;
1732 XML_SetCdataSectionHandler(XML_Parser parser,
1735 if (parser == NULL)
1737 parser->m_startCdataSectionHandler = start;
1738 parser->m_endCdataSectionHandler = end;
1742 XML_SetStartCdataSectionHandler(XML_Parser parser,
1744 if (parser != NULL)
1745 parser->m_startCdataSectionHandler = start;
1749 XML_SetEndCdataSectionHandler(XML_Parser parser,
1751 if (parser != NULL)
1752 parser->m_endCdataSectionHandler = end;
1756 XML_SetDefaultHandler(XML_Parser parser, XML_DefaultHandler handler) {
1757 if (parser == NULL)
1759 parser->m_defaultHandler = handler;
1760 parser->m_defaultExpandInternalEntities = XML_FALSE;
1764 XML_SetDefaultHandlerExpand(XML_Parser parser, XML_DefaultHandler handler) {
1765 if (parser == NULL)
1767 parser->m_defaultHandler = handler;
1768 parser->m_defaultExpandInternalEntities = XML_TRUE;
1772 XML_SetDoctypeDeclHandler(XML_Parser parser, XML_StartDoctypeDeclHandler start,
1774 if (parser == NULL)
1776 parser->m_startDoctypeDeclHandler = start;
1777 parser->m_endDoctypeDeclHandler = end;
1781 XML_SetStartDoctypeDeclHandler(XML_Parser parser,
1783 if (parser != NULL)
1784 parser->m_startDoctypeDeclHandler = start;
1788 XML_SetEndDoctypeDeclHandler(XML_Parser parser, XML_EndDoctypeDeclHandler end) {
1789 if (parser != NULL)
1790 parser->m_endDoctypeDeclHandler = end;
1794 XML_SetUnparsedEntityDeclHandler(XML_Parser parser,
1796 if (parser != NULL)
1797 parser->m_unparsedEntityDeclHandler = handler;
1801 XML_SetNotationDeclHandler(XML_Parser parser, XML_NotationDeclHandler handler) {
1802 if (parser != NULL)
1803 parser->m_notationDeclHandler = handler;
1807 XML_SetNamespaceDeclHandler(XML_Parser parser,
1810 if (parser == NULL)
1812 parser->m_startNamespaceDeclHandler = start;
1813 parser->m_endNamespaceDeclHandler = end;
1817 XML_SetStartNamespaceDeclHandler(XML_Parser parser,
1819 if (parser != NULL)
1820 parser->m_startNamespaceDeclHandler = start;
1824 XML_SetEndNamespaceDeclHandler(XML_Parser parser,
1826 if (parser != NULL)
1827 parser->m_endNamespaceDeclHandler = end;
1831 XML_SetNotStandaloneHandler(XML_Parser parser,
1833 if (parser != NULL)
1834 parser->m_notStandaloneHandler = handler;
1838 XML_SetExternalEntityRefHandler(XML_Parser parser,
1840 if (parser != NULL)
1841 parser->m_externalEntityRefHandler = handler;
1845 XML_SetExternalEntityRefHandlerArg(XML_Parser parser, void *arg) {
1846 if (parser == NULL)
1849 parser->m_externalEntityRefHandlerArg = (XML_Parser)arg;
1851 parser->m_externalEntityRefHandlerArg = parser;
1855 XML_SetSkippedEntityHandler(XML_Parser parser,
1857 if (parser != NULL)
1858 parser->m_skippedEntityHandler = handler;
1862 XML_SetUnknownEncodingHandler(XML_Parser parser,
1864 if (parser == NULL)
1866 parser->m_unknownEncodingHandler = handler;
1867 parser->m_unknownEncodingHandlerData = data;
1871 XML_SetElementDeclHandler(XML_Parser parser, XML_ElementDeclHandler eldecl) {
1872 if (parser != NULL)
1873 parser->m_elementDeclHandler = eldecl;
1877 XML_SetAttlistDeclHandler(XML_Parser parser, XML_AttlistDeclHandler attdecl) {
1878 if (parser != NULL)
1879 parser->m_attlistDeclHandler = attdecl;
1883 XML_SetEntityDeclHandler(XML_Parser parser, XML_EntityDeclHandler handler) {
1884 if (parser != NULL)
1885 parser->m_entityDeclHandler = handler;
1889 XML_SetXmlDeclHandler(XML_Parser parser, XML_XmlDeclHandler handler) {
1890 if (parser != NULL)
1891 parser->m_xmlDeclHandler = handler;
1895 XML_SetParamEntityParsing(XML_Parser parser,
1897 if (parser == NULL)
1900 if (parser->m_parsingStatus.parsing == XML_PARSING
1901 || parser->m_parsingStatus.parsing == XML_SUSPENDED)
1904 parser->m_paramEntityParsing = peParsing;
1912 XML_SetHashSalt(XML_Parser parser, unsigned long hash_salt) {
1913 if (parser == NULL)
1915 if (parser->m_parentParser)
1916 return XML_SetHashSalt(parser->m_parentParser, hash_salt);
1918 if (parser->m_parsingStatus.parsing == XML_PARSING
1919 || parser->m_parsingStatus.parsing == XML_SUSPENDED)
1921 parser->m_hash_secret_salt = hash_salt;
1926 XML_Parse(XML_Parser parser, const char *s, int len, int isFinal) {
1927 if ((parser == NULL) || (len < 0) || ((s == NULL) && (len != 0))) {
1928 if (parser != NULL)
1929 parser->m_errorCode = XML_ERROR_INVALID_ARGUMENT;
1932 switch (parser->m_parsingStatus.parsing) {
1934 parser->m_errorCode = XML_ERROR_SUSPENDED;
1937 parser->m_errorCode = XML_ERROR_FINISHED;
1940 if (parser->m_parentParser == NULL && ! startParsing(parser)) {
1941 parser->m_errorCode = XML_ERROR_NO_MEMORY;
1946 parser->m_parsingStatus.parsing = XML_PARSING;
1950 if (parser->m_bufferPtr == parser->m_bufferEnd) {
1955 if ((XML_Size)len > ((XML_Size)-1) / 2 - parser->m_parseEndByteIndex) {
1956 parser->m_errorCode = XML_ERROR_NO_MEMORY;
1957 parser->m_eventPtr = parser->m_eventEndPtr = NULL;
1958 parser->m_processor = errorProcessor;
1963 parser->m_lastBufferRequestSize = len;
1964 parser->m_parseEndByteIndex += len;
1965 parser->m_positionPtr = s;
1966 parser->m_parsingStatus.finalBuffer = (XML_Bool)isFinal;
1968 parser->m_errorCode
1969 = callProcessor(parser, s, parser->m_parseEndPtr = s + len, &end);
1971 if (parser->m_errorCode != XML_ERROR_NONE) {
1972 parser->m_eventEndPtr = parser->m_eventPtr;
1973 parser->m_processor = errorProcessor;
1976 switch (parser->m_parsingStatus.parsing) {
1983 parser->m_parsingStatus.parsing = XML_FINISHED;
1992 XmlUpdatePosition(parser->m_encoding, parser->m_positionPtr, end,
1993 &parser->m_position);
1998 const enum XML_Parsing originalStatus = parser->m_parsingStatus.parsing;
1999 parser->m_parsingStatus.parsing = XML_PARSING;
2000 void *const temp = XML_GetBuffer(parser, nLeftOver);
2001 parser->m_parsingStatus.parsing = originalStatus;
2004 parser->m_lastBufferRequestSize = len;
2006 // NOTE: parser->m_errorCode has already been set by XML_GetBuffer().
2007 parser->m_eventPtr = parser->m_eventEndPtr = NULL;
2008 parser->m_processor = errorProcessor;
2015 memcpy(parser->m_buffer, end, nLeftOver);
2017 parser->m_bufferPtr = parser->m_buffer;
2018 parser->m_bufferEnd = parser->m_buffer + nLeftOver;
2019 parser->m_positionPtr = parser->m_bufferPtr;
2020 parser->m_parseEndPtr = parser->m_bufferEnd;
2021 parser->m_eventPtr = parser->m_bufferPtr;
2022 parser->m_eventEndPtr = parser->m_bufferPtr;
2026 void *buff = XML_GetBuffer(parser, len);
2033 return XML_ParseBuffer(parser, len, isFinal);
2037 XML_ParseBuffer(XML_Parser parser, int len, int isFinal) {
2041 if (parser == NULL)
2045 parser->m_errorCode = XML_ERROR_INVALID_ARGUMENT;
2049 switch (parser->m_parsingStatus.parsing) {
2051 parser->m_errorCode = XML_ERROR_SUSPENDED;
2054 parser->m_errorCode = XML_ERROR_FINISHED;
2058 if (! parser->m_bufferPtr) {
2059 parser->m_errorCode = XML_ERROR_NO_BUFFER;
2063 if (parser->m_parentParser == NULL && ! startParsing(parser)) {
2064 parser->m_errorCode = XML_ERROR_NO_MEMORY;
2069 parser->m_parsingStatus.parsing = XML_PARSING;
2072 start = parser->m_bufferPtr;
2073 parser->m_positionPtr = start;
2074 parser->m_bufferEnd += len;
2075 parser->m_parseEndPtr = parser->m_bufferEnd;
2076 parser->m_parseEndByteIndex += len;
2077 parser->m_parsingStatus.finalBuffer = (XML_Bool)isFinal;
2079 parser->m_errorCode = callProcessor(parser, start, parser->m_parseEndPtr,
2080 &parser->m_bufferPtr);
2082 if (parser->m_errorCode != XML_ERROR_NONE) {
2083 parser->m_eventEndPtr = parser->m_eventPtr;
2084 parser->m_processor = errorProcessor;
2087 switch (parser->m_parsingStatus.parsing) {
2094 parser->m_parsingStatus.parsing = XML_FINISHED;
2101 XmlUpdatePosition(parser->m_encoding, parser->m_positionPtr,
2102 parser->m_bufferPtr, &parser->m_position);
2103 parser->m_positionPtr = parser->m_bufferPtr;
2108 XML_GetBuffer(XML_Parser parser, int len) {
2109 if (parser == NULL)
2112 parser->m_errorCode = XML_ERROR_NO_MEMORY;
2115 switch (parser->m_parsingStatus.parsing) {
2117 parser->m_errorCode = XML_ERROR_SUSPENDED;
2120 parser->m_errorCode = XML_ERROR_FINISHED;
2127 parser->m_lastBufferRequestSize = len;
2128 if (len > EXPAT_SAFE_PTR_DIFF(parser->m_bufferLim, parser->m_bufferEnd)
2129 || parser->m_buffer == NULL) {
2136 parser->m_bufferEnd, parser->m_bufferPtr));
2138 parser->m_errorCode = XML_ERROR_NO_MEMORY;
2142 keep = (int)EXPAT_SAFE_PTR_DIFF(parser->m_bufferPtr, parser->m_buffer);
2147 parser->m_errorCode = XML_ERROR_NO_MEMORY;
2152 if (parser->m_buffer && parser->m_bufferPtr
2154 <= EXPAT_SAFE_PTR_DIFF(parser->m_bufferLim, parser->m_buffer)) {
2156 if (keep < EXPAT_SAFE_PTR_DIFF(parser->m_bufferPtr, parser->m_buffer)) {
2158 = (int)EXPAT_SAFE_PTR_DIFF(parser->m_bufferPtr, parser->m_buffer)
2162 memmove(parser->m_buffer, &parser->m_buffer[offset],
2163 parser->m_bufferEnd - parser->m_bufferPtr + keep);
2164 parser->m_bufferEnd -= offset;
2165 parser->m_bufferPtr -= offset;
2168 memmove(parser->m_buffer, parser->m_bufferPtr,
2169 EXPAT_SAFE_PTR_DIFF(parser->m_bufferEnd, parser->m_bufferPtr));
2170 parser->m_bufferEnd
2171 = parser->m_buffer
2172 + EXPAT_SAFE_PTR_DIFF(parser->m_bufferEnd, parser->m_bufferPtr);
2173 parser->m_bufferPtr = parser->m_buffer;
2178 = (int)EXPAT_SAFE_PTR_DIFF(parser->m_bufferLim, parser->m_buffer);
2186 parser->m_errorCode = XML_ERROR_NO_MEMORY;
2189 newBuf = (char *)MALLOC(parser, bufferSize);
2191 parser->m_errorCode = XML_ERROR_NO_MEMORY;
2194 parser->m_bufferLim = newBuf + bufferSize;
2196 if (parser->m_bufferPtr) {
2197 memcpy(newBuf, &parser->m_bufferPtr[-keep],
2198 EXPAT_SAFE_PTR_DIFF(parser->m_bufferEnd, parser->m_bufferPtr)
2200 FREE(parser, parser->m_buffer);
2201 parser->m_buffer = newBuf;
2202 parser->m_bufferEnd
2203 = parser->m_buffer
2204 + EXPAT_SAFE_PTR_DIFF(parser->m_bufferEnd, parser->m_bufferPtr)
2206 parser->m_bufferPtr = parser->m_buffer + keep;
2209 parser->m_bufferEnd = newBuf;
2210 parser->m_bufferPtr = parser->m_buffer = newBuf;
2213 if (parser->m_bufferPtr) {
2214 memcpy(newBuf, parser->m_bufferPtr,
2215 EXPAT_SAFE_PTR_DIFF(parser->m_bufferEnd, parser->m_bufferPtr));
2216 FREE(parser, parser->m_buffer);
2217 parser->m_bufferEnd
2219 + EXPAT_SAFE_PTR_DIFF(parser->m_bufferEnd, parser->m_bufferPtr);
2222 parser->m_bufferEnd = newBuf;
2224 parser->m_bufferPtr = parser->m_buffer = newBuf;
2227 parser->m_eventPtr = parser->m_eventEndPtr = NULL;
2228 parser->m_positionPtr = NULL;
2230 return parser->m_bufferEnd;
2234 XML_StopParser(XML_Parser parser, XML_Bool resumable) {
2235 if (parser == NULL)
2237 switch (parser->m_parsingStatus.parsing) {
2239 parser->m_errorCode = XML_ERROR_NOT_STARTED;
2243 parser->m_errorCode = XML_ERROR_SUSPENDED;
2246 parser->m_parsingStatus.parsing = XML_FINISHED;
2249 parser->m_errorCode = XML_ERROR_FINISHED;
2254 if (parser->m_isParamEntity) {
2255 parser->m_errorCode = XML_ERROR_SUSPEND_PE;
2259 parser->m_parsingStatus.parsing = XML_SUSPENDED;
2261 parser->m_parsingStatus.parsing = XML_FINISHED;
2270 XML_ResumeParser(XML_Parser parser) {
2273 if (parser == NULL)
2275 if (parser->m_parsingStatus.parsing != XML_SUSPENDED) {
2276 parser->m_errorCode = XML_ERROR_NOT_SUSPENDED;
2279 parser->m_parsingStatus.parsing = XML_PARSING;
2281 parser->m_errorCode = callProcessor(
2282 parser, parser->m_bufferPtr, parser->m_parseEndPtr, &parser->m_bufferPtr);
2284 if (parser->m_errorCode != XML_ERROR_NONE) {
2285 parser->m_eventEndPtr = parser->m_eventPtr;
2286 parser->m_processor = errorProcessor;
2289 switch (parser->m_parsingStatus.parsing) {
2295 if (parser->m_parsingStatus.finalBuffer) {
2296 parser->m_parsingStatus.parsing = XML_FINISHED;
2303 XmlUpdatePosition(parser->m_encoding, parser->m_positionPtr,
2304 parser->m_bufferPtr, &parser->m_position);
2305 parser->m_positionPtr = parser->m_bufferPtr;
2310 XML_GetParsingStatus(XML_Parser parser, XML_ParsingStatus *status) {
2311 if (parser == NULL)
2314 *status = parser->m_parsingStatus;
2318 XML_GetErrorCode(XML_Parser parser) {
2319 if (parser == NULL)
2321 return parser->m_errorCode;
2325 XML_GetCurrentByteIndex(XML_Parser parser) {
2326 if (parser == NULL)
2328 if (parser->m_eventPtr)
2329 return (XML_Index)(parser->m_parseEndByteIndex
2330 - (parser->m_parseEndPtr - parser->m_eventPtr));
2335 XML_GetCurrentByteCount(XML_Parser parser) {
2336 if (parser == NULL)
2338 if (parser->m_eventEndPtr && parser->m_eventPtr)
2339 return (int)(parser->m_eventEndPtr - parser->m_eventPtr);
2344 XML_GetInputContext(XML_Parser parser, int *offset, int *size) {
2346 if (parser == NULL)
2348 if (parser->m_eventPtr && parser->m_buffer) {
2350 *offset = (int)(parser->m_eventPtr - parser->m_buffer);
2352 *size = (int)(parser->m_bufferEnd - parser->m_buffer);
2353 return parser->m_buffer;
2356 (void)parser;
2364 XML_GetCurrentLineNumber(XML_Parser parser) {
2365 if (parser == NULL)
2367 if (parser->m_eventPtr && parser->m_eventPtr >= parser->m_positionPtr) {
2368 XmlUpdatePosition(parser->m_encoding, parser->m_positionPtr,
2369 parser->m_eventPtr, &parser->m_position);
2370 parser->m_positionPtr = parser->m_eventPtr;
2372 return parser->m_position.lineNumber + 1;
2376 XML_GetCurrentColumnNumber(XML_Parser parser) {
2377 if (parser == NULL)
2379 if (parser->m_eventPtr && parser->m_eventPtr >= parser->m_positionPtr) {
2380 XmlUpdatePosition(parser->m_encoding, parser->m_positionPtr,
2381 parser->m_eventPtr, &parser->m_position);
2382 parser->m_positionPtr = parser->m_eventPtr;
2384 return parser->m_position.columnNumber;
2388 XML_FreeContentModel(XML_Parser parser, XML_Content *model) {
2389 if (parser != NULL)
2390 FREE(parser, model);
2394 XML_MemMalloc(XML_Parser parser, size_t size) {
2395 if (parser == NULL)
2397 return MALLOC(parser, size);
2401 XML_MemRealloc(XML_Parser parser, void *ptr, size_t size) {
2402 if (parser == NULL)
2404 return REALLOC(parser, ptr, size);
2408 XML_MemFree(XML_Parser parser, void *ptr) {
2409 if (parser != NULL)
2410 FREE(parser, ptr);
2414 XML_DefaultCurrent(XML_Parser parser) {
2415 if (parser == NULL)
2417 if (parser->m_defaultHandler) {
2418 if (parser->m_openInternalEntities)
2419 reportDefault(parser, parser->m_internalEncoding,
2420 parser->m_openInternalEntities->internalEventPtr,
2421 parser->m_openInternalEntities->internalEventEndPtr);
2423 reportDefault(parser, parser->m_encoding, parser->m_eventPtr,
2424 parser->m_eventEndPtr);
2478 return XML_L("unexpected parser state - please send a bug report");
2500 return XML_L("parser suspended");
2502 return XML_L("parser not suspended");
2531 return XML_L("parser not started");
2619 XML_Parser parser, float maximumAmplificationFactor) {
2620 if ((parser == NULL) || (parser->m_parentParser != NULL)
2625 parser->m_accounting.maximumAmplificationFactor = maximumAmplificationFactor;
2631 XML_Parser parser, unsigned long long activationThresholdBytes) {
2632 if ((parser == NULL) || (parser->m_parentParser != NULL)) {
2635 parser->m_accounting.activationThresholdBytes = activationThresholdBytes;
2641 XML_SetReparseDeferralEnabled(XML_Parser parser, XML_Bool enabled) {
2642 if (parser != NULL && (enabled == XML_TRUE || enabled == XML_FALSE)) {
2643 parser->m_reparseDeferralEnabled = enabled;
2655 storeRawNames(XML_Parser parser) {
2656 TAG *tag = parser->m_tagStack;
2678 char *temp = (char *)REALLOC(parser, tag->buf, bufSize);
2704 contentProcessor(XML_Parser parser, const char *start, const char *end,
2707 parser, 0, parser->m_encoding, start, end, endPtr,
2708 (XML_Bool)! parser->m_parsingStatus.finalBuffer, XML_ACCOUNT_DIRECT);
2710 if (! storeRawNames(parser))
2717 externalEntityInitProcessor(XML_Parser parser, const char *start,
2719 enum XML_Error result = initializeEncoding(parser);
2722 parser->m_processor = externalEntityInitProcessor2;
2723 return externalEntityInitProcessor2(parser, start, end, endPtr);
2727 externalEntityInitProcessor2(XML_Parser parser, const char *start,
2730 int tok = XmlContentTok(parser->m_encoding, start, end, &next);
2734 if (! accountingDiffTolerated(parser, tok, start, next, __LINE__,
2736 accountingOnAbort(parser);
2746 if (next == end && ! parser->m_parsingStatus.finalBuffer) {
2753 if (! parser->m_parsingStatus.finalBuffer) {
2757 parser->m_eventPtr = start;
2760 if (! parser->m_parsingStatus.finalBuffer) {
2764 parser->m_eventPtr = start;
2767 parser->m_processor = externalEntityInitProcessor3;
2768 return externalEntityInitProcessor3(parser, start, end, endPtr);
2772 externalEntityInitProcessor3(XML_Parser parser, const char *start,
2776 parser->m_eventPtr = start;
2777 tok = XmlContentTok(parser->m_encoding, start, end, &next);
2782 parser->m_eventEndPtr = next;
2787 result = processXmlDecl(parser, 1, start, next);
2790 switch (parser->m_parsingStatus.parsing) {
2801 if (! parser->m_parsingStatus.finalBuffer) {
2807 if (! parser->m_parsingStatus.finalBuffer) {
2813 parser->m_processor = externalEntityContentProcessor;
2814 parser->m_tagLevel = 1;
2815 return externalEntityContentProcessor(parser, start, end, endPtr);
2819 externalEntityContentProcessor(XML_Parser parser, const char *start,
2822 = doContent(parser, 1, parser->m_encoding, start, end, endPtr,
2823 (XML_Bool)! parser->m_parsingStatus.finalBuffer,
2826 if (! storeRawNames(parser))
2833 doContent(XML_Parser parser, int startTagLevel, const ENCODING *enc,
2837 DTD *const dtd = parser->m_dtd;
2841 if (enc == parser->m_encoding) {
2842 eventPP = &parser->m_eventPtr;
2843 eventEndPP = &parser->m_eventEndPtr;
2845 eventPP = &(parser->m_openInternalEntities->internalEventPtr);
2846 eventEndPP = &(parser->m_openInternalEntities->internalEventEndPtr);
2858 if (! accountingDiffTolerated(parser, tok, s, accountAfter, __LINE__,
2860 accountingOnAbort(parser);
2872 if (parser->m_characterDataHandler) {
2874 parser->m_characterDataHandler(parser->m_handlerArg, &c, 1);
2875 } else if (parser->m_defaultHandler)
2876 reportDefault(parser, enc, s, end);
2882 if (parser->m_tagLevel != startTagLevel)
2892 if (parser->m_tagLevel != startTagLevel)
2923 accountingDiffTolerated(parser, tok, (char *)&ch,
2927 if (parser->m_characterDataHandler)
2928 parser->m_characterDataHandler(parser->m_handlerArg, &ch, 1);
2929 else if (parser->m_defaultHandler)
2930 reportDefault(parser, enc, s, next);
2937 entity = (ENTITY *)lookup(parser, &dtd->generalEntities, name, 0);
2949 if (parser->m_skippedEntityHandler)
2950 parser->m_skippedEntityHandler(parser->m_handlerArg, name, 0);
2951 else if (parser->m_defaultHandler)
2952 reportDefault(parser, enc, s, next);
2961 if (! parser->m_defaultExpandInternalEntities) {
2962 if (parser->m_skippedEntityHandler)
2963 parser->m_skippedEntityHandler(parser->m_handlerArg, entity->name,
2965 else if (parser->m_defaultHandler)
2966 reportDefault(parser, enc, s, next);
2969 result = processInternalEntity(parser, entity, XML_FALSE);
2972 } else if (parser->m_externalEntityRefHandler) {
2975 context = getContext(parser);
2979 if (! parser->m_externalEntityRefHandler(
2980 parser->m_externalEntityRefHandlerArg, context, entity->base,
2983 poolDiscard(&parser->m_tempPool);
2984 } else if (parser->m_defaultHandler)
2985 reportDefault(parser, enc, s, next);
2994 if (parser->m_freeTagList) {
2995 tag = parser->m_freeTagList;
2996 parser->m_freeTagList = parser->m_freeTagList->parent;
2998 tag = (TAG *)MALLOC(parser, sizeof(TAG));
3001 tag->buf = (char *)MALLOC(parser, INIT_TAG_BUF_SIZE);
3003 FREE(parser, tag);
3009 tag->parent = parser->m_tagStack;
3010 parser->m_tagStack = tag;
3015 ++parser->m_tagLevel;
3034 char *temp = (char *)REALLOC(parser, tag->buf, bufSize);
3046 = storeAtts(parser, enc, s, &(tag->name), &(tag->bindings), account);
3049 if (parser->m_startElementHandler)
3050 parser->m_startElementHandler(parser->m_handlerArg, tag->name.str,
3051 (const XML_Char **)parser->m_atts);
3052 else if (parser->m_defaultHandler)
3053 reportDefault(parser, enc, s, next);
3054 poolClear(&parser->m_tempPool);
3065 name.str = poolStoreString(&parser->m_tempPool, enc, rawName,
3069 poolFinish(&parser->m_tempPool);
3070 result = storeAtts(parser, enc, s, &name, &bindings,
3073 freeBindings(parser, bindings);
3076 poolFinish(&parser->m_tempPool);
3077 if (parser->m_startElementHandler) {
3078 parser->m_startElementHandler(parser->m_handlerArg, name.str,
3079 (const XML_Char **)parser->m_atts);
3082 if (parser->m_endElementHandler) {
3083 if (parser->m_startElementHandler)
3085 parser->m_endElementHandler(parser->m_handlerArg, name.str);
3088 if (noElmHandlers && parser->m_defaultHandler)
3089 reportDefault(parser, enc, s, next);
3090 poolClear(&parser->m_tempPool);
3091 freeBindings(parser, bindings);
3093 if ((parser->m_tagLevel == 0)
3094 && (parser->m_parsingStatus.parsing != XML_FINISHED)) {
3095 if (parser->m_parsingStatus.parsing == XML_SUSPENDED)
3096 parser->m_processor = epilogProcessor;
3098 return epilogProcessor(parser, next, end, nextPtr);
3102 if (parser->m_tagLevel == startTagLevel)
3107 TAG *tag = parser->m_tagStack;
3115 parser->m_tagStack = tag->parent;
3116 tag->parent = parser->m_freeTagList;
3117 parser->m_freeTagList = tag;
3118 --parser->m_tagLevel;
3119 if (parser->m_endElementHandler) {
3124 if (parser->m_ns && localPart) {
3134 if (parser->m_ns_triplets && prefix) {
3135 *uri++ = parser->m_namespaceSeparator;
3141 parser->m_endElementHandler(parser->m_handlerArg, tag->name.str);
3142 } else if (parser->m_defaultHandler)
3143 reportDefault(parser, enc, s, next);
3146 if (parser->m_endNamespaceDeclHandler)
3147 parser->m_endNamespaceDeclHandler(parser->m_handlerArg,
3150 b->nextTagBinding = parser->m_freeBindingList;
3151 parser->m_freeBindingList = b;
3154 if ((parser->m_tagLevel == 0)
3155 && (parser->m_parsingStatus.parsing != XML_FINISHED)) {
3156 if (parser->m_parsingStatus.parsing == XML_SUSPENDED)
3157 parser->m_processor = epilogProcessor;
3159 return epilogProcessor(parser, next, end, nextPtr);
3167 if (parser->m_characterDataHandler) {
3169 parser->m_characterDataHandler(parser->m_handlerArg, buf,
3171 } else if (parser->m_defaultHandler)
3172 reportDefault(parser, enc, s, next);
3177 if (parser->m_characterDataHandler) {
3179 parser->m_characterDataHandler(parser->m_handlerArg, &c, 1);
3180 } else if (parser->m_defaultHandler)
3181 reportDefault(parser, enc, s, next);
3185 if (parser->m_startCdataSectionHandler)
3186 parser->m_startCdataSectionHandler(parser->m_handlerArg);
3200 else if ((0) && parser->m_characterDataHandler)
3201 parser->m_characterDataHandler(parser->m_handlerArg, parser->m_dataBuf,
3204 else if (parser->m_defaultHandler)
3205 reportDefault(parser, enc, s, next);
3207 = doCdataSection(parser, enc, &next, end, nextPtr, haveMore, account);
3211 parser->m_processor = cdataSectionProcessor;
3220 if (parser->m_characterDataHandler) {
3222 ICHAR *dataPtr = (ICHAR *)parser->m_dataBuf;
3223 XmlConvert(enc, &s, end, &dataPtr, (ICHAR *)parser->m_dataBufEnd);
3224 parser->m_characterDataHandler(
3225 parser->m_handlerArg, parser->m_dataBuf,
3226 (int)(dataPtr - (ICHAR *)parser->m_dataBuf));
3228 parser->m_characterDataHandler(
3229 parser->m_handlerArg, (const XML_Char *)s,
3231 } else if (parser->m_defaultHandler)
3232 reportDefault(parser, enc, s, end);
3240 if (parser->m_tagLevel != startTagLevel) {
3247 XML_CharacterDataHandler charDataHandler = parser->m_characterDataHandler;
3251 ICHAR *dataPtr = (ICHAR *)parser->m_dataBuf;
3253 enc, &s, next, &dataPtr, (ICHAR *)parser->m_dataBufEnd);
3255 charDataHandler(parser->m_handlerArg, parser->m_dataBuf,
3256 (int)(dataPtr - (ICHAR *)parser->m_dataBuf));
3263 charDataHandler(parser->m_handlerArg, (const XML_Char *)s,
3265 } else if (parser->m_defaultHandler)
3266 reportDefault(parser, enc, s, next);
3269 if (! reportProcessingInstruction(parser, enc, s, next))
3273 if (! reportComment(parser, enc, s, next))
3284 if (parser->m_defaultHandler)
3285 reportDefault(parser, enc, s, next);
3290 switch (parser->m_parsingStatus.parsing) {
3303 * moving it to the parser's m_freeBindingList where it can be freed or
3307 freeBindings(XML_Parser parser, BINDING *bindings) {
3314 if (parser->m_endNamespaceDeclHandler)
3315 parser->m_endNamespaceDeclHandler(parser->m_handlerArg, b->prefix->name);
3318 b->nextTagBinding = parser->m_freeBindingList;
3319 parser->m_freeBindingList = b;
3335 storeAtts(XML_Parser parser, const ENCODING *enc, const char *attStr,
3338 DTD *const dtd = parser->m_dtd; /* save one level of indirection */
3353 = (ELEMENT_TYPE *)lookup(parser, &dtd->elementTypes, tagNamePtr->str, 0);
3358 elementType = (ELEMENT_TYPE *)lookup(parser, &dtd->elementTypes, name,
3362 if (parser->m_ns && ! setElementTypePrefix(parser, elementType))
3368 n = XmlGetAttributes(enc, attStr, parser->m_attsSize, parser->m_atts);
3375 if (n + nDefaultAtts > parser->m_attsSize) {
3376 int oldAttsSize = parser->m_attsSize;
3388 parser->m_attsSize = n + nDefaultAtts + INIT_ATTS_SIZE;
3395 if ((unsigned)parser->m_attsSize > (size_t)(-1) / sizeof(ATTRIBUTE)) {
3396 parser->m_attsSize = oldAttsSize;
3401 temp = (ATTRIBUTE *)REALLOC(parser, (void *)parser->m_atts,
3402 parser->m_attsSize * sizeof(ATTRIBUTE));
3404 parser->m_attsSize = oldAttsSize;
3407 parser->m_atts = temp;
3414 if ((unsigned)parser->m_attsSize > (size_t)(-1) / sizeof(XML_AttrInfo)) {
3415 parser->m_attsSize = oldAttsSize;
3420 temp2 = (XML_AttrInfo *)REALLOC(parser, (void *)parser->m_attInfo,
3421 parser->m_attsSize * sizeof(XML_AttrInfo));
3423 parser->m_attsSize = oldAttsSize;
3426 parser->m_attInfo = temp2;
3429 XmlGetAttributes(enc, attStr, n, parser->m_atts);
3432 appAtts = (const XML_Char **)parser->m_atts;
3434 ATTRIBUTE *currAtt = &parser->m_atts[i];
3436 XML_AttrInfo *currAttInfo = &parser->m_attInfo[i];
3440 = getAttributeId(parser, enc, currAtt->name,
3446 = parser->m_parseEndByteIndex - (parser->m_parseEndPtr - currAtt->name);
3449 currAttInfo->valueStart = parser->m_parseEndByteIndex
3450 - (parser->m_parseEndPtr - currAtt->valuePtr);
3451 currAttInfo->valueEnd = parser->m_parseEndByteIndex
3452 - (parser->m_parseEndPtr - currAtt->valueEnd);
3459 if (enc == parser->m_encoding)
3460 parser->m_eventPtr = parser->m_atts[i].name;
3465 if (! parser->m_atts[i].normalized) {
3482 parser, enc, isCdata, parser->m_atts[i].valuePtr,
3483 parser->m_atts[i].valueEnd, &parser->m_tempPool, account);
3486 appAtts[attIndex] = poolStart(&parser->m_tempPool);
3487 poolFinish(&parser->m_tempPool);
3490 appAtts[attIndex] = poolStoreString(&parser->m_tempPool, enc,
3491 parser->m_atts[i].valuePtr,
3492 parser->m_atts[i].valueEnd);
3495 poolFinish(&parser->m_tempPool);
3501 enum XML_Error result = addBinding(parser, attId->prefix, attId,
3517 parser->m_nSpecifiedAtts = attIndex;
3521 parser->m_idAttIndex = i;
3525 parser->m_idAttIndex = -1;
3533 enum XML_Error result = addBinding(parser, da->id->prefix, da->id,
3557 unsigned long version = parser->m_nsAttsVersion;
3560 if (parser->m_nsAttsPower >= sizeof(unsigned int) * 8 /* bits per byte */) {
3564 unsigned int nsAttsSize = 1u << parser->m_nsAttsPower;
3565 unsigned char oldNsAttsPower = parser->m_nsAttsPower;
3568 >> parser->m_nsAttsPower) { /* true for m_nsAttsPower = 0 */
3571 while (nPrefixes >> parser->m_nsAttsPower++)
3573 if (parser->m_nsAttsPower < 3)
3574 parser->m_nsAttsPower = 3;
3577 if (parser->m_nsAttsPower >= sizeof(nsAttsSize) * 8 /* bits per byte */) {
3579 parser->m_nsAttsPower = oldNsAttsPower;
3583 nsAttsSize = 1u << parser->m_nsAttsPower;
3592 parser->m_nsAttsPower = oldNsAttsPower;
3597 temp = (NS_ATT *)REALLOC(parser, parser->m_nsAtts,
3601 parser->m_nsAttsPower = oldNsAttsPower;
3604 parser->m_nsAtts = temp;
3611 parser->m_nsAtts[--j].version = version;
3613 parser->m_nsAttsVersion = --version;
3625 copy_salt_to_sipkey(parser, &sip_key);
3629 id = (ATTRIBUTE_ID *)lookup(parser, &dtd->attributeIds, s, 0);
3653 if (! poolAppendChar(&parser->m_tempPool, c))
3665 if (! poolAppendChar(&parser->m_tempPool, *s))
3672 Derived from code in lookup(parser, HASH_TABLE *table, ...).
3677 while (parser->m_nsAtts[j].version == version) {
3679 if (uriHash == parser->m_nsAtts[j].hash) {
3680 const XML_Char *s1 = poolStart(&parser->m_tempPool);
3681 const XML_Char *s2 = parser->m_nsAtts[j].uriName;
3689 step = PROBE_STEP(uriHash, mask, parser->m_nsAttsPower);
3694 if (parser->m_ns_triplets) { /* append namespace separator and prefix */
3695 parser->m_tempPool.ptr[-1] = parser->m_namespaceSeparator;
3698 if (! poolAppendChar(&parser->m_tempPool, *s))
3704 s = poolStart(&parser->m_tempPool);
3705 poolFinish(&parser->m_tempPool);
3709 parser->m_nsAtts[j].version = version;
3710 parser->m_nsAtts[j].hash = uriHash;
3711 parser->m_nsAtts[j].uriName = s;
3727 if (! parser->m_ns)
3744 if (parser->m_ns_triplets && binding->prefix->name) {
3779 uri = (XML_Char *)MALLOC(parser, (n + EXPAND_SPARE) * sizeof(XML_Char));
3784 for (p = parser->m_tagStack; p; p = p->parent)
3787 FREE(parser, binding->uri);
3796 *uri = parser->m_namespaceSeparator; /* replace null terminator */
3918 addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId,
3990 if (parser->m_ns && (uri[len] == parser->m_namespaceSeparator)
4005 if (parser->m_namespaceSeparator)
4007 if (parser->m_freeBindingList) {
4008 b = parser->m_freeBindingList;
4026 parser, b->uri, sizeof(XML_Char) * (len + EXPAND_SPARE));
4032 parser->m_freeBindingList = b->nextTagBinding;
4034 b = (BINDING *)MALLOC(parser, sizeof(BINDING));
4053 = (XML_Char *)MALLOC(parser, sizeof(XML_Char) * (len + EXPAND_SPARE));
4055 FREE(parser, b);
4062 if (parser->m_namespaceSeparator)
4063 b->uri[len - 1] = parser->m_namespaceSeparator;
4068 if (*uri == XML_T('\0') && prefix == &parser->m_dtd->defaultPrefix)
4075 if (attId && parser->m_startNamespaceDeclHandler)
4076 parser->m_startNamespaceDeclHandler(parser->m_handlerArg, prefix->name,
4085 cdataSectionProcessor(XML_Parser parser, const char *start, const char *end,
4088 parser, parser->m_encoding, &start, end, endPtr,
4089 (XML_Bool)! parser->m_parsingStatus.finalBuffer, XML_ACCOUNT_DIRECT);
4093 if (parser->m_parentParser) { /* we are parsing an external entity */
4094 parser->m_processor = externalEntityContentProcessor;
4095 return externalEntityContentProcessor(parser, start, end, endPtr);
4097 parser->m_processor = contentProcessor;
4098 return contentProcessor(parser, start, end, endPtr);
4108 doCdataSection(XML_Parser parser, const ENCODING *enc, const char **startPtr,
4114 if (enc == parser->m_encoding) {
4115 eventPP = &parser->m_eventPtr;
4117 eventEndPP = &parser->m_eventEndPtr;
4119 eventPP = &(parser->m_openInternalEntities->internalEventPtr);
4120 eventEndPP = &(parser->m_openInternalEntities->internalEventEndPtr);
4129 if (! accountingDiffTolerated(parser, tok, s, next, __LINE__, account)) {
4130 accountingOnAbort(parser);
4139 if (parser->m_endCdataSectionHandler)
4140 parser->m_endCdataSectionHandler(parser->m_handlerArg);
4143 else if ((0) && parser->m_characterDataHandler)
4144 parser->m_characterDataHandler(parser->m_handlerArg, parser->m_dataBuf,
4147 else if (parser->m_defaultHandler)
4148 reportDefault(parser, enc, s, next);
4151 if (parser->m_parsingStatus.parsing == XML_FINISHED)
4156 if (parser->m_characterDataHandler) {
4158 parser->m_characterDataHandler(parser->m_handlerArg, &c, 1);
4159 } else if (parser->m_defaultHandler)
4160 reportDefault(parser, enc, s, next);
4163 XML_CharacterDataHandler charDataHandler = parser->m_characterDataHandler;
4167 ICHAR *dataPtr = (ICHAR *)parser->m_dataBuf;
4169 enc, &s, next, &dataPtr, (ICHAR *)parser->m_dataBufEnd);
4171 charDataHandler(parser->m_handlerArg, parser->m_dataBuf,
4172 (int)(dataPtr - (ICHAR *)parser->m_dataBuf));
4179 charDataHandler(parser->m_handlerArg, (const XML_Char *)s,
4181 } else if (parser->m_defaultHandler)
4182 reportDefault(parser, enc, s, next);
4214 switch (parser->m_parsingStatus.parsing) {
4232 ignoreSectionProcessor(XML_Parser parser, const char *start, const char *end,
4235 = doIgnoreSection(parser, parser->m_encoding, &start, end, endPtr,
4236 (XML_Bool)! parser->m_parsingStatus.finalBuffer);
4240 parser->m_processor = prologProcessor;
4241 return prologProcessor(parser, start, end, endPtr);
4250 doIgnoreSection(XML_Parser parser, const ENCODING *enc, const char **startPtr,
4257 if (enc == parser->m_encoding) {
4258 eventPP = &parser->m_eventPtr;
4260 eventEndPP = &parser->m_eventEndPtr;
4273 eventPP = &(parser->m_openInternalEntities->internalEventPtr);
4274 eventEndPP = &(parser->m_openInternalEntities->internalEventEndPtr);
4281 if (! accountingDiffTolerated(parser, tok, s, next, __LINE__,
4283 accountingOnAbort(parser);
4290 if (parser->m_defaultHandler)
4291 reportDefault(parser, enc, s, next);
4294 if (parser->m_parsingStatus.parsing == XML_FINISHED)
4332 initializeEncoding(XML_Parser parser) {
4337 if (! parser->m_protocolEncodingName)
4341 for (i = 0; parser->m_protocolEncodingName[i]; i++) {
4343 || (parser->m_protocolEncodingName[i] & ~0x7f) != 0) {
4347 encodingBuf[i] = (char)parser->m_protocolEncodingName[i];
4353 s = parser->m_protocolEncodingName;
4355 if ((parser->m_ns ? XmlInitEncodingNS : XmlInitEncoding)(
4356 &parser->m_initEncoding, &parser->m_encoding, s))
4358 return handleUnknownEncoding(parser, parser->m_protocolEncodingName);
4362 processXmlDecl(XML_Parser parser, int isGeneralTextEntity, const char *s,
4373 if (! accountingDiffTolerated(parser, XML_TOK_XML_DECL, s, next, __LINE__,
4375 accountingOnAbort(parser);
4380 if (! (parser->m_ns ? XmlParseXmlDeclNS : XmlParseXmlDecl)(
4381 isGeneralTextEntity, parser->m_encoding, s, next, &parser->m_eventPtr,
4389 parser->m_dtd->standalone = XML_TRUE;
4391 if (parser->m_paramEntityParsing
4393 parser->m_paramEntityParsing = XML_PARAM_ENTITY_PARSING_NEVER;
4396 if (parser->m_xmlDeclHandler) {
4399 &parser->m_temp2Pool, parser->m_encoding, encodingName,
4400 encodingName + XmlNameLength(parser->m_encoding, encodingName));
4403 poolFinish(&parser->m_temp2Pool);
4407 = poolStoreString(&parser->m_temp2Pool, parser->m_encoding, version,
4408 versionend - parser->m_encoding->minBytesPerChar);
4412 parser->m_xmlDeclHandler(parser->m_handlerArg, storedversion, storedEncName,
4414 } else if (parser->m_defaultHandler)
4415 reportDefault(parser, parser->m_encoding, s, next);
4416 if (parser->m_protocolEncodingName == NULL) {
4419 * the parser has already deduced. Do we have the same number
4423 if (newEncoding->minBytesPerChar != parser->m_encoding->minBytesPerChar
4425 && newEncoding != parser->m_encoding)) {
4426 parser->m_eventPtr = encodingName;
4429 parser->m_encoding = newEncoding;
4434 &parser->m_temp2Pool, parser->m_encoding, encodingName,
4435 encodingName + XmlNameLength(parser->m_encoding, encodingName));
4439 result = handleUnknownEncoding(parser, storedEncName);
4440 poolClear(&parser->m_temp2Pool);
4442 parser->m_eventPtr = encodingName;
4448 poolClear(&parser->m_temp2Pool);
4454 handleUnknownEncoding(XML_Parser parser, const XML_Char *encodingName) {
4455 if (parser->m_unknownEncodingHandler) {
4463 if (parser->m_unknownEncodingHandler(parser->m_unknownEncodingHandlerData,
4466 parser->m_unknownEncodingMem = MALLOC(parser, XmlSizeOfUnknownEncoding());
4467 if (! parser->m_unknownEncodingMem) {
4472 enc = (parser->m_ns ? XmlInitUnknownEncodingNS : XmlInitUnknownEncoding)(
4473 parser->m_unknownEncodingMem, info.map, info.convert, info.data);
4475 parser->m_unknownEncodingData = info.data;
4476 parser->m_unknownEncodingRelease = info.release;
4477 parser->m_encoding = enc;
4488 prologInitProcessor(XML_Parser parser, const char *s, const char *end,
4490 enum XML_Error result = initializeEncoding(parser);
4493 parser->m_processor = prologProcessor;
4494 return prologProcessor(parser, s, end, nextPtr);
4500 externalParEntInitProcessor(XML_Parser parser, const char *s, const char *end,
4502 enum XML_Error result = initializeEncoding(parser);
4508 parser->m_dtd->paramEntityRead = XML_TRUE;
4510 if (parser->m_prologState.inEntityValue) {
4511 parser->m_processor = entityValueInitProcessor;
4512 return entityValueInitProcessor(parser, s, end, nextPtr);
4514 parser->m_processor = externalParEntProcessor;
4515 return externalParEntProcessor(parser, s, end, nextPtr);
4520 entityValueInitProcessor(XML_Parser parser, const char *s, const char *end,
4525 parser->m_eventPtr = start;
4528 tok = XmlPrologTok(parser->m_encoding, start, end, &next);
4533 parser->m_eventEndPtr = next;
4535 if (! parser->m_parsingStatus.finalBuffer && tok != XML_TOK_INVALID) {
4551 return storeEntityValue(parser, parser->m_encoding, s, end,
4555 result = processXmlDecl(parser, 0, start, next);
4560 * to suspend the parser, which fails and raises an error. The parser can
4563 if (parser->m_parsingStatus.parsing == XML_FINISHED)
4567 parser->m_processor = entityValueProcessor;
4568 return entityValueProcessor(parser, next, end, nextPtr);
4580 if (! accountingDiffTolerated(parser, tok, s, next, __LINE__,
4582 accountingOnAbort(parser);
4599 parser->m_eventPtr = start;
4604 externalParEntProcessor(XML_Parser parser, const char *s, const char *end,
4609 tok = XmlPrologTok(parser->m_encoding, s, end, &next);
4611 if (! parser->m_parsingStatus.finalBuffer && tok != XML_TOK_INVALID) {
4633 if (! accountingDiffTolerated(parser, tok, s, next, __LINE__,
4635 accountingOnAbort(parser);
4640 tok = XmlPrologTok(parser->m_encoding, s, end, &next);
4643 parser->m_processor = prologProcessor;
4644 return doProlog(parser, parser->m_encoding, s, end, tok, next, nextPtr,
4645 (XML_Bool)! parser->m_parsingStatus.finalBuffer, XML_TRUE,
4650 entityValueProcessor(XML_Parser parser, const char *s, const char *end,
4654 const ENCODING *enc = parser->m_encoding;
4663 if (! parser->m_parsingStatus.finalBuffer && tok != XML_TOK_INVALID) {
4679 return storeEntityValue(parser, enc, s, end, XML_ACCOUNT_DIRECT);
4688 prologProcessor(XML_Parser parser, const char *s, const char *end,
4691 int tok = XmlPrologTok(parser->m_encoding, s, end, &next);
4692 return doProlog(parser, parser->m_encoding, s, end, tok, next, nextPtr,
4693 (XML_Bool)! parser->m_parsingStatus.finalBuffer, XML_TRUE,
4698 doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end,
4732 DTD *const dtd = parser->m_dtd;
4738 if (enc == parser->m_encoding) {
4739 eventPP = &parser->m_eventPtr;
4740 eventEndPP = &parser->m_eventEndPtr;
4742 eventPP = &(parser->m_openInternalEntities->internalEventPtr);
4743 eventEndPP = &(parser->m_openInternalEntities->internalEventEndPtr);
4770 if (enc != parser->m_encoding
4771 && ! parser->m_openInternalEntities->betweenDecl) {
4779 if (parser->m_isParamEntity || enc != parser->m_encoding) {
4780 if (XmlTokenRole(&parser->m_prologState, XML_TOK_NONE, end, end, enc)
4794 role = XmlTokenRole(&parser->m_prologState, tok, s, next, enc);
4804 if (! accountingDiffTolerated(parser, tok, s, next, __LINE__, account)) {
4805 accountingOnAbort(parser);
4812 enum XML_Error result = processXmlDecl(parser, 0, s, next);
4815 enc = parser->m_encoding;
4819 if (parser->m_startDoctypeDeclHandler) {
4820 parser->m_doctypeName
4821 = poolStoreString(&parser->m_tempPool, enc, s, next);
4822 if (! parser->m_doctypeName)
4824 poolFinish(&parser->m_tempPool);
4825 parser->m_doctypePubid = NULL;
4828 parser->m_doctypeSysid = NULL; /* always initialize to NULL */
4831 if (parser->m_startDoctypeDeclHandler) {
4832 parser->m_startDoctypeDeclHandler(
4833 parser->m_handlerArg, parser->m_doctypeName, parser->m_doctypeSysid,
4834 parser->m_doctypePubid, 1);
4835 parser->m_doctypeName = NULL;
4836 poolClear(&parser->m_tempPool);
4842 enum XML_Error result = processXmlDecl(parser, 1, s, next);
4845 enc = parser->m_encoding;
4851 parser->m_useForeignDTD = XML_FALSE;
4852 parser->m_declEntity = (ENTITY *)lookup(
4853 parser, &dtd->paramEntities, externalSubsetName, sizeof(ENTITY));
4854 if (! parser->m_declEntity)
4858 if (parser->m_startDoctypeDeclHandler) {
4862 pubId = poolStoreString(&parser->m_tempPool, enc,
4868 poolFinish(&parser->m_tempPool);
4869 parser->m_doctypePubid = pubId;
4878 if (dtd->keepProcessing && parser->m_declEntity) {
4885 parser->m_declEntity->publicId = tem;
4890 if (parser->m_entityDeclHandler && role == XML_ROLE_ENTITY_PUBLIC_ID)
4900 if (parser->m_doctypeName) {
4901 parser->m_startDoctypeDeclHandler(
4902 parser->m_handlerArg, parser->m_doctypeName, parser->m_doctypeSysid,
4903 parser->m_doctypePubid, 0);
4904 poolClear(&parser->m_tempPool);
4907 /* parser->m_doctypeSysid will be non-NULL in the case of a previous
4908 XML_ROLE_DOCTYPE_SYSTEM_ID, even if parser->m_startDoctypeDeclHandler
4912 if (parser->m_doctypeSysid || parser->m_useForeignDTD) {
4915 if (parser->m_paramEntityParsing
4916 && parser->m_externalEntityRefHandler) {
4917 ENTITY *entity = (ENTITY *)lookup(parser, &dtd->paramEntities,
4927 if (parser->m_useForeignDTD)
4928 entity->base = parser->m_curBase;
4930 if (! parser->m_externalEntityRefHandler(
4931 parser->m_externalEntityRefHandlerArg, 0, entity->base,
4935 if (! dtd->standalone && parser->m_notStandaloneHandler
4936 && ! parser->m_notStandaloneHandler(parser->m_handlerArg))
4942 else if (! parser->m_doctypeSysid)
4946 parser->m_useForeignDTD = XML_FALSE;
4949 if (parser->m_endDoctypeDeclHandler) {
4950 parser->m_endDoctypeDeclHandler(parser->m_handlerArg);
4959 if (parser->m_useForeignDTD) {
4962 if (parser->m_paramEntityParsing
4963 && parser->m_externalEntityRefHandler) {
4964 ENTITY *entity = (ENTITY *)lookup(parser, &dtd->paramEntities,
4968 entity->base = parser->m_curBase;
4970 if (! parser->m_externalEntityRefHandler(
4971 parser->m_externalEntityRefHandlerArg, 0, entity->base,
4975 if (! dtd->standalone && parser->m_notStandaloneHandler
4976 && ! parser->m_notStandaloneHandler(parser->m_handlerArg))
4988 parser->m_processor = contentProcessor;
4989 return contentProcessor(parser, s, end, nextPtr);
4991 parser->m_declElementType = getElementType(parser, enc, s, next);
4992 if (! parser->m_declElementType)
4996 parser->m_declAttributeId = getAttributeId(parser, enc, s, next);
4997 if (! parser->m_declAttributeId)
4999 parser->m_declAttributeIsCdata = XML_FALSE;
5000 parser->m_declAttributeType = NULL;
5001 parser->m_declAttributeIsId = XML_FALSE;
5004 parser->m_declAttributeIsCdata = XML_TRUE;
5005 parser->m_declAttributeType = atypeCDATA;
5008 parser->m_declAttributeIsId = XML_TRUE;
5009 parser->m_declAttributeType = atypeID;
5012 parser->m_declAttributeType = atypeIDREF;
5015 parser->m_declAttributeType = atypeIDREFS;
5018 parser->m_declAttributeType = atypeENTITY;
5021 parser->m_declAttributeType = atypeENTITIES;
5024 parser->m_declAttributeType = atypeNMTOKEN;
5027 parser->m_declAttributeType = atypeNMTOKENS;
5029 if (dtd->keepProcessing && parser->m_attlistDeclHandler)
5034 if (dtd->keepProcessing && parser->m_attlistDeclHandler) {
5036 if (parser->m_declAttributeType) {
5042 if (! poolAppendString(&parser->m_tempPool, prefix))
5044 if (! poolAppend(&parser->m_tempPool, enc, s, next))
5046 parser->m_declAttributeType = parser->m_tempPool.start;
5053 if (! defineAttribute(parser->m_declElementType,
5054 parser->m_declAttributeId,
5055 parser->m_declAttributeIsCdata,
5056 parser->m_declAttributeIsId, 0, parser))
5058 if (parser->m_attlistDeclHandler && parser->m_declAttributeType) {
5059 if (*parser->m_declAttributeType == XML_T(ASCII_LPAREN)
5060 || (*parser->m_declAttributeType == XML_T(ASCII_N)
5061 && parser->m_declAttributeType[1] == XML_T(ASCII_O))) {
5063 if (! poolAppendChar(&parser->m_tempPool, XML_T(ASCII_RPAREN))
5064 || ! poolAppendChar(&parser->m_tempPool, XML_T('\0')))
5066 parser->m_declAttributeType = parser->m_tempPool.start;
5067 poolFinish(&parser->m_tempPool);
5070 parser->m_attlistDeclHandler(
5071 parser->m_handlerArg, parser->m_declElementType->name,
5072 parser->m_declAttributeId->name, parser->m_declAttributeType, 0,
5077 poolClear(&parser->m_tempPool);
5084 parser, enc, parser->m_declAttributeIsCdata,
5093 parser->m_declElementType, parser->m_declAttributeId,
5094 parser->m_declAttributeIsCdata, XML_FALSE, attVal, parser))
5096 if (parser->m_attlistDeclHandler && parser->m_declAttributeType) {
5097 if (*parser->m_declAttributeType == XML_T(ASCII_LPAREN)
5098 || (*parser->m_declAttributeType == XML_T(ASCII_N)
5099 && parser->m_declAttributeType[1] == XML_T(ASCII_O))) {
5101 if (! poolAppendChar(&parser->m_tempPool, XML_T(ASCII_RPAREN))
5102 || ! poolAppendChar(&parser->m_tempPool, XML_T('\0')))
5104 parser->m_declAttributeType = parser->m_tempPool.start;
5105 poolFinish(&parser->m_tempPool);
5108 parser->m_attlistDeclHandler(
5109 parser->m_handlerArg, parser->m_declElementType->name,
5110 parser->m_declAttributeId->name, parser->m_declAttributeType,
5112 poolClear(&parser->m_tempPool);
5121 // parser->m_declEntity->textPtr.
5123 = storeEntityValue(parser, enc, s + enc->minBytesPerChar,
5125 if (parser->m_declEntity) {
5126 parser->m_declEntity->textPtr = poolStart(&dtd->entityValuePool);
5127 parser->m_declEntity->textLen
5130 if (parser->m_entityDeclHandler) {
5132 parser->m_entityDeclHandler(
5133 parser->m_handlerArg, parser->m_declEntity->name,
5134 parser->m_declEntity->is_param, parser->m_declEntity->textPtr,
5135 parser->m_declEntity->textLen, parser->m_curBase, 0, 0, 0);
5143 // This will store "&entity123;" in parser->m_declEntity->textPtr
5145 if (parser->m_declEntity != NULL) {
5147 = storeSelfEntityValue(parser, parser->m_declEntity);
5151 if (parser->m_entityDeclHandler) {
5153 parser->m_entityDeclHandler(
5154 parser->m_handlerArg, parser->m_declEntity->name,
5155 parser->m_declEntity->is_param, parser->m_declEntity->textPtr,
5156 parser->m_declEntity->textLen, parser->m_curBase, 0, 0, 0);
5165 parser->m_useForeignDTD = XML_FALSE;
5168 if (parser->m_startDoctypeDeclHandler) {
5169 parser->m_doctypeSysid = poolStoreString(&parser->m_tempPool, enc,
5172 if (parser->m_doctypeSysid == NULL)
5174 poolFinish(&parser->m_tempPool);
5179 /* use externalSubsetName to make parser->m_doctypeSysid non-NULL
5180 for the case where no parser->m_startDoctypeDeclHandler is set */
5181 parser->m_doctypeSysid = externalSubsetName;
5185 && ! parser->m_paramEntityParsing
5187 && parser->m_notStandaloneHandler
5188 && ! parser->m_notStandaloneHandler(parser->m_handlerArg))
5193 if (! parser->m_declEntity) {
5194 parser->m_declEntity = (ENTITY *)lookup(
5195 parser, &dtd->paramEntities, externalSubsetName, sizeof(ENTITY));
5196 if (! parser->m_declEntity)
5198 parser->m_declEntity->publicId = NULL;
5203 if (dtd->keepProcessing && parser->m_declEntity) {
5204 parser->m_declEntity->systemId
5207 if (! parser->m_declEntity->systemId)
5209 parser->m_declEntity->base = parser->m_curBase;
5214 if (parser->m_entityDeclHandler && role == XML_ROLE_ENTITY_SYSTEM_ID)
5222 if (parser->m_declEntity != NULL) {
5224 = storeSelfEntityValue(parser, parser->m_declEntity);
5229 if (dtd->keepProcessing && parser->m_declEntity
5230 && parser->m_entityDeclHandler) {
5232 parser->m_entityDeclHandler(
5233 parser->m_handlerArg, parser->m_declEntity->name,
5234 parser->m_declEntity->is_param, 0, 0, parser->m_declEntity->base,
5235 parser->m_declEntity->systemId, parser->m_declEntity->publicId, 0);
5240 if (dtd->keepProcessing && parser->m_declEntity) {
5241 parser->m_declEntity->notation
5243 if (! parser->m_declEntity->notation)
5246 if (parser->m_unparsedEntityDeclHandler) {
5248 parser->m_unparsedEntityDeclHandler(
5249 parser->m_handlerArg, parser->m_declEntity->name,
5250 parser->m_declEntity->base, parser->m_declEntity->systemId,
5251 parser->m_declEntity->publicId, parser->m_declEntity->notation);
5253 } else if (parser->m_entityDeclHandler) {
5255 parser->m_entityDeclHandler(
5256 parser->m_handlerArg, parser->m_declEntity->name, 0, 0, 0,
5257 parser->m_declEntity->base, parser->m_declEntity->systemId,
5258 parser->m_declEntity->publicId, parser->m_declEntity->notation);
5265 parser->m_declEntity = NULL;
5272 parser->m_declEntity = (ENTITY *)lookup(parser, &dtd->generalEntities,
5274 if (! parser->m_declEntity)
5276 if (parser->m_declEntity->name != name) {
5278 parser->m_declEntity = NULL;
5281 parser->m_declEntity->publicId = NULL;
5282 parser->m_declEntity->is_param = XML_FALSE;
5283 /* if we have a parent parser or are reading an internal parameter
5286 parser->m_declEntity->is_internal
5287 = ! (parser->m_parentParser || parser->m_openInternalEntities);
5288 if (parser->m_entityDeclHandler)
5293 parser->m_declEntity = NULL;
5302 parser->m_declEntity = (ENTITY *)lookup(parser, &dtd->paramEntities,
5304 if (! parser->m_declEntity)
5306 if (parser->m_declEntity->name != name) {
5308 parser->m_declEntity = NULL;
5311 parser->m_declEntity->publicId = NULL;
5312 parser->m_declEntity->is_param = XML_TRUE;
5313 /* if we have a parent parser or are reading an internal parameter
5316 parser->m_declEntity->is_internal
5317 = ! (parser->m_parentParser || parser->m_openInternalEntities);
5318 if (parser->m_entityDeclHandler)
5323 parser->m_declEntity = NULL;
5326 parser->m_declEntity = NULL;
5330 parser->m_declNotationPublicId = NULL;
5331 parser->m_declNotationName = NULL;
5332 if (parser->m_notationDeclHandler) {
5333 parser->m_declNotationName
5334 = poolStoreString(&parser->m_tempPool, enc, s, next);
5335 if (! parser->m_declNotationName)
5337 poolFinish(&parser->m_tempPool);
5344 if (parser
5346 XML_Char *tem = poolStoreString(&parser->m_tempPool, enc,
5352 parser->m_declNotationPublicId = tem;
5353 poolFinish(&parser->m_tempPool);
5358 if (parser->m_declNotationName && parser->m_notationDeclHandler) {
5359 const XML_Char *systemId = poolStoreString(&parser->m_tempPool, enc,
5365 parser->m_notationDeclHandler(
5366 parser->m_handlerArg, parser->m_declNotationName, parser->m_curBase,
5367 systemId, parser->m_declNotationPublicId);
5370 poolClear(&parser->m_tempPool);
5373 if (parser->m_declNotationPublicId && parser->m_notationDeclHandler) {
5375 parser->m_notationDeclHandler(
5376 parser->m_handlerArg, parser->m_declNotationName, parser->m_curBase,
5377 0, parser->m_declNotationPublicId);
5380 poolClear(&parser->m_tempPool);
5396 if (parser->m_defaultHandler)
5397 reportDefault(parser, enc, s, next);
5399 result = doIgnoreSection(parser, enc, &next, end, nextPtr, haveMore);
5403 parser->m_processor = ignoreSectionProcessor;
5409 if (parser->m_prologState.level >= parser->m_groupSize) {
5410 if (parser->m_groupSize) {
5413 if (parser->m_groupSize > (unsigned int)(-1) / 2u) {
5418 parser, parser->m_groupConnector, parser->m_groupSize *= 2);
5420 parser->m_groupSize /= 2;
5423 parser->m_groupConnector = new_connector;
5432 if (parser->m_groupSize > (size_t)(-1) / sizeof(int)) {
5438 parser, dtd->scaffIndex, parser->m_groupSize * sizeof(int));
5444 parser->m_groupConnector
5445 = (char *)MALLOC(parser, parser->m_groupSize = 32);
5446 if (! parser->m_groupConnector) {
5447 parser->m_groupSize = 0;
5452 parser->m_groupConnector[parser->m_prologState.level] = 0;
5454 int myindex = nextScaffoldPart(parser);
5461 if (parser->m_elementDeclHandler)
5466 if (parser->m_groupConnector[parser->m_prologState.level] == ASCII_PIPE)
5468 parser->m_groupConnector[parser->m_prologState.level] = ASCII_COMMA;
5469 if (dtd->in_eldecl && parser->m_elementDeclHandler)
5473 if (parser->m_groupConnector[parser->m_prologState.level] == ASCII_COMMA)
5476 && ! parser->m_groupConnector[parser->m_prologState.level]
5481 if (parser->m_elementDeclHandler)
5484 parser->m_groupConnector[parser->m_prologState.level] = ASCII_PIPE;
5490 if (! parser->m_paramEntityParsing)
5499 entity = (ENTITY *)lookup(parser, &dtd->paramEntities, name, 0);
5505 if (parser->m_prologState.documentEntity
5506 && (dtd->standalone ? ! parser->m_openInternalEntities
5537 && parser->m_skippedEntityHandler) {
5538 parser->m_skippedEntityHandler(parser->m_handlerArg, name, 1);
5549 result = processInternalEntity(parser, entity, betweenDecl);
5555 if (parser->m_externalEntityRefHandler) {
5558 entityTrackingOnOpen(parser, entity, __LINE__);
5559 if (! parser->m_externalEntityRefHandler(
5560 parser->m_externalEntityRefHandlerArg, 0, entity->base,
5562 entityTrackingOnClose(parser, entity, __LINE__);
5566 entityTrackingOnClose(parser, entity, __LINE__);
5579 if (! dtd->standalone && parser->m_notStandaloneHandler
5580 && ! parser->m_notStandaloneHandler(parser->m_handlerArg))
5587 if (parser->m_elementDeclHandler) {
5588 parser->m_declElementType = getElementType(parser, enc, s, next);
5589 if (! parser->m_declElementType)
5601 if (parser->m_elementDeclHandler) {
5603 = (XML_Content *)MALLOC(parser, sizeof(XML_Content));
5613 parser->m_elementDeclHandler(
5614 parser->m_handlerArg, parser->m_declElementType->name, content);
5625 if (parser->m_elementDeclHandler)
5648 int myindex = nextScaffoldPart(parser);
5653 el = getElementType(parser, enc, s, nxt);
5668 if (parser->m_elementDeclHandler)
5686 if (parser->m_elementDeclHandler)
5692 XML_Content *model = build_model(parser);
5696 parser->m_elementDeclHandler(
5697 parser->m_handlerArg, parser->m_declElementType->name, model);
5707 if (! reportProcessingInstruction(parser, enc, s, next))
5712 if (! reportComment(parser, enc, s, next))
5724 if (parser->m_startDoctypeDeclHandler)
5728 if (dtd->keepProcessing && parser->m_entityDeclHandler)
5732 if (parser->m_notationDeclHandler)
5736 if (dtd->keepProcessing && parser->m_attlistDeclHandler)
5740 if (parser->m_elementDeclHandler)
5745 if (handleDefault && parser->m_defaultHandler)
5746 reportDefault(parser, enc, s, next);
5748 switch (parser->m_parsingStatus.parsing) {
5763 epilogProcessor(XML_Parser parser, const char *s, const char *end,
5765 parser->m_processor = epilogProcessor;
5766 parser->m_eventPtr = s;
5769 int tok = XmlPrologTok(parser->m_encoding, s, end, &next);
5771 if (! accountingDiffTolerated(parser, tok, s, next, __LINE__,
5773 accountingOnAbort(parser);
5777 parser->m_eventEndPtr = next;
5781 if (parser->m_defaultHandler) {
5782 reportDefault(parser, parser->m_encoding, s, next);
5783 if (parser->m_parsingStatus.parsing == XML_FINISHED)
5792 if (parser->m_defaultHandler)
5793 reportDefault(parser, parser->m_encoding, s, next);
5796 if (! reportProcessingInstruction(parser, parser->m_encoding, s, next))
5800 if (! reportComment(parser, parser->m_encoding, s, next))
5804 parser->m_eventPtr = next;
5807 if (! parser->m_parsingStatus.finalBuffer) {
5813 if (! parser->m_parsingStatus.finalBuffer) {
5821 parser->m_eventPtr = s = next;
5822 switch (parser->m_parsingStatus.parsing) {
5834 processInternalEntity(XML_Parser parser, ENTITY *entity, XML_Bool betweenDecl) {
5840 if (parser->m_freeInternalEntities) {
5841 openEntity = parser->m_freeInternalEntities;
5842 parser->m_freeInternalEntities = openEntity->next;
5845 = (OPEN_INTERNAL_ENTITY *)MALLOC(parser, sizeof(OPEN_INTERNAL_ENTITY));
5851 entityTrackingOnOpen(parser, entity, __LINE__);
5854 openEntity->next = parser->m_openInternalEntities;
5855 parser->m_openInternalEntities = openEntity;
5857 openEntity->startTagLevel = parser->m_tagLevel;
5868 = XmlPrologTok(parser->m_internalEncoding, textStart, textEnd, &next);
5869 result = doProlog(parser, parser->m_internalEncoding, textStart, textEnd,
5873 result = doContent(parser, parser->m_tagLevel, parser->m_internalEncoding,
5879 if (textEnd != next && parser->m_parsingStatus.parsing == XML_SUSPENDED) {
5881 parser->m_processor = internalEntityProcessor;
5882 } else if (parser->m_openInternalEntities->entity == entity) {
5884 entityTrackingOnClose(parser, entity, __LINE__);
5887 parser->m_openInternalEntities = openEntity->next;
5889 openEntity->next = parser->m_freeInternalEntities;
5890 parser->m_freeInternalEntities = openEntity;
5897 internalEntityProcessor(XML_Parser parser, const char *s, const char *end,
5903 OPEN_INTERNAL_ENTITY *openEntity = parser->m_openInternalEntities;
5915 = XmlPrologTok(parser->m_internalEncoding, textStart, textEnd, &next);
5916 result = doProlog(parser, parser->m_internalEncoding, textStart, textEnd,
5920 result = doContent(parser, openEntity->startTagLevel,
5921 parser->m_internalEncoding, textStart, textEnd, &next,
5928 if (textEnd != next && parser->m_parsingStatus.parsing == XML_SUSPENDED) {
5934 entityTrackingOnClose(parser, entity, __LINE__);
5937 parser->m_openInternalEntities = openEntity->next;
5939 openEntity->next = parser->m_freeInternalEntities;
5940 parser->m_freeInternalEntities = openEntity;
5945 if (parser->m_openInternalEntities != NULL
5946 && parser->m_parsingStatus.parsing == XML_SUSPENDED) {
5952 parser->m_processor = prologProcessor;
5953 tok = XmlPrologTok(parser->m_encoding, s, end, &next);
5954 return doProlog(parser, parser->m_encoding, s, end, tok, next, nextPtr,
5955 (XML_Bool)! parser->m_parsingStatus.finalBuffer, XML_TRUE,
5958 parser->m_processor = contentProcessor;
5960 result = doContent(parser, parser->m_parentParser ? 1 : 0,
5961 parser->m_encoding, s, end, nextPtr,
5962 (XML_Bool)! parser->m_parsingStatus.finalBuffer,
5965 if (! storeRawNames(parser))
5973 errorProcessor(XML_Parser parser, const char *s, const char *end,
5978 return parser->m_errorCode;
5982 storeAttributeValue(XML_Parser parser, const ENCODING *enc, XML_Bool isCdata,
5986 = appendAttributeValue(parser, enc, isCdata, ptr, end, pool, account);
5997 appendAttributeValue(XML_Parser parser, const ENCODING *enc, XML_Bool isCdata,
6000 DTD *const dtd = parser->m_dtd; /* save one level of indirection */
6010 if (! accountingDiffTolerated(parser, tok, ptr, next, __LINE__, account)) {
6011 accountingOnAbort(parser);
6019 if (enc == parser->m_encoding)
6020 parser->m_eventPtr = next;
6023 if (enc == parser->m_encoding)
6024 parser->m_eventPtr = ptr;
6031 if (enc == parser->m_encoding)
6032 parser->m_eventPtr = ptr;
6078 accountingDiffTolerated(parser, tok, (char *)&ch,
6086 name = poolStoreString(&parser->m_temp2Pool, enc,
6091 entity = (ENTITY *)lookup(parser, &dtd->generalEntities, name, 0);
6092 poolDiscard(&parser->m_temp2Pool);
6099 parser->m_prologState.documentEntity &&
6101 (dtd->standalone ? ! parser->m_openInternalEntities
6103 else /* if (pool == &parser->m_tempPool): we are called from content */
6112 parser->m_skippedEntityHandler.
6113 if (parser->m_skippedEntityHandler)
6114 parser->m_skippedEntityHandler(parser->m_handlerArg, name, 0);
6118 if ((pool == &parser->m_tempPool) && parser->m_defaultHandler)
6119 reportDefault(parser, enc, ptr, next);
6124 if (enc == parser->m_encoding) {
6132 * sets the local encoding ("enc") to the parser's
6142 parser->m_eventPtr = ptr; /* LCOV_EXCL_LINE */
6147 if (enc == parser->m_encoding)
6148 parser->m_eventPtr = ptr;
6152 if (enc == parser->m_encoding)
6153 parser->m_eventPtr = ptr;
6160 entityTrackingOnOpen(parser, entity, __LINE__);
6162 result = appendAttributeValue(parser, parser->m_internalEncoding,
6167 entityTrackingOnClose(parser, entity, __LINE__);
6186 if (enc == parser->m_encoding)
6187 parser->m_eventPtr = ptr;
6198 storeEntityValue(XML_Parser parser, const ENCODING *enc,
6201 DTD *const dtd = parser->m_dtd; /* save one level of indirection */
6205 int oldInEntityValue = parser->m_prologState.inEntityValue;
6206 parser->m_prologState.inEntityValue = 1;
6223 if (! accountingDiffTolerated(parser, tok, entityTextPtr, next, __LINE__,
6225 accountingOnAbort(parser);
6233 if (parser->m_isParamEntity || enc != parser->m_encoding) {
6236 name = poolStoreString(&parser->m_tempPool, enc,
6243 entity = (ENTITY *)lookup(parser, &dtd->paramEntities, name, 0);
6244 poolDiscard(&parser->m_tempPool);
6248 parser->m_skippedEntityHandler
6249 if (parser->m_skippedEntityHandler)
6250 parser->m_skippedEntityHandler(parser->m_handlerArg, name, 0);
6255 if (entity->open || (entity == parser->m_declEntity)) {
6256 if (enc == parser->m_encoding)
6257 parser->m_eventPtr = entityTextPtr;
6262 if (parser->m_externalEntityRefHandler) {
6265 entityTrackingOnOpen(parser, entity, __LINE__);
6266 if (! parser->m_externalEntityRefHandler(
6267 parser->m_externalEntityRefHandlerArg, 0, entity->base,
6269 entityTrackingOnClose(parser, entity, __LINE__);
6274 entityTrackingOnClose(parser, entity, __LINE__);
6282 entityTrackingOnOpen(parser, entity, __LINE__);
6284 parser, parser->m_internalEncoding, (const char *)entity->textPtr,
6287 entityTrackingOnClose(parser, entity, __LINE__);
6297 parser->m_eventPtr = entityTextPtr;
6325 if (enc == parser->m_encoding)
6326 parser->m_eventPtr = entityTextPtr;
6349 if (enc == parser->m_encoding)
6350 parser->m_eventPtr = entityTextPtr;
6354 if (enc == parser->m_encoding)
6355 parser->m_eventPtr = next;
6366 if (enc == parser->m_encoding)
6367 parser->m_eventPtr = entityTextPtr;
6376 parser->m_prologState.inEntityValue = oldInEntityValue;
6384 storeSelfEntityValue(XML_Parser parser, ENTITY *entity) {
6390 STRING_POOL *const pool = &(parser->m_dtd->entityValuePool);
6429 reportProcessingInstruction(XML_Parser parser, const ENCODING *enc,
6434 if (! parser->m_processingInstructionHandler) {
6435 if (parser->m_defaultHandler)
6436 reportDefault(parser, enc, start, end);
6441 target = poolStoreString(&parser->m_tempPool, enc, start, tem);
6444 poolFinish(&parser->m_tempPool);
6445 data = poolStoreString(&parser->m_tempPool, enc, XmlSkipS(enc, tem),
6450 parser->m_processingInstructionHandler(parser->m_handlerArg, target, data);
6451 poolClear(&parser->m_tempPool);
6456 reportComment(XML_Parser parser, const ENCODING *enc, const char *start,
6459 if (! parser->m_commentHandler) {
6460 if (parser->m_defaultHandler)
6461 reportDefault(parser, enc, start, end);
6464 data = poolStoreString(&parser->m_tempPool, enc,
6470 parser->m_commentHandler(parser->m_handlerArg, data);
6471 poolClear(&parser->m_tempPool);
6476 reportDefault(XML_Parser parser, const ENCODING *enc, const char *s,
6482 if (enc == parser->m_encoding) {
6483 eventPP = &parser->m_eventPtr;
6484 eventEndPP = &parser->m_eventEndPtr;
6486 /* To get here, two things must be true; the parser must be
6491 * in is not the same as the parser's encoding are when it is
6502 eventPP = &(parser->m_openInternalEntities->internalEventPtr);
6503 eventEndPP = &(parser->m_openInternalEntities->internalEventEndPtr);
6507 ICHAR *dataPtr = (ICHAR *)parser->m_dataBuf;
6509 = XmlConvert(enc, &s, end, &dataPtr, (ICHAR *)parser->m_dataBufEnd);
6511 parser->m_defaultHandler(parser->m_handlerArg, parser->m_dataBuf,
6512 (int)(dataPtr - (ICHAR *)parser->m_dataBuf));
6517 parser->m_defaultHandler(
6518 parser->m_handlerArg, (const XML_Char *)s,
6524 XML_Bool isId, const XML_Char *value, XML_Parser parser) {
6540 parser, type->allocDefaultAtts * sizeof(DEFAULT_ATTRIBUTE));
6565 temp = (DEFAULT_ATTRIBUTE *)REALLOC(parser, type->defaultAtts,
6584 setElementTypePrefix(XML_Parser parser, ELEMENT_TYPE *elementType) {
6585 DTD *const dtd = parser->m_dtd; /* save one level of indirection */
6597 prefix = (PREFIX *)lookup(parser, &dtd->prefixes, poolStart(&dtd->pool),
6613 getAttributeId(XML_Parser parser, const ENCODING *enc, const char *start,
6615 DTD *const dtd = parser->m_dtd; /* save one level of indirection */
6625 id = (ATTRIBUTE_ID *)lookup(parser, &dtd->attributeIds, name,
6633 if (! parser->m_ns)
6642 id->prefix = (PREFIX *)lookup(parser, &dtd->prefixes, name + 6,
6657 id->prefix = (PREFIX *)lookup(parser, &dtd->prefixes,
6676 getContext(XML_Parser parser) {
6677 DTD *const dtd = parser->m_dtd; /* save one level of indirection */
6684 if (! poolAppendChar(&parser->m_tempPool, XML_T(ASCII_EQUALS)))
6687 if (parser->m_namespaceSeparator)
6690 if (! poolAppendChar(&parser->m_tempPool,
6696 * URI into the parser's temporary string pool. Previously,
6734 if (needSep && ! poolAppendChar(&parser->m_tempPool, CONTEXT_SEP))
6737 if (! poolAppendChar(&parser->m_tempPool, *s))
6739 if (! poolAppendChar(&parser->m_tempPool, XML_T(ASCII_EQUALS)))
6742 if (parser->m_namespaceSeparator)
6745 if (! poolAppendChar(&parser->m_tempPool, prefix->binding->uri[i]))
6758 if (needSep && ! poolAppendChar(&parser->m_tempPool, CONTEXT_SEP))
6761 if (! poolAppendChar(&parser->m_tempPool, *s))
6766 if (! poolAppendChar(&parser->m_tempPool, XML_T('\0')))
6768 return parser->m_tempPool.start;
6772 setContext(XML_Parser parser, const XML_Char *context) {
6777 DTD *const dtd = parser->m_dtd; /* save one level of indirection */
6783 if (! poolAppendChar(&parser->m_tempPool, XML_T('\0')))
6785 e = (ENTITY *)lookup(parser, &dtd->generalEntities,
6786 poolStart(&parser->m_tempPool), 0);
6792 poolDiscard(&parser->m_tempPool);
6795 if (poolLength(&parser->m_tempPool) == 0)
6798 if (! poolAppendChar(&parser->m_tempPool, XML_T('\0')))
6801 = (PREFIX *)lookup(parser, &dtd->prefixes,
6802 poolStart(&parser->m_tempPool), sizeof(PREFIX));
6805 if (prefix->name == poolStart(&parser->m_tempPool)) {
6810 poolDiscard(&parser->m_tempPool);
6814 if (! poolAppendChar(&parser->m_tempPool, *context))
6816 if (! poolAppendChar(&parser->m_tempPool, XML_T('\0')))
6818 if (addBinding(parser, prefix, NULL, poolStart(&parser->m_tempPool),
6819 &parser->m_inheritedBindings)
6822 poolDiscard(&parser->m_tempPool);
6827 if (! poolAppendChar(&parser->m_tempPool, *s))
7177 copy_salt_to_sipkey(XML_Parser parser, struct sipkey *key) {
7179 key->k[1] = get_hash_secret_salt(parser);
7183 hash(XML_Parser parser, KEY s) {
7187 copy_salt_to_sipkey(parser, &key);
7194 lookup(XML_Parser parser, HASH_TABLE *table, KEY name, size_t createSize) {
7210 i = hash(parser, name) & ((unsigned long)table->size - 1);
7212 unsigned long h = hash(parser, name);
7250 unsigned long newHash = hash(parser, table->v[i]->name);
7577 nextScaffoldPart(XML_Parser parser) {
7578 DTD *const dtd = parser->m_dtd; /* save one level of indirection */
7588 if (parser->m_groupSize > ((size_t)(-1) / sizeof(int))) {
7592 dtd->scaffIndex = (int *)MALLOC(parser, parser->m_groupSize * sizeof(int));
7616 parser, dtd->scaffold, dtd->scaffSize * 2 * sizeof(CONTENT_SCAFFOLD));
7621 temp = (CONTENT_SCAFFOLD *)MALLOC(parser, INIT_SCAFFOLD_ELEMENTS
7647 build_model(XML_Parser parser) {
7648 /* Function build_model transforms the existing parser->m_dtd->scaffold
7652 DTD *const dtd = parser->m_dtd; /* save one level of indirection */
7676 ret = (XML_Content *)MALLOC(parser, allocsize);
7774 getElementType(XML_Parser parser, const ENCODING *enc, const char *ptr,
7776 DTD *const dtd = parser->m_dtd; /* save one level of indirection */
7782 ret = (ELEMENT_TYPE *)lookup(parser, &dtd->elementTypes, name,
7790 if (! setElementTypePrefix(parser, ret))
7954 testingAccountingGetCountBytesDirect(XML_Parser parser) {
7955 if (! parser)
7957 return parser->m_accounting.countBytesDirect;
7961 testingAccountingGetCountBytesIndirect(XML_Parser parser) {
7962 if (! parser)
7964 return parser->m_accounting.countBytesIndirect;
8016 getRootParserOf(XML_Parser parser, unsigned int *outLevelDiff) {
8017 XML_Parser rootParser = parser;