Lines Matching refs:parser

67 	XML_Parser parser;  local
145 #define SKIP_TAGSTART(str) ((str) + (parser->toffset > (int)strlen(str) ? strlen(str) : parser->tof…
169 static void _xml_add_to_info(xml_parser *parser,char *name);
170 inline static zend_string *_xml_decode_tag(xml_parser *parser, const char *tag);
364 xml_parser *parser = xml_parser_from_obj(object); in xml_parser_free_obj() local
366 if (parser->parser) { in xml_parser_free_obj()
367 XML_ParserFree(parser->parser); in xml_parser_free_obj()
369 if (parser->ltags) { in xml_parser_free_obj()
371 for (inx = 0; ((inx < parser->level) && (inx < XML_MAXLEVEL)); inx++) in xml_parser_free_obj()
372 efree(parser->ltags[ inx ]); in xml_parser_free_obj()
373 efree(parser->ltags); in xml_parser_free_obj()
375 if (!Z_ISUNDEF(parser->startElementHandler)) { in xml_parser_free_obj()
376 zval_ptr_dtor(&parser->startElementHandler); in xml_parser_free_obj()
378 if (!Z_ISUNDEF(parser->endElementHandler)) { in xml_parser_free_obj()
379 zval_ptr_dtor(&parser->endElementHandler); in xml_parser_free_obj()
381 if (!Z_ISUNDEF(parser->characterDataHandler)) { in xml_parser_free_obj()
382 zval_ptr_dtor(&parser->characterDataHandler); in xml_parser_free_obj()
384 if (!Z_ISUNDEF(parser->processingInstructionHandler)) { in xml_parser_free_obj()
385 zval_ptr_dtor(&parser->processingInstructionHandler); in xml_parser_free_obj()
387 if (!Z_ISUNDEF(parser->defaultHandler)) { in xml_parser_free_obj()
388 zval_ptr_dtor(&parser->defaultHandler); in xml_parser_free_obj()
390 if (!Z_ISUNDEF(parser->unparsedEntityDeclHandler)) { in xml_parser_free_obj()
391 zval_ptr_dtor(&parser->unparsedEntityDeclHandler); in xml_parser_free_obj()
393 if (!Z_ISUNDEF(parser->notationDeclHandler)) { in xml_parser_free_obj()
394 zval_ptr_dtor(&parser->notationDeclHandler); in xml_parser_free_obj()
396 if (!Z_ISUNDEF(parser->externalEntityRefHandler)) { in xml_parser_free_obj()
397 zval_ptr_dtor(&parser->externalEntityRefHandler); in xml_parser_free_obj()
399 if (!Z_ISUNDEF(parser->unknownEncodingHandler)) { in xml_parser_free_obj()
400 zval_ptr_dtor(&parser->unknownEncodingHandler); in xml_parser_free_obj()
402 if (!Z_ISUNDEF(parser->startNamespaceDeclHandler)) { in xml_parser_free_obj()
403 zval_ptr_dtor(&parser->startNamespaceDeclHandler); in xml_parser_free_obj()
405 if (!Z_ISUNDEF(parser->endNamespaceDeclHandler)) { in xml_parser_free_obj()
406 zval_ptr_dtor(&parser->endNamespaceDeclHandler); in xml_parser_free_obj()
408 if (parser->baseURI) { in xml_parser_free_obj()
409 efree(parser->baseURI); in xml_parser_free_obj()
411 if (!Z_ISUNDEF(parser->object)) { in xml_parser_free_obj()
412 zval_ptr_dtor(&parser->object); in xml_parser_free_obj()
415 zend_object_std_dtor(&parser->std); in xml_parser_free_obj()
420 xml_parser *parser = xml_parser_from_obj(object); in xml_parser_get_gc() local
421 *table = &parser->object; in xml_parser_get_gc()
453 static void xml_call_handler(xml_parser *parser, zval *handler, zend_function *function_ptr, int ar… in xml_call_handler() argument
458 if (parser && handler && !EG(exception)) { in xml_call_handler()
464 fci.object = Z_OBJ(parser->object); in xml_call_handler()
592 static void _xml_add_to_info(xml_parser *parser,char *name) in _xml_add_to_info() argument
596 if (Z_ISUNDEF(parser->info)) { in _xml_add_to_info()
600 if ((element = zend_hash_str_find(Z_ARRVAL(parser->info), name, strlen(name))) == NULL) { in _xml_add_to_info()
603 element = zend_hash_str_update(Z_ARRVAL(parser->info), name, strlen(name), &values); in _xml_add_to_info()
606 add_next_index_long(element, parser->curtag); in _xml_add_to_info()
608 parser->curtag++; in _xml_add_to_info()
613 static zend_string *_xml_decode_tag(xml_parser *parser, const char *tag) in _xml_decode_tag() argument
617 str = xml_utf8_decode((const XML_Char *)tag, strlen(tag), parser->target_encoding); in _xml_decode_tag()
619 if (parser->case_folding) { in _xml_decode_tag()
630 xml_parser *parser = (xml_parser *)userData; in _xml_startElementHandler() local
635 if (parser) { in _xml_startElementHandler()
636 parser->level++; in _xml_startElementHandler()
638 tag_name = _xml_decode_tag(parser, (const char *)name); in _xml_startElementHandler()
640 if (!Z_ISUNDEF(parser->startElementHandler)) { in _xml_startElementHandler()
641 ZVAL_COPY(&args[0], &parser->index); in _xml_startElementHandler()
648 att = _xml_decode_tag(parser, (const char *)attributes[0]); in _xml_startElementHandler()
649 val = xml_utf8_decode(attributes[1], strlen((char *)attributes[1]), parser->target_encoding); in _xml_startElementHandler()
659 … xml_call_handler(parser, &parser->startElementHandler, parser->startElementPtr, 3, args, &retval); in _xml_startElementHandler()
663 if (!Z_ISUNDEF(parser->data)) { in _xml_startElementHandler()
664 if (parser->level <= XML_MAXLEVEL) { in _xml_startElementHandler()
671 _xml_add_to_info(parser, ZSTR_VAL(tag_name) + parser->toffset); in _xml_startElementHandler()
675 add_assoc_long(&tag, "level", parser->level); in _xml_startElementHandler()
677 parser->ltags[parser->level-1] = estrdup(ZSTR_VAL(tag_name)); in _xml_startElementHandler()
678 parser->lastwasopen = 1; in _xml_startElementHandler()
685 att = _xml_decode_tag(parser, (const char *)attributes[0]); in _xml_startElementHandler()
686 val = xml_utf8_decode(attributes[1], strlen((char *)attributes[1]), parser->target_encoding); in _xml_startElementHandler()
703 parser->ctag = zend_hash_next_index_insert(Z_ARRVAL(parser->data), &tag); in _xml_startElementHandler()
704 } else if (parser->level == (XML_MAXLEVEL + 1)) { in _xml_startElementHandler()
717 xml_parser *parser = (xml_parser *)userData; in _xml_endElementHandler() local
719 if (parser) { in _xml_endElementHandler()
722 zend_string *tag_name = _xml_decode_tag(parser, (const char *)name); in _xml_endElementHandler()
724 if (!Z_ISUNDEF(parser->endElementHandler)) { in _xml_endElementHandler()
725 ZVAL_COPY(&args[0], &parser->index); in _xml_endElementHandler()
728 xml_call_handler(parser, &parser->endElementHandler, parser->endElementPtr, 2, args, &retval); in _xml_endElementHandler()
732 if (!Z_ISUNDEF(parser->data)) { in _xml_endElementHandler()
735 if (parser->lastwasopen) { in _xml_endElementHandler()
736 add_assoc_string(parser->ctag, "type", "complete"); in _xml_endElementHandler()
740 _xml_add_to_info(parser, ZSTR_VAL(tag_name) + parser->toffset); in _xml_endElementHandler()
744 add_assoc_long(&tag, "level", parser->level); in _xml_endElementHandler()
746 zend_hash_next_index_insert(Z_ARRVAL(parser->data), &tag); in _xml_endElementHandler()
749 parser->lastwasopen = 0; in _xml_endElementHandler()
754 if ((parser->ltags) && (parser->level <= XML_MAXLEVEL)) { in _xml_endElementHandler()
755 efree(parser->ltags[parser->level-1]); in _xml_endElementHandler()
758 parser->level--; in _xml_endElementHandler()
766 xml_parser *parser = (xml_parser *)userData; in _xml_characterDataHandler() local
768 if (parser) { in _xml_characterDataHandler()
771 if (!Z_ISUNDEF(parser->characterDataHandler)) { in _xml_characterDataHandler()
772 ZVAL_COPY(&args[0], &parser->index); in _xml_characterDataHandler()
773 _xml_xmlchar_zval(s, len, parser->target_encoding, &args[1]); in _xml_characterDataHandler()
774 …xml_call_handler(parser, &parser->characterDataHandler, parser->characterDataPtr, 2, args, &retval… in _xml_characterDataHandler()
778 if (!Z_ISUNDEF(parser->data)) { in _xml_characterDataHandler()
783 decoded_value = xml_utf8_decode(s, len, parser->target_encoding); in _xml_characterDataHandler()
784 if (parser->skipwhite) { in _xml_characterDataHandler()
801 if (parser->lastwasopen) { in _xml_characterDataHandler()
805 if ((myval = zend_hash_str_find(Z_ARRVAL_P(parser->ctag), "value", sizeof("value") - 1))) { in _xml_characterDataHandler()
812 if (doprint || (! parser->skipwhite)) { in _xml_characterDataHandler()
813 add_assoc_str(parser->ctag, "value", decoded_value); in _xml_characterDataHandler()
823 ZEND_HASH_REVERSE_FOREACH_VAL(Z_ARRVAL(parser->data), curtag) { in _xml_characterDataHandler()
839 if (parser->level <= XML_MAXLEVEL && parser->level > 0 && (doprint || (! parser->skipwhite))) { in _xml_characterDataHandler()
842 _xml_add_to_info(parser,SKIP_TAGSTART(parser->ltags[parser->level-1])); in _xml_characterDataHandler()
844 add_assoc_string(&tag, "tag", SKIP_TAGSTART(parser->ltags[parser->level-1])); in _xml_characterDataHandler()
847 add_assoc_long(&tag, "level", parser->level); in _xml_characterDataHandler()
849 zend_hash_next_index_insert(Z_ARRVAL(parser->data), &tag); in _xml_characterDataHandler()
850 } else if (parser->level == (XML_MAXLEVEL + 1)) { in _xml_characterDataHandler()
864 xml_parser *parser = (xml_parser *)userData; in _xml_processingInstructionHandler() local
866 if (parser && !Z_ISUNDEF(parser->processingInstructionHandler)) { in _xml_processingInstructionHandler()
869 ZVAL_COPY(&args[0], &parser->index); in _xml_processingInstructionHandler()
870 _xml_xmlchar_zval(target, 0, parser->target_encoding, &args[1]); in _xml_processingInstructionHandler()
871 _xml_xmlchar_zval(data, 0, parser->target_encoding, &args[2]); in _xml_processingInstructionHandler()
872 …xml_call_handler(parser, &parser->processingInstructionHandler, parser->processingInstructionPtr, … in _xml_processingInstructionHandler()
881 xml_parser *parser = (xml_parser *)userData; in _xml_defaultHandler() local
883 if (parser && !Z_ISUNDEF(parser->defaultHandler)) { in _xml_defaultHandler()
886 ZVAL_COPY(&args[0], &parser->index); in _xml_defaultHandler()
887 _xml_xmlchar_zval(s, len, parser->target_encoding, &args[1]); in _xml_defaultHandler()
888 xml_call_handler(parser, &parser->defaultHandler, parser->defaultPtr, 2, args, &retval); in _xml_defaultHandler()
902 xml_parser *parser = (xml_parser *)userData; in _xml_unparsedEntityDeclHandler() local
904 if (parser && !Z_ISUNDEF(parser->unparsedEntityDeclHandler)) { in _xml_unparsedEntityDeclHandler()
907 ZVAL_COPY(&args[0], &parser->index); in _xml_unparsedEntityDeclHandler()
908 _xml_xmlchar_zval(entityName, 0, parser->target_encoding, &args[1]); in _xml_unparsedEntityDeclHandler()
909 _xml_xmlchar_zval(base, 0, parser->target_encoding, &args[2]); in _xml_unparsedEntityDeclHandler()
910 _xml_xmlchar_zval(systemId, 0, parser->target_encoding, &args[3]); in _xml_unparsedEntityDeclHandler()
911 _xml_xmlchar_zval(publicId, 0, parser->target_encoding, &args[4]); in _xml_unparsedEntityDeclHandler()
912 _xml_xmlchar_zval(notationName, 0, parser->target_encoding, &args[5]); in _xml_unparsedEntityDeclHandler()
913 …xml_call_handler(parser, &parser->unparsedEntityDeclHandler, parser->unparsedEntityDeclPtr, 6, arg… in _xml_unparsedEntityDeclHandler()
926 xml_parser *parser = (xml_parser *)userData; in _xml_notationDeclHandler() local
928 if (parser && !Z_ISUNDEF(parser->notationDeclHandler)) { in _xml_notationDeclHandler()
931 ZVAL_COPY(&args[0], &parser->index); in _xml_notationDeclHandler()
932 _xml_xmlchar_zval(notationName, 0, parser->target_encoding, &args[1]); in _xml_notationDeclHandler()
933 _xml_xmlchar_zval(base, 0, parser->target_encoding, &args[2]); in _xml_notationDeclHandler()
934 _xml_xmlchar_zval(systemId, 0, parser->target_encoding, &args[3]); in _xml_notationDeclHandler()
935 _xml_xmlchar_zval(publicId, 0, parser->target_encoding, &args[4]); in _xml_notationDeclHandler()
936 xml_call_handler(parser, &parser->notationDeclHandler, parser->notationDeclPtr, 5, args, &retval); in _xml_notationDeclHandler()
949 xml_parser *parser = XML_GetUserData(parserPtr); in _xml_externalEntityRefHandler() local
952 if (parser && !Z_ISUNDEF(parser->externalEntityRefHandler)) { in _xml_externalEntityRefHandler()
955 ZVAL_COPY(&args[0], &parser->index); in _xml_externalEntityRefHandler()
956 _xml_xmlchar_zval(openEntityNames, 0, parser->target_encoding, &args[1]); in _xml_externalEntityRefHandler()
957 _xml_xmlchar_zval(base, 0, parser->target_encoding, &args[2]); in _xml_externalEntityRefHandler()
958 _xml_xmlchar_zval(systemId, 0, parser->target_encoding, &args[3]); in _xml_externalEntityRefHandler()
959 _xml_xmlchar_zval(publicId, 0, parser->target_encoding, &args[4]); in _xml_externalEntityRefHandler()
960 …xml_call_handler(parser, &parser->externalEntityRefHandler, parser->externalEntityRefPtr, 5, args,… in _xml_externalEntityRefHandler()
975 xml_parser *parser = (xml_parser *)userData; in _xml_startNamespaceDeclHandler() local
977 if (parser && !Z_ISUNDEF(parser->startNamespaceDeclHandler)) { in _xml_startNamespaceDeclHandler()
980 ZVAL_COPY(&args[0], &parser->index); in _xml_startNamespaceDeclHandler()
981 _xml_xmlchar_zval(prefix, 0, parser->target_encoding, &args[1]); in _xml_startNamespaceDeclHandler()
982 _xml_xmlchar_zval(uri, 0, parser->target_encoding, &args[2]); in _xml_startNamespaceDeclHandler()
983 …xml_call_handler(parser, &parser->startNamespaceDeclHandler, parser->startNamespaceDeclPtr, 3, arg… in _xml_startNamespaceDeclHandler()
992 xml_parser *parser = (xml_parser *)userData; in _xml_endNamespaceDeclHandler() local
994 if (parser && !Z_ISUNDEF(parser->endNamespaceDeclHandler)) { in _xml_endNamespaceDeclHandler()
997 ZVAL_COPY(&args[0], &parser->index); in _xml_endNamespaceDeclHandler()
998 _xml_xmlchar_zval(prefix, 0, parser->target_encoding, &args[1]); in _xml_endNamespaceDeclHandler()
999 …xml_call_handler(parser, &parser->endNamespaceDeclHandler, parser->endNamespaceDeclPtr, 2, args, &… in _xml_endNamespaceDeclHandler()
1009 xml_parser *parser; in php_xml_parser_create_impl() local
1050 parser = Z_XMLPARSER_P(return_value); in php_xml_parser_create_impl()
1051 parser->parser = XML_ParserCreate_MM((auto_detect ? NULL : encoding), in php_xml_parser_create_impl()
1054 parser->target_encoding = encoding; in php_xml_parser_create_impl()
1055 parser->case_folding = 1; in php_xml_parser_create_impl()
1056 parser->isparsing = 0; in php_xml_parser_create_impl()
1058 XML_SetUserData(parser->parser, parser); in php_xml_parser_create_impl()
1059 ZVAL_COPY_VALUE(&parser->index, return_value); in php_xml_parser_create_impl()
1080 xml_parser *parser; in PHP_FUNCTION() local
1087 parser = Z_XMLPARSER_P(pind); in PHP_FUNCTION()
1089 zval_ptr_dtor(&parser->object); in PHP_FUNCTION()
1090 ZVAL_OBJ_COPY(&parser->object, Z_OBJ_P(mythis)); in PHP_FUNCTION()
1099 xml_parser *parser; in PHP_FUNCTION() local
1106 parser = Z_XMLPARSER_P(pind); in PHP_FUNCTION()
1107 xml_set_handler(&parser->startElementHandler, shdl); in PHP_FUNCTION()
1108 xml_set_handler(&parser->endElementHandler, ehdl); in PHP_FUNCTION()
1109 XML_SetElementHandler(parser->parser, _xml_startElementHandler, _xml_endElementHandler); in PHP_FUNCTION()
1117 xml_parser *parser; in PHP_FUNCTION() local
1124 parser = Z_XMLPARSER_P(pind); in PHP_FUNCTION()
1125 xml_set_handler(&parser->characterDataHandler, hdl); in PHP_FUNCTION()
1126 XML_SetCharacterDataHandler(parser->parser, _xml_characterDataHandler); in PHP_FUNCTION()
1134 xml_parser *parser; in PHP_FUNCTION() local
1141 parser = Z_XMLPARSER_P(pind); in PHP_FUNCTION()
1142 xml_set_handler(&parser->processingInstructionHandler, hdl); in PHP_FUNCTION()
1143 XML_SetProcessingInstructionHandler(parser->parser, _xml_processingInstructionHandler); in PHP_FUNCTION()
1151 xml_parser *parser; in PHP_FUNCTION() local
1158 parser = Z_XMLPARSER_P(pind); in PHP_FUNCTION()
1159 xml_set_handler(&parser->defaultHandler, hdl); in PHP_FUNCTION()
1160 XML_SetDefaultHandler(parser->parser, _xml_defaultHandler); in PHP_FUNCTION()
1168 xml_parser *parser; in PHP_FUNCTION() local
1175 parser = Z_XMLPARSER_P(pind); in PHP_FUNCTION()
1176 xml_set_handler(&parser->unparsedEntityDeclHandler, hdl); in PHP_FUNCTION()
1177 XML_SetUnparsedEntityDeclHandler(parser->parser, _xml_unparsedEntityDeclHandler); in PHP_FUNCTION()
1185 xml_parser *parser; in PHP_FUNCTION() local
1192 parser = Z_XMLPARSER_P(pind); in PHP_FUNCTION()
1193 xml_set_handler(&parser->notationDeclHandler, hdl); in PHP_FUNCTION()
1194 XML_SetNotationDeclHandler(parser->parser, _xml_notationDeclHandler); in PHP_FUNCTION()
1202 xml_parser *parser; in PHP_FUNCTION() local
1209 parser = Z_XMLPARSER_P(pind); in PHP_FUNCTION()
1210 xml_set_handler(&parser->externalEntityRefHandler, hdl); in PHP_FUNCTION()
1211 XML_SetExternalEntityRefHandler(parser->parser, (void *) _xml_externalEntityRefHandler); in PHP_FUNCTION()
1219 xml_parser *parser; in PHP_FUNCTION() local
1226 parser = Z_XMLPARSER_P(pind); in PHP_FUNCTION()
1227 xml_set_handler(&parser->startNamespaceDeclHandler, hdl); in PHP_FUNCTION()
1228 XML_SetStartNamespaceDeclHandler(parser->parser, _xml_startNamespaceDeclHandler); in PHP_FUNCTION()
1236 xml_parser *parser; in PHP_FUNCTION() local
1243 parser = Z_XMLPARSER_P(pind); in PHP_FUNCTION()
1244 xml_set_handler(&parser->endNamespaceDeclHandler, hdl); in PHP_FUNCTION()
1245 XML_SetEndNamespaceDeclHandler(parser->parser, _xml_endNamespaceDeclHandler); in PHP_FUNCTION()
1253 xml_parser *parser; in PHP_FUNCTION() local
1264 parser = Z_XMLPARSER_P(pind); in PHP_FUNCTION()
1265 if (parser->isparsing) { in PHP_FUNCTION()
1269 parser->isparsing = 1; in PHP_FUNCTION()
1270 ret = XML_Parse(parser->parser, (XML_Char*)data, data_len, isFinal); in PHP_FUNCTION()
1271 parser->isparsing = 0; in PHP_FUNCTION()
1280 xml_parser *parser; in PHP_FUNCTION() local
1290 parser = Z_XMLPARSER_P(pind); in PHP_FUNCTION()
1304 ZVAL_COPY_VALUE(&parser->data, xdata); in PHP_FUNCTION()
1307 ZVAL_COPY_VALUE(&parser->info, info); in PHP_FUNCTION()
1310 parser->level = 0; in PHP_FUNCTION()
1311 parser->ltags = safe_emalloc(XML_MAXLEVEL, sizeof(char *), 0); in PHP_FUNCTION()
1313 XML_SetElementHandler(parser->parser, _xml_startElementHandler, _xml_endElementHandler); in PHP_FUNCTION()
1314 XML_SetCharacterDataHandler(parser->parser, _xml_characterDataHandler); in PHP_FUNCTION()
1316 if (parser->isparsing) { in PHP_FUNCTION()
1320 parser->isparsing = 1; in PHP_FUNCTION()
1321 ret = XML_Parse(parser->parser, (XML_Char*)data, data_len, 1); in PHP_FUNCTION()
1322 parser->isparsing = 0; in PHP_FUNCTION()
1331 xml_parser *parser; in PHP_FUNCTION() local
1338 parser = Z_XMLPARSER_P(pind); in PHP_FUNCTION()
1339 RETURN_LONG((zend_long)XML_GetErrorCode(parser->parser)); in PHP_FUNCTION()
1363 xml_parser *parser; in PHP_FUNCTION() local
1370 parser = Z_XMLPARSER_P(pind); in PHP_FUNCTION()
1371 RETVAL_LONG(XML_GetCurrentLineNumber(parser->parser)); in PHP_FUNCTION()
1378 xml_parser *parser; in PHP_FUNCTION() local
1385 parser = Z_XMLPARSER_P(pind); in PHP_FUNCTION()
1386 RETVAL_LONG(XML_GetCurrentColumnNumber(parser->parser)); in PHP_FUNCTION()
1393 xml_parser *parser; in PHP_FUNCTION() local
1400 parser = Z_XMLPARSER_P(pind); in PHP_FUNCTION()
1401 RETVAL_LONG(XML_GetCurrentByteIndex(parser->parser)); in PHP_FUNCTION()
1409 xml_parser *parser; in PHP_FUNCTION() local
1415 parser = Z_XMLPARSER_P(pind); in PHP_FUNCTION()
1416 if (parser->isparsing == 1) { in PHP_FUNCTION()
1428 xml_parser *parser; in PHP_FUNCTION() local
1436 parser = Z_XMLPARSER_P(pind); in PHP_FUNCTION()
1439 parser->case_folding = zval_get_long(val); in PHP_FUNCTION()
1442 parser->toffset = zval_get_long(val); in PHP_FUNCTION()
1443 if (parser->toffset < 0) { in PHP_FUNCTION()
1445 parser->toffset = 0; in PHP_FUNCTION()
1449 parser->skipwhite = zval_get_long(val); in PHP_FUNCTION()
1463 parser->target_encoding = enc->name; in PHP_FUNCTION()
1478 xml_parser *parser; in PHP_FUNCTION() local
1486 parser = Z_XMLPARSER_P(pind); in PHP_FUNCTION()
1489 RETURN_LONG(parser->case_folding); in PHP_FUNCTION()
1492 RETURN_LONG(parser->toffset); in PHP_FUNCTION()
1495 RETURN_LONG(parser->skipwhite); in PHP_FUNCTION()
1498 RETURN_STRING((char *)parser->target_encoding); in PHP_FUNCTION()