commit 1bcb8303e1b913df31980ca332a5619424a72b01 from: Omar Polo date: Wed Jan 19 23:56:39 2022 UTC move load_page_from_str to telescope.c I'd like to use parser{,_gophermap,_gemtext}.c in standalone testing programs, and this function is getting in the way since it depends on ui.c commit - fe84b7508f733106d346acf1b120951c78ad77a1 commit + 1bcb8303e1b913df31980ca332a5619424a72b01 blob - 44bab64a89cb50c8229446662395b7912dc7e7f6 blob + a44cdba406d715fdfc5e068f0848918ce48fb8d7 --- parser.c +++ parser.c @@ -21,24 +21,7 @@ #include "parser.h" #include "telescope.h" -#include "ui.h" -/* - * Load a text/gemini page given the string page. Always returns 0. - */ -int -load_page_from_str(struct tab *tab, const char *page) -{ - parser_init(tab, gemtext_initparser); - if (!tab->buffer.page.parse(&tab->buffer.page, page, strlen(page))) - abort(); - if (!tab->buffer.page.free(&tab->buffer.page)) - abort(); - ui_on_tab_refresh(tab); - ui_on_tab_loaded(tab); - return 0; -} - void parser_init(struct tab *tab, parserfn fn) { blob - b4cb238fd315805241fb22da61a10bbc6d54b1b7 blob + 372529021fd1833629b45acdab87efb6e8a76704 --- parser.h +++ parser.h @@ -21,9 +21,6 @@ typedef void (*parserfn)(struct parser *); -/* parser.c */ -int load_page_from_str(struct tab *, const char *); - void parser_init(struct tab *, parserfn); int parser_parse(struct tab *, const char *, size_t); int parser_free(struct tab *); blob - eda6299eff5213af93e572d7143665cc0db0d7eb blob + 5662481216175398fd6fab6157e02e1886a1b674 --- telescope.c +++ telescope.c @@ -896,6 +896,19 @@ gopher_send_search_req(struct tab *tab, const char *te make_request(tab, &req, PROTO_GOPHER, NULL); } +int +load_page_from_str(struct tab *tab, const char *page) +{ + parser_init(tab, gemtext_initparser); + if (!tab->buffer.page.parse(&tab->buffer.page, page, strlen(page))) + abort(); + if (!tab->buffer.page.free(&tab->buffer.page)) + abort(); + ui_on_tab_refresh(tab); + ui_on_tab_loaded(tab); + return 0; +} + /* * Effectively load the given url in the given tab. Return 1 when * loading the page asynchronously, and thus when an erase_buffer can blob - 0d382ec23caf170cc4fcefab743e0b2626029bea blob + 06a9bd417000d3c81facb3e263499c6baefaa976 --- telescope.h +++ telescope.h @@ -332,6 +332,7 @@ extern int safe_mode; #define LU_MODE_NOCACHE 0x2 void gopher_send_search_req(struct tab *, const char *); +int load_page_from_str(struct tab *, const char *); void load_url(struct tab *, const char *, const char *, int); void load_url_in_tab(struct tab *, const char *, const char *, int); int load_previous_page(struct tab*);