Deleted Added
full compact
fetch.c (174761) fetch.c (186241)
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>
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 $");
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{
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
77
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{
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{
113 int direct;
114
111
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{
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{
135 int direct;
136
131
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{
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{
161 int direct;
162
155
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 ---
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 ---