projects
/
petitboot
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
lib: Add CCAN headers for endian helpers
[petitboot]
/
test
/
urls
/
parse-url.c
diff --git
a/test/urls/parse-url.c
b/test/urls/parse-url.c
index d748cdb2277d7d5b4fe834c76c40443a06fc1b6c..6637867c50497b5ff668a60194a02033080d0703 100644
(file)
--- a/
test/urls/parse-url.c
+++ b/
test/urls/parse-url.c
@@
-2,28
+2,37
@@
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
+#include <talloc/talloc.h>
#include <url/url.h>
#include <log/log.h>
int main(int argc, char **argv)
{
struct pb_url *url;
#include <url/url.h>
#include <log/log.h>
int main(int argc, char **argv)
{
struct pb_url *url;
-
FILE *null
;
+
void *ctx
;
- if (argc != 2) {
- fprintf(stderr, "Usage: %s <URL>\n", argv[0]);
+ if (argc != 2
&& argc != 3
) {
+ fprintf(stderr, "Usage: %s <URL>
[update]
\n", argv[0]);
return EXIT_FAILURE;
}
return EXIT_FAILURE;
}
- /* discard log output */
- null = fopen("/dev/null", "w");
- pb_log_set_stream(null);
+ ctx = talloc_new(NULL);
- url = pb_url_parse(
NULL
, argv[1]);
+ url = pb_url_parse(
ctx
, argv[1]);
if (!url)
return EXIT_FAILURE;
if (!url)
return EXIT_FAILURE;
- printf("%s\n", argv[1]);
+ if (argc == 2) {
+ printf("%s\n", argv[1]);
+
+ } else {
+ struct pb_url *new_url;
+ printf("%s %s\n", argv[1], argv[2]);
+ new_url = pb_url_join(ctx, url, argv[2]);
+ talloc_free(url);
+ url = new_url;
+ }
+
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("scheme\t%s\n", pb_url_scheme_name(url->scheme));
printf("host\t%s\n", url->host);
printf("port\t%s\n", url->port);
@@
-31,5
+40,7
@@
int main(int argc, char **argv)
printf("dir\t%s\n", url->dir);
printf("file\t%s\n", url->file);
printf("dir\t%s\n", url->dir);
printf("file\t%s\n", url->file);
+ talloc_free(ctx);
+
return EXIT_SUCCESS;
}
return EXIT_SUCCESS;
}