aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2019-08-02 20:08:27 +0200
committerdec05eba <dec05eba@protonmail.com>2019-08-02 20:08:27 +0200
commit65cf7681a04f2511db8c7829e9828b53a6676c88 (patch)
tree6e7db509cf2bce4a10fa6d8bc89a9eae88d893fa /tests
parent109c797d7c89223c9eed07dc322448b5c5fe3373 (diff)
Convert to sfml, starting on manganelo and youtube
Diffstat (limited to 'tests')
-rw-r--r--tests/main.c45
1 files changed, 0 insertions, 45 deletions
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 <stdio.h>
-#include "../include/Program.h"
-#include <quickmedia/HtmlSearch.h>
-#include <stdlib.h>
-#include <string.h>
-
-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;
-}