aboutsummaryrefslogtreecommitdiff
path: root/include/quickmedia
diff options
context:
space:
mode:
Diffstat (limited to 'include/quickmedia')
-rw-r--r--include/quickmedia/HtmlSearch.h31
-rw-r--r--include/quickmedia/NodeSearch.h29
-rw-r--r--include/quickmedia/XpathParser.h8
-rw-r--r--include/quickmedia/XpathTokenizer.h32
4 files changed, 100 insertions, 0 deletions
diff --git a/include/quickmedia/HtmlSearch.h b/include/quickmedia/HtmlSearch.h
new file mode 100644
index 0000000..e3bea33
--- /dev/null
+++ b/include/quickmedia/HtmlSearch.h
@@ -0,0 +1,31 @@
+#ifndef QUICKMEDIA_HTML_SEARCH_H
+#define QUICKMEDIA_HTML_SEARCH_H
+
+#include "NodeSearch.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct {
+ const void *doc;
+ const void *node;
+ void *text;
+} QuickMediaHtmlNode;
+
+/* Returns NULL if attribute doesn't exist or if it doesn't have any value */
+const char* quickmedia_html_node_get_attribute_value(QuickMediaHtmlNode *self, const char *attribute_name);
+
+/* Returns StringView where data is NULL and size is 0 if node doesn't have any text */
+const QuickMediaStringView quickmedia_html_node_get_text(QuickMediaHtmlNode *self);
+
+/* @node is only valid within the callback function scope */
+typedef void (*QuickMediaHtmlSearchResultCallback)(QuickMediaHtmlNode *node, void *userdata);
+
+int quickmedia_html_find_nodes_xpath(const char *html_source, const char *xpath, QuickMediaHtmlSearchResultCallback result_callback, void *userdata);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/quickmedia/NodeSearch.h b/include/quickmedia/NodeSearch.h
new file mode 100644
index 0000000..b512296
--- /dev/null
+++ b/include/quickmedia/NodeSearch.h
@@ -0,0 +1,29 @@
+#ifndef QUICKMEDIA_NODE_SEARCH_H
+#define QUICKMEDIA_NODE_SEARCH_H
+
+typedef struct {
+ char *name;
+ char *value;
+} QuickMediaNodeSearchParam;
+
+typedef struct QuickMediaNodeSearch QuickMediaNodeSearch;
+
+struct QuickMediaNodeSearch {
+ char *name; /* optional */
+ int recursive;
+ QuickMediaNodeSearchParam param; /* optional */
+ int param_defined;
+
+ QuickMediaNodeSearch *child; /* optional */
+};
+
+typedef struct {
+ const char *data;
+ unsigned long long size;
+} QuickMediaStringView;
+
+void quickmedia_node_search_param_init(QuickMediaNodeSearchParam *self);
+void quickmedia_node_search_init(QuickMediaNodeSearch *self);
+void quickmedia_node_search_deinit(QuickMediaNodeSearch *self);
+
+#endif
diff --git a/include/quickmedia/XpathParser.h b/include/quickmedia/XpathParser.h
new file mode 100644
index 0000000..2dfc81e
--- /dev/null
+++ b/include/quickmedia/XpathParser.h
@@ -0,0 +1,8 @@
+#ifndef QUICKMEDIA_XPATH_PARSER_H
+#define QUICKMEDIA_XPATH_PARSER_H
+
+#include "NodeSearch.h"
+
+int quickmedia_parse_xpath(const char *xpath, QuickMediaNodeSearch *result);
+
+#endif
diff --git a/include/quickmedia/XpathTokenizer.h b/include/quickmedia/XpathTokenizer.h
new file mode 100644
index 0000000..8827cff
--- /dev/null
+++ b/include/quickmedia/XpathTokenizer.h
@@ -0,0 +1,32 @@
+#ifndef QUICKMEDIA_XPATH_TOKENIZER_H
+#define QUICKMEDIA_XPATH_TOKENIZER_H
+
+#include "NodeSearch.h"
+
+typedef struct {
+ const char *code;
+ union {
+ QuickMediaStringView string;
+ QuickMediaStringView identifier;
+ };
+} QuickMediaXpathTokenizer;
+
+typedef enum {
+ QUICKMEDIA_XPATH_TOKEN_INVALID,
+ QUICKMEDIA_XPATH_TOKEN_END_OF_FILE,
+ QUICKMEDIA_XPATH_TOKEN_CHILD,
+ QUICKMEDIA_XPATH_TOKEN_CHILD_RECURSIVE,
+ QUICKMEDIA_XPATH_TOKEN_IDENTIFIER,
+ QUICKMEDIA_XPATH_TOKEN_STRING,
+ QUICKMEDIA_XPATH_TOKEN_OPEN_BRACKET,
+ QUICKMEDIA_XPATH_TOKEN_CLOSING_BRACKET,
+ QUICKMEDIA_XPATH_TOKEN_EQUAL
+} QuickMediaXpathToken;
+
+void quickmedia_xpath_tokenizer_init(QuickMediaXpathTokenizer *self, const char *xpath);
+QuickMediaXpathToken quickmedia_xpath_tokenizer_next(QuickMediaXpathTokenizer *self);
+int quickmedia_xpath_tokenizer_next_if(QuickMediaXpathTokenizer *self, QuickMediaXpathToken token);
+char* quickmedia_xpath_tokenizer_copy_identifier(QuickMediaXpathTokenizer *self);
+char* quickmedia_xpath_tokenizer_copy_string(QuickMediaXpathTokenizer *self);
+
+#endif