aboutsummaryrefslogtreecommitdiff
path: root/include/url.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/url.h')
-rwxr-xr-xinclude/url.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/include/url.h b/include/url.h
new file mode 100755
index 0000000..c1278ee
--- /dev/null
+++ b/include/url.h
@@ -0,0 +1,42 @@
+#ifndef _URL_H_
+#define _URL_H_
+
+#define MAX_URL_LENGTH 2048
+
+/**
+ * Molerat URL.
+ *
+ * Holds all relevant for molehole to make requests.
+ */
+struct url {
+ char *scheme;
+ char *host;
+ int port;
+ char *path;
+ char *query;
+ char *fragment;
+};
+
+/**
+ * Parses a `*s` into `*url` as a molerat URL.
+ */
+int parse_url(struct url *url, char *s);
+
+/**
+ * Deallocates `struct url *url`.
+ */
+void free_url(struct url *url);
+
+/**
+ * Initializes a `struct url*` with sensible defaults.
+ */
+struct url *init_url(void);
+
+/**
+ * Get's the strlen of a `struct url*`
+ */
+int len_url(struct url *url);
+
+/* Error codes */
+enum UrlError { INVALID_CHARACTER = -1, MISSING_HOST = -2, MISSING_PORT = -3 };
+#endif