summaryrefslogtreecommitdiffstats
path: root/test/urls/parse-url.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/urls/parse-url.c')
-rw-r--r--test/urls/parse-url.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/urls/parse-url.c b/test/urls/parse-url.c
new file mode 100644
index 0000000..3e2f10f
--- /dev/null
+++ b/test/urls/parse-url.c
@@ -0,0 +1,35 @@
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include <ui/common/url.h>
+#include <log/log.h>
+
+int main(int argc, char **argv)
+{
+ struct pb_url *url;
+ FILE *null;
+
+ if (argc != 2) {
+ fprintf(stderr, "Usage: %s <URL>\n", argv[0]);
+ return EXIT_FAILURE;
+ }
+
+ /* discard log output */
+ null = fopen("/dev/null", "w");
+ pb_log_set_stream(null);
+
+ url = pb_url_parse(NULL, argv[1]);
+ if (!url)
+ return EXIT_FAILURE;
+
+ printf("%s\n", argv[1]);
+ printf("scheme\t%s\n", pb_url_scheme_name(url->scheme));
+ printf("host\t%s\n", url->host);
+ printf("port\t%s\n", url->port);
+ printf("path\t%s\n", url->path);
+ printf("dir\t%s\n", url->dir);
+ printf("file\t%s\n", url->file);
+
+ return EXIT_SUCCESS;
+}
OpenPOWER on IntegriCloud