From 61741ce6c540bd8b274ac6156b3d0bdfe2af2991 Mon Sep 17 00:00:00 2001 From: lexborisov Date: Mon, 21 Nov 2016 15:18:31 +0300 Subject: [PATCH] Added function mycss_entry_selectors for get selectors object from mycss entry https://github.com/lexborisov/Modest/issues/3#issuecomment-261920007 --- examples/selectors/selectors_low_level.c | 6 +++--- include/mycss/entry.h | 3 +++ source/mycss/entry.c | 6 ++++++ source/mycss/entry.h | 3 +++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/examples/selectors/selectors_low_level.c b/examples/selectors/selectors_low_level.c index 3c1272f..084abc8 100644 --- a/examples/selectors/selectors_low_level.c +++ b/examples/selectors/selectors_low_level.c @@ -80,7 +80,7 @@ int main(int argc, const char * argv[]) mycss_status_t out_status; modest_finder_t *finder = modest_finder_create_simple(html_tree, NULL); - mycss_selectors_list_t *list = mycss_selectors_parse(css_entry->selectors, MyHTML_ENCODING_UTF_8, selector, strlen(selector), &out_status); + mycss_selectors_list_t *list = mycss_selectors_parse(mycss_entry_selectors(css_entry), MyHTML_ENCODING_UTF_8, selector, strlen(selector), &out_status); myhtml_collection_t *collection = modest_finder_by_selectors_list(finder, list, html_tree->node_html, NULL); @@ -90,7 +90,7 @@ int main(int argc, const char * argv[]) fprintf(stdout, "\n"); fprintf(stdout, "Selector:\n\t"); - mycss_selectors_serialization_list(css_entry->selectors, list, serialization_callback, NULL); + mycss_selectors_serialization_list(mycss_entry_selectors(css_entry), list, serialization_callback, NULL); fprintf(stdout, "\n"); printf("\nFound result:\n"); @@ -101,7 +101,7 @@ int main(int argc, const char * argv[]) fprintf(stdout, "\n"); // destroy all - mycss_selectors_list_destroy(css_entry->selectors, list, true); + mycss_selectors_list_destroy(mycss_entry_selectors(css_entry), list, true); myhtml_collection_destroy(collection); /* destroy Modest finder */ diff --git a/include/mycss/entry.h b/include/mycss/entry.h index 37f94a3..35abcee 100644 --- a/include/mycss/entry.h +++ b/include/mycss/entry.h @@ -119,6 +119,9 @@ mycss_entry_t * mycss_entry_destroy(mycss_entry_t* entry, bool self_destroy); void mycss_entry_end(mycss_entry_t* entry); +/* api */ +mycss_selectors_t * mycss_entry_selectors(mycss_entry_t* entry); + mycss_token_ready_callback_f mycss_entry_token_ready_callback(mycss_entry_t* entry, mycss_token_ready_callback_f callback_f); size_t mycss_entry_token_count(mycss_entry_t* entry); diff --git a/source/mycss/entry.c b/source/mycss/entry.c index e06bef9..ba4c46e 100644 --- a/source/mycss/entry.c +++ b/source/mycss/entry.c @@ -206,6 +206,12 @@ void mycss_entry_end(mycss_entry_t* entry) /* need some code */ } +/* api */ +mycss_selectors_t * mycss_entry_selectors(mycss_entry_t* entry) +{ + return entry->selectors; +} + myhtml_string_t * mycss_entry_string_create_and_init(mycss_entry_t* entry, size_t string_size) { myhtml_string_t *str = mcobject_malloc(entry->mcobject_string_entries, NULL); diff --git a/source/mycss/entry.h b/source/mycss/entry.h index df03f53..ebb104a 100644 --- a/source/mycss/entry.h +++ b/source/mycss/entry.h @@ -119,6 +119,9 @@ mycss_entry_t * mycss_entry_destroy(mycss_entry_t* entry, bool self_destroy); void mycss_entry_end(mycss_entry_t* entry); +/* api */ +mycss_selectors_t * mycss_entry_selectors(mycss_entry_t* entry); + mycss_token_ready_callback_f mycss_entry_token_ready_callback(mycss_entry_t* entry, mycss_token_ready_callback_f callback_f); size_t mycss_entry_token_count(mycss_entry_t* entry);