"Fossies" - the Fresh Open Source Software Archive  

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

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

util.c  (tnftp-20151004):util.c  (tnftp-20200705)
/* $NetBSD: util.c,v 1.23 2013/05/05 11:51:43 lukem Exp $ */ /* $NetBSD: util.c,v 1.24 2020/07/04 09:59:07 lukem Exp $ */
/* from NetBSD: util.c,v 1.158 2013/02/19 23:29:15 dsl Exp */ /* from NetBSD: util.c,v 1.161 2020/06/08 01:33:27 lukem Exp */
/*- /*-
* Copyright (c) 1997-2009 The NetBSD Foundation, Inc. * Copyright (c) 1997-2020 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,
* NASA Ames Research Center. * NASA Ames Research Center.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
skipping to change at line 72 skipping to change at line 72
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
#include "tnftp.h" #include "tnftp.h"
#if 0 /* tnftp */ #if 0 /* tnftp */
#include <sys/cdefs.h> #include <sys/cdefs.h>
#ifndef lint #ifndef lint
__RCSID(" NetBSD: util.c,v 1.158 2013/02/19 23:29:15 dsl Exp "); __RCSID(" NetBSD: util.c,v 1.161 2020/06/08 01:33:27 lukem Exp ");
#endif /* not lint */ #endif /* not lint */
/* /*
* FTP User Program -- Misc support routines * FTP User Program -- Misc support routines
*/ */
#include <sys/param.h> #include <sys/param.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/time.h> #include <sys/time.h>
#include <netinet/in.h> #include <netinet/in.h>
skipping to change at line 334 skipping to change at line 334
sigint_raised = 1; sigint_raised = 1;
alarmtimer(0); alarmtimer(0);
if (fromatty) if (fromatty)
write(fileno(ttyout), "\n", 1); write(fileno(ttyout), "\n", 1);
siglongjmp(toplevel, 1); siglongjmp(toplevel, 1);
} }
/* /*
* Signal handler for lost connections; cleanup various elements of * Signal handler for lost connections; cleanup various elements of
* the connection state, and call cleanuppeer() to finish it off. * the connection state, and call cleanuppeer() to finish it off.
* This function is not signal safe, so exit if called by a signal.
*/ */
void void
lostpeer(int dummy) lostpeer(int signo)
{ {
int oerrno = errno; int oerrno = errno;
alarmtimer(0); alarmtimer(0);
if (connected) { if (connected) {
if (cout != NULL) { if (cout != NULL) {
(void)shutdown(fileno(cout), 1+1); (void)shutdown(fileno(cout), 1+1);
(void)fclose(cout); (void)fclose(cout);
cout = NULL; cout = NULL;
} }
skipping to change at line 366 skipping to change at line 367
if (cout != NULL) { if (cout != NULL) {
(void)shutdown(fileno(cout), 1+1); (void)shutdown(fileno(cout), 1+1);
(void)fclose(cout); (void)fclose(cout);
cout = NULL; cout = NULL;
} }
connected = 0; connected = 0;
} }
proxflag = 0; proxflag = 0;
pswitch(0); pswitch(0);
cleanuppeer(); cleanuppeer();
if (signo) {
errx(1, "lostpeer due to signal %d", signo);
}
errno = oerrno; errno = oerrno;
} }
/* /*
* Login to remote host, using given username & password if supplied. * Login to remote host, using given username & password if supplied.
* Return non-zero if successful. * Return non-zero if successful.
*/ */
int int
ftp_login(const char *host, const char *luser, const char *lpass) ftp_login(const char *host, const char *luser, const char *lpass)
{ {
skipping to change at line 487 skipping to change at line 491
getremoteinfo(); getremoteinfo();
for (n = 0; n < macnum; ++n) { for (n = 0; n < macnum; ++n) {
if (!strcmp("init", macros[n].mac_name)) { if (!strcmp("init", macros[n].mac_name)) {
(void)strlcpy(line, "$init", sizeof(line)); (void)strlcpy(line, "$init", sizeof(line));
makeargv(); makeargv();
domacro(margc, margv); domacro(margc, margv);
break; break;
} }
} }
updatelocalcwd(); updatelocalcwd();
updateremotecwd(); remotecwd[0] = '\0';
remcwdvalid = 0;
cleanup_ftp_login: cleanup_ftp_login:
FREEPTR(fuser); FREEPTR(fuser);
if (pass != NULL) if (pass != NULL)
memset(pass, 0, strlen(pass)); memset(pass, 0, strlen(pass));
FREEPTR(pass); FREEPTR(pass);
if (facct != NULL) if (facct != NULL)
memset(facct, 0, strlen(facct)); memset(facct, 0, strlen(facct));
FREEPTR(facct); FREEPTR(facct);
return (rval); return (rval);
skipping to change at line 848 skipping to change at line 853
/* /*
* Update global `remotecwd', which contains the state of the remote cwd * Update global `remotecwd', which contains the state of the remote cwd
*/ */
void void
updateremotecwd(void) updateremotecwd(void)
{ {
int overbose, ocode; int overbose, ocode;
size_t i; size_t i;
char *cp; char *cp;
remcwdvalid = 1; /* whether it works or not, we are done */
overbose = verbose; overbose = verbose;
ocode = code; ocode = code;
if (ftp_debug == 0) if (ftp_debug == 0)
verbose = -1; verbose = -1;
if (command("PWD") != COMPLETE) if (command("PWD") != COMPLETE)
goto badremotecwd; goto badremotecwd;
cp = strchr(reply_string, ' '); cp = strchr(reply_string, ' ');
if (cp == NULL || cp[0] == '\0' || cp[1] != '"') if (cp == NULL || cp[0] == '\0' || cp[1] != '"')
goto badremotecwd; goto badremotecwd;
cp += 2; cp += 2;
skipping to change at line 1186 skipping to change at line 1192
ADDBUF(*p); ADDBUF(*p);
continue; continue;
} }
p++; p++;
switch (op = *p) { switch (op = *p) {
case '/': case '/':
case '.': case '.':
case 'c': case 'c':
if (connected && !remcwdvalid)
updateremotecwd();
p2 = connected ? remotecwd : ""; p2 = connected ? remotecwd : "";
updirs = pdirs = 0; updirs = pdirs = 0;
/* option to determine fixed # of dirs from path */ /* option to determine fixed # of dirs from path */
if (op == '.' || op == 'c') { if (op == '.' || op == 'c') {
int skip; int skip;
q = p2; q = p2;
while (*p2) /* calc # of /'s */ while (*p2) /* calc # of /'s */
if (*p2++ == '/') if (*p2++ == '/')
skipping to change at line 1557 skipping to change at line 1565
if (FD_ISSET(fds[i].fd, &xset)) if (FD_ISSET(fds[i].fd, &xset))
fds[i].revents |= (fds[i].events & xsetflags); fds[i].revents |= (fds[i].events & xsetflags);
} }
return rv; return rv;
#else #else
# error no way to implement xpoll # error no way to implement xpoll
#endif #endif
} }
#ifndef SMALL
/* /*
* malloc() with inbuilt error checking * malloc() with inbuilt error checking
*/ */
void * void *
ftp_malloc(size_t size) ftp_malloc(size_t size)
{ {
void *p; void *p;
p = malloc(size); p = malloc(size);
if (p == NULL) if (p == NULL)
skipping to change at line 1611 skipping to change at line 1620
{ {
char *s; char *s;
if (str == NULL) if (str == NULL)
errx(1, "ftp_strdup: called with NULL argument"); errx(1, "ftp_strdup: called with NULL argument");
s = strdup(str); s = strdup(str);
if (s == NULL) if (s == NULL)
err(1, "Unable to allocate memory for string copy"); err(1, "Unable to allocate memory for string copy");
return (s); return (s);
} }
#endif
 End of changes. 11 change blocks. 
6 lines changed or deleted 15 lines changed or added

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