From: millert Date: Wed, 5 Feb 1997 04:55:12 +0000 (+0000) Subject: Include signal.h where reasonable and make signal handlers match X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=db98d155d69911c00fb5fb2219dfb9ed847ff05d;p=openbsd Include signal.h where reasonable and make signal handlers match what signal(3)'s prototype says (and cast when not). Also change MAXFOO+1 -> MAXFOO since MAXFOO includes the NULL. Support $TMPDIR and use utime(3) not utimes(2) for portability's sake. Don't spew "Passive mode enabled/disabled" unless verbose (this means togglevar() needs to watch for a NULL 'message'). --- diff --git a/usr.bin/ftp/cmds.c b/usr.bin/ftp/cmds.c index 3f10868500c..bf3ffe662e2 100644 --- a/usr.bin/ftp/cmds.c +++ b/usr.bin/ftp/cmds.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmds.c,v 1.14 1997/02/03 01:05:33 millert Exp $ */ +/* $OpenBSD: cmds.c,v 1.15 1997/02/05 04:55:12 millert Exp $ */ /* $NetBSD: cmds.c,v 1.18 1997/02/01 10:44:54 lukem Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)cmds.c 8.6 (Berkeley) 10/9/94"; #else -static char rcsid[] = "$OpenBSD: cmds.c,v 1.14 1997/02/03 01:05:33 millert Exp $"; +static char rcsid[] = "$OpenBSD: cmds.c,v 1.15 1997/02/05 04:55:12 millert Exp $"; #endif #endif /* not lint */ @@ -119,7 +119,7 @@ settype(argc, argv) return; } if ((p->t_arg != NULL) && (*(p->t_arg) != '\0')) - comret = command ("TYPE %s %s", p->t_mode, p->t_arg); + comret = command("TYPE %s %s", p->t_mode, p->t_arg); else comret = command("TYPE %s", p->t_mode); if (comret == COMPLETE) { @@ -701,7 +701,8 @@ togglevar(argc, argv, var, mesg) printf("usage: %s [ on | off ]\n", argv[0]); return -1; } - printf("%s %s.\n", mesg, onoff(*var)); + if (mesg) + printf("%s %s.\n", mesg, onoff(*var)); return (*var); } @@ -1504,7 +1505,8 @@ account(argc, argv) jmp_buf abortprox; void -proxabort() +proxabort(notused) + int notused; { alarmtimer(0); @@ -1862,7 +1864,8 @@ setpassive(argc, argv) char *argv[]; { - code = togglevar(argc, argv, &passivemode, "Passive mode"); + code = togglevar(argc, argv, &passivemode, + verbose ? "Passive mode" : NULL); } void diff --git a/usr.bin/ftp/complete.c b/usr.bin/ftp/complete.c index 4a580e660b4..aee1b1868b1 100644 --- a/usr.bin/ftp/complete.c +++ b/usr.bin/ftp/complete.c @@ -1,4 +1,4 @@ -/* $OpenBSD: complete.c,v 1.2 1997/02/03 01:05:35 millert Exp $ */ +/* $OpenBSD: complete.c,v 1.3 1997/02/05 04:55:14 millert Exp $ */ /* $NetBSD: complete.c,v 1.2 1997/02/01 10:44:57 lukem Exp $ */ /*- @@ -38,7 +38,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: complete.c,v 1.2 1997/02/03 01:05:35 millert Exp $"; +static char rcsid[] = "$OpenBSD: complete.c,v 1.3 1997/02/05 04:55:14 millert Exp $"; #endif /* not lint */ /* @@ -77,7 +77,7 @@ complete_ambiguous(word, list, words) int list; StringList *words; { - char insertstr[MAXPATHLEN + 1]; + char insertstr[MAXPATHLEN]; char *lastmatch; int i, j, matchlen, wordlen; @@ -160,7 +160,7 @@ complete_local(word, list) int list; { StringList *words; - char dir[MAXPATHLEN + 1]; + char dir[MAXPATHLEN]; char *file; DIR *dd; struct dirent *dp; @@ -214,10 +214,10 @@ complete_remote(word, list) int list; { static StringList *dirlist; - static char lastdir[MAXPATHLEN + 1]; + static char lastdir[MAXPATHLEN]; static int ftpdslashbug; StringList *words; - char dir[MAXPATHLEN + 1]; + char dir[MAXPATHLEN]; char *file, *cp; int i, offset; unsigned char rv; diff --git a/usr.bin/ftp/extern.h b/usr.bin/ftp/extern.h index cfa536ce915..1ca06b5583b 100644 --- a/usr.bin/ftp/extern.h +++ b/usr.bin/ftp/extern.h @@ -1,5 +1,5 @@ /* $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 $ */ +/* $OpenBSD: extern.h,v 1.8 1997/02/05 04:55:15 millert Exp $ */ /*- * Copyright (c) 1994 The Regents of the University of California. @@ -39,10 +39,10 @@ struct fd_set; void abort_remote __P((FILE *)); -void abortpt __P(()); -void abortrecv __P(()); -void abortsend __P(()); -void aborthttp __P(()); +void abortpt __P((int)); +void abortrecv __P((int)); +void abortsend __P((int)); +void aborthttp __P((int)); void account __P((int, char **)); void alarmtimer __P((int)); int another __P((int *, char ***, const char *)); @@ -51,7 +51,7 @@ void blkfree __P((char **)); void cd __P((int, char **)); void cdup __P((int, char **)); void changetype __P((int, int)); -void cmdabort __P(()); +void cmdabort __P((int)); void cmdscanner __P((int)); int command __P(()); #ifndef SMALLFTP @@ -78,11 +78,11 @@ void help __P((int, char **)); char *hookup __P((const char *, int)); void idle __P((int, char **)); int initconn __P((void)); -void intr __P(()); +void intr __P((void)); void list_vertical __P((StringList *)); void lcd __P((int, char **)); int login __P((const char *)); -void lostpeer __P(()); +void lostpeer __P((void)); void lpwd __P((int, char **)); void ls __P((int, char **)); void mabort __P((int)); @@ -97,10 +97,10 @@ void mput __P((int, char **)); char *onoff __P((int)); void newer __P((int, char **)); void progressmeter __P((int)); -char *prompt __P(()); -void proxabort __P(()); +char *prompt __P((void)); +void proxabort __P((int)); void proxtrans __P((const char *, const char *, const char *)); -void psabort __P(()); +void psabort __P((int)); void psummary __P((int)); void pswitch __P((int)); void ptransfer __P((int)); @@ -157,7 +157,7 @@ char *slurpstring __P(()); void status __P((int, char **)); void syst __P((int, char **)); int togglevar __P((int, char **, int *, const char *)); -void usage __P(()); +void usage __P((void)); void user __P((int, char **)); diff --git a/usr.bin/ftp/fetch.c b/usr.bin/ftp/fetch.c index a6c59628ccd..81e1ea46c81 100644 --- a/usr.bin/ftp/fetch.c +++ b/usr.bin/ftp/fetch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fetch.c,v 1.2 1997/02/03 01:05:37 millert Exp $ */ +/* $OpenBSD: fetch.c,v 1.3 1997/02/05 04:55:16 millert Exp $ */ /* $NetBSD: fetch.c,v 1.2 1997/02/01 10:45:00 lukem Exp $ */ /*- @@ -38,7 +38,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: fetch.c,v 1.2 1997/02/03 01:05:37 millert Exp $"; +static char rcsid[] = "$OpenBSD: fetch.c,v 1.3 1997/02/05 04:55:16 millert Exp $"; #endif /* not lint */ /* @@ -58,6 +58,7 @@ static char rcsid[] = "$OpenBSD: fetch.c,v 1.2 1997/02/03 01:05:37 millert Exp $ #include #include #include +#include #include #include #include @@ -325,7 +326,8 @@ cleanup_http_get: * Abort a http retrieval */ void -aborthttp() +aborthttp(notused) + int notused; { alarmtimer(0); @@ -365,8 +367,8 @@ auto_fetch(argc, argv) disconnect(0, NULL); return (argpos + 1); } - (void)signal(SIGINT, intr); - (void)signal(SIGPIPE, lostpeer); + (void)signal(SIGINT, (sig_t)intr); + (void)signal(SIGPIPE, (sig_t)lostpeer); /* * Loop through as long as there's files to fetch. diff --git a/usr.bin/ftp/ftp.c b/usr.bin/ftp/ftp.c index 835007c8cbf..cb0e8ac8044 100644 --- a/usr.bin/ftp/ftp.c +++ b/usr.bin/ftp/ftp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ftp.c,v 1.11 1997/02/03 01:05:40 millert Exp $ */ +/* $OpenBSD: ftp.c,v 1.12 1997/02/05 04:55:18 millert Exp $ */ /* $NetBSD: ftp.c,v 1.22 1997/02/01 10:45:03 lukem Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)ftp.c 8.6 (Berkeley) 10/27/94"; #else -static char rcsid[] = "$OpenBSD: ftp.c,v 1.11 1997/02/03 01:05:40 millert Exp $"; +static char rcsid[] = "$OpenBSD: ftp.c,v 1.12 1997/02/05 04:55:18 millert Exp $"; #endif #endif /* not lint */ @@ -62,6 +62,7 @@ static char rcsid[] = "$OpenBSD: ftp.c,v 1.11 1997/02/03 01:05:40 millert Exp $" #include #include #include +#include #include #include "ftp_var.h" @@ -88,7 +89,7 @@ hookup(host, port) int s, len, tos; static char hostnamebuf[MAXHOSTNAMELEN]; - memset((char *)&hisctladdr, 0, sizeof(hisctladdr)); + memset((void *)&hisctladdr, 0, sizeof(hisctladdr)); if (inet_aton(host, &hisctladdr.sin_addr) != 0) { hisctladdr.sin_family = AF_INET; (void)strncpy(hostnamebuf, host, sizeof(hostnamebuf) - 1); @@ -194,8 +195,8 @@ login(host) { char tmp[80]; char *user, *pass, *acct; - char anonpass[MAXLOGNAME + MAXHOSTNAMELEN + 2]; /* "user@hostname\0" */ - char hostname[MAXHOSTNAMELEN + 1]; + char anonpass[MAXLOGNAME + 1 + MAXHOSTNAMELEN]; /* "user@hostname" */ + char hostname[MAXHOSTNAMELEN]; int n, aflag = 0; user = pass = acct = NULL; @@ -285,7 +286,8 @@ login(host) } void -cmdabort() +cmdabort(notused) + int notused; { alarmtimer(0); @@ -473,7 +475,8 @@ empty(mask, sec) jmp_buf sendabort; void -abortsend() +abortsend(notused) + int notused; { alarmtimer(0); @@ -750,7 +753,8 @@ abort: jmp_buf recvabort; void -abortrecv() +abortrecv(notused) + int notused; { alarmtimer(0); @@ -775,7 +779,6 @@ recvrequest(cmd, local, remote, lmode, printnames) off_t hashbytes; struct stat st; time_t mtime; - struct timeval tval[2]; hashbytes = mark; direction = "received"; @@ -1053,14 +1056,13 @@ break2: if (preserve && (closefunc == fclose)) { mtime = remotemodtime(remote, 0); if (mtime != -1) { - (void)gettimeofday(&tval[0], - (struct timezone *)0); - tval[1].tv_sec = mtime; - tval[1].tv_usec = 0; - if (utimes(local, tval) == -1) { + struct utimbuf ut; + + ut.actime = time(NULL); + ut.modtime = mtime; + if (utime(local, &ut) == -1) printf("Can't change modification time on %s to %s", local, asctime(localtime(&mtime))); - } } } } @@ -1261,7 +1263,8 @@ psummary(notused) } void -psabort() +psabort(notused) + int notused; { alarmtimer(0); @@ -1362,7 +1365,8 @@ pswitch(flag) } void -abortpt() +abortpt(notused) + int notused; { alarmtimer(0); diff --git a/usr.bin/ftp/main.c b/usr.bin/ftp/main.c index a4cc1fc4909..bcac82b4f75 100644 --- a/usr.bin/ftp/main.c +++ b/usr.bin/ftp/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.19 1997/02/03 01:22:08 millert Exp $ */ +/* $OpenBSD: main.c,v 1.20 1997/02/05 04:55:19 millert Exp $ */ /* $NetBSD: main.c,v 1.17 1997/02/01 10:45:07 lukem Exp $ */ /* @@ -44,7 +44,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 10/9/94"; #else -static char rcsid[] = "$OpenBSD: main.c,v 1.19 1997/02/03 01:22:08 millert Exp $"; +static char rcsid[] = "$OpenBSD: main.c,v 1.20 1997/02/05 04:55:19 millert Exp $"; #endif #endif /* not lint */ @@ -220,8 +220,8 @@ main(argc, argv) if (setjmp(toplevel)) exit(0); - (void)signal(SIGINT, intr); - (void)signal(SIGPIPE, lostpeer); + (void)signal(SIGINT, (sig_t)intr); + (void)signal(SIGPIPE, (sig_t)lostpeer); xargv[0] = __progname; xargv[1] = argv[0]; xargv[2] = argv[1]; @@ -241,8 +241,8 @@ main(argc, argv) } top = setjmp(toplevel) == 0; if (top) { - (void)signal(SIGINT, intr); - (void)signal(SIGPIPE, lostpeer); + (void)signal(SIGINT, (sig_t)intr); + (void)signal(SIGPIPE, (sig_t)lostpeer); } for (;;) { cmdscanner(top); @@ -388,8 +388,8 @@ cmdscanner(top) if (c->c_handler != help) break; } - (void)signal(SIGINT, intr); - (void)signal(SIGPIPE, lostpeer); + (void)signal(SIGINT, (sig_t)intr); + (void)signal(SIGPIPE, (sig_t)lostpeer); } struct cmd * diff --git a/usr.bin/ftp/util.c b/usr.bin/ftp/util.c index f92ad950369..63f2e1e625a 100644 --- a/usr.bin/ftp/util.c +++ b/usr.bin/ftp/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.2 1997/02/03 01:05:46 millert Exp $ */ +/* $OpenBSD: util.c,v 1.3 1997/02/05 04:55:21 millert Exp $ */ /* $NetBSD: util.c,v 1.4 1997/02/01 11:26:34 lukem Exp $ */ /* @@ -35,7 +35,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: util.c,v 1.2 1997/02/03 01:05:46 millert Exp $"; +static char rcsid[] = "$OpenBSD: util.c,v 1.3 1997/02/05 04:55:21 millert Exp $"; #endif /* not lint */ /* @@ -47,8 +47,10 @@ static char rcsid[] = "$OpenBSD: util.c,v 1.2 1997/02/03 01:05:46 millert Exp $" #include #include +#include #include #include +#include #include #include #include @@ -231,10 +233,23 @@ remglob(argv, doswitch) return (cp); } if (ftemp == NULL) { - (void)snprintf(temp, sizeof(temp), "%s%s", _PATH_TMP, TMPFILE) + int len; + + if ((cp = getenv("TMPDIR")) == NULL) + cp = _PATH_TMP; + len = strlen(cp); + if (len + sizeof(TMPFILE) + (cp[len-1] != '/') > sizeof(temp)) { + warnx("unable to create temporary file: %s", + strerror(ENAMETOOLONG)); + return (NULL); + } + + (void)strcpy(temp, cp); + if (temp[len-1] != '/') + temp[len++] = '/'; + (void)strcpy(&temp[len], TMPFILE); ; - fd = mkstemp(temp); - if (fd < 0) { + if ((fd = mkstemp(temp)) < 0) { warn("unable to create temporary file %s", temp); return (NULL); }