aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-07-02 17:42:37 +0200
committerdec05eba <dec05eba@protonmail.com>2021-07-02 17:42:37 +0200
commit2b1a4ac7ad5743400fa875a91ee6869fcd94a9ed (patch)
tree136f282c5fcd53e37d053f39f97acd607529380b /include
parent78f204d79c9ed61815a7eb206f2c1a4f4df289a0 (diff)
Return non-0 value from callback to cancel parsing (and return the value in html_parser_parse)
Diffstat (limited to 'include')
-rw-r--r--include/HtmlParser.h10
1 files changed, 7 insertions, 3 deletions
diff --git a/include/HtmlParser.h b/include/HtmlParser.h
index e6f0c3b..a7cdb4f 100644
--- a/include/HtmlParser.h
+++ b/include/HtmlParser.h
@@ -27,7 +27,8 @@ typedef enum{
HTML_PARSE_JAVASCRIPT_CODE
} HtmlParseType;
-typedef void (*HtmlParseCallback)(HtmlParser *html_parser, HtmlParseType parse_type, void *userdata);
+/* Return 0 to continue */
+typedef int (*HtmlParseCallback)(HtmlParser *html_parser, HtmlParseType parse_type, void *userdata);
#define UNCLOSED_TAGS_SIZE 2048
@@ -53,8 +54,11 @@ struct HtmlParser {
HtmlStringView unclosed_tags[UNCLOSED_TAGS_SIZE];
};
-/* Note: HTML_PARSE_TAG_START is guaranteed to be called for a tag before HTML_PARSE_TAG_END */
-void html_parser_parse(const char *html_source, size_t len, HtmlParseCallback parse_callback, void *userdata);
+/*
+ Returns the value returned from |parse_callback|. 0 meaning success.
+ Note: HTML_PARSE_TAG_START is guaranteed to be called for a tag before HTML_PARSE_TAG_END
+*/
+int html_parser_parse(const char *html_source, size_t len, HtmlParseCallback parse_callback, void *userdata);
#ifdef __cplusplus
}