]> git.ozlabs.org Git - petitboot/blob - urls/parse-url.c
discover/grub2: Allow to separate the --id argument using a space char
[petitboot] / urls / parse-url.c
1
2 #include <stdlib.h>
3 #include <stdio.h>
4
5 #include <url/url.h>
6 #include <log/log.h>
7
8 int main(int argc, char **argv)
9 {
10         struct pb_url *url;
11         FILE *null;
12
13         if (argc != 2) {
14                 fprintf(stderr, "Usage: %s <URL>\n", argv[0]);
15                 return EXIT_FAILURE;
16         }
17
18         /* discard log output */
19         null = fopen("/dev/null", "w");
20         pb_log_set_stream(null);
21
22         url = pb_url_parse(NULL, argv[1]);
23         if (!url)
24                 return EXIT_FAILURE;
25
26         printf("%s\n", argv[1]);
27         printf("scheme\t%s\n", pb_url_scheme_name(url->scheme));
28         printf("host\t%s\n", url->host);
29         printf("port\t%s\n", url->port);
30         printf("path\t%s\n", url->path);
31         printf("dir\t%s\n", url->dir);
32         printf("file\t%s\n", url->file);
33
34         return EXIT_SUCCESS;
35 }