Deleted Added
full compact
ftp.c (174751) ftp.c (174752)
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/ftp.c 174751 2007-12-18 10:41:12Z des $");
30__FBSDID("$FreeBSD: head/lib/libfetch/ftp.c 174752 2007-12-18 11:03:07Z des $");
31
32/*
33 * Portions of this code were taken from or based on ftpio.c:
34 *
35 * ----------------------------------------------------------------------------
36 * "THE BEER-WARE LICENSE" (Revision 42):
37 * <phk@FreeBSD.org> wrote this file. As long as you retain this notice you
38 * can do whatever you want with this stuff. If we meet some day, and you think

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

1052 memcpy(&cached_host, url, sizeof(*url));
1053 return (conn);
1054}
1055
1056/*
1057 * Check the proxy settings
1058 */
1059static struct url *
31
32/*
33 * Portions of this code were taken from or based on ftpio.c:
34 *
35 * ----------------------------------------------------------------------------
36 * "THE BEER-WARE LICENSE" (Revision 42):
37 * <phk@FreeBSD.org> wrote this file. As long as you retain this notice you
38 * can do whatever you want with this stuff. If we meet some day, and you think

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

1052 memcpy(&cached_host, url, sizeof(*url));
1053 return (conn);
1054}
1055
1056/*
1057 * Check the proxy settings
1058 */
1059static struct url *
1060ftp_get_proxy(const char *flags)
1060ftp_get_proxy(struct url * url, const char *flags)
1061{
1062 struct url *purl;
1063 char *p;
1064
1065 if (flags != NULL && strchr(flags, 'd') != NULL)
1066 return (NULL);
1061{
1062 struct url *purl;
1063 char *p;
1064
1065 if (flags != NULL && strchr(flags, 'd') != NULL)
1066 return (NULL);
1067 if (fetch_no_proxy_match(url->host))
1068 return (NULL);
1067 if (((p = getenv("FTP_PROXY")) || (p = getenv("ftp_proxy")) ||
1068 (p = getenv("HTTP_PROXY")) || (p = getenv("http_proxy"))) &&
1069 *p && (purl = fetchParseURL(p)) != NULL) {
1070 if (!*purl->scheme) {
1071 if (getenv("FTP_PROXY") || getenv("ftp_proxy"))
1072 strcpy(purl->scheme, SCHEME_FTP);
1073 else
1074 strcpy(purl->scheme, SCHEME_HTTP);

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

1135}
1136
1137/*
1138 * Get and stat file
1139 */
1140FILE *
1141fetchXGetFTP(struct url *url, struct url_stat *us, const char *flags)
1142{
1069 if (((p = getenv("FTP_PROXY")) || (p = getenv("ftp_proxy")) ||
1070 (p = getenv("HTTP_PROXY")) || (p = getenv("http_proxy"))) &&
1071 *p && (purl = fetchParseURL(p)) != NULL) {
1072 if (!*purl->scheme) {
1073 if (getenv("FTP_PROXY") || getenv("ftp_proxy"))
1074 strcpy(purl->scheme, SCHEME_FTP);
1075 else
1076 strcpy(purl->scheme, SCHEME_HTTP);

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

1137}
1138
1139/*
1140 * Get and stat file
1141 */
1142FILE *
1143fetchXGetFTP(struct url *url, struct url_stat *us, const char *flags)
1144{
1143 return (ftp_request(url, "RETR", us, ftp_get_proxy(flags), flags));
1145 return (ftp_request(url, "RETR", us, ftp_get_proxy(url, flags), flags));
1144}
1145
1146/*
1147 * Get file
1148 */
1149FILE *
1150fetchGetFTP(struct url *url, const char *flags)
1151{
1152 return (fetchXGetFTP(url, NULL, flags));
1153}
1154
1155/*
1156 * Put file
1157 */
1158FILE *
1159fetchPutFTP(struct url *url, const char *flags)
1160{
1146}
1147
1148/*
1149 * Get file
1150 */
1151FILE *
1152fetchGetFTP(struct url *url, const char *flags)
1153{
1154 return (fetchXGetFTP(url, NULL, flags));
1155}
1156
1157/*
1158 * Put file
1159 */
1160FILE *
1161fetchPutFTP(struct url *url, const char *flags)
1162{
1161
1162 return (ftp_request(url, CHECK_FLAG('a') ? "APPE" : "STOR", NULL,
1163 return (ftp_request(url, CHECK_FLAG('a') ? "APPE" : "STOR", NULL,
1163 ftp_get_proxy(flags), flags));
1164 ftp_get_proxy(url, flags), flags));
1164}
1165
1166/*
1167 * Get file stats
1168 */
1169int
1170fetchStatFTP(struct url *url, struct url_stat *us, const char *flags)
1171{
1172 FILE *f;
1173
1165}
1166
1167/*
1168 * Get file stats
1169 */
1170int
1171fetchStatFTP(struct url *url, struct url_stat *us, const char *flags)
1172{
1173 FILE *f;
1174
1174 f = ftp_request(url, "STAT", us, ftp_get_proxy(flags), flags);
1175 f = ftp_request(url, "STAT", us, ftp_get_proxy(url, flags), flags);
1175 if (f == NULL)
1176 return (-1);
1176 if (f == NULL)
1177 return (-1);
1178 fclose(f);
1177 return (0);
1178}
1179
1180/*
1181 * List a directory
1182 */
1183struct url_ent *
1184fetchListFTP(struct url *url __unused, const char *flags __unused)
1185{
1186 warnx("fetchListFTP(): not implemented");
1187 return (NULL);
1188}
1179 return (0);
1180}
1181
1182/*
1183 * List a directory
1184 */
1185struct url_ent *
1186fetchListFTP(struct url *url __unused, const char *flags __unused)
1187{
1188 warnx("fetchListFTP(): not implemented");
1189 return (NULL);
1190}