Upgrade...

This commit is contained in:
Andrey A. Chernov 1994-12-13 20:43:57 +00:00
parent 39ac25d619
commit 5d9b1b20cb
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/vendor/ncftp/dist/; revision=5093
svn path=/vendor/ncftp/1.8.7/; revision=5095; tag=vendor/ncftp/1.8.7
11 changed files with 80 additions and 39 deletions

View File

@ -1,8 +1,8 @@
/* cmds.c */
/* $RCSfile: cmds.c,v $
* $Revision: 14020.14 $
* $Date: 93/07/09 11:31:53 $
* $Revision: 1.1.1.1 $
* $Date: 1994/09/22 23:45:33 $
*/
#include "sys.h"
@ -37,7 +37,7 @@
/* cmds.c globals */
#ifdef PASSIVEMODE
int passivemode = 1;
int passivemode; /* no reverse FTP connections */
#endif
int curtype; /* file transfer type */
char *typeabbrs = "abiet";
@ -594,6 +594,7 @@ int mget(int argc, char **argv)
char *cp;
longstring local;
Sig_t oldintr;
int errs;
if (argc < 2)
argv = re_makeargv("(remote-files) ", &argc);
@ -604,7 +605,7 @@ int mget(int argc, char **argv)
activemcmd = 1;
oldintr = Signal(SIGINT, mabort);
(void) setjmp(jabort);
while ((cp = remglob(argv)) != NULL) {
while ((cp = remglob(argv, &errs)) != NULL) {
if (*cp == '\0') {
activemcmd = 0;
continue;
@ -621,19 +622,22 @@ int mget(int argc, char **argv)
}
(void) Signal(SIGINT,oldintr);
activemcmd = 0;
if (!errs)
return NOERR;
else
return CMDERR;
} /* mget */
char *remglob(char *argv[])
char *remglob(char *argv[], int *errs)
{
static FILE *ftemp = NULL;
int oldverbose, i;
char *cp, *mode;
static string tmpname, str;
int result, errs;
int result;
if (!activemcmd) {
xx:
@ -647,7 +651,7 @@ xx:
if (ftemp == NULL) {
(void) tmp_name(tmpname);
oldverbose = verbose, verbose = V_QUIET;
errs = 0;
*errs = 0;
for (mode = "w", i=1; argv[i] != NULL; i++, mode = "a") {
result = recvrequest ("NLST", tmpname, argv[i], mode);
if (i == 1)
@ -658,11 +662,11 @@ xx:
(strpbrk(argv[i], globchars) != NULL) ? "No match" :
"No such file"
);
errs++;
++(*errs);
}
}
verbose = oldverbose;
if (errs == (i - 1)) {
if (*errs == (i - 1)) {
/* Every pattern was in error, so we can't try anything. */
(void) unlink(tmpname); /* Shouldn't be there anyway. */
return NULL;
@ -876,6 +880,7 @@ int mdelete(int argc, char **argv)
char *cp;
Sig_t oldintr;
string str;
int errs;
if (argc < 2)
argv = re_makeargv("(remote-files) ", &argc);
@ -886,7 +891,7 @@ int mdelete(int argc, char **argv)
activemcmd = 1;
oldintr = Signal(SIGINT, mabort);
(void) setjmp(jabort);
while ((cp = remglob(argv)) != NULL) {
while ((cp = remglob(argv, &errs)) != NULL) {
if (*cp == '\0') {
activemcmd = 0;
continue;
@ -903,6 +908,8 @@ int mdelete(int argc, char **argv)
}
(void) Signal(SIGINT, oldintr);
activemcmd = 0;
if (errs > 0)
return CMDERR;
return NOERR;
} /* mdelete */
@ -1282,9 +1289,12 @@ int rmthelp(int argc, char **argv)
/*ARGSUSED*/
int quit(int argc, char **argv)
{
close_up_shop();
int rc;
/* slightly kludge. argc == -1 means failure from some other caller */
rc = close_up_shop() || argc == -1;
trim_log();
exit(0);
exit(rc);
} /* quit */
@ -1331,19 +1341,22 @@ int disconnect(int argc, char **argv)
void
int
close_up_shop(void)
{
static int only_once = 0;
int rcode = 0;
if (only_once++ > 0)
return;
return (0);
if (connected)
(void) disconnect(0, NULL);
WriteRecentSitesFile();
rcode = WriteRecentSitesFile();
if (logf != NULL) {
(void) fclose(logf);
logf = NULL;
}
return rcode;
} /* close_up_shop */

View File

@ -77,7 +77,7 @@ int rem_glob_one(char *pattern);
int get(int argc, char **argv);
void mabort SIG_PARAMS;
int mget(int argc, char **argv);
char *remglob(char *argv[]);
char *remglob(char *argv[], int *);
int setverbose(int argc, char **argv);
int setprompt(int argc, char **argv);
int setdebug(int argc, char **argv);
@ -100,7 +100,7 @@ int rmthelp(int argc, char **argv);
int quit(int argc, char **argv);
void close_streams(int wantShutDown);
int disconnect(int argc, char **argv);
void close_up_shop(void);
int close_up_shop(void);
int globulize(char **cpp);
int cdup(int argc, char **argv);
int syst(int argc, char **argv);

View File

@ -44,6 +44,18 @@
#define dMPROMPT 0
#endif
#ifndef PASSIVEMODE
#define PASSIVEMODE 1
#endif
/* If passive FTP can be used, this specifies whether it is turned on
* by default. If not, we have passive mode available, but are using
* Port ftp by default.
*/
#ifndef dPASSIVE
#define dPASSIVE 1 /* Works for most folks... */
#endif
#ifndef dVERBOSE /* V_QUIET, V_ERRS, V_TERSE, V_VERBOSE */
#define dVERBOSE V_TERSE
#endif

View File

@ -258,11 +258,12 @@ static void SortRecentList(void)
void WriteRecentSitesFile(void)
int WriteRecentSitesFile(void)
{
FILE *rfp;
recentsite *r;
int i;
int retcode = 0;
if ((recent_file[0] != 0) && (nRecents > 0) && (keep_recent)) {
dbprintf("Attempting to write %s...\n", recent_file);
@ -279,8 +280,10 @@ void WriteRecentSitesFile(void)
(void) chmod(recent_file, 0600);
} else {
perror(recent_file);
++retcode;
}
}
return retcode;
} /* WriteRecentSitesFile */

View File

@ -30,7 +30,7 @@ void AddNewSitePtr(char *word);
int ruserpass2(char *host, char **user, char **pass, char **acct);
void GetFullSiteName(char *host, char *lastdir);
void ReadRecentSitesFile(void);
void WriteRecentSitesFile(void);
int WriteRecentSitesFile(void);
void AddRecentSite(char *host, char *lastdir);
void UpdateRecentSitesList(char *host, char *lastdir);
void PrintSiteList(void);

View File

@ -1,13 +1,8 @@
/* main.c
*
* $RCSfile: main.c,v $
* $Revision: 14020.15 $
* $Date: 93/07/09 11:50:12 $
*/
/* main.c */
#define _main_c_
#define FTP_VERSION "1.8.6 (Octboer 30, 1994)"
#define FTP_VERSION "1.8.7 (December 11, 1994)"
/* #define BETA 1 */ /* If defined, it prints a little warning message. */
@ -116,7 +111,7 @@ static char tcbuf[2048];
#endif
/* main.c externs */
extern int debug, verbose, mprompt;
extern int debug, verbose, mprompt, passivemode;
extern int options, cpend, data, connected, logged_in;
extern int curtype, macnum, remote_is_unix;
extern FILE *cout;
@ -175,6 +170,7 @@ Re-compile, this time with -DZCAT=\\\"/path/to/zcat\\\".\n");
mprompt = dMPROMPT;
debug = dDEBUG;
verbose = dVERBOSE;
passivemode = dPASSIVE;
(void) Strncpy(vstr, short_verbose_msgs[verbose+1]);
(void) Strncpy(curtypename, dTYPESTR);
@ -234,7 +230,7 @@ Re-compile, this time with -DZCAT=\\\"/path/to/zcat\\\".\n");
ignore_rc = 0;
(void) strcpy(oline, "open ");
while ((opt = Getopt(argc, argv, "D:V:INRHaicmup:rd:g:")) >= 0) {
while ((opt = Getopt(argc, argv, "D:V:INPRHaicmup:rd:g:")) >= 0) {
switch(opt) {
case 'a':
case 'c':
@ -270,6 +266,10 @@ Re-compile, this time with -DZCAT=\\\"/path/to/zcat\\\".\n");
++ignore_rc;
break;
case 'P':
passivemode = !passivemode;
break;
case 'H':
(void) show_version(0, NULL);
exit (0);
@ -282,6 +282,7 @@ Program Options:\n\
-H : Show version and compilation information.\n\
-I : Toggle interactive (mprompt) mode.\n\
-N : Toggle reading of the .netrc/.ncftprc.\n\
-P : Toggle passive mode ftp (for use behind firewalls).\n\
-V x : Set verbosity to level x (-1,0,1,2).\n\
Open Options:\n\
-a : Open anonymously (this is the default).\n\
@ -390,7 +391,8 @@ For testing purposes only. Do not re-distribute or subject to novice users."
(void) Signal(SIGPIPE, lostpeer);
}
for (;;) {
(void) cmdscanner(top);
if (cmdscanner(top))
exit(1);
top = 1;
}
} /* main */
@ -569,9 +571,10 @@ void lostpeer SIG_PARAMS
/*
* Command parser.
*/
void cmdscanner(int top)
int cmdscanner(int top)
{
register struct cmd *c;
int cmd_status, rcode = 0;
if (!top)
(void) putchar('\n');
@ -601,13 +604,17 @@ void cmdscanner(int top)
(void) printf ("Not connected.\n");
continue;
}
if ((*c->c_handler)(margc, margv) == USAGE)
cmd_status = (*c->c_handler)(margc, margv);
if (cmd_status == USAGE)
cmd_usage(c);
else if (cmd_status == CMDERR)
rcode = 1;
if (c->c_handler != help)
break;
}
(void) Signal(SIGINT, intr);
(void) Signal(SIGPIPE, lostpeer);
return rcode;
} /* cmdscanner */

View File

@ -22,7 +22,7 @@ int init_arrays(void);
void init_transfer_buffer(void);
void init_prompt(void);
void lostpeer SIG_PARAMS;
void cmdscanner(int top);
int cmdscanner(int top);
char *strprompt(void);
void makeargv(void);
char *slurpstring(void);

View File

@ -1257,6 +1257,9 @@ disables reading of the RC file;
this is provided for compatibility with
.RB `` "ftp \-n" ''.
.TP
.B \-P
toggle passive mode (defaults to on). Useful for work behind firewalls.
.TP
.BI \-V " x"
sets verbosity to level
.I x

View File

@ -399,6 +399,7 @@ void CheckRemoteSystemType(int force_binary)
void ColonMode(OpenOptions *openopt)
{
int tmpverbose;
int cmdstatus;
/* How do we tell if colonmodepath is a file or a directory?
* We first try cd'ing to the path first. If we can, then it
@ -437,15 +438,15 @@ void ColonMode(OpenOptions *openopt)
/* get() also handles 'more'. */
if (openopt->ftpcat)
(void) get(margc, margv);
cmdstatus = get(margc, margv);
else
(void) mget(margc, margv);
cmdstatus = mget(margc, margv);
/* If we were invoked from the command line, quit
* after we got this file.
*/
if (eventnumber == 0L) {
(void) quit(0, NULL);
(void) quit(cmdstatus == CMDERR ? -1 : 0, NULL);
}
}
verbose = tmpverbose;

View File

@ -1,3 +1,7 @@
v1.8.7 - December 11, 1994. Tweaks for FreeBSD. Passive mode enabled and
turned on by default. This should be the last version of ncftp before
version 2.
v1.8.6 - October 30, 1994. Tweaks for Solaris in sys.h.
v1.8.5 - September 20, 1994. Better(?) support for term.

View File

@ -398,12 +398,10 @@ extern int errno;
# endif
#endif /* BSDi */
#ifdef __386BSD__
# ifdef __FreeBSD__
#ifdef __FreeBSD__
# define System "FreeBSD"
# define GZCAT "/usr/bin/gzcat"
# define HAS_DOMAINNAME 1
# endif
# include <sys/types.h>
# include <sys/param.h> /* this two for BSD definition */
/* to avoid redefinition of it to 1 */
@ -415,7 +413,7 @@ extern int errno;
#endif
#ifdef BSD
# ifndef __386BSD__
# ifndef __FreeBSD__
# ifndef SYSDIRH
# define SYSDIRH 1
# endif