X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=lib%2Furl%2Furl.c;h=6d1004f7f806d2ac6e94cfd9e265be4446eee852;hb=e52a8c61a640ab4fce0b4caaa796ae3e1c4ff8a3;hp=1e69774efb4e2a230d8cf24ca0dcd1973b699dcf;hpb=a8f70e4bb930253065a0596a3b1f4d7894b074a9;p=petitboot diff --git a/lib/url/url.c b/lib/url/url.c index 1e69774..6d1004f 100644 --- a/lib/url/url.c +++ b/lib/url/url.c @@ -162,8 +162,6 @@ struct pb_url *pb_url_parse(void *ctx, const char *url_str) struct pb_url *url; const char *p; - pb_log("%s: '%s'\n", __func__, url_str); - if (!url_str || !*url_str) { assert(0 && "bad url"); return NULL; @@ -223,13 +221,6 @@ struct pb_url *pb_url_parse(void *ctx, const char *url_str) pb_url_parse_path(url); - pb_log(" scheme %d\n", url->scheme); - pb_log(" host '%s'\n", url->host); - pb_log(" port '%s'\n", url->port); - pb_log(" path '%s'\n", url->path); - pb_log(" dir '%s'\n", url->dir); - pb_log(" file '%s'\n", url->file); - return url; fail: @@ -242,18 +233,21 @@ static bool is_url(const char *str) return strstr(str, "://") != NULL; } -static void pb_url_update_full(struct pb_url *url) +char *pb_url_to_string(struct pb_url *url) { const struct pb_scheme_info *scheme = pb_url_scheme_info(url->scheme); - assert(scheme); - talloc_free(url->full); - - url->full = talloc_asprintf(url, "%s://%s%s", scheme->str, + return talloc_asprintf(url, "%s://%s%s", scheme->str, scheme->has_host ? url->host : "", url->path); } +static void pb_url_update_full(struct pb_url *url) +{ + talloc_free(url->full); + url->full = pb_url_to_string(url); +} + static struct pb_url *pb_url_copy(void *ctx, const struct pb_url *url) { struct pb_url *new_url;