+/**
+ * load_url - Loads a (possibly) remote URL and returns the local file
+ * path.
+ * @ctx: The talloc context to associate with the returned string.
+ * @URL: The remote file URL.
+ * @tempfile: An optional variable pointer to be set when a temporary local
+ * file is created.
+ *
+ * Returns the local file path in a talloc'ed character string on success,
+ * or NULL on error.
+ */
+
+char *load_url(void *ctx, struct pb_url *url, unsigned int *tempfile)
+{
+ char *local;
+ int tmp = 0;
+
+ if (!url)
+ return NULL;
+
+ switch (url->scheme) {
+ case pb_url_ftp:
+ case pb_url_http:
+ local = load_wget(ctx, url, 0);
+ tmp = !!local;
+ break;
+ case pb_url_https:
+ local = load_wget(ctx, url, wget_no_check_certificate);
+ tmp = !!local;
+ break;
+ case pb_url_nfs:
+ local = load_nfs(ctx, url);
+ tmp = !!local;
+ break;
+ case pb_url_sftp:
+ local = load_sftp(ctx, url);
+ tmp = !!local;
+ break;
+ case pb_url_tftp:
+ local = load_tftp(ctx, url);
+ tmp = !!local;
+ break;
+ default:
+ local = talloc_strdup(ctx, url->full);
+ tmp = 0;
+ break;
+ }
+
+ if (tempfile)
+ *tempfile = tmp;
+
+ return local;
+}