Deleted Added
sdiff udiff text old ( 174761 ) new ( 186241 )
full compact
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 174761 2007-12-19 00:26:36Z des $");
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 int direct;
78
79 direct = CHECK_FLAG('d');
80 if (us != NULL) {
81 us->size = -1;
82 us->atime = us->mtime = 0;
83 }
84 if (strcasecmp(URL->scheme, SCHEME_FILE) == 0)
85 return (fetchXGetFile(URL, us, flags));
86 else if (strcasecmp(URL->scheme, SCHEME_FTP) == 0)
87 return (fetchXGetFTP(URL, us, flags));

--- 17 unchanged lines hidden (view full) ---

105
106/*
107 * Select the appropriate protocol for the URL scheme, and return a
108 * write-only stream connected to the document referenced by the URL.
109 */
110FILE *
111fetchPut(struct url *URL, const char *flags)
112{
113 int direct;
114
115 direct = CHECK_FLAG('d');
116 if (strcasecmp(URL->scheme, SCHEME_FILE) == 0)
117 return (fetchPutFile(URL, flags));
118 else if (strcasecmp(URL->scheme, SCHEME_FTP) == 0)
119 return (fetchPutFTP(URL, flags));
120 else if (strcasecmp(URL->scheme, SCHEME_HTTP) == 0)
121 return (fetchPutHTTP(URL, flags));
122 else if (strcasecmp(URL->scheme, SCHEME_HTTPS) == 0)
123 return (fetchPutHTTP(URL, flags));
124 url_seterr(URL_BAD_SCHEME);
125 return (NULL);
126}
127
128/*
129 * Select the appropriate protocol for the URL scheme, and return the
130 * size of the document referenced by the URL if it exists.
131 */
132int
133fetchStat(struct url *URL, struct url_stat *us, const char *flags)
134{
135 int direct;
136
137 direct = CHECK_FLAG('d');
138 if (us != NULL) {
139 us->size = -1;
140 us->atime = us->mtime = 0;
141 }
142 if (strcasecmp(URL->scheme, SCHEME_FILE) == 0)
143 return (fetchStatFile(URL, us, flags));
144 else if (strcasecmp(URL->scheme, SCHEME_FTP) == 0)
145 return (fetchStatFTP(URL, us, flags));

--- 7 unchanged lines hidden (view full) ---

153
154/*
155 * Select the appropriate protocol for the URL scheme, and return a
156 * list of files in the directory pointed to by the URL.
157 */
158struct url_ent *
159fetchList(struct url *URL, const char *flags)
160{
161 int direct;
162
163 direct = CHECK_FLAG('d');
164 if (strcasecmp(URL->scheme, SCHEME_FILE) == 0)
165 return (fetchListFile(URL, flags));
166 else if (strcasecmp(URL->scheme, SCHEME_FTP) == 0)
167 return (fetchListFTP(URL, flags));
168 else if (strcasecmp(URL->scheme, SCHEME_HTTP) == 0)
169 return (fetchListHTTP(URL, flags));
170 else if (strcasecmp(URL->scheme, SCHEME_HTTPS) == 0)
171 return (fetchListHTTP(URL, flags));

--- 267 unchanged lines hidden ---