summaryrefslogtreecommitdiffstats
path: root/lib/libfetch/fetch.c
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>1998-12-21 19:41:50 +0000
committerdes <des@FreeBSD.org>1998-12-21 19:41:50 +0000
commit9eb60712989a0fae7fcc9dede444f5a2a2257b3e (patch)
tree39586fde93684776babc1e5c17c3e6d030d1e7ff /lib/libfetch/fetch.c
parent5dc2c17026e7f757a215f4d72924dfe769472532 (diff)
downloadFreeBSD-src-9eb60712989a0fae7fcc9dede444f5a2a2257b3e.zip
FreeBSD-src-9eb60712989a0fae7fcc9dede444f5a2a2257b3e.tar.gz
Implement and document file list retrieval.
Diffstat (limited to 'lib/libfetch/fetch.c')
-rw-r--r--lib/libfetch/fetch.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/lib/libfetch/fetch.c b/lib/libfetch/fetch.c
index 1dba89e..d8d2443 100644
--- a/lib/libfetch/fetch.c
+++ b/lib/libfetch/fetch.c
@@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $Id: fetch.c,v 1.6 1998/11/06 22:14:08 des Exp $
+ * $Id: fetch.c,v 1.7 1998/12/16 10:24:54 des Exp $
*/
#include <sys/param.h>
@@ -119,6 +119,25 @@ fetchStat(struct url *URL, struct url_stat *us, char *flags)
}
/*
+ * Select the appropriate protocol for the URL scheme, and return a
+ * list of files in the directory pointed to by the URL.
+ */
+struct url_ent *
+fetchList(struct url *URL, char *flags)
+{
+ if (strcasecmp(URL->scheme, "file") == 0)
+ return fetchListFile(URL, flags);
+ else if (strcasecmp(URL->scheme, "http") == 0)
+ return fetchListHTTP(URL, flags);
+ else if (strcasecmp(URL->scheme, "ftp") == 0)
+ return fetchListFTP(URL, flags);
+ else {
+ _url_seterr(URL_BAD_SCHEME);
+ return NULL;
+ }
+}
+
+/*
* Attempt to parse the given URL; if successful, call fetchGet().
*/
FILE *
@@ -174,6 +193,24 @@ fetchStatURL(char *URL, struct url_stat *us, char *flags)
}
/*
+ * Attempt to parse the given URL; if successful, call fetchList().
+ */
+struct url_ent *
+fetchListURL(char *URL, char *flags)
+{
+ struct url *u;
+ struct url_ent *ue;
+
+ if ((u = fetchParseURL(URL)) == NULL)
+ return NULL;
+
+ ue = fetchList(u, flags);
+
+ free(u);
+ return ue;
+}
+
+/*
* Split an URL into components. URL syntax is:
* method:[//[user[:pwd]@]host[:port]]/[document]
* This almost, but not quite, RFC1738 URL syntax.
OpenPOWER on IntegriCloud