Deleted Added
full compact
fetch.c (90267) fetch.c (97868)
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

--- 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 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 90267 2002-02-05 22:13:51Z des $");
30__FBSDID("$FreeBSD: head/lib/libfetch/fetch.c 97868 2002-06-05 12:46: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>

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

74FILE *
75fetchXGet(struct url *URL, struct url_stat *us, const char *flags)
76{
77 int direct;
78
79 direct = CHECK_FLAG('d');
80 if (strcasecmp(URL->scheme, SCHEME_FILE) == 0)
81 return (fetchXGetFile(URL, us, flags));
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>

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

74FILE *
75fetchXGet(struct url *URL, struct url_stat *us, const char *flags)
76{
77 int direct;
78
79 direct = CHECK_FLAG('d');
80 if (strcasecmp(URL->scheme, SCHEME_FILE) == 0)
81 return (fetchXGetFile(URL, us, flags));
82 else if (strcasecmp(URL->scheme, SCHEME_FTP) == 0)
83 return (fetchXGetFTP(URL, us, flags));
82 else if (strcasecmp(URL->scheme, SCHEME_HTTP) == 0)
83 return (fetchXGetHTTP(URL, us, flags));
84 else if (strcasecmp(URL->scheme, SCHEME_HTTP) == 0)
85 return (fetchXGetHTTP(URL, us, flags));
84 else if (strcasecmp(URL->scheme, SCHEME_FTP) == 0) {
85 return (fetchXGetFTP(URL, us, flags));
86 } else {
87 _url_seterr(URL_BAD_SCHEME);
88 return (NULL);
89 }
86 else if (strcasecmp(URL->scheme, SCHEME_HTTPS) == 0)
87 return (fetchXGetHTTP(URL, us, flags));
88 _url_seterr(URL_BAD_SCHEME);
89 return (NULL);
90}
91
92/*
93 * Select the appropriate protocol for the URL scheme, and return a
94 * read-only stream connected to the document referenced by the URL.
95 */
96FILE *
97fetchGet(struct url *URL, const char *flags)

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

106FILE *
107fetchPut(struct url *URL, const char *flags)
108{
109 int direct;
110
111 direct = CHECK_FLAG('d');
112 if (strcasecmp(URL->scheme, SCHEME_FILE) == 0)
113 return (fetchPutFile(URL, flags));
90}
91
92/*
93 * Select the appropriate protocol for the URL scheme, and return a
94 * read-only stream connected to the document referenced by the URL.
95 */
96FILE *
97fetchGet(struct url *URL, const char *flags)

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

106FILE *
107fetchPut(struct url *URL, const char *flags)
108{
109 int direct;
110
111 direct = CHECK_FLAG('d');
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));
114 else if (strcasecmp(URL->scheme, SCHEME_HTTP) == 0)
115 return (fetchPutHTTP(URL, flags));
116 else if (strcasecmp(URL->scheme, SCHEME_HTTP) == 0)
117 return (fetchPutHTTP(URL, flags));
116 else if (strcasecmp(URL->scheme, SCHEME_FTP) == 0) {
117 return (fetchPutFTP(URL, flags));
118 } else {
119 _url_seterr(URL_BAD_SCHEME);
120 return (NULL);
121 }
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 int direct;
132
133 direct = CHECK_FLAG('d');
134 if (strcasecmp(URL->scheme, SCHEME_FILE) == 0)
135 return (fetchStatFile(URL, us, flags));
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 int direct;
132
133 direct = CHECK_FLAG('d');
134 if (strcasecmp(URL->scheme, SCHEME_FILE) == 0)
135 return (fetchStatFile(URL, us, flags));
136 else if (strcasecmp(URL->scheme, SCHEME_HTTP) == 0)
137 return (fetchStatHTTP(URL, us, flags));
138 else if (strcasecmp(URL->scheme, SCHEME_FTP) == 0)
139 return (fetchStatFTP(URL, us, flags));
136 else if (strcasecmp(URL->scheme, SCHEME_FTP) == 0)
137 return (fetchStatFTP(URL, us, flags));
138 else if (strcasecmp(URL->scheme, SCHEME_HTTP) == 0)
139 return (fetchStatHTTP(URL, us, flags));
140 else if (strcasecmp(URL->scheme, SCHEME_HTTPS) == 0)
141 return (fetchStatHTTP(URL, us, flags));
140 _url_seterr(URL_BAD_SCHEME);
141 return (-1);
142}
143
144/*
145 * Select the appropriate protocol for the URL scheme, and return a
146 * list of files in the directory pointed to by the URL.
147 */
148struct url_ent *
149fetchList(struct url *URL, const char *flags)
150{
151 int direct;
152
153 direct = CHECK_FLAG('d');
154 if (strcasecmp(URL->scheme, SCHEME_FILE) == 0)
155 return (fetchListFile(URL, flags));
142 _url_seterr(URL_BAD_SCHEME);
143 return (-1);
144}
145
146/*
147 * Select the appropriate protocol for the URL scheme, and return a
148 * list of files in the directory pointed to by the URL.
149 */
150struct url_ent *
151fetchList(struct url *URL, const char *flags)
152{
153 int direct;
154
155 direct = CHECK_FLAG('d');
156 if (strcasecmp(URL->scheme, SCHEME_FILE) == 0)
157 return (fetchListFile(URL, flags));
156 else if (strcasecmp(URL->scheme, SCHEME_HTTP) == 0)
157 return (fetchListHTTP(URL, flags));
158 else if (strcasecmp(URL->scheme, SCHEME_FTP) == 0)
159 return (fetchListFTP(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));
160 _url_seterr(URL_BAD_SCHEME);
161 return (NULL);
162}
163
164/*
165 * Attempt to parse the given URL; if successful, call fetchXGet().
166 */
167FILE *

--- 259 unchanged lines hidden ---
164 _url_seterr(URL_BAD_SCHEME);
165 return (NULL);
166}
167
168/*
169 * Attempt to parse the given URL; if successful, call fetchXGet().
170 */
171FILE *

--- 259 unchanged lines hidden ---