utils/hooks: Set linux,stdout-path for primary console
[petitboot] / test / urls / parse-url.c
1
2 #include <stdlib.h>
3 #include <stdio.h>
4
5 #include <talloc/talloc.h>
6 #include <url/url.h>
7 #include <log/log.h>
8
9 int main(int argc, char **argv)
10 {
11         struct pb_url *url;
12         void *ctx;
13
14         if (argc != 2 && argc != 3) {
15                 fprintf(stderr, "Usage: %s <URL> [update]\n", argv[0]);
16                 return EXIT_FAILURE;
17         }
18
19         ctx = talloc_new(NULL);
20
21         url = pb_url_parse(ctx, argv[1]);
22         if (!url)
23                 return EXIT_FAILURE;
24
25         if (argc == 2) {
26                 printf("%s\n", argv[1]);
27
28         } else {
29                 struct pb_url *new_url;
30                 printf("%s %s\n", argv[1], argv[2]);
31                 new_url = pb_url_join(ctx, url, argv[2]);
32                 talloc_free(url);
33                 url = new_url;
34         }
35
36         printf("scheme\t%s\n", pb_url_scheme_name(url->scheme));
37         printf("host\t%s\n", url->host);
38         printf("port\t%s\n", url->port);
39         printf("path\t%s\n", url->path);
40         printf("dir\t%s\n", url->dir);
41         printf("file\t%s\n", url->file);
42
43         talloc_free(ctx);
44
45         return EXIT_SUCCESS;
46 }