summaryrefslogtreecommitdiffstats
path: root/lib/libfetch/fetch.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libfetch/fetch.c')
-rw-r--r--lib/libfetch/fetch.c35
1 files changed, 27 insertions, 8 deletions
diff --git a/lib/libfetch/fetch.c b/lib/libfetch/fetch.c
index adb95c9..cb09efc 100644
--- a/lib/libfetch/fetch.c
+++ b/lib/libfetch/fetch.c
@@ -67,22 +67,23 @@ static struct fetcherr _url_errlist[] = {
/*
* Select the appropriate protocol for the URL scheme, and return a
* read-only stream connected to the document referenced by the URL.
+ * Also fill out the struct url_stat.
*/
FILE *
-fetchGet(struct url *URL, char *flags)
+fetchXGet(struct url *URL, struct url_stat *us, char *flags)
{
int direct;
direct = (flags && strchr(flags, 'd'));
if (strcasecmp(URL->scheme, "file") == 0)
- return fetchGetFile(URL, flags);
+ return fetchXGetFile(URL, us, flags);
else if (strcasecmp(URL->scheme, "http") == 0)
- return fetchGetHTTP(URL, flags);
+ return fetchXGetHTTP(URL, us, flags);
else if (strcasecmp(URL->scheme, "ftp") == 0) {
if (!direct &&
getenv("FTP_PROXY") == NULL && getenv("HTTP_PROXY") != NULL)
- return fetchGetHTTP(URL, flags);
- return fetchGetFTP(URL, flags);
+ return fetchXGetHTTP(URL, us, flags);
+ return fetchXGetFTP(URL, us, flags);
} else {
_url_seterr(URL_BAD_SCHEME);
return NULL;
@@ -91,6 +92,16 @@ fetchGet(struct url *URL, char *flags)
/*
* Select the appropriate protocol for the URL scheme, and return a
+ * read-only stream connected to the document referenced by the URL.
+ */
+FILE *
+fetchGet(struct url *URL, char *flags)
+{
+ return fetchXGet(URL, NULL, flags);
+}
+
+/*
+ * Select the appropriate protocol for the URL scheme, and return a
* write-only stream connected to the document referenced by the URL.
*/
FILE *
@@ -165,10 +176,10 @@ fetchList(struct url *URL, char *flags)
}
/*
- * Attempt to parse the given URL; if successful, call fetchGet().
+ * Attempt to parse the given URL; if successful, call fetchXGet().
*/
FILE *
-fetchGetURL(char *URL, char *flags)
+fetchXGetURL(char *URL, struct url_stat *us, char *flags)
{
struct url *u;
FILE *f;
@@ -176,12 +187,20 @@ fetchGetURL(char *URL, char *flags)
if ((u = fetchParseURL(URL)) == NULL)
return NULL;
- f = fetchGet(u, flags);
+ f = fetchXGet(u, us, flags);
fetchFreeURL(u);
return f;
}
+/*
+ * Attempt to parse the given URL; if successful, call fetchGet().
+ */
+FILE *
+fetchGetURL(char *URL, char *flags)
+{
+ return fetchXGetURL(URL, NULL, flags);
+}
/*
* Attempt to parse the given URL; if successful, call fetchPut().
OpenPOWER on IntegriCloud