Deleted Added
full compact
fetch.c (63334) fetch.c (63340)
1/*-
2 * Copyright (c) 1998 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

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

20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
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 *
1/*-
2 * Copyright (c) 1998 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

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

20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
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 * $FreeBSD: head/lib/libfetch/fetch.c 63334 2000-07-17 20:49:39Z des $
28 * $FreeBSD: head/lib/libfetch/fetch.c 63340 2000-07-17 21:25:00Z des $
29 */
30
31#include <sys/param.h>
32#include <sys/errno.h>
33
34#include <ctype.h>
35#include <stdio.h>
36#include <stdlib.h>

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

62};
63
64
65/*** Public API **************************************************************/
66
67/*
68 * Select the appropriate protocol for the URL scheme, and return a
69 * read-only stream connected to the document referenced by the URL.
29 */
30
31#include <sys/param.h>
32#include <sys/errno.h>
33
34#include <ctype.h>
35#include <stdio.h>
36#include <stdlib.h>

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

62};
63
64
65/*** Public API **************************************************************/
66
67/*
68 * Select the appropriate protocol for the URL scheme, and return a
69 * read-only stream connected to the document referenced by the URL.
70 * Also fill out the struct url_stat.
70 */
71FILE *
71 */
72FILE *
72fetchGet(struct url *URL, char *flags)
73fetchXGet(struct url *URL, struct url_stat *us, char *flags)
73{
74 int direct;
75
76 direct = (flags && strchr(flags, 'd'));
77 if (strcasecmp(URL->scheme, "file") == 0)
74{
75 int direct;
76
77 direct = (flags && strchr(flags, 'd'));
78 if (strcasecmp(URL->scheme, "file") == 0)
78 return fetchGetFile(URL, flags);
79 return fetchXGetFile(URL, us, flags);
79 else if (strcasecmp(URL->scheme, "http") == 0)
80 else if (strcasecmp(URL->scheme, "http") == 0)
80 return fetchGetHTTP(URL, flags);
81 return fetchXGetHTTP(URL, us, flags);
81 else if (strcasecmp(URL->scheme, "ftp") == 0) {
82 if (!direct &&
83 getenv("FTP_PROXY") == NULL && getenv("HTTP_PROXY") != NULL)
82 else if (strcasecmp(URL->scheme, "ftp") == 0) {
83 if (!direct &&
84 getenv("FTP_PROXY") == NULL && getenv("HTTP_PROXY") != NULL)
84 return fetchGetHTTP(URL, flags);
85 return fetchGetFTP(URL, flags);
85 return fetchXGetHTTP(URL, us, flags);
86 return fetchXGetFTP(URL, us, flags);
86 } else {
87 _url_seterr(URL_BAD_SCHEME);
88 return NULL;
89 }
90}
91
92/*
93 * Select the appropriate protocol for the URL scheme, and return a
87 } else {
88 _url_seterr(URL_BAD_SCHEME);
89 return NULL;
90 }
91}
92
93/*
94 * Select the appropriate protocol for the URL scheme, and return a
95 * read-only stream connected to the document referenced by the URL.
96 */
97FILE *
98fetchGet(struct url *URL, char *flags)
99{
100 return fetchXGet(URL, NULL, flags);
101}
102
103/*
104 * Select the appropriate protocol for the URL scheme, and return a
94 * write-only stream connected to the document referenced by the URL.
95 */
96FILE *
97fetchPut(struct url *URL, char *flags)
98{
99 int direct;
100
101 direct = (flags && strchr(flags, 'd'));

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

160 return fetchListFTP(URL, flags);
161 } else {
162 _url_seterr(URL_BAD_SCHEME);
163 return NULL;
164 }
165}
166
167/*
105 * write-only stream connected to the document referenced by the URL.
106 */
107FILE *
108fetchPut(struct url *URL, char *flags)
109{
110 int direct;
111
112 direct = (flags && strchr(flags, 'd'));

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

171 return fetchListFTP(URL, flags);
172 } else {
173 _url_seterr(URL_BAD_SCHEME);
174 return NULL;
175 }
176}
177
178/*
168 * Attempt to parse the given URL; if successful, call fetchGet().
179 * Attempt to parse the given URL; if successful, call fetchXGet().
169 */
170FILE *
180 */
181FILE *
171fetchGetURL(char *URL, char *flags)
182fetchXGetURL(char *URL, struct url_stat *us, char *flags)
172{
173 struct url *u;
174 FILE *f;
175
176 if ((u = fetchParseURL(URL)) == NULL)
177 return NULL;
178
183{
184 struct url *u;
185 FILE *f;
186
187 if ((u = fetchParseURL(URL)) == NULL)
188 return NULL;
189
179 f = fetchGet(u, flags);
190 f = fetchXGet(u, us, flags);
180
181 fetchFreeURL(u);
182 return f;
183}
184
191
192 fetchFreeURL(u);
193 return f;
194}
195
196/*
197 * Attempt to parse the given URL; if successful, call fetchGet().
198 */
199FILE *
200fetchGetURL(char *URL, char *flags)
201{
202 return fetchXGetURL(URL, NULL, flags);
203}
185
186/*
187 * Attempt to parse the given URL; if successful, call fetchPut().
188 */
189FILE *
190fetchPutURL(char *URL, char *flags)
191{
192 struct url *u;

--- 202 unchanged lines hidden ---
204
205/*
206 * Attempt to parse the given URL; if successful, call fetchPut().
207 */
208FILE *
209fetchPutURL(char *URL, char *flags)
210{
211 struct url *u;

--- 202 unchanged lines hidden ---