From 65cf7681a04f2511db8c7829e9828b53a6676c88 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 2 Aug 2019 20:08:27 +0200 Subject: Convert to sfml, starting on manganelo and youtube --- tests/main.c | 45 --------------------------------------------- 1 file changed, 45 deletions(-) delete mode 100644 tests/main.c (limited to 'tests') diff --git a/tests/main.c b/tests/main.c deleted file mode 100644 index 3ba930b..0000000 --- a/tests/main.c +++ /dev/null @@ -1,45 +0,0 @@ -#include -#include "../include/Program.h" -#include -#include -#include - -typedef struct { - char *data; - size_t size; -} Buffer; - -static int program_output_callback(char *data, int size, void *userdata) { - Buffer *buf = userdata; - size_t new_size = buf->size + size; - buf->data = realloc(buf->data, new_size + 1); - buf->data[new_size] = '\0'; - memcpy(buf->data + buf->size, data, size); - buf->size = new_size; - return 0; -} - -static void html_search_callback(QuickMediaHtmlNode *node, void *userdata) { - const char *href = quickmedia_html_node_get_attribute_value(node, "href"); - QuickMediaStringView text = quickmedia_html_node_get_text(node); - printf("a href: %s, text: %.*s\n", href, text.size, text.data); -} - -int main(int argc, char **argv) { - Buffer buf; - buf.data = NULL; - buf.size = 0; - char *args[] = { "/usr/bin/curl", "-s", "-L", "https://manganelo.com/search/naruto", NULL }; - exec_program(args, program_output_callback, &buf); - /*printf("%s\n", buf.data);*/ - - QuickMediaHtmlSearch html_search; - if(quickmedia_html_search_init(&html_search, buf.data) != 0) - return -1; - if(quickmedia_html_find_nodes_xpath(&html_search, "//h3[class=\"story_name\"]//a", html_search_callback, NULL) != 0) - return -1; - quickmedia_html_search_deinit(&html_search); - - free(buf.data); - return 0; -} -- cgit v1.2.3