#include "config.h"
#endif
-#define _GNU_SOURCE
#include <assert.h>
-#include <stdbool.h>
#include <string.h>
#include "log/log.h"
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;
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:
return NULL;
}
-static bool is_url(const char *str)
+bool is_url(const char *str)
{
return strstr(str, "://") != NULL;
}
new_url = talloc(ctx, struct pb_url);
new_url->scheme = url->scheme;
- new_url->full = talloc_strdup(url, url->full);
+ new_url->full = talloc_strdup(new_url, url->full);
- new_url->host = url->host ? talloc_strdup(url, url->host) : NULL;
- new_url->port = url->port ? talloc_strdup(url, url->port) : NULL;
- new_url->path = url->path ? talloc_strdup(url, url->path) : NULL;
- new_url->dir = url->dir ? talloc_strdup(url, url->dir) : NULL;
- new_url->file = url->file ? talloc_strdup(url, url->file) : NULL;
+ new_url->host = url->host ? talloc_strdup(new_url, url->host) : NULL;
+ new_url->port = url->port ? talloc_strdup(new_url, url->port) : NULL;
+ new_url->path = url->path ? talloc_strdup(new_url, url->path) : NULL;
+ new_url->dir = url->dir ? talloc_strdup(new_url, url->dir) : NULL;
+ new_url->file = url->file ? talloc_strdup(new_url, url->file) : NULL;
return new_url;
}