1/*- 2 * Copyright (c) 1998-2004 Dag-Erling Co�dan Sm�rgrav 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 13 unchanged lines hidden (view full) --- 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29#include <sys/cdefs.h> |
30__FBSDID("$FreeBSD: head/lib/libfetch/fetch.c 186241 2008-12-17 18:00:18Z murray $"); |
31 32#include <sys/param.h> 33#include <sys/errno.h> 34 35#include <ctype.h> 36#include <stdio.h> 37#include <stdlib.h> 38#include <string.h> --- 30 unchanged lines hidden (view full) --- 69/* 70 * Select the appropriate protocol for the URL scheme, and return a 71 * read-only stream connected to the document referenced by the URL. 72 * Also fill out the struct url_stat. 73 */ 74FILE * 75fetchXGet(struct url *URL, struct url_stat *us, const char *flags) 76{ |
77 |
78 if (us != NULL) { 79 us->size = -1; 80 us->atime = us->mtime = 0; 81 } 82 if (strcasecmp(URL->scheme, SCHEME_FILE) == 0) 83 return (fetchXGetFile(URL, us, flags)); 84 else if (strcasecmp(URL->scheme, SCHEME_FTP) == 0) 85 return (fetchXGetFTP(URL, us, flags)); --- 17 unchanged lines hidden (view full) --- 103 104/* 105 * Select the appropriate protocol for the URL scheme, and return a 106 * write-only stream connected to the document referenced by the URL. 107 */ 108FILE * 109fetchPut(struct url *URL, const char *flags) 110{ |
111 |
112 if (strcasecmp(URL->scheme, SCHEME_FILE) == 0) 113 return (fetchPutFile(URL, flags)); 114 else if (strcasecmp(URL->scheme, SCHEME_FTP) == 0) 115 return (fetchPutFTP(URL, flags)); 116 else if (strcasecmp(URL->scheme, SCHEME_HTTP) == 0) 117 return (fetchPutHTTP(URL, flags)); 118 else if (strcasecmp(URL->scheme, SCHEME_HTTPS) == 0) 119 return (fetchPutHTTP(URL, flags)); 120 url_seterr(URL_BAD_SCHEME); 121 return (NULL); 122} 123 124/* 125 * Select the appropriate protocol for the URL scheme, and return the 126 * size of the document referenced by the URL if it exists. 127 */ 128int 129fetchStat(struct url *URL, struct url_stat *us, const char *flags) 130{ |
131 |
132 if (us != NULL) { 133 us->size = -1; 134 us->atime = us->mtime = 0; 135 } 136 if (strcasecmp(URL->scheme, SCHEME_FILE) == 0) 137 return (fetchStatFile(URL, us, flags)); 138 else if (strcasecmp(URL->scheme, SCHEME_FTP) == 0) 139 return (fetchStatFTP(URL, us, flags)); --- 7 unchanged lines hidden (view full) --- 147 148/* 149 * Select the appropriate protocol for the URL scheme, and return a 150 * list of files in the directory pointed to by the URL. 151 */ 152struct url_ent * 153fetchList(struct url *URL, const char *flags) 154{ |
155 |
156 if (strcasecmp(URL->scheme, SCHEME_FILE) == 0) 157 return (fetchListFile(URL, flags)); 158 else if (strcasecmp(URL->scheme, SCHEME_FTP) == 0) 159 return (fetchListFTP(URL, flags)); 160 else if (strcasecmp(URL->scheme, SCHEME_HTTP) == 0) 161 return (fetchListHTTP(URL, flags)); 162 else if (strcasecmp(URL->scheme, SCHEME_HTTPS) == 0) 163 return (fetchListHTTP(URL, flags)); --- 267 unchanged lines hidden --- |