From 9eb60712989a0fae7fcc9dede444f5a2a2257b3e Mon Sep 17 00:00:00 2001 From: des Date: Mon, 21 Dec 1998 19:41:50 +0000 Subject: Implement and document file list retrieval. --- lib/libfetch/fetch.c | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'lib/libfetch/fetch.c') 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 @@ -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. -- cgit v1.1