I'm anal. Closer to KNF now.
+# $OpenBSD: Makefile,v 1.6 1997/02/03 01:05:31 millert Exp $
# $NetBSD: Makefile,v 1.8 1997/01/19 14:19:02 lukem Exp $
# from: @(#)Makefile 8.2 (Berkeley) 4/3/94
#SMALLFTP=yes
PROG= ftp
-SRCS= cmds.c cmdtab.c domacro.c fetch.c ftp.c main.c ruserpass.c util.c
+SRCS= cmds.c cmdtab.c domacro.c fetch.c ftp.c main.c ruserpass.c \
+ stringlist.c util.c
.if defined(SMALLFTP)
CFLAGS+=-DSMALLFTP
+/* $OpenBSD: cmds.c,v 1.14 1997/02/03 01:05:33 millert Exp $ */
/* $NetBSD: cmds.c,v 1.18 1997/02/01 10:44:54 lukem Exp $ */
/*
#if 0
static char sccsid[] = "@(#)cmds.c 8.6 (Berkeley) 10/9/94";
#else
-static char rcsid[] = "$NetBSD: cmds.c,v 1.18 1997/02/01 10:44:54 lukem Exp $";
+static char rcsid[] = "$OpenBSD: cmds.c,v 1.14 1997/02/03 01:05:33 millert Exp $";
#endif
#endif /* not lint */
printf("%s%s", sep, p->t_name);
sep = " | ";
}
- printf(" ]\n");
+ puts(" ]");
code = -1;
return;
}
else
comret = command("TYPE %s", p->t_mode);
if (comret == COMPLETE) {
- (void) strcpy(typename, p->t_name);
+ (void)strcpy(typename, p->t_name);
curtype = type = p->t_type;
}
}
mname = argv[0];
mflag = 1;
oldintr = signal(SIGINT, mabort);
- (void) setjmp(jabort);
+ (void)setjmp(jabort);
if (proxy) {
char *cp, *tp2, tmpbuf[MAXPATHLEN];
}
}
}
- (void) signal(SIGINT, oldintr);
+ (void)signal(SIGINT, oldintr);
mflag = 0;
return;
}
}
globfree(&gl);
}
- (void) signal(SIGINT, oldintr);
+ (void)signal(SIGINT, oldintr);
mflag = 0;
}
char *argv[];
{
- (void) getit(argc, argv, 1, "r+w");
+ (void)getit(argc, argv, 1, "r+w");
}
void
char *argv[];
{
- (void) getit(argc, argv, 0, restart_point ? "r+w" : "w" );
+ (void)getit(argc, argv, 0, restart_point ? "r+w" : "w" );
}
/*
int ointer, oconf;
alarmtimer(0);
- printf("\n");
- (void) fflush(stdout);
+ putchar('\n');
+ (void)fflush(stdout);
if (mflag && fromatty) {
ointer = interactive;
oconf = confirmrest;
mname = argv[0];
mflag = 1;
oldintr = signal(SIGINT, mabort);
- (void) setjmp(jabort);
+ (void)setjmp(jabort);
while ((cp = remglob(argv, proxy)) != NULL) {
if (*cp == '\0') {
mflag = 0;
}
}
}
- (void) signal(SIGINT, oldintr);
+ (void)signal(SIGINT, oldintr);
mflag = 0;
}
if (connected)
printf("Connected to %s.\n", hostname);
else
- printf("Not connected.\n");
+ puts("Not connected.");
if (!proxy) {
pswitch(1);
if (connected) {
hostname);
}
else {
- printf("No proxy connection.\n");
+ puts("No proxy connection.");
}
pswitch(0);
}
printf("Ntrans: (in) %s (out) %s\n", ntin, ntout);
}
else {
- printf("Ntrans: off\n");
+ puts("Ntrans: off");
}
if (mapflag) {
printf("Nmap: (in) %s (out) %s\n", mapin, mapout);
}
else {
- printf("Nmap: off\n");
+ puts("Nmap: off");
}
printf("Hash mark printing: %s; Mark count: %d; Progress bar: %s\n",
onoff(hash), mark, onoff(progress));
printf("Command line editing: %s\n", onoff(editing));
#endif /* !SMALLFTP */
if (macnum > 0) {
- printf("Macros:\n");
+ puts("Macros:");
for (i=0; i<macnum; i++) {
printf("\t%s\n", macros[i].mac_name);
}
return -1;
}
printf("%s %s.\n", mesg, onoff(*var));
- return *var;
+ return (*var);
}
/*
printf("Hash mark printing %s", onoff(hash));
if (hash)
printf(" (%d bytes/hash mark)", mark);
- printf(".\n");
+ puts(".");
code = hash;
}
r = command("CWD %s", argv[1]);
if (r == ERROR && code == 500) {
if (verbose)
- printf("CWD command not recognized, trying XCWD\n");
+ puts("CWD command not recognized, trying XCWD");
r = command("XCWD %s", argv[1]);
}
if (r == COMPLETE)
code = -1;
return;
}
- (void) command("DELE %s", argv[1]);
+ (void)command("DELE %s", argv[1]);
}
/*
mname = argv[0];
mflag = 1;
oldintr = signal(SIGINT, mabort);
- (void) setjmp(jabort);
+ (void)setjmp(jabort);
while ((cp = remglob(argv, 0)) != NULL) {
if (*cp == '\0') {
mflag = 0;
continue;
}
if (mflag && confirm(argv[0], cp)) {
- (void) command("DELE %s", cp);
+ (void)command("DELE %s", cp);
if (!mflag && fromatty) {
ointer = interactive;
interactive = 1;
}
}
}
- (void) signal(SIGINT, oldintr);
+ (void)signal(SIGINT, oldintr);
mflag = 0;
}
return;
}
if (command("RNFR %s", argv[1]) == CONTINUE)
- (void) command("RNTO %s", argv[2]);
+ (void)command("RNTO %s", argv[2]);
}
/*
mname = argv[0];
mflag = 1;
oldintr = signal(SIGINT, mabort);
- (void) setjmp(jabort);
+ (void)setjmp(jabort);
for (i = 1; mflag && i < argc-1; ++i) {
*mode = (i == 1) ? 'w' : 'a';
recvrequest(cmd, dest, argv[i], mode, 0);
interactive = ointer;
}
}
- (void) signal(SIGINT, oldintr);
+ (void)signal(SIGINT, oldintr);
mflag = 0;
}
old2 = signal (SIGQUIT, SIG_IGN);
if ((pid = fork()) == 0) {
for (pid = 3; pid < 20; pid++)
- (void) close(pid);
- (void) signal(SIGINT, SIG_DFL);
- (void) signal(SIGQUIT, SIG_DFL);
+ (void)close(pid);
+ (void)signal(SIGINT, SIG_DFL);
+ (void)signal(SIGQUIT, SIG_DFL);
shell = getenv("SHELL");
if (shell == NULL)
shell = _PATH_BSHELL;
if (namep == NULL)
namep = shell;
shellnam[0] = '-';
- (void) strncpy(shellnam + 1, ++namep, sizeof(shellnam) - 1);
+ (void)strncpy(shellnam + 1, ++namep, sizeof(shellnam) - 2);
+ shellnam[sizeof(shellnam) - 1] = '\0';
if (strcmp(namep, "sh") != 0)
shellnam[0] = '+';
if (debug) {
- printf ("%s\n", shell);
- (void) fflush (stdout);
+ puts(shell);
+ (void)fflush(stdout);
}
if (argc > 1) {
execl(shell, shellnam, "-c", altarg, (char *)0);
if (pid > 0)
while (wait((int *)&status) != pid)
;
- (void) signal(SIGINT, old1);
- (void) signal(SIGQUIT, old2);
+ (void)signal(SIGINT, old1);
+ (void)signal(SIGQUIT, old2);
if (pid == -1) {
warn("%s", "Try again later");
code = -1;
int n, aflag = 0;
if (argc < 2)
- (void) another(&argc, &argv, "username");
+ (void)another(&argc, &argv, "username");
if (argc < 2 || argc > 4) {
printf("usage: %s username [password] [account]\n", argv[0]);
code = -1;
}
if (n == CONTINUE) {
if (argc < 4) {
- printf("Account: "); (void) fflush(stdout);
- (void) fgets(acct, sizeof(acct) - 1, stdin);
+ (void)fputs("Account: ", stdout);
+ (void)fflush(stdout);
+ (void)fgets(acct, sizeof(acct) - 1, stdin);
acct[strlen(acct) - 1] = '\0';
argv[3] = acct; argc++;
}
aflag++;
}
if (n != COMPLETE) {
- fprintf(stdout, "Login failed.\n");
+ puts("Login failed.");
return;
}
if (!aflag && argc == 4) {
- (void) command("ACCT %s", argv[3]);
+ (void)command("ACCT %s", argv[3]);
}
}
*/
verbose = 1;
if (command("PWD") == ERROR && code == 500) {
- printf("PWD command not recognized, trying XPWD\n");
- (void) command("XPWD");
+ puts("PWD command not recognized, trying XPWD");
+ (void)command("XPWD");
}
verbose = oldverbose;
}
}
if (command("MKD %s", argv[1]) == ERROR && code == 500) {
if (verbose)
- printf("MKD command not recognized, trying XMKD\n");
- (void) command("XMKD %s", argv[1]);
+ puts("MKD command not recognized, trying XMKD");
+ (void)command("XMKD %s", argv[1]);
}
}
}
if (command("RMD %s", argv[1]) == ERROR && code == 500) {
if (verbose)
- printf("RMD command not recognized, trying XRMD\n");
- (void) command("XRMD %s", argv[1]);
+ puts("RMD command not recognized, trying XRMD");
+ (void)command("XRMD %s", argv[1]);
}
}
int i, len;
char buf[BUFSIZ]; /* must be >= sizeof(line) */
- (void) strncpy(buf, initial, sizeof(buf));
+ (void)strncpy(buf, initial, sizeof(buf) - 1);
+ buf[sizeof(buf) - 1] = '\0';
if (argc > 1) {
len = strlen(buf);
- len += strlen(strncpy(&buf[len], argv[1], sizeof(buf) - len));
- for (i = 2; i < argc; i++) {
+ len += strlen(strncpy(&buf[len], argv[1], sizeof(buf) - len - 1));
+ for (i = 2; i < argc && len < sizeof(buf); i++) {
buf[len++] = ' ';
len += strlen(strncpy(&buf[len], argv[i],
- sizeof(buf) - len));
+ sizeof(buf) - len) - 1);
}
}
if (command(buf) == PRELIM) {
code = -1;
return;
}
- (void) command("SITE CHMOD %s %s", argv[1], argv[2]);
+ (void)command("SITE CHMOD %s %s", argv[1], argv[2]);
}
void
int oldverbose = verbose;
verbose = 1;
- (void) command(argc == 1 ? "SITE UMASK" : "SITE UMASK %s", argv[1]);
+ (void)command(argc == 1 ? "SITE UMASK" : "SITE UMASK %s", argv[1]);
verbose = oldverbose;
}
int oldverbose = verbose;
verbose = 1;
- (void) command(argc == 1 ? "SITE IDLE" : "SITE IDLE %s", argv[1]);
+ (void)command(argc == 1 ? "SITE IDLE" : "SITE IDLE %s", argv[1]);
verbose = oldverbose;
}
int oldverbose = verbose;
verbose = 1;
- (void) command(argc == 1 ? "HELP" : "HELP %s", argv[1]);
+ (void)command(argc == 1 ? "HELP" : "HELP %s", argv[1]);
verbose = oldverbose;
}
if (!connected)
return;
- (void) command("QUIT");
+ (void)command("QUIT");
if (cout) {
- (void) fclose(cout);
+ (void)fclose(cout);
}
cout = NULL;
connected = 0;
ap = argv[1];
else
ap = getpass("Account:");
- (void) command("ACCT %s", ap);
+ (void)command("ACCT %s", ap);
}
jmp_buf abortprox;
}
c = getcmd(argv[1]);
if (c == (struct cmd *) -1) {
- printf("?Ambiguous command\n");
- (void) fflush(stdout);
+ puts("?Ambiguous command");
+ (void)fflush(stdout);
code = -1;
return;
}
if (c == 0) {
- printf("?Invalid command\n");
- (void) fflush(stdout);
+ puts("?Invalid command");
+ (void)fflush(stdout);
code = -1;
return;
}
if (!c->c_proxy) {
- printf("?Invalid proxy command\n");
- (void) fflush(stdout);
+ puts("?Invalid proxy command");
+ (void)fflush(stdout);
code = -1;
return;
}
oldintr = signal(SIGINT, proxabort);
pswitch(1);
if (c->c_conn && !connected) {
- printf("Not connected\n");
- (void) fflush(stdout);
+ puts("Not connected");
+ (void)fflush(stdout);
pswitch(0);
- (void) signal(SIGINT, oldintr);
+ (void)signal(SIGINT, oldintr);
code = -1;
return;
}
proxflag = 0;
}
pswitch(0);
- (void) signal(SIGINT, oldintr);
+ (void)signal(SIGINT, oldintr);
}
void
{
if (argc == 1) {
ntflag = 0;
- printf("Ntrans off.\n");
+ puts("Ntrans off.");
code = ntflag;
return;
}
ntflag++;
code = ntflag;
- (void) strncpy(ntin, argv[1], 16);
- ntin[16] = '\0';
+ (void)strncpy(ntin, argv[1], sizeof(ntin) - 1);
+ ntin[sizeof(ntin) - 1] = '\0';
if (argc == 2) {
ntout[0] = '\0';
return;
}
- (void) strncpy(ntout, argv[2], 16);
- ntout[16] = '\0';
+ (void)strncpy(ntout, argv[2], sizeof(ntout) - 1);
+ ntout[sizeof(ntout) - 1] = '\0';
}
char *
if (argc == 1) {
mapflag = 0;
- printf("Nmap off.\n");
+ puts("Nmap off.");
code = mapflag;
return;
}
cp = strchr(altarg, ' ');
}
*cp = '\0';
- (void) strncpy(mapin, altarg, MAXPATHLEN - 1);
+ (void)strncpy(mapin, altarg, MAXPATHLEN - 1);
while (*++cp == ' ')
continue;
- (void) strncpy(mapout, cp, MAXPATHLEN - 1);
+ (void)strncpy(mapout, cp, MAXPATHLEN - 1);
}
char *
}
}
if (!*cp2) {
- printf("nmap: unbalanced "
- "brackets\n");
+ puts("nmap: unbalanced brackets");
return (name);
}
match = 1;
}
}
if (!*cp2) {
- printf("nmap: unbalanced "
- "brackets\n");
+ puts("nmap: unbalanced brackets");
return (name);
}
break;
r = command("CDUP");
if (r == ERROR && code == 500) {
if (verbose)
- printf("CDUP command not recognized, trying XCUP\n");
+ puts("CDUP command not recognized, trying XCUP");
r = command("XCUP");
}
if (r == COMPLETE)
{
if (argc != 2)
- printf("restart: offset not specified\n");
+ puts("restart: offset not specified");
else {
restart_point = atol(argv[1]);
printf("Restarting at %qd. Execute get, put or append to"
char *argv[];
{
- (void) command("SYST");
+ (void)command("SYST");
}
void
int c;
if (macnum == 16) {
- printf("Limit of 16 macros have already been defined\n");
+ puts("Limit of 16 macros have already been defined");
code = -1;
return;
}
return;
}
if (interactive) {
- printf("Enter macro line by line, terminating it with a "
- "null line\n");
+ puts("Enter macro line by line, terminating it with a null line");
}
- (void) strncpy(macros[macnum].mac_name, argv[1], 8);
- if (macnum == 0) {
+ (void)strncpy(macros[macnum].mac_name, argv[1],
+ sizeof(macros[macnum].mac_name) - 1);
+ macros[macnum].mac_name[sizeof(macros[macnum].mac_name) - 1] = '\0';
+ if (macnum == 0)
macros[macnum].mac_start = macbuf;
- }
- else {
+ else
macros[macnum].mac_start = macros[macnum - 1].mac_end + 1;
- }
tmp = macros[macnum].mac_start;
while (tmp != macbuf+4096) {
if ((c = getchar()) == EOF) {
- printf("macdef:end of file encountered\n");
+ puts("macdef: end of file encountered");
code = -1;
return;
}
while ((c = getchar()) != '\n' && c != EOF)
/* LOOP */;
if (c == EOF || getchar() == '\n') {
- printf("Macro not defined - 4k buffer exceeded\n");
+ puts("Macro not defined - 4k buffer exceeded");
code = -1;
return;
}
char *argv[];
{
- (void) command(argc > 1 ? "STAT %s" : "STAT" , argv[1]);
+ (void)command(argc > 1 ? "STAT %s" : "STAT" , argv[1]);
}
/*
+/* $OpenBSD: cmdtab.c,v 1.6 1997/02/03 01:05:34 millert Exp $ */
/* $NetBSD: cmdtab.c,v 1.12 1997/01/19 14:19:05 lukem Exp $ */
/*
#if 0
static char sccsid[] = "@(#)cmdtab.c 8.4 (Berkeley) 10/9/94";
#else
-static char rcsid[] = "$NetBSD: cmdtab.c,v 1.12 1997/01/19 14:19:05 lukem Exp $";
+static char rcsid[] = "$OpenBSD: cmdtab.c,v 1.6 1997/02/03 01:05:34 millert Exp $";
#endif
#endif /* not lint */
{ 0 },
};
-int NCMDS = (sizeof (cmdtab) / sizeof (cmdtab[0])) - 1;
+int NCMDS = (sizeof(cmdtab) / sizeof(cmdtab[0])) - 1;
+/* $OpenBSD: complete.c,v 1.2 1997/02/03 01:05:35 millert Exp $ */
/* $NetBSD: complete.c,v 1.2 1997/02/01 10:44:57 lukem Exp $ */
/*-
*/
#ifndef lint
-static char rcsid[] = "$NetBSD: complete.c,v 1.2 1997/02/01 10:44:57 lukem Exp $";
+static char rcsid[] = "$OpenBSD: complete.c,v 1.2 1997/02/03 01:05:35 millert Exp $";
#endif /* not lint */
/*
case 'r': /* remote complete */
case 'R':
if (!connected) {
- printf("\nMust be connected to complete\n");
+ puts("\nMust be connected to complete");
return CC_REDISPLAY;
}
return complete_remote(word, dolist);
+/* $OpenBSD: domacro.c,v 1.4 1997/02/03 01:05:36 millert Exp $ */
/* $NetBSD: domacro.c,v 1.8 1997/01/19 14:19:08 lukem Exp $ */
/*
#if 0
static char sccsid[] = "@(#)domacro.c 8.3 (Berkeley) 4/2/94";
#else
-static char rcsid[] = "$NetBSD: domacro.c,v 1.8 1997/01/19 14:19:08 lukem Exp $";
+static char rcsid[] = "$OpenBSD: domacro.c,v 1.4 1997/02/03 01:05:36 millert Exp $";
#endif
#endif /* not lint */
code = -1;
return;
}
- (void) strcpy(line2, line);
+ (void)strcpy(line2, line);
TOP:
cp1 = macros[i].mac_start;
while (cp1 != macros[i].mac_end) {
}
cp1--;
if (argc - 2 >= j) {
- (void) strcpy(cp2, argv[j+1]);
+ (void)strcpy(cp2, argv[j+1]);
cp2 += strlen(argv[j+1]);
}
break;
loopflg = 1;
cp1++;
if (count < argc) {
- (void) strcpy(cp2, argv[count]);
+ (void)strcpy(cp2, argv[count]);
cp2 += strlen(argv[count]);
}
break;
makeargv();
c = getcmd(margv[0]);
if (c == (struct cmd *)-1) {
- printf("?Ambiguous command\n");
+ puts("?Ambiguous command");
code = -1;
}
else if (c == 0) {
- printf("?Invalid command\n");
+ puts("?Invalid command");
code = -1;
}
else if (c->c_conn && !connected) {
- printf("Not connected.\n");
+ puts("Not connected.");
code = -1;
}
else {
if (verbose) {
- printf("%s\n", line);
+ puts(line);
}
(*c->c_handler)(margc, margv);
if (bell && c->c_bell) {
- (void) putchar('\007');
+ (void)putchar('\007');
}
- (void) strcpy(line, line2);
+ (void)strcpy(line, line2);
makeargv();
argc = margc;
argv = margv;
/* $NetBSD: extern.h,v 1.11 1997/02/01 10:44:58 lukem Exp $ */
+/* $OpenBSD: extern.h,v 1.7 1997/02/03 01:05:37 millert Exp $ */
/*-
* Copyright (c) 1994 The Regents of the University of California.
+/* $OpenBSD: fetch.c,v 1.2 1997/02/03 01:05:37 millert Exp $ */
/* $NetBSD: fetch.c,v 1.2 1997/02/01 10:45:00 lukem Exp $ */
/*-
*/
#ifndef lint
-static char rcsid[] = "$NetBSD: fetch.c,v 1.2 1997/02/01 10:45:00 lukem Exp $";
+static char rcsid[] = "$OpenBSD: fetch.c,v 1.2 1997/02/03 01:05:37 millert Exp $";
#endif /* not lint */
/*
oldintr = NULL;
if (setjmp(httpabort)) {
if (oldintr)
- (void) signal(SIGINT, oldintr);
+ (void)signal(SIGINT, oldintr);
goto cleanup_http_get;
}
oldintr = signal(SIGINT, aborthttp);
}
if (hash && !progress) {
while (bytes >= hashbytes) {
- (void) putchar('#');
+ (void)putchar('#');
hashbytes += mark;
}
- (void) fflush(stdout);
+ (void)fflush(stdout);
}
}
if (hash && !progress && bytes > 0) {
if (bytes < mark)
- (void) putchar('#');
- (void) putchar('\n');
- (void) fflush(stdout);
+ (void)putchar('#');
+ (void)putchar('\n');
+ (void)fflush(stdout);
}
if (len != 0) {
warn("Reading from socket");
}
progressmeter(1);
if (verbose)
- printf("Successfully retrieved file.\n");
- (void) signal(SIGINT, oldintr);
+ puts("Successfully retrieved file.");
+ (void)signal(SIGINT, oldintr);
close(s);
close(out);
if (proxy)
free(proxy);
- return(0);
+ return (0);
improper:
warnx("improper response from %s", host);
close(s);
if (proxy)
free(proxy);
- return(-1);
+ return (-1);
}
/*
{
alarmtimer(0);
- printf("\nhttp fetch aborted\n");
- (void) fflush(stdout);
+ puts("\nhttp fetch aborted");
+ (void)fflush(stdout);
longjmp(httpabort, 1);
}
* files of the form "host:path", "ftp://host/path" using the
* ftp protocol, and files of the form "http://host/path" using
* the http protocol.
- * If path has a trailing "/", then return(-1);
+ * If path has a trailing "/", then return (-1);
* the path will be cd-ed into and the connection remains open,
* and the function will return -1 (to indicate the connection
* is alive).
if (setjmp(toplevel)) {
if (connected)
disconnect(0, NULL);
- return(argpos + 1);
+ return (argpos + 1);
}
- (void) signal(SIGINT, intr);
- (void) signal(SIGPIPE, lostpeer);
+ (void)signal(SIGINT, intr);
+ (void)signal(SIGPIPE, lostpeer);
/*
* Loop through as long as there's files to fetch.
+.\" $OpenBSD: ftp.1,v 1.7 1997/02/03 01:05:38 millert Exp $
.\" $NetBSD: ftp.1,v 1.17 1997/02/01 10:45:01 lukem Exp $
.\"
.\" Copyright (c) 1985, 1989, 1990, 1993
.Op Fl n
.Op Fl p
.Op Fl P Ar port
+.Op Fl r Ar seconds
.Op Fl t
.Op Fl v
.Op Fl V
.Nm ftp
http://\fIhost\fR[:\fIport\fR]/\fIfile\fR
.Nm ftp
-\fIhost\fR:\fIfile\fR[/]
+\fIhost\fR:\fI/path/file\fR[/]
.Sh DESCRIPTION
-.Nm
+.Nm Ftp
is the user interface to the
.Tn ARPANET
standard File Transfer Protocol.
The program allows a user to transfer files to and from a
remote network site.
.Pp
+The latter three usage formats will fetch a file using either the
+HTTP or FTP protocols into the current directory.
+This is ideal for scripts.
+.Pp
Options may be specified at the command line, or to the
command interpreter.
.Bl -tag -width "port "
.It Fl P Ar port
Sets the port number to
.Ar port .
+.It Fl r Ar number
+Retry to connect if failed, pausing for
+.Ar number
+of seconds.
.It Fl t
Enables packet tracing.
.It Fl v
is specified it is used to set the debugging level.
When debugging is on,
.Nm
-prints each command sent to the remote machine, preceded
-by the string
+prints each command sent to the remote machine,
+preceded by the string
.Ql \-\->
.It Ic dir Op Ar remote-directory Op Ar local-file
Print a listing of the contents of a
.Nm
command appeared in
.Bx 4.2 .
-.Pp
-Various features such as command line editing, context sensitive
-command and file completion, dynamic progress bar, automatic
-fetching of files, ftp and http URLs, and modification time
-preservation were implemented in
-.Nx 1.2b
-by Luke Mewburn, with assistance from Jason Thorpe.
.Sh BUGS
Correct execution of many commands depends upon proper behavior
by the remote server.
+/* $OpenBSD: ftp.c,v 1.11 1997/02/03 01:05:40 millert Exp $ */
/* $NetBSD: ftp.c,v 1.22 1997/02/01 10:45:03 lukem Exp $ */
/*
#if 0
static char sccsid[] = "@(#)ftp.c 8.6 (Berkeley) 10/27/94";
#else
-static char rcsid[] = "$NetBSD: ftp.c,v 1.22 1997/02/01 10:45:03 lukem Exp $";
+static char rcsid[] = "$OpenBSD: ftp.c,v 1.11 1997/02/03 01:05:40 millert Exp $";
#endif
#endif /* not lint */
int s, len, tos;
static char hostnamebuf[MAXHOSTNAMELEN];
- memset((char *)&hisctladdr, 0, sizeof (hisctladdr));
+ memset((char *)&hisctladdr, 0, sizeof(hisctladdr));
if (inet_aton(host, &hisctladdr.sin_addr) != 0) {
hisctladdr.sin_family = AF_INET;
- (void) strncpy(hostnamebuf, host, sizeof(hostnamebuf));
+ (void)strncpy(hostnamebuf, host, sizeof(hostnamebuf) - 1);
+ hostnamebuf[sizeof(hostnamebuf) - 1] = '\0';
} else {
hp = gethostbyname(host);
if (hp == NULL) {
return ((char *) 0);
}
hisctladdr.sin_family = hp->h_addrtype;
- memmove((caddr_t)&hisctladdr.sin_addr,
- hp->h_addr_list[0], hp->h_length);
- memcpy(&hisctladdr.sin_addr, hp->h_addr, hp->h_length);
- (void) strncpy(hostnamebuf, hp->h_name, sizeof(hostnamebuf));
+ memcpy(&hisctladdr.sin_addr, hp->h_addr_list[0], hp->h_length);
+ (void)strncpy(hostnamebuf, hp->h_name, sizeof(hostnamebuf) - 1);
+ hostnamebuf[sizeof(hostnamebuf) - 1] = '\0';
}
hostname = hostnamebuf;
s = socket(hisctladdr.sin_family, SOCK_STREAM, 0);
}
hisctladdr.sin_port = port;
while (connect(s, (struct sockaddr *)&hisctladdr,
- sizeof (hisctladdr)) < 0) {
+ sizeof(hisctladdr)) < 0) {
if (hp && hp->h_addr_list[1]) {
int oerrno = errno;
char *ia;
errno = oerrno;
warn("connect to address %s", ia);
hp->h_addr_list++;
- memmove((caddr_t)&hisctladdr.sin_addr,
- hp->h_addr_list[0], hp->h_length);
- fprintf(stdout, "Trying %s...\n",
- inet_ntoa(hisctladdr.sin_addr));
- (void) close(s);
+ memcpy(&hisctladdr.sin_addr, hp->h_addr_list[0],
+ hp->h_length);
+ printf("Trying %s...\n", inet_ntoa(hisctladdr.sin_addr));
+ (void)close(s);
s = socket(hisctladdr.sin_family, SOCK_STREAM, 0);
if (s < 0) {
warn("socket");
code = -1;
goto bad;
}
- len = sizeof (myctladdr);
+ len = sizeof(myctladdr);
if (getsockname(s, (struct sockaddr *)&myctladdr, &len) < 0) {
warn("getsockname");
code = -1;
if (cin == NULL || cout == NULL) {
warnx("fdopen failed.");
if (cin)
- (void) fclose(cin);
+ (void)fclose(cin);
if (cout)
- (void) fclose(cout);
+ (void)fclose(cout);
code = -1;
goto bad;
}
printf("Connected to %s.\n", hostname);
if (getreply(0) > 2) { /* read startup message from server */
if (cin)
- (void) fclose(cin);
+ (void)fclose(cin);
if (cout)
- (void) fclose(cout);
+ (void)fclose(cout);
code = -1;
goto bad;
}
return (hostname);
bad:
- (void) close(s);
+ (void)close(s);
return ((char *)0);
}
printf("Name (%s:%s): ", host, myname);
else
printf("Name (%s): ", host);
- (void) fgets(tmp, sizeof(tmp) - 1, stdin);
+ (void)fgets(tmp, sizeof(tmp) - 1, stdin);
tmp[strlen(tmp) - 1] = '\0';
if (*tmp == '\0')
user = myname;
return (0);
}
if (!aflag && acct != NULL)
- (void) command("ACCT %s", acct);
+ (void)command("ACCT %s", acct);
if (proxy)
return (1);
for (n = 0; n < macnum; ++n) {
if (!strcmp("init", macros[n].mac_name)) {
- (void) strcpy(line, "$init");
+ (void)strcpy(line, "$init");
makeargv();
domacro(margc, margv);
break;
{
alarmtimer(0);
- printf("\n");
- (void) fflush(stdout);
+ putchar('\n');
+ (void)fflush(stdout);
abrtflag++;
if (ptflag)
longjmp(ptabort, 1);
abrtflag = 0;
if (debug) {
- printf("---> ");
+ fputs("---> ", stdout);
va_start(ap);
fmt = va_arg(ap, char *);
if (strncmp("PASS ", fmt, 5) == 0)
- printf("PASS XXXX");
+ fputs("PASS XXXX", stdout);
else if (strncmp("ACCT ", fmt, 5) == 0)
- printf("ACCT XXXX");
+ fputs("ACCT XXXX", stdout);
else
- vfprintf(stdout, fmt, ap);
+ vprintf(fmt, ap);
va_end(ap);
- printf("\n");
- (void) fflush(stdout);
+ putchar('\n');
+ (void)fflush(stdout);
}
if (cout == NULL) {
warn("No control connection for command");
fmt = va_arg(ap, char *);
vfprintf(cout, fmt, ap);
va_end(ap);
- fprintf(cout, "\r\n");
- (void) fflush(cout);
+ fputs("\r\n", cout);
+ (void)fflush(cout);
cpend = 1;
r = getreply(!strcmp(fmt, "QUIT"));
if (abrtflag && oldintr != SIG_IGN)
(*oldintr)(SIGINT);
- (void) signal(SIGINT, oldintr);
+ (void)signal(SIGINT, oldintr);
return (r);
}
case WONT:
c = getc(cin);
fprintf(cout, "%c%c%c", IAC, DONT, c);
- (void) fflush(cout);
+ (void)fflush(cout);
break;
case DO:
case DONT:
c = getc(cin);
fprintf(cout, "%c%c%c", IAC, WONT, c);
- (void) fflush(cout);
+ (void)fflush(cout);
break;
default:
break;
dig++;
if (c == EOF) {
if (expecteof) {
- (void) signal(SIGINT, oldintr);
+ (void)signal(SIGINT, oldintr);
code = 221;
return (0);
}
lostpeer();
if (verbose) {
- printf("421 Service not available, "
- "remote server has closed "
- "connection\n");
- (void) fflush(stdout);
+ puts(
+"421 Service not available, remote server has closed connection");
+ (void)fflush(stdout);
}
code = 421;
return (4);
}
if (c != '\r' && (verbose > 0 ||
- (verbose > -1 && n == '5' && dig > 4))) {
+ (verbose > -1 && n == '5' && dig > 4)) &&
+ (n < '5' || !retry_connect)) {
if (proxflag &&
(dig == 1 || (dig == 5 && verbose == 0)))
printf("%s:", hostname);
- (void) putchar(c);
+ (void)putchar(c);
}
if (dig < 4 && isdigit(c))
code = code * 10 + (c - '0');
if (cp < ¤t_line[sizeof(current_line) - 1])
*cp++ = c;
}
- if (verbose > 0 || (verbose > -1 && n == '5')) {
- (void) putchar(c);
- (void) fflush (stdout);
+ if (verbose > 0 || ((verbose > -1 && n == '5') &&
+ (n < '5' || !retry_connect))) {
+ (void)putchar(c);
+ (void)fflush (stdout);
}
if (line == 0) {
size_t len = cp - current_line;
if (len > sizeof(reply_string))
len = sizeof(reply_string);
- (void) strncpy(reply_string, current_line, len);
+ (void)strncpy(reply_string, current_line, len);
reply_string[len] = '\0';
}
if (continuation && code != originalcode) {
*cp = '\0';
if (n != '1')
cpend = 0;
- (void) signal(SIGINT, oldintr);
+ (void)signal(SIGINT, oldintr);
if (code == 421 || originalcode == 421)
lostpeer();
if (abrtflag && oldintr != cmdabort && oldintr != SIG_IGN)
alarmtimer(0);
mflag = 0;
abrtflag = 0;
- printf("\nsend aborted\nwaiting for remote to finish abort\n");
- (void) fflush(stdout);
+ puts("\nsend aborted\nwaiting for remote to finish abort");
+ (void)fflush(stdout);
longjmp(sendabort, 1);
}
lmode = "w";
if (setjmp(sendabort)) {
while (cpend) {
- (void) getreply(0);
+ (void)getreply(0);
}
if (data >= 0) {
- (void) close(data);
+ (void)close(data);
data = -1;
}
if (oldintr)
- (void) signal(SIGINT, oldintr);
+ (void)signal(SIGINT, oldintr);
if (oldintp)
- (void) signal(SIGPIPE, oldintp);
+ (void)signal(SIGPIPE, oldintp);
if (oldinti)
- (void) signal(SIGINFO, oldinti);
+ (void)signal(SIGINFO, oldinti);
code = -1;
return;
}
fin = popen(local + 1, "r");
if (fin == NULL) {
warn("%s", local + 1);
- (void) signal(SIGINT, oldintr);
- (void) signal(SIGPIPE, oldintp);
- (void) signal(SIGINFO, oldinti);
+ (void)signal(SIGINT, oldintr);
+ (void)signal(SIGPIPE, oldintp);
+ (void)signal(SIGINFO, oldinti);
code = -1;
return;
}
fin = fopen(local, "r");
if (fin == NULL) {
warn("local: %s", local);
- (void) signal(SIGINT, oldintr);
- (void) signal(SIGINFO, oldinti);
+ (void)signal(SIGINT, oldintr);
+ (void)signal(SIGINFO, oldinti);
code = -1;
return;
}
closefunc = fclose;
if (fstat(fileno(fin), &st) < 0 ||
(st.st_mode&S_IFMT) != S_IFREG) {
- fprintf(stdout, "%s: not a plain file.\n", local);
- (void) signal(SIGINT, oldintr);
- (void) signal(SIGINFO, oldinti);
+ printf("%s: not a plain file.\n", local);
+ (void)signal(SIGINT, oldintr);
+ (void)signal(SIGINFO, oldinti);
fclose(fin);
code = -1;
return;
filesize = st.st_size;
}
if (initconn()) {
- (void) signal(SIGINT, oldintr);
- (void) signal(SIGINFO, oldinti);
+ (void)signal(SIGINT, oldintr);
+ (void)signal(SIGINFO, oldinti);
if (oldintp)
- (void) signal(SIGPIPE, oldintp);
+ (void)signal(SIGPIPE, oldintp);
code = -1;
if (closefunc != NULL)
(*closefunc)(fin);
}
if (remote) {
if (command("%s %s", cmd, remote) != PRELIM) {
- (void) signal(SIGINT, oldintr);
- (void) signal(SIGINFO, oldinti);
+ (void)signal(SIGINT, oldintr);
+ (void)signal(SIGINFO, oldinti);
if (oldintp)
- (void) signal(SIGPIPE, oldintp);
+ (void)signal(SIGPIPE, oldintp);
if (closefunc != NULL)
(*closefunc)(fin);
return;
}
} else
if (command("%s", cmd) != PRELIM) {
- (void) signal(SIGINT, oldintr);
- (void) signal(SIGINFO, oldinti);
+ (void)signal(SIGINT, oldintr);
+ (void)signal(SIGINFO, oldinti);
if (oldintp)
- (void) signal(SIGPIPE, oldintp);
+ (void)signal(SIGPIPE, oldintp);
if (closefunc != NULL)
(*closefunc)(fin);
return;
case TYPE_I:
case TYPE_L:
errno = d = 0;
- while ((c = read(fileno(fin), buf, sizeof (buf))) > 0) {
+ while ((c = read(fileno(fin), buf, sizeof(buf))) > 0) {
bytes += c;
for (bufp = buf; c > 0; c -= d, bufp += d)
if ((d = write(fileno(dout), bufp, c)) <= 0)
break;
if (hash && (!progress || filesize < 0) ) {
while (bytes >= hashbytes) {
- (void) putchar('#');
+ (void)putchar('#');
hashbytes += mark;
}
- (void) fflush(stdout);
+ (void)fflush(stdout);
}
}
if (hash && (!progress || filesize < 0) && bytes > 0) {
if (bytes < mark)
- (void) putchar('#');
- (void) putchar('\n');
- (void) fflush(stdout);
+ (void)putchar('#');
+ (void)putchar('\n');
+ (void)fflush(stdout);
}
if (c < 0)
warn("local: %s", local);
if (c == '\n') {
while (hash && (!progress || filesize < 0) &&
(bytes >= hashbytes)) {
- (void) putchar('#');
- (void) fflush(stdout);
+ (void)putchar('#');
+ (void)fflush(stdout);
hashbytes += mark;
}
if (ferror(dout))
break;
- (void) putc('\r', dout);
+ (void)putc('\r', dout);
bytes++;
}
- (void) putc(c, dout);
+ (void)putc(c, dout);
bytes++;
#if 0 /* this violates RFC */
if (c == '\r') {
}
if (hash && (!progress || filesize < 0)) {
if (bytes < hashbytes)
- (void) putchar('#');
- (void) putchar('\n');
- (void) fflush(stdout);
+ (void)putchar('#');
+ (void)putchar('\n');
+ (void)fflush(stdout);
}
if (ferror(fin))
warn("local: %s", local);
progressmeter(1);
if (closefunc != NULL)
(*closefunc)(fin);
- (void) fclose(dout);
- (void) getreply(0);
- (void) signal(SIGINT, oldintr);
- (void) signal(SIGINFO, oldinti);
+ (void)fclose(dout);
+ (void)getreply(0);
+ (void)signal(SIGINT, oldintr);
+ (void)signal(SIGINFO, oldinti);
if (oldintp)
- (void) signal(SIGPIPE, oldintp);
+ (void)signal(SIGPIPE, oldintp);
if (bytes > 0)
ptransfer(0);
return;
abort:
- (void) signal(SIGINT, oldintr);
- (void) signal(SIGINFO, oldinti);
+ (void)signal(SIGINT, oldintr);
+ (void)signal(SIGINFO, oldinti);
if (oldintp)
- (void) signal(SIGPIPE, oldintp);
+ (void)signal(SIGPIPE, oldintp);
if (!cpend) {
code = -1;
return;
}
if (data >= 0) {
- (void) close(data);
+ (void)close(data);
data = -1;
}
if (dout)
- (void) fclose(dout);
- (void) getreply(0);
+ (void)fclose(dout);
+ (void)getreply(0);
code = -1;
if (closefunc != NULL && fin != NULL)
(*closefunc)(fin);
alarmtimer(0);
mflag = 0;
abrtflag = 0;
- printf("\nreceive aborted\nwaiting for remote to finish abort\n");
- (void) fflush(stdout);
+ puts("\nreceive aborted\nwaiting for remote to finish abort");
+ (void)fflush(stdout);
longjmp(recvabort, 1);
}
tcrflag = !crflag && is_retr;
if (setjmp(recvabort)) {
while (cpend) {
- (void) getreply(0);
+ (void)getreply(0);
}
if (data >= 0) {
- (void) close(data);
+ (void)close(data);
data = -1;
}
if (oldintr)
- (void) signal(SIGINT, oldintr);
+ (void)signal(SIGINT, oldintr);
if (oldinti)
- (void) signal(SIGINFO, oldinti);
+ (void)signal(SIGINFO, oldinti);
code = -1;
return;
}
if (errno != ENOENT && errno != EACCES) {
warn("local: %s", local);
- (void) signal(SIGINT, oldintr);
- (void) signal(SIGINFO, oldinti);
+ (void)signal(SIGINT, oldintr);
+ (void)signal(SIGINFO, oldinti);
code = -1;
return;
}
*dir = '/';
if (d < 0) {
warn("local: %s", local);
- (void) signal(SIGINT, oldintr);
- (void) signal(SIGINFO, oldinti);
+ (void)signal(SIGINT, oldintr);
+ (void)signal(SIGINFO, oldinti);
code = -1;
return;
}
if (!runique && errno == EACCES &&
chmod(local, 0600) < 0) {
warn("local: %s", local);
- (void) signal(SIGINT, oldintr);
- (void) signal(SIGINFO, oldinti);
+ (void)signal(SIGINT, oldintr);
+ (void)signal(SIGINFO, oldinti);
code = -1;
return;
}
if (runique && errno == EACCES &&
(local = gunique(local)) == NULL) {
- (void) signal(SIGINT, oldintr);
- (void) signal(SIGINFO, oldinti);
+ (void)signal(SIGINT, oldintr);
+ (void)signal(SIGINFO, oldinti);
code = -1;
return;
}
}
else if (runique && (local = gunique(local)) == NULL) {
- (void) signal(SIGINT, oldintr);
- (void) signal(SIGINFO, oldinti);
+ (void)signal(SIGINT, oldintr);
+ (void)signal(SIGINFO, oldinti);
code = -1;
return;
}
filesize = remotesize(remote, 0);
}
if (initconn()) {
- (void) signal(SIGINT, oldintr);
- (void) signal(SIGINFO, oldinti);
+ (void)signal(SIGINT, oldintr);
+ (void)signal(SIGINFO, oldinti);
code = -1;
return;
}
return;
if (remote) {
if (command("%s %s", cmd, remote) != PRELIM) {
- (void) signal(SIGINT, oldintr);
- (void) signal(SIGINFO, oldinti);
+ (void)signal(SIGINT, oldintr);
+ (void)signal(SIGINFO, oldinti);
return;
}
} else {
if (command("%s", cmd) != PRELIM) {
- (void) signal(SIGINT, oldintr);
- (void) signal(SIGINFO, oldinti);
+ (void)signal(SIGINT, oldintr);
+ (void)signal(SIGINFO, oldinti);
return;
}
}
st.st_blksize = BUFSIZ;
if (st.st_blksize > bufsize) {
if (buf)
- (void) free(buf);
+ (void)free(buf);
buf = malloc((unsigned)st.st_blksize);
if (buf == NULL) {
warn("malloc");
bytes += c;
if (hash && (!progress || filesize < 0)) {
while (bytes >= hashbytes) {
- (void) putchar('#');
+ (void)putchar('#');
hashbytes += mark;
}
- (void) fflush(stdout);
+ (void)fflush(stdout);
}
}
if (hash && (!progress || filesize < 0) && bytes > 0) {
if (bytes < mark)
- (void) putchar('#');
- (void) putchar('\n');
- (void) fflush(stdout);
+ (void)putchar('#');
+ (void)putchar('\n');
+ (void)fflush(stdout);
}
if (c < 0) {
if (errno != EPIPE)
while (c == '\r') {
while (hash && (!progress || filesize < 0) &&
(bytes >= hashbytes)) {
- (void) putchar('#');
- (void) fflush(stdout);
+ (void)putchar('#');
+ (void)fflush(stdout);
hashbytes += mark;
}
bytes++;
if ((c = getc(din)) != '\n' || tcrflag) {
if (ferror(fout))
goto break2;
- (void) putc('\r', fout);
+ (void)putc('\r', fout);
if (c == '\0') {
bytes++;
goto contin2;
goto contin2;
}
}
- (void) putc(c, fout);
+ (void)putc(c, fout);
bytes++;
contin2: ;
}
break2:
if (bare_lfs) {
- printf("WARNING! %d bare linefeeds received in ASCII "
- "mode\n", bare_lfs);
- printf("File may not have transferred correctly.\n");
+ printf("WARNING! %d bare linefeeds received in ASCII mode\n",
+ bare_lfs);
+ puts("File may not have transferred correctly.");
}
if (hash && (!progress || filesize < 0)) {
if (bytes < hashbytes)
- (void) putchar('#');
- (void) putchar('\n');
- (void) fflush(stdout);
+ (void)putchar('#');
+ (void)putchar('\n');
+ (void)fflush(stdout);
}
if (ferror(din)) {
if (errno != EPIPE)
progressmeter(1);
if (closefunc != NULL)
(*closefunc)(fout);
- (void) signal(SIGINT, oldintr);
- (void) signal(SIGINFO, oldinti);
+ (void)signal(SIGINT, oldintr);
+ (void)signal(SIGINFO, oldinti);
if (oldintp)
- (void) signal(SIGPIPE, oldintp);
- (void) fclose(din);
- (void) getreply(0);
+ (void)signal(SIGPIPE, oldintp);
+ (void)fclose(din);
+ (void)getreply(0);
if (bytes >= 0 && is_retr) {
if (bytes > 0)
ptransfer(0);
if (preserve && (closefunc == fclose)) {
mtime = remotemodtime(remote, 0);
if (mtime != -1) {
- (void) gettimeofday(&tval[0],
+ (void)gettimeofday(&tval[0],
(struct timezone *)0);
tval[1].tv_sec = mtime;
tval[1].tv_usec = 0;
if (utimes(local, tval) == -1) {
- printf("Can't change modification time "
- "on %s to %s", local,
- asctime(localtime(&mtime)));
+ printf("Can't change modification time on %s to %s",
+ local, asctime(localtime(&mtime)));
}
}
}
/* abort using RFC959 recommended IP,SYNC sequence */
if (oldintp)
- (void) signal(SIGPIPE, oldintp);
- (void) signal(SIGINT, SIG_IGN);
+ (void)signal(SIGPIPE, oldintp);
+ (void)signal(SIGINT, SIG_IGN);
if (!cpend) {
code = -1;
- (void) signal(SIGINT, oldintr);
- (void) signal(SIGINFO, oldinti);
+ (void)signal(SIGINT, oldintr);
+ (void)signal(SIGINFO, oldinti);
return;
}
abort_remote(din);
code = -1;
if (data >= 0) {
- (void) close(data);
+ (void)close(data);
data = -1;
}
if (closefunc != NULL && fout != NULL)
(*closefunc)(fout);
if (din)
- (void) fclose(din);
+ (void)fclose(din);
if (bytes > 0)
ptransfer(0);
- (void) signal(SIGINT, oldintr);
- (void) signal(SIGINFO, oldinti);
+ (void)signal(SIGINT, oldintr);
+ (void)signal(SIGINFO, oldinti);
}
/*
}
if ((options & SO_DEBUG) &&
setsockopt(data, SOL_SOCKET, SO_DEBUG, (char *)&on,
- sizeof (on)) < 0)
+ sizeof(on)) < 0)
warn("setsockopt (ignored)");
if (command("PASV") != COMPLETE) {
- printf("Passive mode refused.\n");
+ puts("Passive mode refused.");
goto bad;
}
if (sscanf(pasv, "%d,%d,%d,%d,%d,%d",
&a0, &a1, &a2, &a3, &p0, &p1) != 6) {
- printf("Passive mode address scan failure. "
- "Shouldn't happen!\n");
+ puts("Passive mode address scan failure. Shouldn't happen!");
goto bad;
}
if (sendport)
data_addr.sin_port = 0; /* let system pick one */
if (data != -1)
- (void) close(data);
+ (void)close(data);
data = socket(AF_INET, SOCK_STREAM, 0);
if (data < 0) {
warn("socket");
}
if (!sendport)
if (setsockopt(data, SOL_SOCKET, SO_REUSEADDR, (char *)&on,
- sizeof (on)) < 0) {
+ sizeof(on)) < 0) {
warn("setsockopt (reuse address)");
goto bad;
}
- if (bind(data, (struct sockaddr *)&data_addr, sizeof (data_addr)) < 0) {
+ if (bind(data, (struct sockaddr *)&data_addr, sizeof(data_addr)) < 0) {
warn("bind");
goto bad;
}
if (options & SO_DEBUG &&
setsockopt(data, SOL_SOCKET, SO_DEBUG, (char *)&on,
- sizeof (on)) < 0)
+ sizeof(on)) < 0)
warn("setsockopt (ignored)");
- len = sizeof (data_addr);
+ len = sizeof(data_addr);
if (getsockname(data, (struct sockaddr *)&data_addr, &len) < 0) {
warn("getsockname");
goto bad;
#endif
return (0);
bad:
- (void) close(data), data = -1;
+ (void)close(data), data = -1;
if (tmpno)
sendport = 1;
return (1);
const char *lmode;
{
struct sockaddr_in from;
- int s, fromlen = sizeof (from), tos;
+ int s, fromlen = sizeof(from), tos;
if (passivemode)
return (fdopen(data, lmode));
s = accept(data, (struct sockaddr *) &from, &fromlen);
if (s < 0) {
warn("accept");
- (void) close(data), data = -1;
+ (void)close(data), data = -1;
return (NULL);
}
- (void) close(data);
+ (void)close(data);
data = s;
#ifdef IP_TOS
tos = IPTOS_THROUGHPUT;
ip->connect = connected;
connected = op->connect;
if (hostname) {
- (void) strncpy(ip->name, hostname, sizeof(ip->name) - 1);
- ip->name[strlen(ip->name)] = '\0';
+ (void)strncpy(ip->name, hostname, sizeof(ip->name) - 1);
+ ip->name[sizeof(ip->name) - 1] = '\0';
} else
- ip->name[0] = 0;
+ ip->name[0] = '\0';
hostname = op->name;
ip->hctl = hisctladdr;
hisctladdr = op->hctl;
mcase = op->mcse;
ip->ntflg = ntflag;
ntflag = op->ntflg;
- (void) strncpy(ip->nti, ntin, 16);
- (ip->nti)[strlen(ip->nti)] = '\0';
- (void) strcpy(ntin, op->nti);
- (void) strncpy(ip->nto, ntout, 16);
- (ip->nto)[strlen(ip->nto)] = '\0';
- (void) strcpy(ntout, op->nto);
+ (void)strncpy(ip->nti, ntin, sizeof(ip->nti) - 1);
+ (ip->nti)[sizeof(ip->nti) - 1] = '\0';
+ (void)strcpy(ntin, op->nti);
+ (void)strncpy(ip->nto, ntout, sizeof(ip->nto) - 1);
+ (ip->nto)[sizeof(ip->nto) - 1] = '\0';
+ (void)strcpy(ntout, op->nto);
ip->mapflg = mapflag;
mapflag = op->mapflg;
- (void) strncpy(ip->mi, mapin, MAXPATHLEN - 1);
- (ip->mi)[strlen(ip->mi)] = '\0';
- (void) strcpy(mapin, op->mi);
- (void) strncpy(ip->mo, mapout, MAXPATHLEN - 1);
- (ip->mo)[strlen(ip->mo)] = '\0';
- (void) strcpy(mapout, op->mo);
- (void) signal(SIGINT, oldintr);
+ (void)strncpy(ip->mi, mapin, sizeof(ip->mi) - 1);
+ (ip->mi)[sizeof(ip->mi) - 1] = '\0';
+ (void)strcpy(mapin, op->mi);
+ (void)strncpy(ip->mo, mapout, sizeof(ip->mo) - 1);
+ (ip->mo)[sizeof(ip->mo) - 1] = '\0';
+ (void)strcpy(mapout, op->mo);
+ (void)signal(SIGINT, oldintr);
if (abrtflag) {
abrtflag = 0;
(*oldintr)(SIGINT);
{
alarmtimer(0);
- printf("\n");
- (void) fflush(stdout);
+ putchar('\n');
+ (void)fflush(stdout);
ptabflg++;
mflag = 0;
abrtflag = 0;
if (curtype != prox_type)
changetype(prox_type, 1);
if (command("PASV") != COMPLETE) {
- printf("proxy server does not support third party "
- "transfers.\n");
+ puts("proxy server does not support third party transfers.");
return;
}
pswitch(0);
if (!connected) {
- printf("No primary connection\n");
+ puts("No primary connection");
pswitch(1);
code = -1;
return;
goto abort;
oldintr = signal(SIGINT, abortpt);
if (command("%s %s", cmd, remote) != PRELIM) {
- (void) signal(SIGINT, oldintr);
+ (void)signal(SIGINT, oldintr);
pswitch(1);
return;
}
if (command("%s %s", cmd2, local) != PRELIM)
goto abort;
ptflag++;
- (void) getreply(0);
+ (void)getreply(0);
pswitch(0);
- (void) getreply(0);
- (void) signal(SIGINT, oldintr);
+ (void)getreply(0);
+ (void)signal(SIGINT, oldintr);
pswitch(1);
ptflag = 0;
printf("local: %s remote: %s\n", local, remote);
return;
abort:
- (void) signal(SIGINT, SIG_IGN);
+ (void)signal(SIGINT, SIG_IGN);
ptflag = 0;
if (strcmp(cmd, "RETR") && !proxy)
pswitch(1);
pswitch(1);
if (ptabflg)
code = -1;
- (void) signal(SIGINT, oldintr);
+ (void)signal(SIGINT, oldintr);
return;
}
if (cpend)
pswitch(1);
if (ptabflg)
code = -1;
- (void) signal(SIGINT, oldintr);
+ (void)signal(SIGINT, oldintr);
return;
}
}
code = -1;
lostpeer();
}
- (void) getreply(0);
- (void) getreply(0);
+ (void)getreply(0);
+ (void)getreply(0);
}
if (proxy)
pswitch(0);
pswitch(1);
if (ptabflg)
code = -1;
- (void) signal(SIGINT, oldintr);
+ (void)signal(SIGINT, oldintr);
}
void
lostpeer();
}
else if (nfnd) {
- (void) getreply(0);
+ (void)getreply(0);
}
}
}
warn("local: %s", local);
return ((char *) 0);
}
- (void) strcpy(new, local);
+ (void)strcpy(new, local);
cp = new + strlen(new);
*cp++ = '.';
while (!d) {
if (++count == 100) {
- printf("runique: can't find unique file name.\n");
+ puts("runique: can't find unique file name.");
return ((char *) 0);
}
*cp++ = ext;
if (send(fileno(cout), buf, 3, MSG_OOB) != 3)
warn("abort");
fprintf(cout, "%cABOR\r\n", DM);
- (void) fflush(cout);
+ (void)fflush(cout);
FD_ZERO(&mask);
FD_SET(fileno(cin), &mask);
if (din) {
}
if (getreply(0) == ERROR && code == 552) {
/* 552 needed for nic style abort */
- (void) getreply(0);
+ (void)getreply(0);
}
- (void) getreply(0);
+ (void)getreply(0);
}
+/* $OpenBSD: ftp_var.h,v 1.7 1997/02/03 01:05:41 millert Exp $ */
/* $NetBSD: ftp_var.h,v 1.13 1997/02/01 10:45:05 lukem Exp $ */
/*
#include <sys/param.h>
#include <setjmp.h>
-#include <stringlist.h>
#ifndef SMALLFTP
#include <histedit.h>
#endif /* !SMALLFTP */
+#include "stringlist.h"
#include "extern.h"
#define HASHBYTES 1024
int bytesize; /* local byte size in binary */
int anonftp; /* automatic anonymous login */
int dirchange; /* remote directory changed by cd command */
+int retry_connect; /* retry connect if failed */
int ttywidth; /* width of tty */
#ifndef SMALLFTP
+/* $OpenBSD: main.c,v 1.18 1997/02/03 01:05:42 millert Exp $ */
/* $NetBSD: main.c,v 1.17 1997/02/01 10:45:07 lukem Exp $ */
/*
#if 0
static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 10/9/94";
#else
-static char rcsid[] = "$NetBSD: main.c,v 1.17 1997/02/01 10:45:07 lukem Exp $";
+static char rcsid[] = "$OpenBSD: main.c,v 1.18 1997/02/03 01:05:42 millert Exp $";
#endif
#endif /* not lint */
#include <sys/types.h>
#include <sys/socket.h>
+#include <ctype.h>
#include <err.h>
#include <netdb.h>
#include <pwd.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <unistd.h>
if (isatty(fileno(stdout)))
progress = 1; /* progress bar on if going to a tty */
- while ((ch = getopt(argc, argv, "adginpP:tvV")) != EOF) {
+ while ((ch = getopt(argc, argv, "adginpPr:tvV")) != -1) {
switch (ch) {
case 'a':
anonftp = 1;
case 'P':
port = atoi(optarg);
if (port <= 0)
- warnx("bad port number: %s", optarg);
+ warnx("bad port number: %s (ignored)", optarg);
else
ftpport = htons(port);
break;
+ case 'r':
+ if (isdigit(*optarg))
+ retry_connect = atoi(optarg);
+ else
+ errx(1, "-r requires numeric argument");
+ break;
+
case 't':
trace = 1;
break;
pw = getpwuid(getuid());
if (pw != NULL) {
home = homedir;
- (void) strcpy(home, pw->pw_dir);
+ (void)strcpy(home, pw->pw_dir);
}
#ifndef SMALLFTP
#endif /* !SMALLFTP */
setttywidth(0);
- (void) signal(SIGWINCH, setttywidth);
+ (void)signal(SIGWINCH, setttywidth);
if (argc > 0) {
if (strchr(argv[0], ':') != NULL) {
if (setjmp(toplevel))
exit(0);
- (void) signal(SIGINT, intr);
- (void) signal(SIGPIPE, lostpeer);
+ (void)signal(SIGINT, intr);
+ (void)signal(SIGPIPE, lostpeer);
xargv[0] = __progname;
xargv[1] = argv[0];
xargv[2] = argv[1];
xargv[3] = argv[2];
xargv[4] = NULL;
- setpeer(argc+1, xargv);
+ do {
+ setpeer(argc+1, xargv);
+ if (!retry_connect)
+ break;
+ if (!connected) {
+ macnum = 0;
+ puts("Retrying...");
+ sleep(retry_connect);
+ }
+ } while (!connected);
}
}
top = setjmp(toplevel) == 0;
if (top) {
- (void) signal(SIGINT, intr);
- (void) signal(SIGPIPE, lostpeer);
+ (void)signal(SIGINT, intr);
+ (void)signal(SIGPIPE, lostpeer);
}
for (;;) {
cmdscanner(top);
alarmtimer(0);
if (connected) {
if (cout != NULL) {
- (void) shutdown(fileno(cout), 1+1);
- (void) fclose(cout);
+ (void)shutdown(fileno(cout), 1+1);
+ (void)fclose(cout);
cout = NULL;
}
if (data >= 0) {
- (void) shutdown(data, 1+1);
- (void) close(data);
+ (void)shutdown(data, 1+1);
+ (void)close(data);
data = -1;
}
connected = 0;
pswitch(1);
if (connected) {
if (cout != NULL) {
- (void) shutdown(fileno(cout), 1+1);
- (void) fclose(cout);
+ (void)shutdown(fileno(cout), 1+1);
+ (void)fclose(cout);
cout = NULL;
}
connected = 0;
&& !editing
#endif /* !SMALLFTP */
)
- (void) putchar('\n');
+ (void)putchar('\n');
for (;;) {
#ifndef SMALLFTP
if (!editing) {
#endif /* !SMALLFTP */
if (fromatty) {
- printf("%s", prompt());
- (void) fflush(stdout);
+ fputs(prompt(), stdout);
+ (void)fflush(stdout);
}
if (fgets(line, sizeof(line), stdin) == NULL)
quit(0, 0);
break;
line[num] = '\0';
} else if (num == sizeof(line) - 2) {
- printf("sorry, input line too long\n");
+ puts("sorry, input line too long");
while ((num = getchar()) != '\n' && num != EOF)
/* void */;
break;
if (num == 0)
break;
} else if (num >= sizeof(line)) {
- printf("sorry, input line too long\n");
+ puts("sorry, input line too long");
break;
}
memcpy(line, buf, num);
#endif /* !SMALLFTP */
c = getcmd(margv[0]);
if (c == (struct cmd *)-1) {
- printf("?Ambiguous command\n");
+ puts("?Ambiguous command");
continue;
}
if (c == 0) {
- printf("?Invalid command\n");
+ puts("?Invalid command");
continue;
}
if (c->c_conn && !connected) {
- printf("Not connected.\n");
+ puts("Not connected.");
continue;
}
confirmrest = 0;
(*c->c_handler)(margc, margv);
if (bell && c->c_bell)
- (void) putchar('\007');
+ (void)putchar('\007');
if (c->c_handler != help)
break;
}
- (void) signal(SIGINT, intr);
- (void) signal(SIGPIPE, lostpeer);
+ (void)signal(SIGINT, intr);
+ (void)signal(SIGPIPE, lostpeer);
}
struct cmd *
return;
}
-#define HELPINDENT ((int) sizeof ("disconnect"))
+#define HELPINDENT ((int) sizeof("disconnect"))
while (--argc > 0) {
char *arg;
usage()
{
(void)fprintf(stderr,
- "usage: %s [-adginptvV] [host [port]]\n"
+ "usage: %s [-adginprtvV] [host [port]]\n"
" %s host:path[/]\n"
" %s ftp://host[:port]/path[/]\n"
" %s http://host[:port]/file\n",
+/* $OpenBSD: pathnames.h,v 1.5 1997/02/03 01:05:43 millert Exp $ */
/* $NetBSD: pathnames.h,v 1.7 1997/01/09 20:19:40 tls Exp $ */
/*
+/* $OpenBSD: ruserpass.c,v 1.5 1997/02/03 01:05:44 millert Exp $ */
/* $NetBSD: ruserpass.c,v 1.11 1997/01/19 14:19:16 lukem Exp $ */
/*
#if 0
static char sccsid[] = "@(#)ruserpass.c 8.4 (Berkeley) 4/27/95";
#else
-static char rcsid[] = "$NetBSD: ruserpass.c,v 1.11 1997/01/19 14:19:16 lukem Exp $";
+static char rcsid[] = "$OpenBSD: ruserpass.c,v 1.5 1997/02/03 01:05:44 millert Exp $";
#endif
#endif /* not lint */
if (hdir == NULL)
hdir = ".";
if (strlen(hdir) + sizeof(".netrc") < sizeof(buf)) {
- (void) sprintf(buf, "%s/.netrc", hdir);
+ (void)sprintf(buf, "%s/.netrc", hdir);
} else {
warnx("%s/.netrc: %s", hdir, strerror(ENAMETOOLONG));
return (0);
if (*aname == 0) {
*aname = malloc((unsigned)
strlen(tokval) + 1);
- (void) strcpy(*aname, tokval);
+ (void)strcpy(*aname, tokval);
} else {
if (strcmp(*aname, tokval))
goto next;
}
if (token() && *apass == 0) {
*apass = malloc((unsigned) strlen(tokval) + 1);
- (void) strcpy(*apass, tokval);
+ (void)strcpy(*apass, tokval);
}
break;
case ACCOUNT:
}
if (token() && *aacct == 0) {
*aacct = malloc((unsigned) strlen(tokval) + 1);
- (void) strcpy(*aacct, tokval);
+ (void)strcpy(*aacct, tokval);
}
break;
case MACDEF:
if (proxy) {
- (void) fclose(cfile);
+ (void)fclose(cfile);
return (0);
}
while ((c=getc(cfile)) != EOF)
if (c != ' ' && c != '\t')
break;
if (c == EOF || c == '\n') {
- printf("Missing macdef name argument.\n");
+ puts("Missing macdef name argument.");
goto bad;
}
if (macnum == 16) {
- printf(
-"Limit of 16 macros have already been defined\n");
+ puts(
+"Limit of 16 macros have already been defined");
goto bad;
}
tmp = macros[macnum].mac_name;
*tmp++ = c;
}
if (c == EOF) {
- printf(
-"Macro definition missing null line terminator.\n");
+ puts(
+"Macro definition missing null line terminator.");
goto bad;
}
*tmp = '\0';
while ((c=getc(cfile)) != EOF && c != '\n');
}
if (c == EOF) {
- printf(
-"Macro definition missing null line terminator.\n");
+ puts(
+"Macro definition missing null line terminator.");
goto bad;
}
if (macnum == 0) {
tmp = macros[macnum].mac_start;
while (tmp != macbuf + 4096) {
if ((c=getc(cfile)) == EOF) {
- printf(
-"Macro definition missing null line terminator.\n");
+ puts(
+"Macro definition missing null line terminator.");
goto bad;
}
*tmp = c;
tmp++;
}
if (tmp == macbuf + 4096) {
- printf("4K macro buffer exceeded\n");
+ puts("4K macro buffer exceeded");
goto bad;
}
break;
goto done;
}
done:
- (void) fclose(cfile);
+ (void)fclose(cfile);
return (0);
bad:
- (void) fclose(cfile);
+ (void)fclose(cfile);
return (-1);
}
--- /dev/null
+/* $OpenBSD: stringlist.c,v 1.1 1997/02/03 01:05:44 millert Exp $ */
+/* $NetBSD: stringlist.c,v 1.2 1997/01/17 07:26:20 lukem Exp $ */
+
+/*
+ * Copyright (c) 1994 Christos Zoulas
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Christos Zoulas.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char *rcsid = "$OpenBSD: stringlist.c,v 1.1 1997/02/03 01:05:44 millert Exp $";
+#endif /* LIBC_SCCS and not lint */
+
+#include <stdio.h>
+#include <string.h>
+#include <err.h>
+#include <stdlib.h>
+
+#include "stringlist.h"
+
+#define _SL_CHUNKSIZE 20
+
+/*
+ * sl_init(): Initialize a string list
+ */
+StringList *
+sl_init()
+{
+ StringList *sl = malloc(sizeof(StringList));
+ if (sl == NULL)
+ _err(1, "stringlist: %m");
+
+ sl->sl_cur = 0;
+ sl->sl_max = _SL_CHUNKSIZE;
+ sl->sl_str = malloc(sl->sl_max * sizeof(char *));
+ if (sl->sl_str == NULL)
+ _err(1, "stringlist: %m");
+ return sl;
+}
+
+
+/*
+ * sl_add(): Add an item to the string list
+ */
+void
+sl_add(sl, name)
+ StringList *sl;
+ char *name;
+{
+ if (sl->sl_cur == sl->sl_max - 1) {
+ sl->sl_max += _SL_CHUNKSIZE;
+ sl->sl_str = realloc(sl->sl_str, sl->sl_max * sizeof(char *));
+ if (sl->sl_str == NULL)
+ _err(1, "stringlist: %m");
+ }
+ sl->sl_str[sl->sl_cur++] = name;
+}
+
+
+/*
+ * sl_free(): Free a stringlist
+ */
+void
+sl_free(sl, all)
+ StringList *sl;
+ int all;
+{
+ size_t i;
+
+ if (sl == NULL)
+ return;
+ if (sl->sl_str) {
+ if (all)
+ for (i = 0; i < sl->sl_cur; i++)
+ free(sl->sl_str[i]);
+ free(sl->sl_str);
+ }
+ free(sl);
+}
+
+
+/*
+ * sl_find(): Find a name in the string list
+ */
+char *
+sl_find(sl, name)
+ StringList *sl;
+ char *name;
+{
+ size_t i;
+
+ for (i = 0; i < sl->sl_cur; i++)
+ if (strcmp(sl->sl_str[i], name) == 0)
+ return sl->sl_str[i];
+
+ return NULL;
+}
--- /dev/null
+/* $OpenBSD: stringlist.h,v 1.1 1997/02/03 01:05:45 millert Exp $ */
+/* $NetBSD: stringlist.h,v 1.2 1997/01/17 06:11:36 lukem Exp $ */
+
+/*
+ * Copyright (c) 1994 Christos Zoulas
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Christos Zoulas.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ */
+
+#ifndef _STRINGLIST_H
+#define _STRINGLIST_H
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+
+/*
+ * Simple string list
+ */
+typedef struct _stringlist {
+ char **sl_str;
+ size_t sl_max;
+ size_t sl_cur;
+} StringList;
+
+__BEGIN_DECLS
+StringList *sl_init __P((void));
+void sl_add __P((StringList *, char *));
+void sl_free __P((StringList *, int));
+char *sl_find __P((StringList *, char *));
+__END_DECLS
+
+#endif /* _STRINGLIST_H */
+/* $OpenBSD: util.c,v 1.2 1997/02/03 01:05:46 millert Exp $ */
/* $NetBSD: util.c,v 1.4 1997/02/01 11:26:34 lukem Exp $ */
/*
*/
#ifndef lint
-static char rcsid[] = "$NetBSD: util.c,v 1.4 1997/02/01 11:26:34 lukem Exp $";
+static char rcsid[] = "$OpenBSD: util.c,v 1.2 1997/02/03 01:05:46 millert Exp $";
#endif /* not lint */
/*
#include <fcntl.h>
#include <glob.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
if (connected) {
printf("Already connected to %s, use close first.\n",
- hostname);
+ hostname);
code = -1;
return;
}
if (argc < 2)
- (void) another(&argc, &argv, "to");
+ (void)another(&argc, &argv, "to");
if (argc < 2 || argc > 3) {
printf("usage: %s host-name [port]\n", argv[0]);
code = -1;
/*
* Set up defaults for FTP.
*/
- (void) strcpy(typename, "ascii"), type = TYPE_A;
+ (void)strcpy(typename, "ascii"), type = TYPE_A;
curtype = TYPE_A;
- (void) strcpy(formname, "non-print"), form = FORM_N;
- (void) strcpy(modename, "stream"), mode = MODE_S;
- (void) strcpy(structname, "file"), stru = STRU_F;
- (void) strcpy(bytename, "8"), bytesize = 8;
+ (void)strcpy(formname, "non-print"), form = FORM_N;
+ (void)strcpy(modename, "stream"), mode = MODE_S;
+ (void)strcpy(structname, "file"), stru = STRU_F;
+ (void)strcpy(bytename, "8"), bytesize = 8;
if (autologin)
- (void) login(argv[1]);
+ (void)login(argv[1]);
+#if (defined(unix) || defined(BSD)) && NBBY == 8
+/*
+ * this ifdef is to keep someone form "porting" this to an incompatible
+ * system and not checking this out. This way they have to think about it.
+ */
overbose = verbose;
if (debug == 0)
verbose = -1;
*cp = '\0';
}
- printf("Remote system type is %s.\n",
- reply_string+4);
+ printf("Remote system type is %s.\n", reply_string + 4);
if (cp)
*cp = c;
}
* for text files unless changed by the user.
*/
type = 0;
- (void) strcpy(typename, "binary");
+ (void)strcpy(typename, "binary");
if (overbose)
printf("Using %s mode to transfer files.\n",
typename);
unix_server = 0;
if (overbose &&
!strncmp(reply_string, "215 TOPS20", 10))
- printf("Remember to set tenex mode when "
- "transferring binary files from this "
- "machine.\n");
+ puts(
+"Remember to set tenex mode when transferring binary files from this machine.");
}
verbose = overbose;
+#endif /* unix || BSD */
}
}
int len = strlen(line), ret;
if (len >= sizeof(line) - 3) {
- printf("sorry, arguments too long\n");
+ puts("sorry, arguments too long");
intr();
}
printf("(%s) ", prompt);
}
else {
if (ftemp) {
- (void) fclose(ftemp);
+ (void)fclose(ftemp);
ftemp = NULL;
}
}
return (cp);
}
if (ftemp == NULL) {
- (void) snprintf(temp, sizeof(temp), "%s%s", _PATH_TMP, TMPFILE)
+ (void)snprintf(temp, sizeof(temp), "%s%s", _PATH_TMP, TMPFILE)
;
fd = mkstemp(temp);
if (fd < 0) {
}
verbose = oldverbose; hash = oldhash;
ftemp = fopen(temp, "r");
- (void) unlink(temp);
+ (void)unlink(temp);
if (ftemp == NULL) {
- printf("can't find list of remote files, oops\n");
+ puts("can't find list of remote files, oops");
return (NULL);
}
}
- if (fgets(buf, sizeof (buf), ftemp) == NULL) {
- (void) fclose(ftemp), ftemp = NULL;
+ if (fgets(buf, sizeof(buf), ftemp) == NULL) {
+ (void)fclose(ftemp), ftemp = NULL;
return (NULL);
}
if ((cp = strchr(buf, '\n')) != NULL)
if (!interactive || confirmrest)
return (1);
printf("%s %s? ", cmd, file);
- (void) fflush(stdout);
+ (void)fflush(stdout);
if (fgets(line, sizeof(line), stdin) == NULL)
return (0);
switch (tolower(*line)) {
return (0);
case 'p':
interactive = 0;
- printf("Interactive mode: off\n");
+ puts("Interactive mode: off");
break;
case 'a':
confirmrest = 1;
else
rtime += timebuf.tm_gmtoff; /* conv. local -> GMT */
} else if (noisy && debug == 0)
- printf("%s\n", reply_string);
+ puts(reply_string);
verbose = overbose;
return (rtime);
}
char buf[256];
if (flag == -1) {
- (void) gettimeofday(&start, (struct timezone *)0);
+ (void)gettimeofday(&start, (struct timezone *)0);
lastupdate = start;
lastsize = restart_point;
}
- (void) gettimeofday(&now, (struct timezone *)0);
+ (void)gettimeofday(&now, (struct timezone *)0);
if (!progress || filesize <= 0)
return;
cursize = bytes + restart_point;
(void)write(STDOUT_FILENO, buf, strlen(buf));
if (flag == -1) {
- (void) signal(SIGALRM, updateprogressmeter);
+ (void)signal(SIGALRM, updateprogressmeter);
alarmtimer(1); /* set alarm timer for 1 Hz */
} else if (flag == 1) {
alarmtimer(0);
- (void) putchar('\n');
+ (void)putchar('\n');
}
fflush(stdout);
}
if (!verbose && !siginfo)
return;
- (void) gettimeofday(&now, (struct timezone *)0);
+ (void)gettimeofday(&now, (struct timezone *)0);
timersub(&now, &start, &td);
elapsed = td.tv_sec + (td.tv_usec / 1000000.0);
bs = bytes / (elapsed == 0.0 ? 1 : elapsed);
for (j = 0; j < columns; j++) {
p = sl->sl_str[j * lines + i];
if (p)
- printf("%s", p);
+ fputs(p, stdout);
if (j * lines + i + lines >= sl->sl_cur) {
- printf("\n");
+ putchar('\n');
break;
}
w = strlen(p);
while (w < width) {
w = (w + 8) &~ 7;
- (void) putchar('\t');
+ (void)putchar('\t');
}
}
}