summary refs log tree commit diff stats
path: root/test.c
diff options
context:
space:
mode:
authorAli Fardan <raiz@stellarbound.space>2020-11-18 10:55:20 +0300
committerAli Fardan <raiz@stellarbound.space>2020-11-18 10:55:20 +0300
commit6f3d10a3ec09cc278041ced4d4e506cb89a7c69a (patch)
tree5b5c7db3104d805d71029534cffcfd5d9c2aca0b /test.c
downloadlibyuri-6f3d10a3ec09cc278041ced4d4e506cb89a7c69a.tar.gz
initial commit; todo: thorough testing
Diffstat (limited to 'test.c')
-rw-r--r--test.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/test.c b/test.c
new file mode 100644
index 0000000..c1cdd72
--- /dev/null
+++ b/test.c
@@ -0,0 +1,38 @@
+#include <stdio.h>
+
+#include "yuri.h"
+
+static void
+_print_uri(struct uri *u)
+{
+	int i;
+
+	printf("Scheme: \"%s\"\n", u->scheme);
+	printf("Authority type: %d\n", u->authority.type);
+	printf("Authority user: \"%s\"\n", u->authority.user);
+	printf("Authority host: \"%s\"\n", u->authority.host);
+	printf("Authority port: %d\n", u->authority.port);
+	for (i = 0; i < u->npath; i++)
+		printf("Path: %d: \"%s\"\n", i+1, u->path[i]);
+	printf("Query: \"%s\"\n", u->query);
+	printf("Fragment: \"%s\"\n", u->fragment);
+}
+
+int
+main(int argc, char *argv[])
+{
+	struct uri *u;
+
+	if (argc < 2) {
+		fprintf(stderr, "Usage %s url\n", argv[0]);
+		return 1;
+	}
+	u = uri_decode(argv[1]);
+	if (u == NULL)
+		return 1;
+	if (uri_normalize(u) == -1)
+		return 1;
+	_print_uri(u);
+	uri_free(u);
+	return 0;
+}