"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/cmds.c" between
tnftp-20151004.tar.gz and tnftp-20200705.tar.gz

About: tnftp is an enhanced ftp client (prior name "lukemftp").

cmds.c  (tnftp-20151004):cmds.c  (tnftp-20200705)
/* $NetBSD: cmds.c,v 1.18 2013/05/05 11:17:30 lukem Exp $ */ /* $NetBSD: cmds.c,v 1.19 2020/07/04 09:59:07 lukem Exp $ */
/* from NetBSD: cmds.c,v 1.135 2012/12/22 16:57:09 christos Exp */ /* from NetBSD: cmds.c,v 1.140 2019/02/06 07:56:42 martin Exp */
/*- /*-
* Copyright (c) 1996-2009 The NetBSD Foundation, Inc. * Copyright (c) 1996-2009 The NetBSD Foundation, Inc.
* All rights reserved. * All rights reserved.
* *
* This code is derived from software contributed to The NetBSD Foundation * This code is derived from software contributed to The NetBSD Foundation
* by Luke Mewburn. * by Luke Mewburn.
* *
* This code is derived from software contributed to The NetBSD Foundation * This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
skipping to change at line 104 skipping to change at line 104
#include "tnftp.h" #include "tnftp.h"
#if 0 /* tnftp */ #if 0 /* tnftp */
#include <sys/cdefs.h> #include <sys/cdefs.h>
#ifndef lint #ifndef lint
#if 0 #if 0
static char sccsid[] = "@(#)cmds.c 8.6 (Berkeley) 10/9/94"; static char sccsid[] = "@(#)cmds.c 8.6 (Berkeley) 10/9/94";
#else #else
__RCSID(" NetBSD: cmds.c,v 1.135 2012/12/22 16:57:09 christos Exp "); __RCSID(" NetBSD: cmds.c,v 1.140 2019/02/06 07:56:42 martin Exp ");
#endif #endif
#endif /* not lint */ #endif /* not lint */
/* /*
* FTP User Program -- Command Routines. * FTP User Program -- Command Routines.
*/ */
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/wait.h> #include <sys/wait.h>
skipping to change at line 1168 skipping to change at line 1168
} }
r = command("CWD %s", argv[1]); r = command("CWD %s", argv[1]);
if (r == ERROR && code == 500) { if (r == ERROR && code == 500) {
if (verbose) if (verbose)
fputs("CWD command not recognized, trying XCWD.\n", fputs("CWD command not recognized, trying XCWD.\n",
ttyout); ttyout);
r = command("XCWD %s", argv[1]); r = command("XCWD %s", argv[1]);
} }
if (r == COMPLETE) { if (r == COMPLETE) {
dirchange = 1; dirchange = 1;
updateremotecwd(); remotecwd[0] = '\0';
remcwdvalid = 0;
} }
} }
/* /*
* Set current working directory on local machine. * Set current working directory on local machine.
*/ */
void void
lcd(int argc, char *argv[]) lcd(int argc, char *argv[])
{ {
char *locdir; char *locdir;
skipping to change at line 1554 skipping to change at line 1555
/*VARARGS*/ /*VARARGS*/
void void
pwd(int argc, char *argv[]) pwd(int argc, char *argv[])
{ {
code = -1; code = -1;
if (argc != 1) { if (argc != 1) {
UPRINTF("usage: %s\n", argv[0]); UPRINTF("usage: %s\n", argv[0]);
return; return;
} }
if (! remotecwd[0]) if (!remcwdvalid || remotecwd[0] == '\0')
updateremotecwd(); updateremotecwd();
if (! remotecwd[0]) if (remotecwd[0] == '\0')
fprintf(ttyout, "Unable to determine remote directory\n"); fprintf(ttyout, "Unable to determine remote directory\n");
else { else {
fprintf(ttyout, "Remote directory: %s\n", remotecwd); fprintf(ttyout, "Remote directory: %s\n", remotecwd);
code = 0; code = 0;
} }
} }
/* /*
* Print working directory on local machine. * Print working directory on local machine.
*/ */
skipping to change at line 1785 skipping to change at line 1786
return; return;
} }
if (connected) if (connected)
disconnect(0, NULL); disconnect(0, NULL);
pswitch(1); pswitch(1);
if (connected) if (connected)
disconnect(0, NULL); disconnect(0, NULL);
exit(0); exit(0);
} }
void __dead
justquit(void)
{
quit(0, NULL);
/*
* quit is not __dead, but for our invocation it never will return,
* but some compilers are not smart enough to find this out.
*/
exit(0);
}
/* /*
* Terminate session, but don't exit. * Terminate session, but don't exit.
* May be called with 0, NULL. * May be called with 0, NULL.
*/ */
void void
disconnect(int argc, char *argv[]) disconnect(int argc, char *argv[])
{ {
/* this may be called with argc == 0, argv == NULL */ /* this may be called with argc == 0, argv == NULL */
if (argc == 0 && argv != NULL) { if (argc == 0 && argv != NULL) {
skipping to change at line 1977 skipping to change at line 1990
(void)strlcpy(ntout, argv[2], sizeof(ntout)); (void)strlcpy(ntout, argv[2], sizeof(ntout));
} }
static const char * static const char *
dotrans(char *dst, size_t dlen, const char *src) dotrans(char *dst, size_t dlen, const char *src)
{ {
const char *cp1; const char *cp1;
char *cp2 = dst; char *cp2 = dst;
size_t i, ostop; size_t i, ostop;
for (ostop = 0; *(ntout + ostop) && ostop < 16; ostop++) for (ostop = 0; ntout[ostop] && ostop < sizeof(ntout); ostop++)
continue; continue;
for (cp1 = src; *cp1; cp1++) { for (cp1 = src; *cp1; cp1++) {
int found = 0; int found = 0;
for (i = 0; *(ntin + i) && i < 16; i++) { for (i = 0; i < sizeof(ntin) && ntin[i]; i++) {
if (*cp1 == *(ntin + i)) { if (*cp1 == ntin[i]) {
found++; found++;
if (i < ostop) { if (i < ostop) {
*cp2++ = *(ntout + i); *cp2++ = ntout[i];
if (cp2 - dst >= (ptrdiff_t)(dlen - 1)) if (cp2 - dst >= (ptrdiff_t)(dlen - 1))
goto out; goto out;
} }
break; break;
} }
} }
if (!found) { if (!found) {
*cp2++ = *cp1; *cp2++ = *cp1;
} }
} }
skipping to change at line 2194 skipping to change at line 2207
} }
else if (toks[toknum = *cp1 - '1']) { else if (toks[toknum = *cp1 - '1']) {
const char *cp3 = tp[toknum]; const char *cp3 = tp[toknum];
while (cp3 != te[toknum]) { while (cp3 != te[toknum]) {
*cp2++ = *cp3++; *cp2++ = *cp3++;
} }
} }
break; break;
} }
/* intentional drop through */ /* FALLTHROUGH */
default: default:
*cp2++ = *cp1; *cp2++ = *cp1;
break; break;
} }
cp1++; cp1++;
} }
*cp2 = '\0'; *cp2 = '\0';
return *dst ? dst : src; return *dst ? dst : src;
} }
skipping to change at line 2368 skipping to change at line 2381
} }
r = command("CDUP"); r = command("CDUP");
if (r == ERROR && code == 500) { if (r == ERROR && code == 500) {
if (verbose) if (verbose)
fputs("CDUP command not recognized, trying XCUP.\n", fputs("CDUP command not recognized, trying XCUP.\n",
ttyout); ttyout);
r = command("XCUP"); r = command("XCUP");
} }
if (r == COMPLETE) { if (r == COMPLETE) {
dirchange = 1; dirchange = 1;
updateremotecwd(); remotecwd[0] = '\0';
remcwdvalid = 0;
} }
} }
/* /*
* Restart transfer at specific point * Restart transfer at specific point
*/ */
void void
restart(int argc, char *argv[]) restart(int argc, char *argv[])
{ {
 End of changes. 11 change blocks. 
12 lines changed or deleted 26 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)