2002-11-30 06:10:53 +03:00
|
|
|
/* $NetBSD: cmds.c,v 1.100 2002/11/30 03:10:55 lukem Exp $ */
|
1998-07-10 08:39:03 +04:00
|
|
|
|
|
|
|
/*-
|
2002-06-05 14:20:46 +04:00
|
|
|
* Copyright (c) 1996-2002 The NetBSD Foundation, Inc.
|
1998-07-10 08:39:03 +04:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
1999-10-05 05:16:11 +04:00
|
|
|
* by Luke Mewburn.
|
1998-07-10 08:39:03 +04:00
|
|
|
*
|
1999-05-12 15:06:00 +04:00
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
1999-10-05 05:16:11 +04:00
|
|
|
* by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
|
|
|
|
* NASA Ames Research Center.
|
1999-05-12 15:06:00 +04:00
|
|
|
*
|
1998-07-10 08:39:03 +04:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the NetBSD
|
|
|
|
* Foundation, Inc. and its contributors.
|
|
|
|
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
1995-09-08 05:05:59 +04:00
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
/*
|
1994-08-25 07:47:50 +04:00
|
|
|
* Copyright (c) 1985, 1989, 1993, 1994
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
1993-03-21 12:45:37 +03:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the University of
|
|
|
|
* California, Berkeley and its contributors.
|
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
1999-10-01 03:51:26 +04:00
|
|
|
/*
|
|
|
|
* Copyright (C) 1997 and 1998 WIDE Project.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. Neither the name of the project nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
1997-07-20 13:45:35 +04:00
|
|
|
#include <sys/cdefs.h>
|
1993-03-21 12:45:37 +03:00
|
|
|
#ifndef lint
|
1995-09-08 05:05:59 +04:00
|
|
|
#if 0
|
|
|
|
static char sccsid[] = "@(#)cmds.c 8.6 (Berkeley) 10/9/94";
|
|
|
|
#else
|
2002-11-30 06:10:53 +03:00
|
|
|
__RCSID("$NetBSD: cmds.c,v 1.100 2002/11/30 03:10:55 lukem Exp $");
|
1995-09-08 05:05:59 +04:00
|
|
|
#endif
|
1993-03-21 12:45:37 +03:00
|
|
|
#endif /* not lint */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FTP User Program -- Command Routines.
|
|
|
|
*/
|
1997-01-19 17:19:02 +03:00
|
|
|
#include <sys/types.h>
|
1993-03-21 12:45:37 +03:00
|
|
|
#include <sys/socket.h>
|
1997-01-19 17:19:02 +03:00
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/wait.h>
|
1993-03-21 12:45:37 +03:00
|
|
|
#include <arpa/ftp.h>
|
|
|
|
|
1994-08-25 07:47:50 +04:00
|
|
|
#include <ctype.h>
|
|
|
|
#include <err.h>
|
|
|
|
#include <glob.h>
|
1998-08-08 06:51:49 +04:00
|
|
|
#include <limits.h>
|
1994-08-25 07:47:50 +04:00
|
|
|
#include <netdb.h>
|
1999-10-01 10:18:32 +04:00
|
|
|
#include <paths.h>
|
1993-03-21 12:45:37 +03:00
|
|
|
#include <stdio.h>
|
1994-08-25 07:47:50 +04:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
1998-04-02 01:07:03 +04:00
|
|
|
#include <time.h>
|
1994-08-25 07:47:50 +04:00
|
|
|
#include <unistd.h>
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
#include "ftp_var.h"
|
1999-12-06 01:54:35 +03:00
|
|
|
#include "version.h"
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
struct types {
|
|
|
|
char *t_name;
|
|
|
|
char *t_mode;
|
|
|
|
int t_type;
|
|
|
|
char *t_arg;
|
|
|
|
} types[] = {
|
|
|
|
{ "ascii", "A", TYPE_A, 0 },
|
|
|
|
{ "binary", "I", TYPE_I, 0 },
|
|
|
|
{ "image", "I", TYPE_I, 0 },
|
|
|
|
{ "ebcdic", "E", TYPE_E, 0 },
|
|
|
|
{ "tenex", "L", TYPE_L, bytename },
|
1994-08-25 07:47:50 +04:00
|
|
|
{ NULL }
|
1993-03-21 12:45:37 +03:00
|
|
|
};
|
|
|
|
|
1999-10-12 10:04:59 +04:00
|
|
|
sigjmp_buf jabort;
|
|
|
|
char *mname;
|
|
|
|
|
2000-05-01 14:35:16 +04:00
|
|
|
static int confirm(const char *, const char *);
|
1999-10-12 10:04:59 +04:00
|
|
|
|
|
|
|
static int
|
2000-05-01 14:35:16 +04:00
|
|
|
confirm(const char *cmd, const char *file)
|
1999-10-12 10:04:59 +04:00
|
|
|
{
|
|
|
|
char line[BUFSIZ];
|
|
|
|
|
|
|
|
if (!interactive || confirmrest)
|
|
|
|
return (1);
|
|
|
|
while (1) {
|
|
|
|
fprintf(ttyout, "%s %s [anpqy?]? ", cmd, file);
|
|
|
|
(void)fflush(ttyout);
|
|
|
|
if (fgets(line, sizeof(line), stdin) == NULL) {
|
|
|
|
mflag = 0;
|
|
|
|
fprintf(ttyout, "\nEOF received; %s aborted\n", mname);
|
|
|
|
clearerr(stdin);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
switch (tolower(*line)) {
|
|
|
|
case 'a':
|
|
|
|
confirmrest = 1;
|
|
|
|
fprintf(ttyout,
|
|
|
|
"Prompting off for duration of %s.\n", cmd);
|
|
|
|
break;
|
|
|
|
case 'p':
|
|
|
|
interactive = 0;
|
|
|
|
fputs("Interactive mode: off.\n", ttyout);
|
|
|
|
break;
|
|
|
|
case 'q':
|
|
|
|
mflag = 0;
|
1999-10-24 16:31:36 +04:00
|
|
|
fprintf(ttyout, "%s aborted.\n", mname);
|
1999-10-13 06:47:54 +04:00
|
|
|
/* FALLTHROUGH */
|
|
|
|
case 'n':
|
1999-10-12 10:04:59 +04:00
|
|
|
return (0);
|
|
|
|
case '?':
|
|
|
|
fprintf(ttyout,
|
1999-10-24 16:31:36 +04:00
|
|
|
" confirmation options:\n"
|
1999-10-12 10:04:59 +04:00
|
|
|
"\ta answer `yes' for the duration of %s\n"
|
|
|
|
"\tn answer `no' for this file\n"
|
|
|
|
"\tp turn off `prompt' mode\n"
|
|
|
|
"\tq stop the current %s\n"
|
|
|
|
"\ty answer `yes' for this file\n"
|
|
|
|
"\t? this help list\n",
|
|
|
|
cmd, cmd);
|
1999-10-13 06:47:54 +04:00
|
|
|
continue; /* back to while(1) */
|
1999-10-12 10:04:59 +04:00
|
|
|
}
|
1999-10-13 06:47:54 +04:00
|
|
|
return (1);
|
1999-10-12 10:04:59 +04:00
|
|
|
}
|
|
|
|
/* NOTREACHED */
|
|
|
|
}
|
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
/*
|
|
|
|
* Set transfer type.
|
|
|
|
*/
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
settype(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1994-08-25 07:47:50 +04:00
|
|
|
struct types *p;
|
1993-03-21 12:45:37 +03:00
|
|
|
int comret;
|
|
|
|
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
if (argc == 0 || argc > 2) {
|
1993-03-21 12:45:37 +03:00
|
|
|
char *sep;
|
|
|
|
|
1998-06-04 12:28:35 +04:00
|
|
|
fprintf(ttyout, "usage: %s [", argv[0]);
|
1993-03-21 12:45:37 +03:00
|
|
|
sep = " ";
|
|
|
|
for (p = types; p->t_name; p++) {
|
1998-06-04 12:28:35 +04:00
|
|
|
fprintf(ttyout, "%s%s", sep, p->t_name);
|
1993-03-21 12:45:37 +03:00
|
|
|
sep = " | ";
|
|
|
|
}
|
1998-06-04 12:28:35 +04:00
|
|
|
fputs(" ]\n", ttyout);
|
1993-03-21 12:45:37 +03:00
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (argc < 2) {
|
1998-06-04 12:28:35 +04:00
|
|
|
fprintf(ttyout, "Using %s mode to transfer files.\n", typename);
|
1993-03-21 12:45:37 +03:00
|
|
|
code = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (p = types; p->t_name; p++)
|
|
|
|
if (strcmp(argv[1], p->t_name) == 0)
|
|
|
|
break;
|
|
|
|
if (p->t_name == 0) {
|
1998-06-04 12:28:35 +04:00
|
|
|
fprintf(ttyout, "%s: unknown mode.\n", argv[1]);
|
1993-03-21 12:45:37 +03:00
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ((p->t_arg != NULL) && (*(p->t_arg) != '\0'))
|
1997-03-13 09:23:11 +03:00
|
|
|
comret = command("TYPE %s %s", p->t_mode, p->t_arg);
|
1993-03-21 12:45:37 +03:00
|
|
|
else
|
|
|
|
comret = command("TYPE %s", p->t_mode);
|
|
|
|
if (comret == COMPLETE) {
|
1999-09-28 10:47:38 +04:00
|
|
|
(void)strlcpy(typename, p->t_name, sizeof(typename));
|
1993-03-21 12:45:37 +03:00
|
|
|
curtype = type = p->t_type;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Internal form of settype; changes current type in use with server
|
|
|
|
* without changing our notion of the type for data transfers.
|
|
|
|
* Used to change to and from ascii for listings.
|
|
|
|
*/
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
changetype(int newtype, int show)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1994-08-25 07:47:50 +04:00
|
|
|
struct types *p;
|
1993-03-21 12:45:37 +03:00
|
|
|
int comret, oldverbose = verbose;
|
|
|
|
|
|
|
|
if (newtype == 0)
|
|
|
|
newtype = TYPE_I;
|
|
|
|
if (newtype == curtype)
|
|
|
|
return;
|
|
|
|
if (debug == 0 && show == 0)
|
|
|
|
verbose = 0;
|
|
|
|
for (p = types; p->t_name; p++)
|
|
|
|
if (newtype == p->t_type)
|
|
|
|
break;
|
|
|
|
if (p->t_name == 0) {
|
1997-03-13 09:23:11 +03:00
|
|
|
warnx("internal error: unknown type %d.", newtype);
|
1993-03-21 12:45:37 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (newtype == TYPE_L && bytename[0] != '\0')
|
|
|
|
comret = command("TYPE %s %s", p->t_mode, bytename);
|
|
|
|
else
|
|
|
|
comret = command("TYPE %s", p->t_mode);
|
|
|
|
if (comret == COMPLETE)
|
|
|
|
curtype = newtype;
|
|
|
|
verbose = oldverbose;
|
|
|
|
}
|
|
|
|
|
|
|
|
char *stype[] = {
|
|
|
|
"type",
|
|
|
|
"",
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set binary transfer type.
|
|
|
|
*/
|
|
|
|
/*VARARGS*/
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
setbinary(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1994-08-25 07:47:50 +04:00
|
|
|
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
if (argc == 0) {
|
1999-10-24 16:31:36 +04:00
|
|
|
fprintf(ttyout, "usage: %s\n", argv[0]);
|
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
stype[1] = "binary";
|
|
|
|
settype(2, stype);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set ascii transfer type.
|
|
|
|
*/
|
|
|
|
/*VARARGS*/
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
setascii(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1994-08-25 07:47:50 +04:00
|
|
|
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
if (argc == 0) {
|
1999-10-24 16:31:36 +04:00
|
|
|
fprintf(ttyout, "usage: %s\n", argv[0]);
|
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
stype[1] = "ascii";
|
|
|
|
settype(2, stype);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set tenex transfer type.
|
|
|
|
*/
|
|
|
|
/*VARARGS*/
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
settenex(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1994-08-25 07:47:50 +04:00
|
|
|
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
if (argc == 0) {
|
1999-10-24 16:31:36 +04:00
|
|
|
fprintf(ttyout, "usage: %s\n", argv[0]);
|
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
stype[1] = "tenex";
|
|
|
|
settype(2, stype);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set file transfer mode.
|
|
|
|
*/
|
|
|
|
/*ARGSUSED*/
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
setftmode(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
if (argc != 2) {
|
1999-10-24 16:31:36 +04:00
|
|
|
fprintf(ttyout, "usage: %s mode-name\n", argv[0]);
|
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
1998-06-04 12:28:35 +04:00
|
|
|
fprintf(ttyout, "We only support %s mode, sorry.\n", modename);
|
1993-03-21 12:45:37 +03:00
|
|
|
code = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set file transfer format.
|
|
|
|
*/
|
|
|
|
/*ARGSUSED*/
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
setform(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
if (argc != 2) {
|
1999-10-24 16:31:36 +04:00
|
|
|
fprintf(ttyout, "usage: %s format\n", argv[0]);
|
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
1998-06-04 12:28:35 +04:00
|
|
|
fprintf(ttyout, "We only support %s format, sorry.\n", formname);
|
1993-03-21 12:45:37 +03:00
|
|
|
code = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set file transfer structure.
|
|
|
|
*/
|
|
|
|
/*ARGSUSED*/
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
setstruct(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
if (argc != 2) {
|
1999-10-24 16:31:36 +04:00
|
|
|
fprintf(ttyout, "usage: %s struct-mode\n", argv[0]);
|
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
1998-06-04 12:28:35 +04:00
|
|
|
fprintf(ttyout, "We only support %s structure, sorry.\n", structname);
|
1993-03-21 12:45:37 +03:00
|
|
|
code = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Send a single file.
|
|
|
|
*/
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
put(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
char *cmd;
|
|
|
|
int loc = 0;
|
1999-09-28 10:47:38 +04:00
|
|
|
char *locfile, *remfile;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
if (argc == 2) {
|
|
|
|
argc++;
|
|
|
|
argv[2] = argv[1];
|
|
|
|
loc++;
|
|
|
|
}
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
if (argc == 0 || (argc == 1 && !another(&argc, &argv, "local-file")))
|
1993-03-21 12:45:37 +03:00
|
|
|
goto usage;
|
1996-11-28 06:12:28 +03:00
|
|
|
if ((argc < 3 && !another(&argc, &argv, "remote-file")) || argc > 3) {
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
usage:
|
1999-10-24 16:31:36 +04:00
|
|
|
fprintf(ttyout, "usage: %s local-file [remote-file]\n",
|
1998-06-04 12:28:35 +04:00
|
|
|
argv[0]);
|
1993-03-21 12:45:37 +03:00
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
1999-09-28 10:47:38 +04:00
|
|
|
if ((locfile = globulize(argv[1])) == NULL) {
|
1993-03-21 12:45:37 +03:00
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
1999-09-28 10:47:38 +04:00
|
|
|
remfile = argv[2];
|
|
|
|
if (loc) /* If argv[2] is a copy of the old argv[1], update it */
|
|
|
|
remfile = locfile;
|
1993-03-21 12:45:37 +03:00
|
|
|
cmd = (argv[0][0] == 'a') ? "APPE" : ((sunique) ? "STOU" : "STOR");
|
1999-09-28 10:47:38 +04:00
|
|
|
if (loc && ntflag)
|
|
|
|
remfile = dotrans(remfile);
|
|
|
|
if (loc && mapflag)
|
|
|
|
remfile = domap(remfile);
|
|
|
|
sendrequest(cmd, locfile, remfile,
|
|
|
|
locfile != argv[1] || remfile != argv[2]);
|
|
|
|
free(locfile);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Send multiple files.
|
|
|
|
*/
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
mput(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1994-08-25 07:47:50 +04:00
|
|
|
int i;
|
2000-02-01 01:01:03 +03:00
|
|
|
sigfunc oldintr;
|
1993-03-21 12:45:37 +03:00
|
|
|
int ointer;
|
|
|
|
char *tp;
|
|
|
|
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
if (argc == 0 || (argc == 1 && !another(&argc, &argv, "local-files"))) {
|
1998-06-04 12:28:35 +04:00
|
|
|
fprintf(ttyout, "usage: %s local-files\n", argv[0]);
|
1993-03-21 12:45:37 +03:00
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
mname = argv[0];
|
|
|
|
mflag = 1;
|
1999-10-09 07:00:55 +04:00
|
|
|
oldintr = xsignal(SIGINT, mintr);
|
|
|
|
if (sigsetjmp(jabort, 1))
|
|
|
|
mabort();
|
1993-03-21 12:45:37 +03:00
|
|
|
if (proxy) {
|
1999-09-28 10:47:38 +04:00
|
|
|
char *cp;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1997-03-13 09:23:11 +03:00
|
|
|
while ((cp = remglob(argv, 0, NULL)) != NULL) {
|
1999-10-24 16:31:36 +04:00
|
|
|
if (*cp == '\0' || !connected) {
|
1993-03-21 12:45:37 +03:00
|
|
|
mflag = 0;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (mflag && confirm(argv[0], cp)) {
|
|
|
|
tp = cp;
|
1999-09-28 10:47:38 +04:00
|
|
|
if (mcase)
|
|
|
|
tp = docase(tp);
|
|
|
|
if (ntflag)
|
1993-03-21 12:45:37 +03:00
|
|
|
tp = dotrans(tp);
|
1999-09-28 10:47:38 +04:00
|
|
|
if (mapflag)
|
1993-03-21 12:45:37 +03:00
|
|
|
tp = domap(tp);
|
|
|
|
sendrequest((sunique) ? "STOU" : "STOR",
|
|
|
|
cp, tp, cp != tp || !interactive);
|
|
|
|
if (!mflag && fromatty) {
|
|
|
|
ointer = interactive;
|
|
|
|
interactive = 1;
|
1996-11-28 06:12:28 +03:00
|
|
|
if (confirm("Continue with", "mput")) {
|
1993-03-21 12:45:37 +03:00
|
|
|
mflag++;
|
|
|
|
}
|
|
|
|
interactive = ointer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-10-09 07:00:55 +04:00
|
|
|
goto cleanupmput;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1999-10-24 16:31:36 +04:00
|
|
|
for (i = 1; i < argc && connected; i++) {
|
1996-11-25 08:13:18 +03:00
|
|
|
char **cpp;
|
1994-08-25 07:47:50 +04:00
|
|
|
glob_t gl;
|
|
|
|
int flags;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
if (!doglob) {
|
|
|
|
if (mflag && confirm(argv[0], argv[i])) {
|
|
|
|
tp = (ntflag) ? dotrans(argv[i]) : argv[i];
|
|
|
|
tp = (mapflag) ? domap(tp) : tp;
|
|
|
|
sendrequest((sunique) ? "STOU" : "STOR",
|
|
|
|
argv[i], tp, tp != argv[i] || !interactive);
|
|
|
|
if (!mflag && fromatty) {
|
|
|
|
ointer = interactive;
|
|
|
|
interactive = 1;
|
1996-11-28 06:12:28 +03:00
|
|
|
if (confirm("Continue with", "mput")) {
|
1993-03-21 12:45:37 +03:00
|
|
|
mflag++;
|
|
|
|
}
|
|
|
|
interactive = ointer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
1994-08-25 07:47:50 +04:00
|
|
|
|
|
|
|
memset(&gl, 0, sizeof(gl));
|
1998-06-20 02:58:04 +04:00
|
|
|
flags = GLOB_BRACE|GLOB_NOCHECK|GLOB_TILDE;
|
1994-08-25 07:47:50 +04:00
|
|
|
if (glob(argv[i], flags, NULL, &gl) || gl.gl_pathc == 0) {
|
|
|
|
warnx("%s: not found", argv[i]);
|
|
|
|
globfree(&gl);
|
1993-03-21 12:45:37 +03:00
|
|
|
continue;
|
|
|
|
}
|
1999-10-24 16:31:36 +04:00
|
|
|
for (cpp = gl.gl_pathv; cpp && *cpp != NULL && connected;
|
|
|
|
cpp++) {
|
1993-03-21 12:45:37 +03:00
|
|
|
if (mflag && confirm(argv[0], *cpp)) {
|
|
|
|
tp = (ntflag) ? dotrans(*cpp) : *cpp;
|
|
|
|
tp = (mapflag) ? domap(tp) : tp;
|
|
|
|
sendrequest((sunique) ? "STOU" : "STOR",
|
|
|
|
*cpp, tp, *cpp != tp || !interactive);
|
|
|
|
if (!mflag && fromatty) {
|
|
|
|
ointer = interactive;
|
|
|
|
interactive = 1;
|
1996-11-28 06:12:28 +03:00
|
|
|
if (confirm("Continue with", "mput")) {
|
1993-03-21 12:45:37 +03:00
|
|
|
mflag++;
|
|
|
|
}
|
|
|
|
interactive = ointer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1994-08-25 07:47:50 +04:00
|
|
|
globfree(&gl);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
cleanupmput:
|
1999-09-28 03:09:42 +04:00
|
|
|
(void)xsignal(SIGINT, oldintr);
|
1993-03-21 12:45:37 +03:00
|
|
|
mflag = 0;
|
|
|
|
}
|
|
|
|
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
reget(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1994-08-25 07:47:50 +04:00
|
|
|
|
2002-05-07 06:04:09 +04:00
|
|
|
(void)getit(argc, argv, 1, "r+");
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
get(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1994-08-25 07:47:50 +04:00
|
|
|
|
2002-05-07 06:04:09 +04:00
|
|
|
(void)getit(argc, argv, 0, restart_point ? "r+" : "w" );
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Receive one file.
|
2000-11-15 03:10:59 +03:00
|
|
|
* If restartit is 1, restart the xfer always.
|
|
|
|
* If restartit is -1, restart the xfer only if the remote file is newer.
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
1994-08-25 07:47:50 +04:00
|
|
|
int
|
2000-05-01 14:35:16 +04:00
|
|
|
getit(int argc, char *argv[], int restartit, const char *mode)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
2001-02-19 21:15:28 +03:00
|
|
|
int loc, rval;
|
|
|
|
char *remfile, *locfile, *olocfile;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
2001-02-19 21:15:28 +03:00
|
|
|
loc = rval = 0;
|
1993-03-21 12:45:37 +03:00
|
|
|
if (argc == 2) {
|
|
|
|
argc++;
|
|
|
|
argv[2] = argv[1];
|
|
|
|
loc++;
|
|
|
|
}
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
if (argc == 0 || (argc == 1 && !another(&argc, &argv, "remote-file")))
|
1993-03-21 12:45:37 +03:00
|
|
|
goto usage;
|
1996-11-28 06:12:28 +03:00
|
|
|
if ((argc < 3 && !another(&argc, &argv, "local-file")) || argc > 3) {
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
usage:
|
1999-10-24 16:31:36 +04:00
|
|
|
fprintf(ttyout, "usage: %s remote-file [local-file]\n",
|
1998-06-04 12:28:35 +04:00
|
|
|
argv[0]);
|
1993-03-21 12:45:37 +03:00
|
|
|
code = -1;
|
|
|
|
return (0);
|
|
|
|
}
|
1999-09-28 10:47:38 +04:00
|
|
|
remfile = argv[1];
|
|
|
|
if ((olocfile = globulize(argv[2])) == NULL) {
|
1993-03-21 12:45:37 +03:00
|
|
|
code = -1;
|
|
|
|
return (0);
|
|
|
|
}
|
1999-09-28 10:47:38 +04:00
|
|
|
locfile = olocfile;
|
|
|
|
if (loc && mcase)
|
|
|
|
locfile = docase(locfile);
|
1993-03-21 12:45:37 +03:00
|
|
|
if (loc && ntflag)
|
1999-09-28 10:47:38 +04:00
|
|
|
locfile = dotrans(locfile);
|
1993-03-21 12:45:37 +03:00
|
|
|
if (loc && mapflag)
|
1999-09-28 10:47:38 +04:00
|
|
|
locfile = domap(locfile);
|
1993-03-21 12:45:37 +03:00
|
|
|
if (restartit) {
|
|
|
|
struct stat stbuf;
|
|
|
|
int ret;
|
|
|
|
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
if (! features[FEAT_REST_STREAM]) {
|
|
|
|
fprintf(ttyout,
|
|
|
|
"Restart is not supported by the remote server.\n");
|
|
|
|
return (0);
|
|
|
|
}
|
1999-09-28 10:47:38 +04:00
|
|
|
ret = stat(locfile, &stbuf);
|
1993-03-21 12:45:37 +03:00
|
|
|
if (restartit == 1) {
|
|
|
|
if (ret < 0) {
|
1999-09-28 10:47:38 +04:00
|
|
|
warn("local: %s", locfile);
|
1997-08-18 14:20:13 +04:00
|
|
|
goto freegetit;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
restart_point = stbuf.st_size;
|
|
|
|
} else {
|
|
|
|
if (ret == 0) {
|
1996-11-28 06:12:28 +03:00
|
|
|
time_t mtime;
|
|
|
|
|
1996-12-29 07:05:29 +03:00
|
|
|
mtime = remotemodtime(argv[1], 0);
|
1996-11-28 06:12:28 +03:00
|
|
|
if (mtime == -1)
|
1997-08-18 14:20:13 +04:00
|
|
|
goto freegetit;
|
|
|
|
if (stbuf.st_mtime >= mtime) {
|
|
|
|
rval = 1;
|
|
|
|
goto freegetit;
|
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-09-28 10:47:38 +04:00
|
|
|
recvrequest("RETR", locfile, remfile, mode,
|
|
|
|
remfile != argv[1] || locfile != argv[2], loc);
|
1993-03-21 12:45:37 +03:00
|
|
|
restart_point = 0;
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
freegetit:
|
1999-09-28 10:47:38 +04:00
|
|
|
(void)free(olocfile);
|
1997-08-18 14:20:13 +04:00
|
|
|
return (rval);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1994-08-25 07:47:50 +04:00
|
|
|
/* ARGSUSED */
|
1993-03-21 12:45:37 +03:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
mintr(int signo)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
|
[Yet Another Huge Ftp Commit - hopefully the last for a while,
barring any more little things people want added ...]
New features:
* progressmeter is now asynchronous, so "stalled" transfers can be
detected. "- stalled -" is displayed instead of the ETA in this case.
When the xfer resumes, the time that the xfer was stalled for is
factored out of the ETA. It is debatable whether this is better than
not factoring it out, but I like it this way (I.e, if it stalls for 8
seconds and the ETA was 30 seconds, when it resumes the ETA will still
be 30 seconds).
* verbosity can be disabled on the command line (-V), so that in auto-fetch
mode the only lines displayed will be a description of the file, and
the progress bar (if possible)
* if the screen is resized (and detected via the SIGWINCH signal), the
progress bar will rescale automatically.
Bugs fixed:
* progress bar will not use the last character on the line, as this can
cause problems on some terminals
* screen dimensions (via ioctl(TIOCWINSZ)) should use stdout not stdin
* progressmeter() used some vars before initialising them
* ^D will quit now. [fixes bin/3162]
* use hstrerror() to generate error message for host name lookup failure.
* use getcwd instead of getwd (it should have been OK, but why tempt fate?)
* auto-fetch transfers will always return a positive exit value upon failure
or interruption, relative to the file's position in argv[].
* remote completion of / will work, without putting a leading "///".
This is actually a bug in ftpd(1), where "NLST /" prefixes all names
with "//", but fixing every ftpd(1) is not an option...
1997-02-01 13:44:54 +03:00
|
|
|
alarmtimer(0);
|
1999-10-12 10:04:59 +04:00
|
|
|
if (fromatty)
|
|
|
|
write(fileno(ttyout), "\n", 1);
|
1999-10-09 07:00:55 +04:00
|
|
|
siglongjmp(jabort, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
mabort(void)
|
1999-10-09 07:00:55 +04:00
|
|
|
{
|
|
|
|
int ointer, oconf;
|
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
if (mflag && fromatty) {
|
|
|
|
ointer = interactive;
|
1996-11-28 06:12:28 +03:00
|
|
|
oconf = confirmrest;
|
1993-03-21 12:45:37 +03:00
|
|
|
interactive = 1;
|
1996-11-28 06:12:28 +03:00
|
|
|
confirmrest = 0;
|
1993-03-21 12:45:37 +03:00
|
|
|
if (confirm("Continue with", mname)) {
|
|
|
|
interactive = ointer;
|
1996-11-28 06:12:28 +03:00
|
|
|
confirmrest = oconf;
|
1999-10-09 07:00:55 +04:00
|
|
|
return;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
interactive = ointer;
|
1996-11-28 06:12:28 +03:00
|
|
|
confirmrest = oconf;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
mflag = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get multiple files.
|
|
|
|
*/
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
mget(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
2000-02-01 01:01:03 +03:00
|
|
|
sigfunc oldintr;
|
2000-11-15 03:10:59 +03:00
|
|
|
int ointer;
|
|
|
|
char *cp, *tp;
|
|
|
|
int restartit;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
if (argc == 0 ||
|
1999-10-24 16:31:36 +04:00
|
|
|
(argc == 1 && !another(&argc, &argv, "remote-files"))) {
|
1998-06-04 12:28:35 +04:00
|
|
|
fprintf(ttyout, "usage: %s remote-files\n", argv[0]);
|
1993-03-21 12:45:37 +03:00
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
mname = argv[0];
|
|
|
|
mflag = 1;
|
2000-11-15 03:10:59 +03:00
|
|
|
restart_point = 0;
|
|
|
|
restartit = 0;
|
|
|
|
if (strcmp(argv[0], "mreget") == 0) {
|
|
|
|
if (! features[FEAT_REST_STREAM]) {
|
|
|
|
fprintf(ttyout,
|
|
|
|
"Restart is not supported by the remote server.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
restartit = 1;
|
|
|
|
}
|
1999-10-09 07:00:55 +04:00
|
|
|
oldintr = xsignal(SIGINT, mintr);
|
|
|
|
if (sigsetjmp(jabort, 1))
|
|
|
|
mabort();
|
1997-03-13 09:23:11 +03:00
|
|
|
while ((cp = remglob(argv, proxy, NULL)) != NULL) {
|
1999-10-24 16:31:36 +04:00
|
|
|
if (*cp == '\0' || !connected) {
|
1993-03-21 12:45:37 +03:00
|
|
|
mflag = 0;
|
|
|
|
continue;
|
|
|
|
}
|
2000-11-15 03:10:59 +03:00
|
|
|
if (! mflag || !confirm(argv[0], cp))
|
|
|
|
continue;
|
|
|
|
tp = cp;
|
|
|
|
if (mcase)
|
|
|
|
tp = docase(tp);
|
|
|
|
if (ntflag)
|
|
|
|
tp = dotrans(tp);
|
|
|
|
if (mapflag)
|
|
|
|
tp = domap(tp);
|
|
|
|
if (restartit) {
|
|
|
|
struct stat stbuf;
|
|
|
|
|
|
|
|
if (stat(tp, &stbuf) == 0)
|
|
|
|
restart_point = stbuf.st_size;
|
|
|
|
else
|
|
|
|
warn("stat %s", tp);
|
|
|
|
}
|
2002-05-07 06:04:09 +04:00
|
|
|
recvrequest("RETR", tp, cp, restart_point ? "r+" : "w",
|
2000-11-15 03:10:59 +03:00
|
|
|
tp != cp || !interactive, 1);
|
|
|
|
restart_point = 0;
|
|
|
|
if (!mflag && fromatty) {
|
|
|
|
ointer = interactive;
|
|
|
|
interactive = 1;
|
|
|
|
if (confirm("Continue with", "mget"))
|
|
|
|
mflag++;
|
|
|
|
interactive = ointer;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
}
|
1999-09-28 03:09:42 +04:00
|
|
|
(void)xsignal(SIGINT, oldintr);
|
1993-03-21 12:45:37 +03:00
|
|
|
mflag = 0;
|
|
|
|
}
|
|
|
|
|
2000-05-01 13:44:53 +04:00
|
|
|
/*
|
|
|
|
* Read list of filenames from a local file and get those
|
|
|
|
*/
|
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
fget(int argc, char *argv[])
|
2000-05-01 13:44:53 +04:00
|
|
|
{
|
|
|
|
char *buf, *mode;
|
|
|
|
FILE *fp;
|
|
|
|
|
|
|
|
if (argc != 2) {
|
|
|
|
fprintf(ttyout, "usage: %s localfile\n", argv[0]);
|
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
fp = fopen(argv[1], "r");
|
|
|
|
if (fp == NULL) {
|
|
|
|
fprintf(ttyout, "Cannot open source file %s\n", argv[1]);
|
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
argv[0] = "get";
|
2002-05-07 06:04:09 +04:00
|
|
|
mode = restart_point ? "r+" : "w";
|
2000-05-01 13:44:53 +04:00
|
|
|
|
|
|
|
for (;
|
|
|
|
(buf = fparseln(fp, NULL, NULL, "\0\0\0", 0)) != NULL;
|
|
|
|
free(buf)) {
|
|
|
|
if (buf[0] == '\0')
|
|
|
|
continue;
|
|
|
|
argv[1] = buf;
|
|
|
|
(void)getit(argc, argv, 0, mode);
|
|
|
|
}
|
|
|
|
fclose(fp);
|
|
|
|
}
|
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
char *
|
2000-05-01 14:35:16 +04:00
|
|
|
onoff(int bool)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
|
|
|
|
return (bool ? "on" : "off");
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Show status.
|
|
|
|
*/
|
|
|
|
/*ARGSUSED*/
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
status(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
if (argc == 0) {
|
1999-10-24 16:31:36 +04:00
|
|
|
fprintf(ttyout, "usage: %s\n", argv[0]);
|
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
if (connected)
|
1998-06-04 12:28:35 +04:00
|
|
|
fprintf(ttyout, "Connected %sto %s.\n",
|
1997-04-14 13:09:15 +04:00
|
|
|
connected == -1 ? "and logged in" : "", hostname);
|
1993-03-21 12:45:37 +03:00
|
|
|
else
|
1998-06-04 12:28:35 +04:00
|
|
|
fputs("Not connected.\n", ttyout);
|
1993-03-21 12:45:37 +03:00
|
|
|
if (!proxy) {
|
|
|
|
pswitch(1);
|
|
|
|
if (connected) {
|
1998-06-04 12:28:35 +04:00
|
|
|
fprintf(ttyout, "Connected for proxy commands to %s.\n",
|
1996-11-28 06:12:28 +03:00
|
|
|
hostname);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
else {
|
1998-06-04 12:28:35 +04:00
|
|
|
fputs("No proxy connection.\n", ttyout);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
pswitch(0);
|
|
|
|
}
|
1999-07-02 12:07:40 +04:00
|
|
|
fprintf(ttyout, "Gate ftp: %s, server %s, port %s.\n", onoff(gatemode),
|
|
|
|
*gateserver ? gateserver : "(none)", gateport);
|
1999-10-24 16:31:36 +04:00
|
|
|
fprintf(ttyout, "Passive mode: %s; fallback to active mode: %s.\n",
|
|
|
|
onoff(passivemode), onoff(activefallback));
|
1998-06-04 12:28:35 +04:00
|
|
|
fprintf(ttyout, "Mode: %s; Type: %s; Form: %s; Structure: %s.\n",
|
|
|
|
modename, typename, formname, structname);
|
|
|
|
fprintf(ttyout, "Verbose: %s; Bell: %s; Prompting: %s; Globbing: %s.\n",
|
|
|
|
onoff(verbose), onoff(bell), onoff(interactive), onoff(doglob));
|
|
|
|
fprintf(ttyout, "Store unique: %s; Receive unique: %s.\n",
|
|
|
|
onoff(sunique), onoff(runique));
|
|
|
|
fprintf(ttyout, "Preserve modification times: %s.\n", onoff(preserve));
|
|
|
|
fprintf(ttyout, "Case: %s; CR stripping: %s.\n", onoff(mcase),
|
|
|
|
onoff(crflag));
|
1993-03-21 12:45:37 +03:00
|
|
|
if (ntflag) {
|
1998-06-04 12:28:35 +04:00
|
|
|
fprintf(ttyout, "Ntrans: (in) %s (out) %s\n", ntin, ntout);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
else {
|
1998-06-04 12:28:35 +04:00
|
|
|
fputs("Ntrans: off.\n", ttyout);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
if (mapflag) {
|
1998-06-04 12:28:35 +04:00
|
|
|
fprintf(ttyout, "Nmap: (in) %s (out) %s\n", mapin, mapout);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
else {
|
1998-06-04 12:28:35 +04:00
|
|
|
fputs("Nmap: off.\n", ttyout);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1998-06-04 12:28:35 +04:00
|
|
|
fprintf(ttyout,
|
|
|
|
"Hash mark printing: %s; Mark count: %d; Progress bar: %s.\n",
|
1996-12-06 05:06:46 +03:00
|
|
|
onoff(hash), mark, onoff(progress));
|
[fear this; more ftp hacking from lukem :-]
features:
---------
* transfer rate throttling with the new `rate' command. syntax:
rate direction [max [incr]]
where direction is `all', `get' or `put'.
if max is not supplied, the current settings are displayed.
if max is supplied, then transfers in the given direction will
be throttled to this value.
if incr is supplied, the increment for the `on-the-fly' scaling
will be set to that, otherwise `1024' is used.
currently implemented for binary get, binary put, and url fetches.
not yet supported for ascii get or put, or local file copies.
* on-the-fly scaling of the throttle based on signals:
- SIGUSR1 raises the throttle rate by the increment for that direction
- SIGUSR2 lowers the throttle rate by the increment for that direction
* -T dir,max[,incr] option to set rate from the command line
* `k', `m', `g' suffix support for bytecounts in the `hash', `rate',
`rcvbuf' and `sndbuf' commands)
bug fixes and code mods:
------------------------
* fix up ftp_login() so that ruserpass() is always called, even for
command-line url fetches.
* implement strsuftoi(), which parses a given number into a int with
suffix support. replaces getsockbufsize()
* implement parserate(), which does the argv parsing for -T and rate
* save and restore errno in signal handlers (may not be necessary, but
it doesn't hurt)
notes:
------
the rate command has had reasonable testing, but I'd like feedback
if it doesn't do the right thing, especially from people on slower
(i.e, modem) links.
I haven't tested the rate throttle against a http server which does
`transfer-encoding: chunked' because I couldn't find a server to
test against.
1999-06-29 14:43:16 +04:00
|
|
|
fprintf(ttyout,
|
|
|
|
"Get transfer rate throttle: %s; maximum: %d; increment %d.\n",
|
|
|
|
onoff(rate_get), rate_get, rate_get_incr);
|
|
|
|
fprintf(ttyout,
|
|
|
|
"Put transfer rate throttle: %s; maximum: %d; increment %d.\n",
|
|
|
|
onoff(rate_put), rate_put, rate_put_incr);
|
1999-09-22 11:18:31 +04:00
|
|
|
fprintf(ttyout,
|
|
|
|
"Socket buffer sizes: send %d, receive %d.\n",
|
|
|
|
sndbuf_size, rcvbuf_size);
|
1998-06-04 12:28:35 +04:00
|
|
|
fprintf(ttyout, "Use of PORT cmds: %s.\n", onoff(sendport));
|
1999-10-01 12:01:12 +04:00
|
|
|
fprintf(ttyout, "Use of EPSV/EPRT cmds for IPv4: %s%s.\n", onoff(epsv4),
|
|
|
|
epsv4bad ? " (disabled for this connection)" : "");
|
1999-10-05 04:54:07 +04:00
|
|
|
fprintf(ttyout, "Command line editing: %s.\n",
|
|
|
|
#ifdef NO_EDITCOMPLETE
|
|
|
|
"support not compiled in"
|
|
|
|
#else /* !def NO_EDITCOMPLETE */
|
|
|
|
onoff(editing)
|
|
|
|
#endif /* !def NO_EDITCOMPLETE */
|
|
|
|
);
|
1999-11-10 01:03:49 +03:00
|
|
|
fprintf(ttyout, "Version: %s %s\n", FTP_PRODUCT, FTP_VERSION);
|
1993-03-21 12:45:37 +03:00
|
|
|
if (macnum > 0) {
|
1998-06-04 12:28:35 +04:00
|
|
|
fputs("Macros:\n", ttyout);
|
1993-03-21 12:45:37 +03:00
|
|
|
for (i=0; i<macnum; i++) {
|
1998-06-04 12:28:35 +04:00
|
|
|
fprintf(ttyout, "\t%s\n", macros[i].mac_name);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
code = 0;
|
|
|
|
}
|
|
|
|
|
1996-11-28 06:12:28 +03:00
|
|
|
/*
|
|
|
|
* Toggle a variable
|
|
|
|
*/
|
|
|
|
int
|
2000-05-01 14:35:16 +04:00
|
|
|
togglevar(int argc, char *argv[], int *var, const char *mesg)
|
1996-11-28 06:12:28 +03:00
|
|
|
{
|
1999-10-24 16:31:36 +04:00
|
|
|
if (argc == 1) {
|
1996-11-28 06:12:28 +03:00
|
|
|
*var = !*var;
|
|
|
|
} else if (argc == 2 && strcasecmp(argv[1], "on") == 0) {
|
|
|
|
*var = 1;
|
|
|
|
} else if (argc == 2 && strcasecmp(argv[1], "off") == 0) {
|
|
|
|
*var = 0;
|
|
|
|
} else {
|
1998-06-04 12:28:35 +04:00
|
|
|
fprintf(ttyout, "usage: %s [ on | off ]\n", argv[0]);
|
1997-03-13 09:23:11 +03:00
|
|
|
return (-1);
|
1996-11-28 06:12:28 +03:00
|
|
|
}
|
1999-01-24 05:39:29 +03:00
|
|
|
if (mesg)
|
1998-06-04 12:28:35 +04:00
|
|
|
fprintf(ttyout, "%s %s.\n", mesg, onoff(*var));
|
1997-03-13 09:23:11 +03:00
|
|
|
return (*var);
|
1996-11-28 06:12:28 +03:00
|
|
|
}
|
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
/*
|
|
|
|
* Set beep on cmd completed mode.
|
|
|
|
*/
|
|
|
|
/*VARARGS*/
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
setbell(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
|
1996-11-28 06:12:28 +03:00
|
|
|
code = togglevar(argc, argv, &bell, "Bell mode");
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1997-01-19 17:19:02 +03:00
|
|
|
/*
|
|
|
|
* Set command line editing
|
|
|
|
*/
|
|
|
|
/*VARARGS*/
|
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
setedit(int argc, char *argv[])
|
1997-01-19 17:19:02 +03:00
|
|
|
{
|
|
|
|
|
1999-10-05 04:54:07 +04:00
|
|
|
#ifdef NO_EDITCOMPLETE
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
if (argc == 0) {
|
1999-10-24 16:31:36 +04:00
|
|
|
fprintf(ttyout, "usage: %s\n", argv[0]);
|
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
1999-10-05 04:54:07 +04:00
|
|
|
if (verbose)
|
|
|
|
fputs("Editing support not compiled in; ignoring command.\n",
|
|
|
|
ttyout);
|
|
|
|
#else /* !def NO_EDITCOMPLETE */
|
1997-01-19 17:19:02 +03:00
|
|
|
code = togglevar(argc, argv, &editing, "Editing mode");
|
1997-04-05 07:27:32 +04:00
|
|
|
controlediting();
|
1999-10-05 04:54:07 +04:00
|
|
|
#endif /* !def NO_EDITCOMPLETE */
|
1997-01-19 17:19:02 +03:00
|
|
|
}
|
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
/*
|
|
|
|
* Turn on packet tracing.
|
|
|
|
*/
|
|
|
|
/*VARARGS*/
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
settrace(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
|
1996-11-28 06:12:28 +03:00
|
|
|
code = togglevar(argc, argv, &trace, "Packet tracing");
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1996-11-25 08:13:18 +03:00
|
|
|
* Toggle hash mark printing during transfers, or set hash mark bytecount.
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
|
|
|
/*VARARGS*/
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
sethash(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1996-11-28 06:12:28 +03:00
|
|
|
if (argc == 1)
|
1996-11-25 08:13:18 +03:00
|
|
|
hash = !hash;
|
1996-11-28 06:12:28 +03:00
|
|
|
else if (argc != 2) {
|
1998-06-04 12:28:35 +04:00
|
|
|
fprintf(ttyout, "usage: %s [ on | off | bytecount ]\n",
|
|
|
|
argv[0]);
|
1996-11-28 06:12:28 +03:00
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
} else if (strcasecmp(argv[1], "on") == 0)
|
|
|
|
hash = 1;
|
|
|
|
else if (strcasecmp(argv[1], "off") == 0)
|
|
|
|
hash = 0;
|
|
|
|
else {
|
1997-11-01 17:36:49 +03:00
|
|
|
int nmark;
|
|
|
|
|
[fear this; more ftp hacking from lukem :-]
features:
---------
* transfer rate throttling with the new `rate' command. syntax:
rate direction [max [incr]]
where direction is `all', `get' or `put'.
if max is not supplied, the current settings are displayed.
if max is supplied, then transfers in the given direction will
be throttled to this value.
if incr is supplied, the increment for the `on-the-fly' scaling
will be set to that, otherwise `1024' is used.
currently implemented for binary get, binary put, and url fetches.
not yet supported for ascii get or put, or local file copies.
* on-the-fly scaling of the throttle based on signals:
- SIGUSR1 raises the throttle rate by the increment for that direction
- SIGUSR2 lowers the throttle rate by the increment for that direction
* -T dir,max[,incr] option to set rate from the command line
* `k', `m', `g' suffix support for bytecounts in the `hash', `rate',
`rcvbuf' and `sndbuf' commands)
bug fixes and code mods:
------------------------
* fix up ftp_login() so that ruserpass() is always called, even for
command-line url fetches.
* implement strsuftoi(), which parses a given number into a int with
suffix support. replaces getsockbufsize()
* implement parserate(), which does the argv parsing for -T and rate
* save and restore errno in signal handlers (may not be necessary, but
it doesn't hurt)
notes:
------
the rate command has had reasonable testing, but I'd like feedback
if it doesn't do the right thing, especially from people on slower
(i.e, modem) links.
I haven't tested the rate throttle against a http server which does
`transfer-encoding: chunked' because I couldn't find a server to
test against.
1999-06-29 14:43:16 +04:00
|
|
|
nmark = strsuftoi(argv[1]);
|
|
|
|
if (nmark < 1) {
|
1998-06-04 12:28:35 +04:00
|
|
|
fprintf(ttyout, "mark: bad bytecount value `%s'.\n",
|
|
|
|
argv[1]);
|
1996-11-28 06:12:28 +03:00
|
|
|
code = -1;
|
|
|
|
return;
|
1996-11-25 08:13:18 +03:00
|
|
|
}
|
1996-11-28 06:12:28 +03:00
|
|
|
mark = nmark;
|
|
|
|
hash = 1;
|
1996-11-25 08:13:18 +03:00
|
|
|
}
|
1998-06-04 12:28:35 +04:00
|
|
|
fprintf(ttyout, "Hash mark printing %s", onoff(hash));
|
1996-11-28 06:12:28 +03:00
|
|
|
if (hash)
|
1998-06-04 12:28:35 +04:00
|
|
|
fprintf(ttyout, " (%d bytes/hash mark)", mark);
|
|
|
|
fputs(".\n", ttyout);
|
1998-10-08 18:45:26 +04:00
|
|
|
if (hash)
|
|
|
|
progress = 0;
|
1996-11-28 06:12:28 +03:00
|
|
|
code = hash;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Turn on printing of server echo's.
|
|
|
|
*/
|
|
|
|
/*VARARGS*/
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
setverbose(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
|
1996-11-28 06:12:28 +03:00
|
|
|
code = togglevar(argc, argv, &verbose, "Verbose mode");
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1999-07-02 12:07:40 +04:00
|
|
|
* Toggle PORT/LPRT cmd use before each data connection.
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
|
|
|
/*VARARGS*/
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
setport(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
|
1999-07-02 12:07:40 +04:00
|
|
|
code = togglevar(argc, argv, &sendport, "Use of PORT/LPRT cmds");
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1996-12-06 05:06:46 +03:00
|
|
|
/*
|
|
|
|
* Toggle transfer progress bar.
|
|
|
|
*/
|
|
|
|
/*VARARGS*/
|
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
setprogress(int argc, char *argv[])
|
1996-12-06 05:06:46 +03:00
|
|
|
{
|
|
|
|
|
|
|
|
code = togglevar(argc, argv, &progress, "Progress bar");
|
1998-10-08 18:45:26 +04:00
|
|
|
if (progress)
|
|
|
|
hash = 0;
|
1996-12-06 05:06:46 +03:00
|
|
|
}
|
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
/*
|
1997-08-18 14:20:13 +04:00
|
|
|
* Turn on interactive prompting during mget, mput, and mdelete.
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
|
|
|
/*VARARGS*/
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
setprompt(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
|
1996-11-28 06:12:28 +03:00
|
|
|
code = togglevar(argc, argv, &interactive, "Interactive mode");
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1997-08-18 14:20:13 +04:00
|
|
|
* Toggle gate-ftp mode, or set gate-ftp server
|
|
|
|
*/
|
|
|
|
/*VARARGS*/
|
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
setgate(int argc, char *argv[])
|
1997-08-18 14:20:13 +04:00
|
|
|
{
|
|
|
|
static char gsbuf[MAXHOSTNAMELEN];
|
|
|
|
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
if (argc == 0 || argc > 3) {
|
1998-06-04 12:28:35 +04:00
|
|
|
fprintf(ttyout,
|
1999-10-24 16:31:36 +04:00
|
|
|
"usage: %s [ on | off | gateserver [port] ]\n", argv[0]);
|
1997-08-18 14:20:13 +04:00
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
} else if (argc < 2) {
|
|
|
|
gatemode = !gatemode;
|
|
|
|
} else {
|
|
|
|
if (argc == 2 && strcasecmp(argv[1], "on") == 0)
|
|
|
|
gatemode = 1;
|
|
|
|
else if (argc == 2 && strcasecmp(argv[1], "off") == 0)
|
|
|
|
gatemode = 0;
|
|
|
|
else {
|
1999-09-24 04:48:24 +04:00
|
|
|
if (argc == 3)
|
2002-07-12 07:05:13 +04:00
|
|
|
gateport = xstrdup(argv[2]);
|
1999-09-28 10:47:38 +04:00
|
|
|
(void)strlcpy(gsbuf, argv[1], sizeof(gsbuf));
|
1997-08-18 14:20:13 +04:00
|
|
|
gateserver = gsbuf;
|
|
|
|
gatemode = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (gatemode && (gateserver == NULL || *gateserver == '\0')) {
|
1998-06-04 12:28:35 +04:00
|
|
|
fprintf(ttyout,
|
1997-08-18 14:20:13 +04:00
|
|
|
"Disabling gate-ftp mode - no gate-ftp server defined.\n");
|
|
|
|
gatemode = 0;
|
|
|
|
} else {
|
1999-07-02 12:07:40 +04:00
|
|
|
fprintf(ttyout, "Gate ftp: %s, server %s, port %s.\n",
|
1998-06-04 12:28:35 +04:00
|
|
|
onoff(gatemode), *gateserver ? gateserver : "(none)",
|
1999-07-02 12:07:40 +04:00
|
|
|
gateport);
|
1997-08-18 14:20:13 +04:00
|
|
|
}
|
|
|
|
code = gatemode;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Toggle metacharacter interpretation on local file names.
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
|
|
|
/*VARARGS*/
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
setglob(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1996-11-25 08:13:18 +03:00
|
|
|
|
1996-11-28 06:12:28 +03:00
|
|
|
code = togglevar(argc, argv, &doglob, "Globbing");
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1998-07-26 16:58:16 +04:00
|
|
|
* Toggle preserving modification times on retrieved files.
|
1996-11-28 06:12:28 +03:00
|
|
|
*/
|
|
|
|
/*VARARGS*/
|
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
setpreserve(int argc, char *argv[])
|
1996-11-28 06:12:28 +03:00
|
|
|
{
|
|
|
|
|
|
|
|
code = togglevar(argc, argv, &preserve, "Preserve modification times");
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1997-08-18 14:20:13 +04:00
|
|
|
* Set debugging mode on/off and/or set level of debugging.
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
|
|
|
/*VARARGS*/
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
setdebug(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
if (argc == 0 || argc > 2) {
|
1998-06-04 12:28:35 +04:00
|
|
|
fprintf(ttyout, "usage: %s [ on | off | debuglevel ]\n",
|
|
|
|
argv[0]);
|
1996-11-28 06:12:28 +03:00
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
} else if (argc == 2) {
|
|
|
|
if (strcasecmp(argv[1], "on") == 0)
|
|
|
|
debug = 1;
|
|
|
|
else if (strcasecmp(argv[1], "off") == 0)
|
|
|
|
debug = 0;
|
|
|
|
else {
|
[fear this; more ftp hacking from lukem :-]
features:
---------
* transfer rate throttling with the new `rate' command. syntax:
rate direction [max [incr]]
where direction is `all', `get' or `put'.
if max is not supplied, the current settings are displayed.
if max is supplied, then transfers in the given direction will
be throttled to this value.
if incr is supplied, the increment for the `on-the-fly' scaling
will be set to that, otherwise `1024' is used.
currently implemented for binary get, binary put, and url fetches.
not yet supported for ascii get or put, or local file copies.
* on-the-fly scaling of the throttle based on signals:
- SIGUSR1 raises the throttle rate by the increment for that direction
- SIGUSR2 lowers the throttle rate by the increment for that direction
* -T dir,max[,incr] option to set rate from the command line
* `k', `m', `g' suffix support for bytecounts in the `hash', `rate',
`rcvbuf' and `sndbuf' commands)
bug fixes and code mods:
------------------------
* fix up ftp_login() so that ruserpass() is always called, even for
command-line url fetches.
* implement strsuftoi(), which parses a given number into a int with
suffix support. replaces getsockbufsize()
* implement parserate(), which does the argv parsing for -T and rate
* save and restore errno in signal handlers (may not be necessary, but
it doesn't hurt)
notes:
------
the rate command has had reasonable testing, but I'd like feedback
if it doesn't do the right thing, especially from people on slower
(i.e, modem) links.
I haven't tested the rate throttle against a http server which does
`transfer-encoding: chunked' because I couldn't find a server to
test against.
1999-06-29 14:43:16 +04:00
|
|
|
int val;
|
1997-07-20 13:45:35 +04:00
|
|
|
|
[fear this; more ftp hacking from lukem :-]
features:
---------
* transfer rate throttling with the new `rate' command. syntax:
rate direction [max [incr]]
where direction is `all', `get' or `put'.
if max is not supplied, the current settings are displayed.
if max is supplied, then transfers in the given direction will
be throttled to this value.
if incr is supplied, the increment for the `on-the-fly' scaling
will be set to that, otherwise `1024' is used.
currently implemented for binary get, binary put, and url fetches.
not yet supported for ascii get or put, or local file copies.
* on-the-fly scaling of the throttle based on signals:
- SIGUSR1 raises the throttle rate by the increment for that direction
- SIGUSR2 lowers the throttle rate by the increment for that direction
* -T dir,max[,incr] option to set rate from the command line
* `k', `m', `g' suffix support for bytecounts in the `hash', `rate',
`rcvbuf' and `sndbuf' commands)
bug fixes and code mods:
------------------------
* fix up ftp_login() so that ruserpass() is always called, even for
command-line url fetches.
* implement strsuftoi(), which parses a given number into a int with
suffix support. replaces getsockbufsize()
* implement parserate(), which does the argv parsing for -T and rate
* save and restore errno in signal handlers (may not be necessary, but
it doesn't hurt)
notes:
------
the rate command has had reasonable testing, but I'd like feedback
if it doesn't do the right thing, especially from people on slower
(i.e, modem) links.
I haven't tested the rate throttle against a http server which does
`transfer-encoding: chunked' because I couldn't find a server to
test against.
1999-06-29 14:43:16 +04:00
|
|
|
val = strsuftoi(argv[1]);
|
|
|
|
if (val < 0) {
|
1998-06-04 12:28:35 +04:00
|
|
|
fprintf(ttyout, "%s: bad debugging value.\n",
|
|
|
|
argv[1]);
|
1996-11-28 06:12:28 +03:00
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
[fear this; more ftp hacking from lukem :-]
features:
---------
* transfer rate throttling with the new `rate' command. syntax:
rate direction [max [incr]]
where direction is `all', `get' or `put'.
if max is not supplied, the current settings are displayed.
if max is supplied, then transfers in the given direction will
be throttled to this value.
if incr is supplied, the increment for the `on-the-fly' scaling
will be set to that, otherwise `1024' is used.
currently implemented for binary get, binary put, and url fetches.
not yet supported for ascii get or put, or local file copies.
* on-the-fly scaling of the throttle based on signals:
- SIGUSR1 raises the throttle rate by the increment for that direction
- SIGUSR2 lowers the throttle rate by the increment for that direction
* -T dir,max[,incr] option to set rate from the command line
* `k', `m', `g' suffix support for bytecounts in the `hash', `rate',
`rcvbuf' and `sndbuf' commands)
bug fixes and code mods:
------------------------
* fix up ftp_login() so that ruserpass() is always called, even for
command-line url fetches.
* implement strsuftoi(), which parses a given number into a int with
suffix support. replaces getsockbufsize()
* implement parserate(), which does the argv parsing for -T and rate
* save and restore errno in signal handlers (may not be necessary, but
it doesn't hurt)
notes:
------
the rate command has had reasonable testing, but I'd like feedback
if it doesn't do the right thing, especially from people on slower
(i.e, modem) links.
I haven't tested the rate throttle against a http server which does
`transfer-encoding: chunked' because I couldn't find a server to
test against.
1999-06-29 14:43:16 +04:00
|
|
|
debug = val;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
} else
|
1996-12-06 05:06:46 +03:00
|
|
|
debug = !debug;
|
1993-03-21 12:45:37 +03:00
|
|
|
if (debug)
|
|
|
|
options |= SO_DEBUG;
|
|
|
|
else
|
|
|
|
options &= ~SO_DEBUG;
|
1998-06-04 12:28:35 +04:00
|
|
|
fprintf(ttyout, "Debugging %s (debug=%d).\n", onoff(debug), debug);
|
1993-03-21 12:45:37 +03:00
|
|
|
code = debug > 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1997-08-18 14:20:13 +04:00
|
|
|
* Set current working directory on remote machine.
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
cd(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1997-01-19 17:19:02 +03:00
|
|
|
int r;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
if (argc == 0 || argc > 2 ||
|
|
|
|
(argc == 1 && !another(&argc, &argv, "remote-directory"))) {
|
1998-06-04 12:28:35 +04:00
|
|
|
fprintf(ttyout, "usage: %s remote-directory\n", argv[0]);
|
1993-03-21 12:45:37 +03:00
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
1997-01-19 23:17:37 +03:00
|
|
|
r = command("CWD %s", argv[1]);
|
1997-01-19 17:19:02 +03:00
|
|
|
if (r == ERROR && code == 500) {
|
1993-03-21 12:45:37 +03:00
|
|
|
if (verbose)
|
1998-06-04 12:28:35 +04:00
|
|
|
fputs("CWD command not recognized, trying XCWD.\n",
|
|
|
|
ttyout);
|
1997-01-19 17:19:02 +03:00
|
|
|
r = command("XCWD %s", argv[1]);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1999-11-11 05:53:02 +03:00
|
|
|
if (r == COMPLETE) {
|
1997-01-19 17:19:02 +03:00
|
|
|
dirchange = 1;
|
1999-11-11 05:53:02 +03:00
|
|
|
updateremotepwd();
|
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1997-08-18 14:20:13 +04:00
|
|
|
* Set current working directory on local machine.
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
lcd(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
char buf[MAXPATHLEN];
|
1999-09-28 10:47:38 +04:00
|
|
|
char *locdir;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1999-10-24 16:31:36 +04:00
|
|
|
code = -1;
|
|
|
|
if (argc == 1) {
|
1999-09-30 16:18:03 +04:00
|
|
|
argc++;
|
2000-11-15 03:10:59 +03:00
|
|
|
argv[1] = localhome;
|
1999-09-30 16:18:03 +04:00
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
if (argc != 2) {
|
1999-10-24 16:31:36 +04:00
|
|
|
fprintf(ttyout, "usage: %s [local-directory]\n", argv[0]);
|
1993-03-21 12:45:37 +03:00
|
|
|
return;
|
|
|
|
}
|
1999-10-24 16:31:36 +04:00
|
|
|
if ((locdir = globulize(argv[1])) == NULL)
|
1993-03-21 12:45:37 +03:00
|
|
|
return;
|
1999-10-24 16:31:36 +04:00
|
|
|
if (chdir(locdir) < 0)
|
1999-09-28 10:47:38 +04:00
|
|
|
warn("local: %s", locdir);
|
1999-10-24 16:31:36 +04:00
|
|
|
else {
|
|
|
|
if (getcwd(buf, sizeof(buf)) != NULL) {
|
1998-06-04 12:28:35 +04:00
|
|
|
fprintf(ttyout, "Local directory now %s\n", buf);
|
1999-10-24 16:31:36 +04:00
|
|
|
code = 0;
|
|
|
|
} else
|
1999-09-28 10:47:38 +04:00
|
|
|
warn("getcwd: %s", locdir);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1999-09-28 10:47:38 +04:00
|
|
|
(void)free(locdir);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Delete a single file.
|
|
|
|
*/
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
delete(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
|
2000-05-01 14:35:16 +04:00
|
|
|
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
if (argc == 0 || argc > 2 ||
|
|
|
|
(argc == 1 && !another(&argc, &argv, "remote-file"))) {
|
1998-06-04 12:28:35 +04:00
|
|
|
fprintf(ttyout, "usage: %s remote-file\n", argv[0]);
|
1993-03-21 12:45:37 +03:00
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
1997-03-13 09:23:11 +03:00
|
|
|
(void)command("DELE %s", argv[1]);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Delete multiple files.
|
|
|
|
*/
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
mdelete(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
2000-02-01 01:01:03 +03:00
|
|
|
sigfunc oldintr;
|
1993-03-21 12:45:37 +03:00
|
|
|
int ointer;
|
|
|
|
char *cp;
|
|
|
|
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
if (argc == 0 ||
|
|
|
|
(argc == 1 && !another(&argc, &argv, "remote-files"))) {
|
1999-10-24 16:31:36 +04:00
|
|
|
fprintf(ttyout, "usage: %s [remote-files]\n", argv[0]);
|
1993-03-21 12:45:37 +03:00
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
mname = argv[0];
|
|
|
|
mflag = 1;
|
1999-10-09 07:00:55 +04:00
|
|
|
oldintr = xsignal(SIGINT, mintr);
|
|
|
|
if (sigsetjmp(jabort, 1))
|
|
|
|
mabort();
|
1997-03-13 09:23:11 +03:00
|
|
|
while ((cp = remglob(argv, 0, NULL)) != NULL) {
|
1993-03-21 12:45:37 +03:00
|
|
|
if (*cp == '\0') {
|
|
|
|
mflag = 0;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (mflag && confirm(argv[0], cp)) {
|
1997-03-13 09:23:11 +03:00
|
|
|
(void)command("DELE %s", cp);
|
1993-03-21 12:45:37 +03:00
|
|
|
if (!mflag && fromatty) {
|
|
|
|
ointer = interactive;
|
|
|
|
interactive = 1;
|
|
|
|
if (confirm("Continue with", "mdelete")) {
|
|
|
|
mflag++;
|
|
|
|
}
|
|
|
|
interactive = ointer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-09-28 03:09:42 +04:00
|
|
|
(void)xsignal(SIGINT, oldintr);
|
1993-03-21 12:45:37 +03:00
|
|
|
mflag = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Rename a remote file.
|
|
|
|
*/
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
renamefile(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
if (argc == 0 || (argc == 1 && !another(&argc, &argv, "from-name")))
|
1993-03-21 12:45:37 +03:00
|
|
|
goto usage;
|
1996-11-28 06:12:28 +03:00
|
|
|
if ((argc < 3 && !another(&argc, &argv, "to-name")) || argc > 3) {
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
usage:
|
1998-06-04 12:28:35 +04:00
|
|
|
fprintf(ttyout, "usage: %s from-name to-name\n", argv[0]);
|
1993-03-21 12:45:37 +03:00
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (command("RNFR %s", argv[1]) == CONTINUE)
|
1997-03-13 09:23:11 +03:00
|
|
|
(void)command("RNTO %s", argv[2]);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1997-08-18 14:20:13 +04:00
|
|
|
* Get a directory listing of remote files.
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
* Supports being invoked as:
|
|
|
|
* cmd runs
|
|
|
|
* --- ----
|
|
|
|
* dir, ls LIST
|
|
|
|
* mlsd MLSD
|
|
|
|
* nlist NLST
|
|
|
|
* pdir, pls LIST |$PAGER
|
|
|
|
* mmlsd MLSD |$PAGER
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
ls(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1996-11-28 06:12:28 +03:00
|
|
|
const char *cmd;
|
1999-09-28 10:47:38 +04:00
|
|
|
char *remdir, *locfile;
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
int freelocfile, pagecmd, mlsdcmd;
|
1999-09-28 10:47:38 +04:00
|
|
|
|
|
|
|
remdir = NULL;
|
|
|
|
locfile = "-";
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
freelocfile = pagecmd = mlsdcmd = 0;
|
1999-09-28 10:47:38 +04:00
|
|
|
/*
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
* the only commands that start with `p' are
|
|
|
|
* the `pager' versions.
|
1999-09-28 10:47:38 +04:00
|
|
|
*/
|
|
|
|
if (argv[0][0] == 'p')
|
|
|
|
pagecmd = 1;
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
if (strcmp(argv[0] + pagecmd , "mlsd") == 0) {
|
|
|
|
if (! features[FEAT_MLST]) {
|
|
|
|
fprintf(ttyout,
|
|
|
|
"MLSD is not supported by the remote server.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
mlsdcmd = 1;
|
|
|
|
}
|
|
|
|
if (argc == 0)
|
1999-10-24 16:31:36 +04:00
|
|
|
goto usage;
|
1999-09-28 10:47:38 +04:00
|
|
|
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
if (mlsdcmd)
|
|
|
|
cmd = "MLSD";
|
|
|
|
else if (strcmp(argv[0] + pagecmd, "nlist") == 0)
|
2000-05-28 11:53:30 +04:00
|
|
|
cmd = "NLST";
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
else
|
|
|
|
cmd = "LIST";
|
1999-09-28 10:47:38 +04:00
|
|
|
|
|
|
|
if (argc > 1)
|
|
|
|
remdir = argv[1];
|
|
|
|
if (argc > 2)
|
|
|
|
locfile = argv[2];
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
if (argc > 3 || ((pagecmd | mlsdcmd) && argc > 2)) {
|
1999-10-24 16:31:36 +04:00
|
|
|
usage:
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
if (pagecmd || mlsdcmd)
|
1999-09-28 10:47:38 +04:00
|
|
|
fprintf(ttyout,
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
"usage: %s [remote-path]\n", argv[0]);
|
1999-09-28 10:47:38 +04:00
|
|
|
else
|
|
|
|
fprintf(ttyout,
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
"usage: %s [remote-path [local-file]]\n",
|
1999-09-28 10:47:38 +04:00
|
|
|
argv[0]);
|
1993-03-21 12:45:37 +03:00
|
|
|
code = -1;
|
1999-09-28 10:47:38 +04:00
|
|
|
goto freels;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pagecmd) {
|
|
|
|
char *p;
|
|
|
|
int len;
|
|
|
|
|
1999-10-24 16:31:36 +04:00
|
|
|
p = getoptionvalue("pager");
|
|
|
|
if (EMPTYSTRING(p))
|
|
|
|
p = DEFAULTPAGER;
|
1999-09-28 10:47:38 +04:00
|
|
|
len = strlen(p) + 2;
|
|
|
|
locfile = xmalloc(len);
|
|
|
|
locfile[0] = '|';
|
|
|
|
(void)strlcpy(locfile + 1, p, len - 1);
|
|
|
|
freelocfile = 1;
|
|
|
|
} else if ((strcmp(locfile, "-") != 0) && *locfile != '|') {
|
|
|
|
if ((locfile = globulize(locfile)) == NULL ||
|
|
|
|
!confirm("output to local-file:", locfile)) {
|
1993-03-21 12:45:37 +03:00
|
|
|
code = -1;
|
1997-08-18 14:20:13 +04:00
|
|
|
goto freels;
|
1999-09-28 10:47:38 +04:00
|
|
|
}
|
|
|
|
freelocfile = 1;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1999-09-28 10:47:38 +04:00
|
|
|
recvrequest(cmd, locfile, remdir, "w", 0, 0);
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
freels:
|
1999-09-28 10:47:38 +04:00
|
|
|
if (freelocfile && locfile)
|
|
|
|
(void)free(locfile);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1997-08-18 14:20:13 +04:00
|
|
|
* Get a directory listing of multiple remote files.
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
mls(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
2000-02-01 01:01:03 +03:00
|
|
|
sigfunc oldintr;
|
1993-03-21 12:45:37 +03:00
|
|
|
int ointer, i;
|
1997-07-20 13:45:35 +04:00
|
|
|
int dolist;
|
2002-05-06 18:36:41 +04:00
|
|
|
char *mode, *dest, *odest;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
if (argc == 0)
|
1999-10-24 16:31:36 +04:00
|
|
|
goto usage;
|
1993-03-21 12:45:37 +03:00
|
|
|
if (argc < 2 && !another(&argc, &argv, "remote-files"))
|
|
|
|
goto usage;
|
|
|
|
if (argc < 3 && !another(&argc, &argv, "local-file")) {
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
usage:
|
1998-06-04 12:28:35 +04:00
|
|
|
fprintf(ttyout, "usage: %s remote-files local-file\n", argv[0]);
|
1993-03-21 12:45:37 +03:00
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
1997-08-18 14:20:13 +04:00
|
|
|
odest = dest = argv[argc - 1];
|
1993-03-21 12:45:37 +03:00
|
|
|
argv[argc - 1] = NULL;
|
|
|
|
if (strcmp(dest, "-") && *dest != '|')
|
1999-09-28 10:47:38 +04:00
|
|
|
if (((dest = globulize(dest)) == NULL) ||
|
1993-03-21 12:45:37 +03:00
|
|
|
!confirm("output to local-file:", dest)) {
|
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
1997-07-20 13:45:35 +04:00
|
|
|
dolist = strcmp(argv[0], "mls");
|
1993-03-21 12:45:37 +03:00
|
|
|
mname = argv[0];
|
|
|
|
mflag = 1;
|
1999-10-09 07:00:55 +04:00
|
|
|
oldintr = xsignal(SIGINT, mintr);
|
|
|
|
if (sigsetjmp(jabort, 1))
|
|
|
|
mabort();
|
1999-10-24 16:31:36 +04:00
|
|
|
for (i = 1; mflag && i < argc-1 && connected; i++) {
|
2002-05-06 18:36:41 +04:00
|
|
|
mode = (i == 1) ? "w" : "a";
|
1997-08-18 14:20:13 +04:00
|
|
|
recvrequest(dolist ? "LIST" : "NLST", dest, argv[i], mode,
|
|
|
|
0, 0);
|
1993-03-21 12:45:37 +03:00
|
|
|
if (!mflag && fromatty) {
|
|
|
|
ointer = interactive;
|
|
|
|
interactive = 1;
|
|
|
|
if (confirm("Continue with", argv[0])) {
|
|
|
|
mflag ++;
|
|
|
|
}
|
|
|
|
interactive = ointer;
|
|
|
|
}
|
|
|
|
}
|
1999-09-28 03:09:42 +04:00
|
|
|
(void)xsignal(SIGINT, oldintr);
|
1993-03-21 12:45:37 +03:00
|
|
|
mflag = 0;
|
1997-08-18 14:20:13 +04:00
|
|
|
if (dest != odest) /* free up after globulize() */
|
|
|
|
free(dest);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Do a shell escape
|
|
|
|
*/
|
|
|
|
/*ARGSUSED*/
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
shell(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1994-08-25 07:47:50 +04:00
|
|
|
pid_t pid;
|
2000-02-01 01:01:03 +03:00
|
|
|
sigfunc old1;
|
1996-12-29 07:05:29 +03:00
|
|
|
char shellnam[MAXPATHLEN], *shell, *namep;
|
1997-09-21 05:06:30 +04:00
|
|
|
int wait_status;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
if (argc == 0) {
|
1999-10-24 16:31:36 +04:00
|
|
|
fprintf(ttyout, "usage: %s [command [args]]\n", argv[0]);
|
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
1999-09-28 03:09:42 +04:00
|
|
|
old1 = xsignal(SIGINT, SIG_IGN);
|
1993-03-21 12:45:37 +03:00
|
|
|
if ((pid = fork()) == 0) {
|
|
|
|
for (pid = 3; pid < 20; pid++)
|
1997-03-13 09:23:11 +03:00
|
|
|
(void)close(pid);
|
1999-09-28 03:09:42 +04:00
|
|
|
(void)xsignal(SIGINT, SIG_DFL);
|
1993-03-21 12:45:37 +03:00
|
|
|
shell = getenv("SHELL");
|
|
|
|
if (shell == NULL)
|
|
|
|
shell = _PATH_BSHELL;
|
1996-11-28 06:12:28 +03:00
|
|
|
namep = strrchr(shell, '/');
|
1993-03-21 12:45:37 +03:00
|
|
|
if (namep == NULL)
|
|
|
|
namep = shell;
|
1999-10-05 17:05:39 +04:00
|
|
|
else
|
|
|
|
namep++;
|
|
|
|
(void)strlcpy(shellnam, namep, sizeof(shellnam));
|
1993-03-21 12:45:37 +03:00
|
|
|
if (debug) {
|
1998-06-04 12:28:35 +04:00
|
|
|
fputs(shell, ttyout);
|
|
|
|
putc('\n', ttyout);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
if (argc > 1) {
|
1996-11-28 06:12:28 +03:00
|
|
|
execl(shell, shellnam, "-c", altarg, (char *)0);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
else {
|
1996-11-28 06:12:28 +03:00
|
|
|
execl(shell, shellnam, (char *)0);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1994-08-25 07:47:50 +04:00
|
|
|
warn("%s", shell);
|
1993-03-21 12:45:37 +03:00
|
|
|
code = -1;
|
|
|
|
exit(1);
|
1994-08-25 07:47:50 +04:00
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
if (pid > 0)
|
1997-09-21 05:06:30 +04:00
|
|
|
while (wait(&wait_status) != pid)
|
1993-03-21 12:45:37 +03:00
|
|
|
;
|
1999-09-28 03:09:42 +04:00
|
|
|
(void)xsignal(SIGINT, old1);
|
1993-03-21 12:45:37 +03:00
|
|
|
if (pid == -1) {
|
1997-03-13 09:23:11 +03:00
|
|
|
warn("Try again later");
|
1993-03-21 12:45:37 +03:00
|
|
|
code = -1;
|
1999-10-24 16:31:36 +04:00
|
|
|
} else
|
1993-03-21 12:45:37 +03:00
|
|
|
code = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Send new user information (re-login)
|
|
|
|
*/
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
user(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1994-08-25 07:47:50 +04:00
|
|
|
char acct[80];
|
1993-03-21 12:45:37 +03:00
|
|
|
int n, aflag = 0;
|
|
|
|
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
if (argc == 0)
|
1999-10-24 16:31:36 +04:00
|
|
|
goto usage;
|
1993-03-21 12:45:37 +03:00
|
|
|
if (argc < 2)
|
1997-03-13 09:23:11 +03:00
|
|
|
(void)another(&argc, &argv, "username");
|
1993-03-21 12:45:37 +03:00
|
|
|
if (argc < 2 || argc > 4) {
|
1999-10-24 16:31:36 +04:00
|
|
|
usage:
|
|
|
|
fprintf(ttyout, "usage: %s username [password [account]]\n",
|
1998-06-04 12:28:35 +04:00
|
|
|
argv[0]);
|
1993-03-21 12:45:37 +03:00
|
|
|
code = -1;
|
1994-08-25 07:47:50 +04:00
|
|
|
return;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
n = command("USER %s", argv[1]);
|
|
|
|
if (n == CONTINUE) {
|
1999-06-02 06:03:57 +04:00
|
|
|
if (argc < 3) {
|
|
|
|
argv[2] = getpass("Password: ");
|
|
|
|
argc++;
|
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
n = command("PASS %s", argv[2]);
|
|
|
|
}
|
|
|
|
if (n == CONTINUE) {
|
|
|
|
if (argc < 4) {
|
1998-06-04 12:28:35 +04:00
|
|
|
(void)fputs("Account: ", ttyout);
|
|
|
|
(void)fflush(ttyout);
|
1999-06-02 06:03:57 +04:00
|
|
|
if (fgets(acct, sizeof(acct) - 1, stdin) == NULL) {
|
|
|
|
fprintf(ttyout,
|
|
|
|
"\nEOF received; login aborted.\n");
|
1999-10-12 10:04:59 +04:00
|
|
|
clearerr(stdin);
|
1999-06-02 06:03:57 +04:00
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
acct[strlen(acct) - 1] = '\0';
|
|
|
|
argv[3] = acct; argc++;
|
|
|
|
}
|
|
|
|
n = command("ACCT %s", argv[3]);
|
|
|
|
aflag++;
|
|
|
|
}
|
|
|
|
if (n != COMPLETE) {
|
1998-06-04 12:28:35 +04:00
|
|
|
fputs("Login failed.\n", ttyout);
|
1994-08-25 07:47:50 +04:00
|
|
|
return;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
if (!aflag && argc == 4) {
|
1997-03-13 09:23:11 +03:00
|
|
|
(void)command("ACCT %s", argv[3]);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1997-04-14 13:09:15 +04:00
|
|
|
connected = -1;
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
getremoteinfo();
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1996-11-28 06:12:28 +03:00
|
|
|
* Print working directory on remote machine.
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
|
|
|
/*VARARGS*/
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
pwd(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
int oldverbose = verbose;
|
|
|
|
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
if (argc == 0) {
|
1999-10-24 16:31:36 +04:00
|
|
|
fprintf(ttyout, "usage: %s\n", argv[0]);
|
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
verbose = 1; /* If we aren't verbose, this doesn't do anything! */
|
1993-03-21 12:45:37 +03:00
|
|
|
if (command("PWD") == ERROR && code == 500) {
|
1998-06-04 12:28:35 +04:00
|
|
|
fputs("PWD command not recognized, trying XPWD.\n", ttyout);
|
1997-03-13 09:23:11 +03:00
|
|
|
(void)command("XPWD");
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
verbose = oldverbose;
|
|
|
|
}
|
|
|
|
|
1996-11-28 06:12:28 +03:00
|
|
|
/*
|
|
|
|
* Print working directory on local machine.
|
|
|
|
*/
|
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
lpwd(int argc, char *argv[])
|
1996-11-28 06:12:28 +03:00
|
|
|
{
|
|
|
|
char buf[MAXPATHLEN];
|
|
|
|
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
if (argc == 0) {
|
1999-10-24 16:31:36 +04:00
|
|
|
fprintf(ttyout, "usage: %s\n", argv[0]);
|
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (getcwd(buf, sizeof(buf)) != NULL) {
|
1998-06-04 12:28:35 +04:00
|
|
|
fprintf(ttyout, "Local directory %s\n", buf);
|
1999-10-24 16:31:36 +04:00
|
|
|
code = 0;
|
|
|
|
} else {
|
[Yet Another Huge Ftp Commit - hopefully the last for a while,
barring any more little things people want added ...]
New features:
* progressmeter is now asynchronous, so "stalled" transfers can be
detected. "- stalled -" is displayed instead of the ETA in this case.
When the xfer resumes, the time that the xfer was stalled for is
factored out of the ETA. It is debatable whether this is better than
not factoring it out, but I like it this way (I.e, if it stalls for 8
seconds and the ETA was 30 seconds, when it resumes the ETA will still
be 30 seconds).
* verbosity can be disabled on the command line (-V), so that in auto-fetch
mode the only lines displayed will be a description of the file, and
the progress bar (if possible)
* if the screen is resized (and detected via the SIGWINCH signal), the
progress bar will rescale automatically.
Bugs fixed:
* progress bar will not use the last character on the line, as this can
cause problems on some terminals
* screen dimensions (via ioctl(TIOCWINSZ)) should use stdout not stdin
* progressmeter() used some vars before initialising them
* ^D will quit now. [fixes bin/3162]
* use hstrerror() to generate error message for host name lookup failure.
* use getcwd instead of getwd (it should have been OK, but why tempt fate?)
* auto-fetch transfers will always return a positive exit value upon failure
or interruption, relative to the file's position in argv[].
* remote completion of / will work, without putting a leading "///".
This is actually a bug in ftpd(1), where "NLST /" prefixes all names
with "//", but fixing every ftpd(1) is not an option...
1997-02-01 13:44:54 +03:00
|
|
|
warn("getcwd");
|
1999-10-24 16:31:36 +04:00
|
|
|
code = -1;
|
|
|
|
}
|
1996-11-28 06:12:28 +03:00
|
|
|
}
|
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
/*
|
|
|
|
* Make a directory.
|
|
|
|
*/
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
makedir(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
if (argc == 0 || argc > 2 ||
|
|
|
|
(argc == 1 && !another(&argc, &argv, "directory-name"))) {
|
1998-06-04 12:28:35 +04:00
|
|
|
fprintf(ttyout, "usage: %s directory-name\n", argv[0]);
|
1993-03-21 12:45:37 +03:00
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (command("MKD %s", argv[1]) == ERROR && code == 500) {
|
|
|
|
if (verbose)
|
1998-06-04 12:28:35 +04:00
|
|
|
fputs("MKD command not recognized, trying XMKD.\n",
|
|
|
|
ttyout);
|
1997-03-13 09:23:11 +03:00
|
|
|
(void)command("XMKD %s", argv[1]);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Remove a directory.
|
|
|
|
*/
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
removedir(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
if (argc == 0 || argc > 2 ||
|
|
|
|
(argc == 1 && !another(&argc, &argv, "directory-name"))) {
|
1998-06-04 12:28:35 +04:00
|
|
|
fprintf(ttyout, "usage: %s directory-name\n", argv[0]);
|
1993-03-21 12:45:37 +03:00
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (command("RMD %s", argv[1]) == ERROR && code == 500) {
|
|
|
|
if (verbose)
|
1998-06-04 12:28:35 +04:00
|
|
|
fputs("RMD command not recognized, trying XRMD.\n",
|
|
|
|
ttyout);
|
1997-03-13 09:23:11 +03:00
|
|
|
(void)command("XRMD %s", argv[1]);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Send a line, verbatim, to the remote machine.
|
|
|
|
*/
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
quote(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
if (argc == 0 ||
|
|
|
|
(argc == 1 && !another(&argc, &argv, "command line to send"))) {
|
1998-06-04 12:28:35 +04:00
|
|
|
fprintf(ttyout, "usage: %s line-to-send\n", argv[0]);
|
1993-03-21 12:45:37 +03:00
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
quote1("", argc, argv);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Send a SITE command to the remote machine. The line
|
|
|
|
* is sent verbatim to the remote machine, except that the
|
|
|
|
* word "SITE" is added at the front.
|
|
|
|
*/
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
site(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
if (argc == 0 ||
|
|
|
|
(argc == 1 && !another(&argc, &argv, "arguments to SITE command"))){
|
1998-06-04 12:28:35 +04:00
|
|
|
fprintf(ttyout, "usage: %s line-to-send\n", argv[0]);
|
1993-03-21 12:45:37 +03:00
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
quote1("SITE ", argc, argv);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Turn argv[1..argc) into a space-separated string, then prepend initial text.
|
|
|
|
* Send the result as a one-line command and get response.
|
|
|
|
*/
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
quote1(const char *initial, int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1999-09-28 10:47:38 +04:00
|
|
|
int i;
|
1993-03-21 12:45:37 +03:00
|
|
|
char buf[BUFSIZ]; /* must be >= sizeof(line) */
|
|
|
|
|
1999-09-28 10:47:38 +04:00
|
|
|
(void)strlcpy(buf, initial, sizeof(buf));
|
|
|
|
for (i = 1; i < argc; i++) {
|
|
|
|
(void)strlcat(buf, argv[i], sizeof(buf));
|
|
|
|
if (i < (argc - 1))
|
|
|
|
(void)strlcat(buf, " ", sizeof(buf));
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1998-09-01 18:25:52 +04:00
|
|
|
if (command("%s", buf) == PRELIM) {
|
1994-08-25 07:47:50 +04:00
|
|
|
while (getreply(0) == PRELIM)
|
|
|
|
continue;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
do_chmod(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
if (argc == 0 || (argc == 1 && !another(&argc, &argv, "mode")))
|
1993-03-21 12:45:37 +03:00
|
|
|
goto usage;
|
1999-10-24 16:31:36 +04:00
|
|
|
if ((argc < 3 && !another(&argc, &argv, "remote-file")) || argc > 3) {
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
usage:
|
1999-10-24 16:31:36 +04:00
|
|
|
fprintf(ttyout, "usage: %s mode remote-file\n", argv[0]);
|
1993-03-21 12:45:37 +03:00
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
1997-03-13 09:23:11 +03:00
|
|
|
(void)command("SITE CHMOD %s %s", argv[1], argv[2]);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
2000-10-11 18:46:00 +04:00
|
|
|
#define COMMAND_1ARG(argc, argv, cmd) \
|
|
|
|
if (argc == 1) \
|
|
|
|
command(cmd); \
|
|
|
|
else \
|
|
|
|
command(cmd " %s", argv[1])
|
|
|
|
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
do_umask(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
int oldverbose = verbose;
|
|
|
|
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
if (argc == 0) {
|
1999-10-24 16:31:36 +04:00
|
|
|
fprintf(ttyout, "usage: %s [umask]\n", argv[0]);
|
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
verbose = 1;
|
2000-10-11 18:46:00 +04:00
|
|
|
COMMAND_1ARG(argc, argv, "SITE UMASK");
|
1993-03-21 12:45:37 +03:00
|
|
|
verbose = oldverbose;
|
|
|
|
}
|
|
|
|
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
idlecmd(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
int oldverbose = verbose;
|
|
|
|
|
1999-11-27 00:41:55 +03:00
|
|
|
if (argc < 1 || argc > 2) {
|
1999-10-24 16:31:36 +04:00
|
|
|
fprintf(ttyout, "usage: %s [seconds]\n", argv[0]);
|
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
verbose = 1;
|
2000-10-11 18:46:00 +04:00
|
|
|
COMMAND_1ARG(argc, argv, "SITE IDLE");
|
1993-03-21 12:45:37 +03:00
|
|
|
verbose = oldverbose;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Ask the other side for help.
|
|
|
|
*/
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
rmthelp(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
int oldverbose = verbose;
|
|
|
|
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
if (argc == 0) {
|
1999-10-24 16:31:36 +04:00
|
|
|
fprintf(ttyout, "usage: %s\n", argv[0]);
|
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
verbose = 1;
|
2000-10-11 18:46:00 +04:00
|
|
|
COMMAND_1ARG(argc, argv, "HELP");
|
1993-03-21 12:45:37 +03:00
|
|
|
verbose = oldverbose;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Terminate session and exit.
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
* May be called with 0, NULL.
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
|
|
|
/*VARARGS*/
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
quit(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
/* this may be called with argc == 0, argv == NULL */
|
1999-10-24 16:31:36 +04:00
|
|
|
if (argc == 0 && argv != NULL) {
|
|
|
|
fprintf(ttyout, "usage: %s\n", argv[0]);
|
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
if (connected)
|
1999-10-24 16:31:36 +04:00
|
|
|
disconnect(0, NULL);
|
1993-03-21 12:45:37 +03:00
|
|
|
pswitch(1);
|
1999-10-24 16:31:36 +04:00
|
|
|
if (connected)
|
|
|
|
disconnect(0, NULL);
|
1993-03-21 12:45:37 +03:00
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Terminate session, but don't exit.
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
* May be called with 0, NULL.
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
disconnect(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
/* this may be called with argc == 0, argv == NULL */
|
1999-10-24 16:31:36 +04:00
|
|
|
if (argc == 0 && argv != NULL) {
|
|
|
|
fprintf(ttyout, "usage: %s\n", argv[0]);
|
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
if (!connected)
|
|
|
|
return;
|
1997-03-13 09:23:11 +03:00
|
|
|
(void)command("QUIT");
|
1999-10-24 16:31:36 +04:00
|
|
|
cleanuppeer();
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
account(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1996-12-29 07:05:29 +03:00
|
|
|
char *ap;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
if (argc == 0 || argc > 2) {
|
1998-06-04 12:28:35 +04:00
|
|
|
fprintf(ttyout, "usage: %s [password]\n", argv[0]);
|
1996-12-29 07:05:29 +03:00
|
|
|
code = -1;
|
|
|
|
return;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1996-12-29 07:05:29 +03:00
|
|
|
else if (argc == 2)
|
|
|
|
ap = argv[1];
|
|
|
|
else
|
1993-03-21 12:45:37 +03:00
|
|
|
ap = getpass("Account:");
|
1997-03-13 09:23:11 +03:00
|
|
|
(void)command("ACCT %s", ap);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1999-10-11 02:33:54 +04:00
|
|
|
sigjmp_buf abortprox;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
proxabort(int notused)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
|
[Yet Another Huge Ftp Commit - hopefully the last for a while,
barring any more little things people want added ...]
New features:
* progressmeter is now asynchronous, so "stalled" transfers can be
detected. "- stalled -" is displayed instead of the ETA in this case.
When the xfer resumes, the time that the xfer was stalled for is
factored out of the ETA. It is debatable whether this is better than
not factoring it out, but I like it this way (I.e, if it stalls for 8
seconds and the ETA was 30 seconds, when it resumes the ETA will still
be 30 seconds).
* verbosity can be disabled on the command line (-V), so that in auto-fetch
mode the only lines displayed will be a description of the file, and
the progress bar (if possible)
* if the screen is resized (and detected via the SIGWINCH signal), the
progress bar will rescale automatically.
Bugs fixed:
* progress bar will not use the last character on the line, as this can
cause problems on some terminals
* screen dimensions (via ioctl(TIOCWINSZ)) should use stdout not stdin
* progressmeter() used some vars before initialising them
* ^D will quit now. [fixes bin/3162]
* use hstrerror() to generate error message for host name lookup failure.
* use getcwd instead of getwd (it should have been OK, but why tempt fate?)
* auto-fetch transfers will always return a positive exit value upon failure
or interruption, relative to the file's position in argv[].
* remote completion of / will work, without putting a leading "///".
This is actually a bug in ftpd(1), where "NLST /" prefixes all names
with "//", but fixing every ftpd(1) is not an option...
1997-02-01 13:44:54 +03:00
|
|
|
alarmtimer(0);
|
1993-03-21 12:45:37 +03:00
|
|
|
if (!proxy) {
|
|
|
|
pswitch(1);
|
|
|
|
}
|
|
|
|
if (connected) {
|
|
|
|
proxflag = 1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
proxflag = 0;
|
|
|
|
}
|
|
|
|
pswitch(0);
|
1999-10-09 07:00:55 +04:00
|
|
|
siglongjmp(abortprox, 1);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
doproxy(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1994-08-25 07:47:50 +04:00
|
|
|
struct cmd *c;
|
1997-01-03 05:55:59 +03:00
|
|
|
int cmdpos;
|
2000-02-01 01:01:03 +03:00
|
|
|
sigfunc oldintr;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
if (argc == 0 || (argc == 1 && !another(&argc, &argv, "command"))) {
|
1998-06-04 12:28:35 +04:00
|
|
|
fprintf(ttyout, "usage: %s command\n", argv[0]);
|
1993-03-21 12:45:37 +03:00
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
c = getcmd(argv[1]);
|
|
|
|
if (c == (struct cmd *) -1) {
|
1998-06-04 12:28:35 +04:00
|
|
|
fputs("?Ambiguous command.\n", ttyout);
|
1993-03-21 12:45:37 +03:00
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (c == 0) {
|
1998-06-04 12:28:35 +04:00
|
|
|
fputs("?Invalid command.\n", ttyout);
|
1993-03-21 12:45:37 +03:00
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!c->c_proxy) {
|
1998-06-04 12:28:35 +04:00
|
|
|
fputs("?Invalid proxy command.\n", ttyout);
|
1993-03-21 12:45:37 +03:00
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
1999-10-09 07:00:55 +04:00
|
|
|
if (sigsetjmp(abortprox, 1)) {
|
1993-03-21 12:45:37 +03:00
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
1999-09-28 03:09:42 +04:00
|
|
|
oldintr = xsignal(SIGINT, proxabort);
|
1993-03-21 12:45:37 +03:00
|
|
|
pswitch(1);
|
|
|
|
if (c->c_conn && !connected) {
|
1998-06-04 12:28:35 +04:00
|
|
|
fputs("Not connected.\n", ttyout);
|
1993-03-21 12:45:37 +03:00
|
|
|
pswitch(0);
|
1999-09-28 03:09:42 +04:00
|
|
|
(void)xsignal(SIGINT, oldintr);
|
1993-03-21 12:45:37 +03:00
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
1997-01-03 05:55:59 +03:00
|
|
|
cmdpos = strcspn(line, " \t");
|
|
|
|
if (cmdpos > 0) /* remove leading "proxy " from input buffer */
|
|
|
|
memmove(line, line + cmdpos + 1, strlen(line) - cmdpos + 1);
|
2000-12-15 05:22:50 +03:00
|
|
|
argv[1] = c->c_name;
|
1993-03-21 12:45:37 +03:00
|
|
|
(*c->c_handler)(argc-1, argv+1);
|
|
|
|
if (connected) {
|
|
|
|
proxflag = 1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
proxflag = 0;
|
|
|
|
}
|
|
|
|
pswitch(0);
|
1999-09-28 03:09:42 +04:00
|
|
|
(void)xsignal(SIGINT, oldintr);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
setcase(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1994-08-25 07:47:50 +04:00
|
|
|
|
1996-11-28 06:12:28 +03:00
|
|
|
code = togglevar(argc, argv, &mcase, "Case mapping");
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1999-09-28 10:47:38 +04:00
|
|
|
/*
|
|
|
|
* convert the given name to lower case if it's all upper case, into
|
|
|
|
* a static buffer which is returned to the caller
|
|
|
|
*/
|
|
|
|
char *
|
2000-05-01 14:35:16 +04:00
|
|
|
docase(char *name)
|
1999-09-28 10:47:38 +04:00
|
|
|
{
|
|
|
|
static char new[MAXPATHLEN];
|
|
|
|
int i, dochange;
|
|
|
|
|
|
|
|
dochange = 1;
|
|
|
|
for (i = 0; name[i] != '\0' && i < sizeof(new) - 1; i++) {
|
|
|
|
new[i] = name[i];
|
|
|
|
if (islower((unsigned char)new[i]))
|
|
|
|
dochange = 0;
|
|
|
|
}
|
|
|
|
new[i] = '\0';
|
|
|
|
|
|
|
|
if (dochange) {
|
|
|
|
for (i = 0; new[i] != '\0'; i++)
|
|
|
|
if (isupper((unsigned char)new[i]))
|
|
|
|
new[i] = tolower(new[i]);
|
|
|
|
}
|
|
|
|
return (new);
|
|
|
|
}
|
|
|
|
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
setcr(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1994-08-25 07:47:50 +04:00
|
|
|
|
1996-11-28 06:12:28 +03:00
|
|
|
code = togglevar(argc, argv, &crflag, "Carriage Return stripping");
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
setntrans(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1999-10-24 16:31:36 +04:00
|
|
|
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
if (argc == 0 || argc > 3) {
|
1999-10-24 16:31:36 +04:00
|
|
|
fprintf(ttyout, "usage: %s [inchars [outchars]]\n", argv[0]);
|
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
if (argc == 1) {
|
|
|
|
ntflag = 0;
|
1998-06-04 12:28:35 +04:00
|
|
|
fputs("Ntrans off.\n", ttyout);
|
1993-03-21 12:45:37 +03:00
|
|
|
code = ntflag;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ntflag++;
|
|
|
|
code = ntflag;
|
1999-09-28 10:47:38 +04:00
|
|
|
(void)strlcpy(ntin, argv[1], sizeof(ntin));
|
1993-03-21 12:45:37 +03:00
|
|
|
if (argc == 2) {
|
|
|
|
ntout[0] = '\0';
|
|
|
|
return;
|
|
|
|
}
|
1999-09-28 10:47:38 +04:00
|
|
|
(void)strlcpy(ntout, argv[2], sizeof(ntout));
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
char *
|
2000-05-01 14:35:16 +04:00
|
|
|
dotrans(char *name)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
static char new[MAXPATHLEN];
|
|
|
|
char *cp1, *cp2 = new;
|
1994-08-25 07:47:50 +04:00
|
|
|
int i, ostop, found;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1994-08-25 07:47:50 +04:00
|
|
|
for (ostop = 0; *(ntout + ostop) && ostop < 16; ostop++)
|
|
|
|
continue;
|
1993-03-21 12:45:37 +03:00
|
|
|
for (cp1 = name; *cp1; cp1++) {
|
|
|
|
found = 0;
|
|
|
|
for (i = 0; *(ntin + i) && i < 16; i++) {
|
|
|
|
if (*cp1 == *(ntin + i)) {
|
|
|
|
found++;
|
|
|
|
if (i < ostop) {
|
|
|
|
*cp2++ = *(ntout + i);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!found) {
|
|
|
|
*cp2++ = *cp1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*cp2 = '\0';
|
1994-08-25 07:47:50 +04:00
|
|
|
return (new);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
setnmap(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
char *cp;
|
|
|
|
|
|
|
|
if (argc == 1) {
|
|
|
|
mapflag = 0;
|
1998-06-04 12:28:35 +04:00
|
|
|
fputs("Nmap off.\n", ttyout);
|
1993-03-21 12:45:37 +03:00
|
|
|
code = mapflag;
|
|
|
|
return;
|
|
|
|
}
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
if (argc == 0 ||
|
1999-10-24 16:31:36 +04:00
|
|
|
(argc < 3 && !another(&argc, &argv, "mapout")) || argc > 3) {
|
1998-06-04 12:28:35 +04:00
|
|
|
fprintf(ttyout, "usage: %s [mapin mapout]\n", argv[0]);
|
1993-03-21 12:45:37 +03:00
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
mapflag = 1;
|
|
|
|
code = 1;
|
1994-08-25 07:47:50 +04:00
|
|
|
cp = strchr(altarg, ' ');
|
1993-03-21 12:45:37 +03:00
|
|
|
if (proxy) {
|
1994-08-25 07:47:50 +04:00
|
|
|
while(*++cp == ' ')
|
|
|
|
continue;
|
1993-03-21 12:45:37 +03:00
|
|
|
altarg = cp;
|
1994-08-25 07:47:50 +04:00
|
|
|
cp = strchr(altarg, ' ');
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
*cp = '\0';
|
1999-09-28 10:47:38 +04:00
|
|
|
(void)strlcpy(mapin, altarg, MAXPATHLEN);
|
1994-08-25 07:47:50 +04:00
|
|
|
while (*++cp == ' ')
|
|
|
|
continue;
|
1999-09-28 10:47:38 +04:00
|
|
|
(void)strlcpy(mapout, cp, MAXPATHLEN);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
char *
|
2000-05-01 14:35:16 +04:00
|
|
|
domap(char *name)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
static char new[MAXPATHLEN];
|
1994-08-25 07:47:50 +04:00
|
|
|
char *cp1 = name, *cp2 = mapin;
|
1993-03-21 12:45:37 +03:00
|
|
|
char *tp[9], *te[9];
|
|
|
|
int i, toks[9], toknum = 0, match = 1;
|
|
|
|
|
|
|
|
for (i=0; i < 9; ++i) {
|
|
|
|
toks[i] = 0;
|
|
|
|
}
|
|
|
|
while (match && *cp1 && *cp2) {
|
|
|
|
switch (*cp2) {
|
|
|
|
case '\\':
|
|
|
|
if (*++cp2 != *cp1) {
|
|
|
|
match = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case '$':
|
|
|
|
if (*(cp2+1) >= '1' && (*cp2+1) <= '9') {
|
|
|
|
if (*cp1 != *(++cp2+1)) {
|
|
|
|
toks[toknum = *cp2 - '1']++;
|
|
|
|
tp[toknum] = cp1;
|
|
|
|
while (*++cp1 && *(cp2+1)
|
|
|
|
!= *cp1);
|
|
|
|
te[toknum] = cp1;
|
|
|
|
}
|
|
|
|
cp2++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* FALLTHROUGH */
|
|
|
|
default:
|
|
|
|
if (*cp2 != *cp1) {
|
|
|
|
match = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (match && *cp1) {
|
|
|
|
cp1++;
|
|
|
|
}
|
|
|
|
if (match && *cp2) {
|
|
|
|
cp2++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!match && *cp1) /* last token mismatch */
|
|
|
|
{
|
|
|
|
toks[toknum] = 0;
|
|
|
|
}
|
|
|
|
cp1 = new;
|
|
|
|
*cp1 = '\0';
|
|
|
|
cp2 = mapout;
|
|
|
|
while (*cp2) {
|
|
|
|
match = 0;
|
|
|
|
switch (*cp2) {
|
|
|
|
case '\\':
|
|
|
|
if (*(cp2 + 1)) {
|
|
|
|
*cp1++ = *++cp2;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case '[':
|
|
|
|
LOOP:
|
1998-05-20 04:52:29 +04:00
|
|
|
if (*++cp2 == '$' &&
|
|
|
|
isdigit((unsigned char)*(cp2+1))) {
|
1993-03-21 12:45:37 +03:00
|
|
|
if (*++cp2 == '0') {
|
|
|
|
char *cp3 = name;
|
|
|
|
|
|
|
|
while (*cp3) {
|
|
|
|
*cp1++ = *cp3++;
|
|
|
|
}
|
|
|
|
match = 1;
|
|
|
|
}
|
|
|
|
else if (toks[toknum = *cp2 - '1']) {
|
|
|
|
char *cp3 = tp[toknum];
|
|
|
|
|
|
|
|
while (cp3 != te[toknum]) {
|
|
|
|
*cp1++ = *cp3++;
|
|
|
|
}
|
|
|
|
match = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
1996-11-25 08:13:18 +03:00
|
|
|
while (*cp2 && *cp2 != ',' &&
|
1993-03-21 12:45:37 +03:00
|
|
|
*cp2 != ']') {
|
|
|
|
if (*cp2 == '\\') {
|
|
|
|
cp2++;
|
|
|
|
}
|
|
|
|
else if (*cp2 == '$' &&
|
1998-05-20 04:52:29 +04:00
|
|
|
isdigit((unsigned char)*(cp2+1))) {
|
1993-03-21 12:45:37 +03:00
|
|
|
if (*++cp2 == '0') {
|
|
|
|
char *cp3 = name;
|
|
|
|
|
|
|
|
while (*cp3) {
|
|
|
|
*cp1++ = *cp3++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (toks[toknum =
|
|
|
|
*cp2 - '1']) {
|
|
|
|
char *cp3=tp[toknum];
|
|
|
|
|
|
|
|
while (cp3 !=
|
|
|
|
te[toknum]) {
|
|
|
|
*cp1++ = *cp3++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (*cp2) {
|
|
|
|
*cp1++ = *cp2++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!*cp2) {
|
1998-06-04 12:28:35 +04:00
|
|
|
fputs(
|
|
|
|
"nmap: unbalanced brackets.\n",
|
|
|
|
ttyout);
|
1994-08-25 07:47:50 +04:00
|
|
|
return (name);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
match = 1;
|
|
|
|
cp2--;
|
|
|
|
}
|
|
|
|
if (match) {
|
|
|
|
while (*++cp2 && *cp2 != ']') {
|
|
|
|
if (*cp2 == '\\' && *(cp2 + 1)) {
|
|
|
|
cp2++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!*cp2) {
|
1998-06-04 12:28:35 +04:00
|
|
|
fputs(
|
|
|
|
"nmap: unbalanced brackets.\n",
|
|
|
|
ttyout);
|
1994-08-25 07:47:50 +04:00
|
|
|
return (name);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
switch (*++cp2) {
|
|
|
|
case ',':
|
|
|
|
goto LOOP;
|
|
|
|
case ']':
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
cp2--;
|
|
|
|
goto LOOP;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case '$':
|
1998-05-20 04:52:29 +04:00
|
|
|
if (isdigit((unsigned char)*(cp2 + 1))) {
|
1993-03-21 12:45:37 +03:00
|
|
|
if (*++cp2 == '0') {
|
|
|
|
char *cp3 = name;
|
|
|
|
|
|
|
|
while (*cp3) {
|
|
|
|
*cp1++ = *cp3++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (toks[toknum = *cp2 - '1']) {
|
|
|
|
char *cp3 = tp[toknum];
|
|
|
|
|
|
|
|
while (cp3 != te[toknum]) {
|
|
|
|
*cp1++ = *cp3++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* intentional drop through */
|
|
|
|
default:
|
|
|
|
*cp1++ = *cp2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
cp2++;
|
|
|
|
}
|
|
|
|
*cp1 = '\0';
|
|
|
|
if (!*new) {
|
1994-08-25 07:47:50 +04:00
|
|
|
return (name);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1994-08-25 07:47:50 +04:00
|
|
|
return (new);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1994-08-25 08:27:41 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
setpassive(int argc, char *argv[])
|
1994-08-25 08:27:41 +04:00
|
|
|
{
|
|
|
|
|
1999-10-24 16:31:36 +04:00
|
|
|
if (argc == 1) {
|
|
|
|
passivemode = !passivemode;
|
|
|
|
activefallback = passivemode;
|
|
|
|
} else if (argc != 2) {
|
|
|
|
passiveusage:
|
|
|
|
fprintf(ttyout, "usage: %s [ on | off | auto ]\n", argv[0]);
|
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
} else if (strcasecmp(argv[1], "on") == 0) {
|
|
|
|
passivemode = 1;
|
|
|
|
activefallback = 0;
|
|
|
|
} else if (strcasecmp(argv[1], "off") == 0) {
|
|
|
|
passivemode = 0;
|
|
|
|
activefallback = 0;
|
|
|
|
} else if (strcasecmp(argv[1], "auto") == 0) {
|
|
|
|
passivemode = 1;
|
|
|
|
activefallback = 1;
|
|
|
|
} else
|
|
|
|
goto passiveusage;
|
|
|
|
fprintf(ttyout, "Passive mode: %s; fallback to active mode: %s.\n",
|
|
|
|
onoff(passivemode), onoff(activefallback));
|
|
|
|
code = passivemode;
|
1994-08-25 08:27:41 +04:00
|
|
|
}
|
|
|
|
|
1999-10-01 12:01:12 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
setepsv4(int argc, char *argv[])
|
1999-10-01 12:01:12 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
code = togglevar(argc, argv, &epsv4,
|
|
|
|
verbose ? "EPSV/EPRT on IPv4" : NULL);
|
|
|
|
epsv4bad = 0;
|
|
|
|
}
|
|
|
|
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
setsunique(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1994-08-25 07:47:50 +04:00
|
|
|
|
1996-11-28 06:12:28 +03:00
|
|
|
code = togglevar(argc, argv, &sunique, "Store unique");
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
setrunique(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1994-08-25 07:47:50 +04:00
|
|
|
|
1996-11-28 06:12:28 +03:00
|
|
|
code = togglevar(argc, argv, &runique, "Receive unique");
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
[fear this; more ftp hacking from lukem :-]
features:
---------
* transfer rate throttling with the new `rate' command. syntax:
rate direction [max [incr]]
where direction is `all', `get' or `put'.
if max is not supplied, the current settings are displayed.
if max is supplied, then transfers in the given direction will
be throttled to this value.
if incr is supplied, the increment for the `on-the-fly' scaling
will be set to that, otherwise `1024' is used.
currently implemented for binary get, binary put, and url fetches.
not yet supported for ascii get or put, or local file copies.
* on-the-fly scaling of the throttle based on signals:
- SIGUSR1 raises the throttle rate by the increment for that direction
- SIGUSR2 lowers the throttle rate by the increment for that direction
* -T dir,max[,incr] option to set rate from the command line
* `k', `m', `g' suffix support for bytecounts in the `hash', `rate',
`rcvbuf' and `sndbuf' commands)
bug fixes and code mods:
------------------------
* fix up ftp_login() so that ruserpass() is always called, even for
command-line url fetches.
* implement strsuftoi(), which parses a given number into a int with
suffix support. replaces getsockbufsize()
* implement parserate(), which does the argv parsing for -T and rate
* save and restore errno in signal handlers (may not be necessary, but
it doesn't hurt)
notes:
------
the rate command has had reasonable testing, but I'd like feedback
if it doesn't do the right thing, especially from people on slower
(i.e, modem) links.
I haven't tested the rate throttle against a http server which does
`transfer-encoding: chunked' because I couldn't find a server to
test against.
1999-06-29 14:43:16 +04:00
|
|
|
int
|
2000-05-01 14:35:16 +04:00
|
|
|
parserate(int argc, char *argv[], int cmdlineopt)
|
[fear this; more ftp hacking from lukem :-]
features:
---------
* transfer rate throttling with the new `rate' command. syntax:
rate direction [max [incr]]
where direction is `all', `get' or `put'.
if max is not supplied, the current settings are displayed.
if max is supplied, then transfers in the given direction will
be throttled to this value.
if incr is supplied, the increment for the `on-the-fly' scaling
will be set to that, otherwise `1024' is used.
currently implemented for binary get, binary put, and url fetches.
not yet supported for ascii get or put, or local file copies.
* on-the-fly scaling of the throttle based on signals:
- SIGUSR1 raises the throttle rate by the increment for that direction
- SIGUSR2 lowers the throttle rate by the increment for that direction
* -T dir,max[,incr] option to set rate from the command line
* `k', `m', `g' suffix support for bytecounts in the `hash', `rate',
`rcvbuf' and `sndbuf' commands)
bug fixes and code mods:
------------------------
* fix up ftp_login() so that ruserpass() is always called, even for
command-line url fetches.
* implement strsuftoi(), which parses a given number into a int with
suffix support. replaces getsockbufsize()
* implement parserate(), which does the argv parsing for -T and rate
* save and restore errno in signal handlers (may not be necessary, but
it doesn't hurt)
notes:
------
the rate command has had reasonable testing, but I'd like feedback
if it doesn't do the right thing, especially from people on slower
(i.e, modem) links.
I haven't tested the rate throttle against a http server which does
`transfer-encoding: chunked' because I couldn't find a server to
test against.
1999-06-29 14:43:16 +04:00
|
|
|
{
|
|
|
|
int dir, max, incr, showonly;
|
2000-02-01 01:01:03 +03:00
|
|
|
sigfunc oldusr1, oldusr2;
|
[fear this; more ftp hacking from lukem :-]
features:
---------
* transfer rate throttling with the new `rate' command. syntax:
rate direction [max [incr]]
where direction is `all', `get' or `put'.
if max is not supplied, the current settings are displayed.
if max is supplied, then transfers in the given direction will
be throttled to this value.
if incr is supplied, the increment for the `on-the-fly' scaling
will be set to that, otherwise `1024' is used.
currently implemented for binary get, binary put, and url fetches.
not yet supported for ascii get or put, or local file copies.
* on-the-fly scaling of the throttle based on signals:
- SIGUSR1 raises the throttle rate by the increment for that direction
- SIGUSR2 lowers the throttle rate by the increment for that direction
* -T dir,max[,incr] option to set rate from the command line
* `k', `m', `g' suffix support for bytecounts in the `hash', `rate',
`rcvbuf' and `sndbuf' commands)
bug fixes and code mods:
------------------------
* fix up ftp_login() so that ruserpass() is always called, even for
command-line url fetches.
* implement strsuftoi(), which parses a given number into a int with
suffix support. replaces getsockbufsize()
* implement parserate(), which does the argv parsing for -T and rate
* save and restore errno in signal handlers (may not be necessary, but
it doesn't hurt)
notes:
------
the rate command has had reasonable testing, but I'd like feedback
if it doesn't do the right thing, especially from people on slower
(i.e, modem) links.
I haven't tested the rate throttle against a http server which does
`transfer-encoding: chunked' because I couldn't find a server to
test against.
1999-06-29 14:43:16 +04:00
|
|
|
|
|
|
|
if (argc > 4 || (argc < (cmdlineopt ? 3 : 2))) {
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
usage:
|
[fear this; more ftp hacking from lukem :-]
features:
---------
* transfer rate throttling with the new `rate' command. syntax:
rate direction [max [incr]]
where direction is `all', `get' or `put'.
if max is not supplied, the current settings are displayed.
if max is supplied, then transfers in the given direction will
be throttled to this value.
if incr is supplied, the increment for the `on-the-fly' scaling
will be set to that, otherwise `1024' is used.
currently implemented for binary get, binary put, and url fetches.
not yet supported for ascii get or put, or local file copies.
* on-the-fly scaling of the throttle based on signals:
- SIGUSR1 raises the throttle rate by the increment for that direction
- SIGUSR2 lowers the throttle rate by the increment for that direction
* -T dir,max[,incr] option to set rate from the command line
* `k', `m', `g' suffix support for bytecounts in the `hash', `rate',
`rcvbuf' and `sndbuf' commands)
bug fixes and code mods:
------------------------
* fix up ftp_login() so that ruserpass() is always called, even for
command-line url fetches.
* implement strsuftoi(), which parses a given number into a int with
suffix support. replaces getsockbufsize()
* implement parserate(), which does the argv parsing for -T and rate
* save and restore errno in signal handlers (may not be necessary, but
it doesn't hurt)
notes:
------
the rate command has had reasonable testing, but I'd like feedback
if it doesn't do the right thing, especially from people on slower
(i.e, modem) links.
I haven't tested the rate throttle against a http server which does
`transfer-encoding: chunked' because I couldn't find a server to
test against.
1999-06-29 14:43:16 +04:00
|
|
|
if (cmdlineopt)
|
|
|
|
fprintf(ttyout,
|
1999-10-01 09:08:31 +04:00
|
|
|
"usage: %s (all|get|put),maximum-bytes[,increment-bytes]]\n",
|
[fear this; more ftp hacking from lukem :-]
features:
---------
* transfer rate throttling with the new `rate' command. syntax:
rate direction [max [incr]]
where direction is `all', `get' or `put'.
if max is not supplied, the current settings are displayed.
if max is supplied, then transfers in the given direction will
be throttled to this value.
if incr is supplied, the increment for the `on-the-fly' scaling
will be set to that, otherwise `1024' is used.
currently implemented for binary get, binary put, and url fetches.
not yet supported for ascii get or put, or local file copies.
* on-the-fly scaling of the throttle based on signals:
- SIGUSR1 raises the throttle rate by the increment for that direction
- SIGUSR2 lowers the throttle rate by the increment for that direction
* -T dir,max[,incr] option to set rate from the command line
* `k', `m', `g' suffix support for bytecounts in the `hash', `rate',
`rcvbuf' and `sndbuf' commands)
bug fixes and code mods:
------------------------
* fix up ftp_login() so that ruserpass() is always called, even for
command-line url fetches.
* implement strsuftoi(), which parses a given number into a int with
suffix support. replaces getsockbufsize()
* implement parserate(), which does the argv parsing for -T and rate
* save and restore errno in signal handlers (may not be necessary, but
it doesn't hurt)
notes:
------
the rate command has had reasonable testing, but I'd like feedback
if it doesn't do the right thing, especially from people on slower
(i.e, modem) links.
I haven't tested the rate throttle against a http server which does
`transfer-encoding: chunked' because I couldn't find a server to
test against.
1999-06-29 14:43:16 +04:00
|
|
|
argv[0]);
|
|
|
|
else
|
|
|
|
fprintf(ttyout,
|
1999-10-01 09:08:31 +04:00
|
|
|
"usage: %s (all|get|put) [maximum-bytes [increment-bytes]]\n",
|
[fear this; more ftp hacking from lukem :-]
features:
---------
* transfer rate throttling with the new `rate' command. syntax:
rate direction [max [incr]]
where direction is `all', `get' or `put'.
if max is not supplied, the current settings are displayed.
if max is supplied, then transfers in the given direction will
be throttled to this value.
if incr is supplied, the increment for the `on-the-fly' scaling
will be set to that, otherwise `1024' is used.
currently implemented for binary get, binary put, and url fetches.
not yet supported for ascii get or put, or local file copies.
* on-the-fly scaling of the throttle based on signals:
- SIGUSR1 raises the throttle rate by the increment for that direction
- SIGUSR2 lowers the throttle rate by the increment for that direction
* -T dir,max[,incr] option to set rate from the command line
* `k', `m', `g' suffix support for bytecounts in the `hash', `rate',
`rcvbuf' and `sndbuf' commands)
bug fixes and code mods:
------------------------
* fix up ftp_login() so that ruserpass() is always called, even for
command-line url fetches.
* implement strsuftoi(), which parses a given number into a int with
suffix support. replaces getsockbufsize()
* implement parserate(), which does the argv parsing for -T and rate
* save and restore errno in signal handlers (may not be necessary, but
it doesn't hurt)
notes:
------
the rate command has had reasonable testing, but I'd like feedback
if it doesn't do the right thing, especially from people on slower
(i.e, modem) links.
I haven't tested the rate throttle against a http server which does
`transfer-encoding: chunked' because I couldn't find a server to
test against.
1999-06-29 14:43:16 +04:00
|
|
|
argv[0]);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
dir = max = incr = showonly = 0;
|
1999-10-24 16:31:36 +04:00
|
|
|
#define RATE_GET 1
|
|
|
|
#define RATE_PUT 2
|
|
|
|
#define RATE_ALL (RATE_GET | RATE_PUT)
|
[fear this; more ftp hacking from lukem :-]
features:
---------
* transfer rate throttling with the new `rate' command. syntax:
rate direction [max [incr]]
where direction is `all', `get' or `put'.
if max is not supplied, the current settings are displayed.
if max is supplied, then transfers in the given direction will
be throttled to this value.
if incr is supplied, the increment for the `on-the-fly' scaling
will be set to that, otherwise `1024' is used.
currently implemented for binary get, binary put, and url fetches.
not yet supported for ascii get or put, or local file copies.
* on-the-fly scaling of the throttle based on signals:
- SIGUSR1 raises the throttle rate by the increment for that direction
- SIGUSR2 lowers the throttle rate by the increment for that direction
* -T dir,max[,incr] option to set rate from the command line
* `k', `m', `g' suffix support for bytecounts in the `hash', `rate',
`rcvbuf' and `sndbuf' commands)
bug fixes and code mods:
------------------------
* fix up ftp_login() so that ruserpass() is always called, even for
command-line url fetches.
* implement strsuftoi(), which parses a given number into a int with
suffix support. replaces getsockbufsize()
* implement parserate(), which does the argv parsing for -T and rate
* save and restore errno in signal handlers (may not be necessary, but
it doesn't hurt)
notes:
------
the rate command has had reasonable testing, but I'd like feedback
if it doesn't do the right thing, especially from people on slower
(i.e, modem) links.
I haven't tested the rate throttle against a http server which does
`transfer-encoding: chunked' because I couldn't find a server to
test against.
1999-06-29 14:43:16 +04:00
|
|
|
|
|
|
|
if (strcasecmp(argv[1], "all") == 0)
|
|
|
|
dir = RATE_ALL;
|
|
|
|
else if (strcasecmp(argv[1], "get") == 0)
|
|
|
|
dir = RATE_GET;
|
|
|
|
else if (strcasecmp(argv[1], "put") == 0)
|
|
|
|
dir = RATE_PUT;
|
|
|
|
else
|
|
|
|
goto usage;
|
|
|
|
|
|
|
|
if (argc >= 3) {
|
|
|
|
if ((max = strsuftoi(argv[2])) < 0)
|
|
|
|
goto usage;
|
|
|
|
} else
|
|
|
|
showonly = 1;
|
|
|
|
|
|
|
|
if (argc == 4) {
|
|
|
|
if ((incr = strsuftoi(argv[3])) <= 0)
|
|
|
|
goto usage;
|
|
|
|
} else
|
|
|
|
incr = DEFAULTINCR;
|
|
|
|
|
1999-09-28 03:09:42 +04:00
|
|
|
oldusr1 = xsignal(SIGUSR1, SIG_IGN);
|
|
|
|
oldusr2 = xsignal(SIGUSR2, SIG_IGN);
|
[fear this; more ftp hacking from lukem :-]
features:
---------
* transfer rate throttling with the new `rate' command. syntax:
rate direction [max [incr]]
where direction is `all', `get' or `put'.
if max is not supplied, the current settings are displayed.
if max is supplied, then transfers in the given direction will
be throttled to this value.
if incr is supplied, the increment for the `on-the-fly' scaling
will be set to that, otherwise `1024' is used.
currently implemented for binary get, binary put, and url fetches.
not yet supported for ascii get or put, or local file copies.
* on-the-fly scaling of the throttle based on signals:
- SIGUSR1 raises the throttle rate by the increment for that direction
- SIGUSR2 lowers the throttle rate by the increment for that direction
* -T dir,max[,incr] option to set rate from the command line
* `k', `m', `g' suffix support for bytecounts in the `hash', `rate',
`rcvbuf' and `sndbuf' commands)
bug fixes and code mods:
------------------------
* fix up ftp_login() so that ruserpass() is always called, even for
command-line url fetches.
* implement strsuftoi(), which parses a given number into a int with
suffix support. replaces getsockbufsize()
* implement parserate(), which does the argv parsing for -T and rate
* save and restore errno in signal handlers (may not be necessary, but
it doesn't hurt)
notes:
------
the rate command has had reasonable testing, but I'd like feedback
if it doesn't do the right thing, especially from people on slower
(i.e, modem) links.
I haven't tested the rate throttle against a http server which does
`transfer-encoding: chunked' because I couldn't find a server to
test against.
1999-06-29 14:43:16 +04:00
|
|
|
if (dir & RATE_GET) {
|
|
|
|
if (!showonly) {
|
|
|
|
rate_get = max;
|
|
|
|
rate_get_incr = incr;
|
|
|
|
}
|
|
|
|
if (!cmdlineopt || verbose)
|
|
|
|
fprintf(ttyout,
|
1999-06-29 16:41:22 +04:00
|
|
|
"Get transfer rate throttle: %s; maximum: %d; increment %d.\n",
|
[fear this; more ftp hacking from lukem :-]
features:
---------
* transfer rate throttling with the new `rate' command. syntax:
rate direction [max [incr]]
where direction is `all', `get' or `put'.
if max is not supplied, the current settings are displayed.
if max is supplied, then transfers in the given direction will
be throttled to this value.
if incr is supplied, the increment for the `on-the-fly' scaling
will be set to that, otherwise `1024' is used.
currently implemented for binary get, binary put, and url fetches.
not yet supported for ascii get or put, or local file copies.
* on-the-fly scaling of the throttle based on signals:
- SIGUSR1 raises the throttle rate by the increment for that direction
- SIGUSR2 lowers the throttle rate by the increment for that direction
* -T dir,max[,incr] option to set rate from the command line
* `k', `m', `g' suffix support for bytecounts in the `hash', `rate',
`rcvbuf' and `sndbuf' commands)
bug fixes and code mods:
------------------------
* fix up ftp_login() so that ruserpass() is always called, even for
command-line url fetches.
* implement strsuftoi(), which parses a given number into a int with
suffix support. replaces getsockbufsize()
* implement parserate(), which does the argv parsing for -T and rate
* save and restore errno in signal handlers (may not be necessary, but
it doesn't hurt)
notes:
------
the rate command has had reasonable testing, but I'd like feedback
if it doesn't do the right thing, especially from people on slower
(i.e, modem) links.
I haven't tested the rate throttle against a http server which does
`transfer-encoding: chunked' because I couldn't find a server to
test against.
1999-06-29 14:43:16 +04:00
|
|
|
onoff(rate_get), rate_get, rate_get_incr);
|
|
|
|
}
|
|
|
|
if (dir & RATE_PUT) {
|
|
|
|
if (!showonly) {
|
|
|
|
rate_put = max;
|
|
|
|
rate_put_incr = incr;
|
|
|
|
}
|
|
|
|
if (!cmdlineopt || verbose)
|
|
|
|
fprintf(ttyout,
|
1999-06-29 16:41:22 +04:00
|
|
|
"Put transfer rate throttle: %s; maximum: %d; increment %d.\n",
|
[fear this; more ftp hacking from lukem :-]
features:
---------
* transfer rate throttling with the new `rate' command. syntax:
rate direction [max [incr]]
where direction is `all', `get' or `put'.
if max is not supplied, the current settings are displayed.
if max is supplied, then transfers in the given direction will
be throttled to this value.
if incr is supplied, the increment for the `on-the-fly' scaling
will be set to that, otherwise `1024' is used.
currently implemented for binary get, binary put, and url fetches.
not yet supported for ascii get or put, or local file copies.
* on-the-fly scaling of the throttle based on signals:
- SIGUSR1 raises the throttle rate by the increment for that direction
- SIGUSR2 lowers the throttle rate by the increment for that direction
* -T dir,max[,incr] option to set rate from the command line
* `k', `m', `g' suffix support for bytecounts in the `hash', `rate',
`rcvbuf' and `sndbuf' commands)
bug fixes and code mods:
------------------------
* fix up ftp_login() so that ruserpass() is always called, even for
command-line url fetches.
* implement strsuftoi(), which parses a given number into a int with
suffix support. replaces getsockbufsize()
* implement parserate(), which does the argv parsing for -T and rate
* save and restore errno in signal handlers (may not be necessary, but
it doesn't hurt)
notes:
------
the rate command has had reasonable testing, but I'd like feedback
if it doesn't do the right thing, especially from people on slower
(i.e, modem) links.
I haven't tested the rate throttle against a http server which does
`transfer-encoding: chunked' because I couldn't find a server to
test against.
1999-06-29 14:43:16 +04:00
|
|
|
onoff(rate_put), rate_put, rate_put_incr);
|
|
|
|
}
|
1999-09-28 03:09:42 +04:00
|
|
|
(void)xsignal(SIGUSR1, oldusr1);
|
|
|
|
(void)xsignal(SIGUSR2, oldusr2);
|
[fear this; more ftp hacking from lukem :-]
features:
---------
* transfer rate throttling with the new `rate' command. syntax:
rate direction [max [incr]]
where direction is `all', `get' or `put'.
if max is not supplied, the current settings are displayed.
if max is supplied, then transfers in the given direction will
be throttled to this value.
if incr is supplied, the increment for the `on-the-fly' scaling
will be set to that, otherwise `1024' is used.
currently implemented for binary get, binary put, and url fetches.
not yet supported for ascii get or put, or local file copies.
* on-the-fly scaling of the throttle based on signals:
- SIGUSR1 raises the throttle rate by the increment for that direction
- SIGUSR2 lowers the throttle rate by the increment for that direction
* -T dir,max[,incr] option to set rate from the command line
* `k', `m', `g' suffix support for bytecounts in the `hash', `rate',
`rcvbuf' and `sndbuf' commands)
bug fixes and code mods:
------------------------
* fix up ftp_login() so that ruserpass() is always called, even for
command-line url fetches.
* implement strsuftoi(), which parses a given number into a int with
suffix support. replaces getsockbufsize()
* implement parserate(), which does the argv parsing for -T and rate
* save and restore errno in signal handlers (may not be necessary, but
it doesn't hurt)
notes:
------
the rate command has had reasonable testing, but I'd like feedback
if it doesn't do the right thing, especially from people on slower
(i.e, modem) links.
I haven't tested the rate throttle against a http server which does
`transfer-encoding: chunked' because I couldn't find a server to
test against.
1999-06-29 14:43:16 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
setrate(int argc, char *argv[])
|
[fear this; more ftp hacking from lukem :-]
features:
---------
* transfer rate throttling with the new `rate' command. syntax:
rate direction [max [incr]]
where direction is `all', `get' or `put'.
if max is not supplied, the current settings are displayed.
if max is supplied, then transfers in the given direction will
be throttled to this value.
if incr is supplied, the increment for the `on-the-fly' scaling
will be set to that, otherwise `1024' is used.
currently implemented for binary get, binary put, and url fetches.
not yet supported for ascii get or put, or local file copies.
* on-the-fly scaling of the throttle based on signals:
- SIGUSR1 raises the throttle rate by the increment for that direction
- SIGUSR2 lowers the throttle rate by the increment for that direction
* -T dir,max[,incr] option to set rate from the command line
* `k', `m', `g' suffix support for bytecounts in the `hash', `rate',
`rcvbuf' and `sndbuf' commands)
bug fixes and code mods:
------------------------
* fix up ftp_login() so that ruserpass() is always called, even for
command-line url fetches.
* implement strsuftoi(), which parses a given number into a int with
suffix support. replaces getsockbufsize()
* implement parserate(), which does the argv parsing for -T and rate
* save and restore errno in signal handlers (may not be necessary, but
it doesn't hurt)
notes:
------
the rate command has had reasonable testing, but I'd like feedback
if it doesn't do the right thing, especially from people on slower
(i.e, modem) links.
I haven't tested the rate throttle against a http server which does
`transfer-encoding: chunked' because I couldn't find a server to
test against.
1999-06-29 14:43:16 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
code = parserate(argc, argv, 0);
|
|
|
|
}
|
|
|
|
|
1997-01-19 17:19:02 +03:00
|
|
|
/* change directory to parent directory */
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
cdup(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1997-01-19 17:19:02 +03:00
|
|
|
int r;
|
1994-08-25 07:47:50 +04:00
|
|
|
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
if (argc == 0) {
|
1999-10-24 16:31:36 +04:00
|
|
|
fprintf(ttyout, "usage: %s\n", argv[0]);
|
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
1997-01-19 17:19:02 +03:00
|
|
|
r = command("CDUP");
|
|
|
|
if (r == ERROR && code == 500) {
|
1993-03-21 12:45:37 +03:00
|
|
|
if (verbose)
|
1998-06-04 12:28:35 +04:00
|
|
|
fputs("CDUP command not recognized, trying XCUP.\n",
|
|
|
|
ttyout);
|
1997-01-19 17:19:02 +03:00
|
|
|
r = command("XCUP");
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1999-11-11 05:53:02 +03:00
|
|
|
if (r == COMPLETE) {
|
1997-01-19 17:19:02 +03:00
|
|
|
dirchange = 1;
|
1999-11-11 05:53:02 +03:00
|
|
|
updateremotepwd();
|
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1997-08-18 14:20:13 +04:00
|
|
|
/*
|
|
|
|
* Restart transfer at specific point
|
|
|
|
*/
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
restart(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1994-08-25 07:47:50 +04:00
|
|
|
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
if (argc == 0 || argc > 2) {
|
|
|
|
fprintf(ttyout, "usage: %s [restart-point]\n", argv[0]);
|
1997-11-01 17:36:49 +03:00
|
|
|
code = -1;
|
|
|
|
return;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
if (! features[FEAT_REST_STREAM]) {
|
|
|
|
fprintf(ttyout,
|
|
|
|
"Restart is not supported by the remote server.\n");
|
|
|
|
return;
|
|
|
|
}
|
1997-11-01 17:36:49 +03:00
|
|
|
if (argc == 2) {
|
1999-09-24 16:52:18 +04:00
|
|
|
off_t rp;
|
1997-11-01 17:36:49 +03:00
|
|
|
char *ep;
|
|
|
|
|
2000-07-30 08:42:37 +04:00
|
|
|
rp = STRTOLL(argv[1], &ep, 10);
|
1997-11-01 17:36:49 +03:00
|
|
|
if (rp < 0 || *ep != '\0')
|
1998-06-04 12:28:35 +04:00
|
|
|
fprintf(ttyout, "restart: Invalid offset `%s'\n",
|
|
|
|
argv[1]);
|
1997-11-01 17:36:49 +03:00
|
|
|
else
|
|
|
|
restart_point = rp;
|
|
|
|
}
|
|
|
|
if (restart_point == 0)
|
1998-06-04 12:28:35 +04:00
|
|
|
fputs("No restart point defined.\n", ttyout);
|
1997-11-01 17:36:49 +03:00
|
|
|
else
|
1998-06-04 12:28:35 +04:00
|
|
|
fprintf(ttyout,
|
2000-08-02 02:47:25 +04:00
|
|
|
"Restarting at " LLF " for next get, put or append\n",
|
|
|
|
(LLT)restart_point);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1999-03-08 06:09:08 +03:00
|
|
|
/*
|
1997-08-18 14:20:13 +04:00
|
|
|
* Show remote system type
|
|
|
|
*/
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
syst(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
int oldverbose = verbose;
|
1994-08-25 07:47:50 +04:00
|
|
|
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
if (argc == 0) {
|
1999-10-24 16:31:36 +04:00
|
|
|
fprintf(ttyout, "usage: %s\n", argv[0]);
|
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
verbose = 1; /* If we aren't verbose, this doesn't do anything! */
|
1997-03-13 09:23:11 +03:00
|
|
|
(void)command("SYST");
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
verbose = oldverbose;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
macdef(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
char *tmp;
|
|
|
|
int c;
|
|
|
|
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
if (argc == 0)
|
1999-10-24 16:31:36 +04:00
|
|
|
goto usage;
|
1993-03-21 12:45:37 +03:00
|
|
|
if (macnum == 16) {
|
1998-06-04 12:28:35 +04:00
|
|
|
fputs("Limit of 16 macros have already been defined.\n",
|
|
|
|
ttyout);
|
1993-03-21 12:45:37 +03:00
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
1996-11-28 06:12:28 +03:00
|
|
|
if ((argc < 2 && !another(&argc, &argv, "macro name")) || argc > 2) {
|
1999-10-24 16:31:36 +04:00
|
|
|
usage:
|
1998-06-04 12:28:35 +04:00
|
|
|
fprintf(ttyout, "usage: %s macro_name\n", argv[0]);
|
1993-03-21 12:45:37 +03:00
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
1997-03-13 09:23:11 +03:00
|
|
|
if (interactive)
|
1998-06-04 12:28:35 +04:00
|
|
|
fputs(
|
|
|
|
"Enter macro line by line, terminating it with a null line.\n",
|
|
|
|
ttyout);
|
1999-09-28 10:47:38 +04:00
|
|
|
(void)strlcpy(macros[macnum].mac_name, argv[1],
|
|
|
|
sizeof(macros[macnum].mac_name));
|
1997-03-13 09:23:11 +03:00
|
|
|
if (macnum == 0)
|
1993-03-21 12:45:37 +03:00
|
|
|
macros[macnum].mac_start = macbuf;
|
1997-03-13 09:23:11 +03:00
|
|
|
else
|
1993-03-21 12:45:37 +03:00
|
|
|
macros[macnum].mac_start = macros[macnum - 1].mac_end + 1;
|
|
|
|
tmp = macros[macnum].mac_start;
|
|
|
|
while (tmp != macbuf+4096) {
|
|
|
|
if ((c = getchar()) == EOF) {
|
1998-06-04 12:28:35 +04:00
|
|
|
fputs("macdef: end of file encountered.\n", ttyout);
|
1993-03-21 12:45:37 +03:00
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ((*tmp = c) == '\n') {
|
|
|
|
if (tmp == macros[macnum].mac_start) {
|
|
|
|
macros[macnum++].mac_end = tmp;
|
|
|
|
code = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (*(tmp-1) == '\0') {
|
|
|
|
macros[macnum++].mac_end = tmp - 1;
|
|
|
|
code = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
*tmp = '\0';
|
|
|
|
}
|
|
|
|
tmp++;
|
|
|
|
}
|
|
|
|
while (1) {
|
|
|
|
while ((c = getchar()) != '\n' && c != EOF)
|
|
|
|
/* LOOP */;
|
|
|
|
if (c == EOF || getchar() == '\n') {
|
1998-06-04 12:28:35 +04:00
|
|
|
fputs("Macro not defined - 4K buffer exceeded.\n",
|
|
|
|
ttyout);
|
1993-03-21 12:45:37 +03:00
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1997-08-18 14:20:13 +04:00
|
|
|
* Get size of file on remote machine
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
sizecmd(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1996-12-06 05:06:46 +03:00
|
|
|
off_t size;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
if (argc == 0 || argc > 2 ||
|
|
|
|
(argc == 1 && !another(&argc, &argv, "remote-file"))) {
|
1999-10-24 16:31:36 +04:00
|
|
|
fprintf(ttyout, "usage: %s remote-file\n", argv[0]);
|
1993-03-21 12:45:37 +03:00
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
1996-12-29 07:05:29 +03:00
|
|
|
size = remotesize(argv[1], 1);
|
1996-12-06 05:06:46 +03:00
|
|
|
if (size != -1)
|
1998-06-04 12:28:35 +04:00
|
|
|
fprintf(ttyout,
|
2000-08-02 02:47:25 +04:00
|
|
|
"%s\t" LLF "\n", argv[1], (LLT)size);
|
1999-10-24 16:31:36 +04:00
|
|
|
code = (size > 0);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1996-11-28 06:12:28 +03:00
|
|
|
/*
|
1997-08-18 14:20:13 +04:00
|
|
|
* Get last modification time of file on remote machine
|
1996-11-28 06:12:28 +03:00
|
|
|
*/
|
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
modtime(int argc, char *argv[])
|
1996-11-28 06:12:28 +03:00
|
|
|
{
|
|
|
|
time_t mtime;
|
|
|
|
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
if (argc == 0 || argc > 2 ||
|
|
|
|
(argc == 1 && !another(&argc, &argv, "remote-file"))) {
|
1999-10-24 16:31:36 +04:00
|
|
|
fprintf(ttyout, "usage: %s remote-file\n", argv[0]);
|
1996-11-28 06:12:28 +03:00
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
1996-12-29 07:05:29 +03:00
|
|
|
mtime = remotemodtime(argv[1], 1);
|
1996-11-28 06:12:28 +03:00
|
|
|
if (mtime != -1)
|
1998-06-04 12:28:35 +04:00
|
|
|
fprintf(ttyout, "%s\t%s", argv[1], asctime(localtime(&mtime)));
|
1999-10-24 16:31:36 +04:00
|
|
|
code = (mtime > 0);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1997-08-18 14:20:13 +04:00
|
|
|
* Show status on remote machine
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
rmtstatus(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1994-08-25 07:47:50 +04:00
|
|
|
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
if (argc == 0) {
|
1999-10-24 16:31:36 +04:00
|
|
|
fprintf(ttyout, "usage: %s [remote-file]\n", argv[0]);
|
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
2000-10-11 18:46:00 +04:00
|
|
|
COMMAND_1ARG(argc, argv, "STAT");
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1997-08-18 14:20:13 +04:00
|
|
|
* Get file if modtime is more recent than current file
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
1994-08-25 07:47:50 +04:00
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
newer(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1994-08-25 07:47:50 +04:00
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
if (getit(argc, argv, -1, "w"))
|
1998-06-04 12:28:35 +04:00
|
|
|
fprintf(ttyout,
|
|
|
|
"Local file \"%s\" is newer than remote file \"%s\".\n",
|
|
|
|
argv[2], argv[1]);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1997-03-13 09:23:11 +03:00
|
|
|
|
|
|
|
/*
|
1999-10-24 16:31:36 +04:00
|
|
|
* Display one local file through $PAGER.
|
1997-03-13 09:23:11 +03:00
|
|
|
*/
|
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
lpage(int argc, char *argv[])
|
1997-03-13 09:23:11 +03:00
|
|
|
{
|
1999-09-28 10:47:38 +04:00
|
|
|
int len;
|
|
|
|
char *p, *pager, *locfile;
|
1997-03-13 09:23:11 +03:00
|
|
|
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
if (argc == 0 || argc > 2 ||
|
|
|
|
(argc == 1 && !another(&argc, &argv, "local-file"))) {
|
1999-10-24 16:31:36 +04:00
|
|
|
fprintf(ttyout, "usage: %s local-file\n", argv[0]);
|
1997-03-13 09:23:11 +03:00
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
1999-09-28 10:47:38 +04:00
|
|
|
if ((locfile = globulize(argv[1])) == NULL) {
|
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
1999-10-24 16:31:36 +04:00
|
|
|
p = getoptionvalue("pager");
|
|
|
|
if (EMPTYSTRING(p))
|
|
|
|
p = DEFAULTPAGER;
|
1999-09-28 10:47:38 +04:00
|
|
|
len = strlen(p) + strlen(locfile) + 2;
|
|
|
|
pager = xmalloc(len);
|
|
|
|
(void)strlcpy(pager, p, len);
|
|
|
|
(void)strlcat(pager, " ", len);
|
|
|
|
(void)strlcat(pager, locfile, len);
|
|
|
|
system(pager);
|
1999-10-24 16:31:36 +04:00
|
|
|
code = 0;
|
1999-09-28 10:47:38 +04:00
|
|
|
(void)free(pager);
|
|
|
|
(void)free(locfile);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1999-10-24 16:31:36 +04:00
|
|
|
* Display one remote file through $PAGER.
|
1999-09-28 10:47:38 +04:00
|
|
|
*/
|
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
page(int argc, char *argv[])
|
1999-09-28 10:47:38 +04:00
|
|
|
{
|
|
|
|
int ohash, orestart_point, overbose, len;
|
|
|
|
char *p, *pager;
|
|
|
|
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
if (argc == 0 || argc > 2 ||
|
|
|
|
(argc == 1 && !another(&argc, &argv, "remote-file"))) {
|
1999-10-24 16:31:36 +04:00
|
|
|
fprintf(ttyout, "usage: %s remote-file\n", argv[0]);
|
1997-03-13 09:23:11 +03:00
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
1999-10-24 16:31:36 +04:00
|
|
|
p = getoptionvalue("pager");
|
|
|
|
if (EMPTYSTRING(p))
|
|
|
|
p = DEFAULTPAGER;
|
1999-06-02 06:03:57 +04:00
|
|
|
len = strlen(p) + 2;
|
|
|
|
pager = xmalloc(len);
|
1999-09-22 07:01:53 +04:00
|
|
|
pager[0] = '|';
|
1999-09-28 10:47:38 +04:00
|
|
|
(void)strlcpy(pager + 1, p, len - 1);
|
1997-03-13 09:23:11 +03:00
|
|
|
|
|
|
|
ohash = hash;
|
1998-06-04 12:28:35 +04:00
|
|
|
orestart_point = restart_point;
|
1997-03-13 09:23:11 +03:00
|
|
|
overbose = verbose;
|
1998-06-04 12:28:35 +04:00
|
|
|
hash = restart_point = verbose = 0;
|
2002-05-07 06:04:09 +04:00
|
|
|
recvrequest("RETR", pager, argv[1], "r+", 1, 0);
|
1997-03-13 09:23:11 +03:00
|
|
|
hash = ohash;
|
1998-06-04 12:28:35 +04:00
|
|
|
restart_point = orestart_point;
|
1997-03-13 09:23:11 +03:00
|
|
|
verbose = overbose;
|
1999-09-28 10:47:38 +04:00
|
|
|
(void)free(pager);
|
1997-03-13 09:23:11 +03:00
|
|
|
}
|
1998-07-10 08:39:03 +04:00
|
|
|
|
|
|
|
/*
|
1999-09-22 11:18:31 +04:00
|
|
|
* Set the socket send or receive buffer size.
|
1998-07-10 08:39:03 +04:00
|
|
|
*/
|
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
setxferbuf(int argc, char *argv[])
|
1998-07-10 08:39:03 +04:00
|
|
|
{
|
1999-09-22 11:18:31 +04:00
|
|
|
int size, dir;
|
1998-07-10 08:39:03 +04:00
|
|
|
|
|
|
|
if (argc != 2) {
|
1999-09-22 11:18:31 +04:00
|
|
|
usage:
|
|
|
|
fprintf(ttyout, "usage: %s size\n", argv[0]);
|
1998-07-10 08:39:03 +04:00
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
1999-09-22 11:18:31 +04:00
|
|
|
if (strcasecmp(argv[0], "sndbuf") == 0)
|
|
|
|
dir = RATE_PUT;
|
|
|
|
else if (strcasecmp(argv[0], "rcvbuf") == 0)
|
|
|
|
dir = RATE_GET;
|
|
|
|
else if (strcasecmp(argv[0], "xferbuf") == 0)
|
|
|
|
dir = RATE_ALL;
|
1998-07-10 08:39:03 +04:00
|
|
|
else
|
1999-09-22 11:18:31 +04:00
|
|
|
goto usage;
|
1998-07-10 08:39:03 +04:00
|
|
|
|
1999-09-22 11:18:31 +04:00
|
|
|
if ((size = strsuftoi(argv[1])) == -1)
|
|
|
|
goto usage;
|
1998-07-10 08:39:03 +04:00
|
|
|
|
1999-09-22 11:18:31 +04:00
|
|
|
if (size == 0) {
|
|
|
|
fprintf(ttyout, "%s: size must be positive.\n", argv[0]);
|
|
|
|
goto usage;
|
1998-07-10 08:39:03 +04:00
|
|
|
}
|
|
|
|
|
1999-09-22 11:18:31 +04:00
|
|
|
if (dir & RATE_PUT)
|
|
|
|
sndbuf_size = size;
|
|
|
|
if (dir & RATE_GET)
|
|
|
|
rcvbuf_size = size;
|
|
|
|
fprintf(ttyout, "Socket buffer sizes: send %d, receive %d.\n",
|
|
|
|
sndbuf_size, rcvbuf_size);
|
1999-10-24 16:31:36 +04:00
|
|
|
code = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set or display options (defaults are provided by various env vars)
|
|
|
|
*/
|
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
setoption(int argc, char *argv[])
|
1999-10-24 16:31:36 +04:00
|
|
|
{
|
|
|
|
struct option *o;
|
|
|
|
|
|
|
|
code = -1;
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
if (argc == 0 || (argc != 1 && argc != 3)) {
|
1999-10-24 16:31:36 +04:00
|
|
|
fprintf(ttyout, "usage: %s [option value]\n", argv[0]);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define OPTIONINDENT ((int) sizeof("http_proxy"))
|
|
|
|
if (argc == 1) {
|
|
|
|
for (o = optiontab; o->name != NULL; o++) {
|
|
|
|
fprintf(ttyout, "%-*s\t%s\n", OPTIONINDENT,
|
|
|
|
o->name, o->value ? o->value : "");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
o = getoption(argv[1]);
|
|
|
|
if (o == NULL) {
|
|
|
|
fprintf(ttyout, "No such option `%s'.\n", argv[1]);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
FREEPTR(o->value);
|
|
|
|
o->value = xstrdup(argv[2]);
|
|
|
|
if (verbose)
|
|
|
|
fprintf(ttyout, "Setting `%s' to `%s'.\n",
|
|
|
|
o->name, o->value);
|
|
|
|
}
|
|
|
|
code = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Unset an option
|
|
|
|
*/
|
|
|
|
void
|
2000-05-01 14:35:16 +04:00
|
|
|
unsetoption(int argc, char *argv[])
|
1999-10-24 16:31:36 +04:00
|
|
|
{
|
|
|
|
struct option *o;
|
|
|
|
|
|
|
|
code = -1;
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
if (argc == 0 || argc != 2) {
|
1999-10-24 16:31:36 +04:00
|
|
|
fprintf(ttyout, "usage: %s option\n", argv[0]);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
o = getoption(argv[1]);
|
|
|
|
if (o == NULL) {
|
|
|
|
fprintf(ttyout, "No such option `%s'.\n", argv[1]);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
FREEPTR(o->value);
|
|
|
|
fprintf(ttyout, "Unsetting `%s'.\n", o->name);
|
|
|
|
code = 0;
|
1998-07-10 08:39:03 +04:00
|
|
|
}
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Display features supported by the remote host.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
feat(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
int oldverbose = verbose;
|
|
|
|
|
|
|
|
if (argc == 0) {
|
|
|
|
fprintf(ttyout, "usage: %s\n", argv[0]);
|
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (! features[FEAT_FEAT]) {
|
|
|
|
fprintf(ttyout,
|
|
|
|
"FEAT is not supported by the remote server.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
verbose = 1; /* If we aren't verbose, this doesn't do anything! */
|
|
|
|
(void)command("FEAT");
|
|
|
|
verbose = oldverbose;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
mlst(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
int oldverbose = verbose;
|
|
|
|
|
|
|
|
if (argc < 1 || argc > 2) {
|
|
|
|
fprintf(ttyout, "usage: %s [remote-path]\n", argv[0]);
|
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (! features[FEAT_MLST]) {
|
|
|
|
fprintf(ttyout,
|
|
|
|
"MLST is not supported by the remote server.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
verbose = 1; /* If we aren't verbose, this doesn't do anything! */
|
2000-10-11 18:46:00 +04:00
|
|
|
COMMAND_1ARG(argc, argv, "MLST");
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
verbose = oldverbose;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
opts(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
int oldverbose = verbose;
|
|
|
|
|
|
|
|
if (argc < 2 || argc > 3) {
|
|
|
|
fprintf(ttyout, "usage: %s command [options]\n", argv[0]);
|
|
|
|
code = -1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (! features[FEAT_FEAT]) {
|
|
|
|
fprintf(ttyout,
|
|
|
|
"OPTS is not supported by the remote server.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
verbose = 1; /* If we aren't verbose, this doesn't do anything! */
|
2000-10-11 18:46:00 +04:00
|
|
|
if (argc == 2)
|
|
|
|
command("OPTS %s", argv[1]);
|
|
|
|
else
|
|
|
|
command("OPTS %s %s", argv[1], argv[2]);
|
add support for FEAT and OPTS commands with `features' and `opts'.
(from RFC 2389).
add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd'
and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11)
rename remotesyst() to getremoteinfo(), and modify to parse the result from
FEAT (if supported), and take into account the support for the various
extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS.
put each feature into one of the following categories:
- known to work (explicit FEAT)
- unknown but assume works until explicit failure, when it's
then tagged as `known not to work'.
- known not to work (FEAT succeeded but didn't return anything,
or was unknown and then explicit failure)
assign results into features[] matrix.
add support to getreply() so that an optional callback will be called
for each line received from the server except for the first and last.
this is used in FEAT (and MLST) parsing.
modify various commands to check if REST (STREAM), MDTM and SIZE are
explicitly or implicitly supported before using.
fix `syst' when verbose is off.
minor knf (indent goto labels by one space, etc).
simply various command usage handlers by assuming that argv != NULL except
for quit() and disconnect().
2000-07-18 11:16:52 +04:00
|
|
|
verbose = oldverbose;
|
|
|
|
}
|