Deleted Added
full compact
ftp.c (40975) ftp.c (41862)
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 * $Id: ftp.c,v 1.6 1998/11/05 19:48:17 des Exp $
28 * $Id: ftp.c,v 1.7 1998/11/06 22:14:08 des Exp $
29 */
30
31/*
32 * Portions of this code were taken from or based on ftpio.c:
33 *
34 * ----------------------------------------------------------------------------
35 * "THE BEER-WARE LICENSE" (Revision 42):
36 * <phk@login.dknet.dk> wrote this file. As long as you retain this notice you

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

50 *
51 * Turned inside out. Now returns xfers as new file ids, not as a special
52 * `state' of FTP_t
53 *
54 * $ftpioId: ftpio.c,v 1.30 1998/04/11 07:28:53 phk Exp $
55 *
56 */
57
29 */
30
31/*
32 * Portions of this code were taken from or based on ftpio.c:
33 *
34 * ----------------------------------------------------------------------------
35 * "THE BEER-WARE LICENSE" (Revision 42):
36 * <phk@login.dknet.dk> wrote this file. As long as you retain this notice you

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

50 *
51 * Turned inside out. Now returns xfers as new file ids, not as a special
52 * `state' of FTP_t
53 *
54 * $ftpioId: ftpio.c,v 1.30 1998/04/11 07:28:53 phk Exp $
55 *
56 */
57
58#include <sys/types.h>
58#include <sys/param.h>
59#include <sys/socket.h>
60#include <netinet/in.h>
61#include <sys/errno.h>
62
63#include <ctype.h>
64#include <errno.h>
65#include <netdb.h>
66#include <stdarg.h>
67#include <stdio.h>
68#include <stdlib.h>
69#include <string.h>
70#include <unistd.h>
71
72#include "fetch.h"
73#include "common.h"
59#include <sys/socket.h>
60#include <netinet/in.h>
61#include <sys/errno.h>
62
63#include <ctype.h>
64#include <errno.h>
65#include <netdb.h>
66#include <stdarg.h>
67#include <stdio.h>
68#include <stdlib.h>
69#include <string.h>
70#include <unistd.h>
71
72#include "fetch.h"
73#include "common.h"
74#include "ftperr.inc"
74#include "ftperr.h"
75
76#define FTP_DEFAULT_TO_ANONYMOUS
77#define FTP_ANONYMOUS_USER "ftp"
78#define FTP_ANONYMOUS_PASSWORD "ftp"
79#define FTP_DEFAULT_PORT 21
80
81#define FTP_OPEN_DATA_CONNECTION 150
82#define FTP_OK 200

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

270 close(sd);
271 return NULL;
272}
273
274/*
275 * Log on to FTP server
276 */
277static FILE *
75
76#define FTP_DEFAULT_TO_ANONYMOUS
77#define FTP_ANONYMOUS_USER "ftp"
78#define FTP_ANONYMOUS_PASSWORD "ftp"
79#define FTP_DEFAULT_PORT 21
80
81#define FTP_OPEN_DATA_CONNECTION 150
82#define FTP_OK 200

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

270 close(sd);
271 return NULL;
272}
273
274/*
275 * Log on to FTP server
276 */
277static FILE *
278_ftp_connect(char *host, int port, char *user, char *pwd)
278_ftp_connect(char *host, int port, char *user, char *pwd, int verbose)
279{
280 int sd, e, pp = FTP_DEFAULT_PORT;
281 char *p, *q;
282 FILE *f;
283
284 /* check for proxy */
285 if ((p = getenv("FTP_PROXY")) != NULL) {
286 if ((q = strchr(p, ':')) != NULL) {
287 /* XXX check that it's a valid number */
288 pp = atoi(q+1);
289 }
290 if (q)
291 *q = 0;
279{
280 int sd, e, pp = FTP_DEFAULT_PORT;
281 char *p, *q;
282 FILE *f;
283
284 /* check for proxy */
285 if ((p = getenv("FTP_PROXY")) != NULL) {
286 if ((q = strchr(p, ':')) != NULL) {
287 /* XXX check that it's a valid number */
288 pp = atoi(q+1);
289 }
290 if (q)
291 *q = 0;
292 sd = fetchConnect(p, pp);
292 sd = fetchConnect(p, pp, verbose);
293 if (q)
294 *q = ':';
295 } else {
296 /* no proxy, go straight to target */
293 if (q)
294 *q = ':';
295 } else {
296 /* no proxy, go straight to target */
297 sd = fetchConnect(host, port);
297 sd = fetchConnect(host, port, verbose);
298 }
299
300 /* check connection */
301 if (sd == -1) {
302 _fetch_syserr();
303 return NULL;
304 }
305

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

393 if (_ftp_isconnected(url)) {
394 _ftp_chkerr(cached_socket, &e);
395 if (e > 0)
396 cf = cached_socket;
397 }
398
399 /* connect to server */
400 if (!cf) {
298 }
299
300 /* check connection */
301 if (sd == -1) {
302 _fetch_syserr();
303 return NULL;
304 }
305

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

393 if (_ftp_isconnected(url)) {
394 _ftp_chkerr(cached_socket, &e);
395 if (e > 0)
396 cf = cached_socket;
397 }
398
399 /* connect to server */
400 if (!cf) {
401 cf = _ftp_connect(url->host, url->port, url->user, url->pwd);
401 cf = _ftp_connect(url->host, url->port, url->user, url->pwd,
402 (strchr(flags, 'v') != NULL));
402 if (!cf)
403 return NULL;
404 if (cached_socket)
405 _ftp_disconnect(cached_socket);
406 cached_socket = cf;
407 memcpy(&cached_host, url, sizeof(struct url));
408 }
409

--- 29 unchanged lines hidden ---
403 if (!cf)
404 return NULL;
405 if (cached_socket)
406 _ftp_disconnect(cached_socket);
407 cached_socket = cf;
408 memcpy(&cached_host, url, sizeof(struct url));
409 }
410

--- 29 unchanged lines hidden ---