summaryrefslogtreecommitdiffstats
path: root/lib/libfetch/fetch.c
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2000-07-17 21:25:00 +0000
committerdes <des@FreeBSD.org>2000-07-17 21:25:00 +0000
commit3033318809d10165bff918597656578a8dc16bd9 (patch)
tree00a4cf3f1c1814ebff20dc85906c41eb5d9c7ccb /lib/libfetch/fetch.c
parent9e42d615d8102289f59981b6332a387ed4c92781 (diff)
downloadFreeBSD-src-3033318809d10165bff918597656578a8dc16bd9.zip
FreeBSD-src-3033318809d10165bff918597656578a8dc16bd9.tar.gz
Introduce fetchXGet*(), which combine the functionalities of fetchGet*() and
fetchStat*(). In most cases, either fetchGet*() or fetchXGet*() is a wrapper around the other; in all cases, calling fetchGet*() is identical to calling fetchXGet*() with the second argument set to NULL.
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