Subject: bin/13976: bin/rcp with corrected style
To: None <gnats-bugs@gnats.netbsd.org>
From: Petri Koistinen <thoron@mb-u10ip029.mbnet.fi>
List: netbsd-bugs
Date: 09/16/2001 22:30:08
>Number:         13976
>Category:       bin
>Synopsis:       bin/rcp with corrected style
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sun Sep 16 12:28:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Petri Koistinen
>Release:        NetBSD-current Sun Sep 16 22:27:41 EEST 2001
>Organization:
>Environment:
System: NetBSD mb-u10ip029.mbnet.fi 1.5Y NetBSD 1.5Y (SPEEDBALL) #4: Sun Sep 16 17:06:05 EEST 2001 thoron@legoland:/usr/src/sys/arch/amiga/compile/SPEEDBALL amiga
Architecture: m68k
Machine: amiga
>Description:
	Please apply attached patch for bin/rcp program.
>How-To-Repeat:
>Fix:
Index: extern.h
===================================================================
RCS file: /cvsroot/basesrc/bin/rcp/extern.h,v
retrieving revision 1.3
diff -u -r1.3 extern.h
--- extern.h	1997/05/28 00:32:18	1.3
+++ extern.h	2001/09/16 19:21:31
@@ -1,4 +1,4 @@
-/*	$NetBSD: extern.h,v 1.3 1997/05/28 00:32:18 mrg Exp $	*/
+/* $NetBSD: extern.h,v 1.3 1997/05/28 00:32:18 mrg Exp $ */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -35,18 +35,23 @@
  *	@(#)extern.h	8.1 (Berkeley) 5/31/93
  */
 
+#ifndef _EXTERN_H_
+#define _EXTERN_H_
+
 typedef struct {
 	int cnt;
 	char *buf;
 } BUF;
 
 extern int iamremote;
+
+BUF	*allocbuf(BUF *, int, int);
+char	*colon(char *);
+void	lostconn(int);
+void	nospace(void);
+int	okname(char *);
+void	run_err(const char *, ...);
+int	susystem(char *);
+void	verifydir(char *);
 
-BUF	*allocbuf __P((BUF *, int, int));
-char	*colon __P((char *));
-void	 lostconn __P((int));
-void	 nospace __P((void));
-int	 okname __P((char *));
-void	 run_err __P((const char *, ...));
-int	 susystem __P((char *));
-void	 verifydir __P((char *));
+#endif /* !_EXTERN_H_ */
Index: pathnames.h
===================================================================
RCS file: /cvsroot/basesrc/bin/rcp/pathnames.h,v
retrieving revision 1.5
diff -u -r1.5 pathnames.h
--- pathnames.h	1995/03/21 08:19:03	1.5
+++ pathnames.h	2001/09/16 19:21:31
@@ -1,4 +1,4 @@
-/*	$NetBSD: pathnames.h,v 1.5 1995/03/21 08:19:03 cgd Exp $	*/
+/* $NetBSD: pathnames.h,v 1.5 1995/03/21 08:19:03 cgd Exp $ */
 
 /*
  * Copyright (c) 1989, 1993
@@ -35,7 +35,12 @@
  *	@(#)pathnames.h	8.1 (Berkeley) 5/31/93
  */
 
+#ifndef _PATHNAMES_H_
+#define _PATHNAMES_H_
+
 #include <paths.h>
 
 #define	_PATH_CP	"/bin/cp"
 #define	_PATH_RSH	"/usr/bin/rsh"
+
+#endif /* !_PATHNAMES_H_ */
Index: rcp.c
===================================================================
RCS file: /cvsroot/basesrc/bin/rcp/rcp.c,v
retrieving revision 1.27
diff -u -r1.27 rcp.c
--- rcp.c	2001/01/04 15:39:51	1.27
+++ rcp.c	2001/09/16 19:21:33
@@ -1,4 +1,4 @@
-/*	$NetBSD: rcp.c,v 1.27 2001/01/04 15:39:51 lukem Exp $	*/
+/* $NetBSD: rcp.c,v 1.27 2001/01/04 15:39:51 lukem Exp $ */
 
 /*
  * Copyright (c) 1983, 1990, 1992, 1993
@@ -77,13 +77,13 @@
 #include <kerberosIV/krb.h>
 #include "krb.h"
 
-char	dst_realm_buf[REALM_SZ];
-char	*dest_realm = NULL;
-int	use_kerberos = 1;
-CREDENTIALS 	cred;
+char		dst_realm_buf[REALM_SZ];
+char		*dest_realm = NULL;
+int		use_kerberos = 1;
+CREDENTIALS	cred;
 Key_schedule	schedule;
 #ifdef CRYPT
-int	doencrypt = 0;
+int		doencrypt = 0;
 #define	OPTIONS	"dfKk:prtx"
 #else
 #define	OPTIONS	"dfKk:prt"
@@ -95,38 +95,45 @@
 struct passwd *pwd;
 char *pwname;
 u_short	port;
-uid_t	userid;
-int errs, rem;
-int pflag, iamremote, iamrecursive, targetshouldbedirectory;
+uid_t userid;
+int errs, pflag, iamrecursive, iamremote, rem, targetshouldbedirectory;
 
 #define	CMDNEEDS	64
 char cmd[CMDNEEDS];		/* must hold "rcp -r -p -d\0" */
 
 #ifdef KERBEROS
-int	 kerberos __P((char **, char *, char *, char *));
-void	 oldw __P((const char *, ...));
+int	 kerberos(char **, char *, char *, char *);
+void	 oldw(const char *, ...);
 #endif
-int	 response __P((void));
-void	 rsource __P((char *, struct stat *));
-void	 sink __P((int, char *[]));
-void	 source __P((int, char *[]));
-void	 tolocal __P((int, char *[]));
-void	 toremote __P((char *, int, char *[]));
-void	 usage __P((void));
-int	 main __P((int, char *[]));
+int	 response(void);
+void	 rsource(char *, struct stat *);
+void	 sink(int, char *[]);
+void	 source(int, char *[]);
+void	 tolocal(int, char *[]);
+void	 toremote(char *, int, char *[]);
+void	 usage(void);
+int	 main(int, char *[]);
 
 int
-main(argc, argv)
-	int argc;
-	char *argv[];
+main(int argc, char *argv[])
 {
 	struct servent *sp;
 	int ch, fflag, tflag;
-	char *targ, *shell;
+	char *shell, *targ;
 
+	setprogname(argv[0]);
 	fflag = tflag = 0;
 	while ((ch = getopt(argc, argv, OPTIONS)) != -1)
 		switch(ch) {			/* User-visible flags. */
+                case 'd':
+                        targetshouldbedirectory = 1;
+                        break;
+                                                /* Server options. */
+                case 'f':                       /* "from" */
+                        iamremote = 1;   
+                        fflag = 1;
+                        break;
+
 		case 'K':
 #ifdef KERBEROS
 			use_kerberos = 0;
@@ -150,14 +157,6 @@
 		case 'r':
 			iamrecursive = 1;
 			break;
-						/* Server options. */
-		case 'd':
-			targetshouldbedirectory = 1;
-			break;
-		case 'f':			/* "from" */
-			iamremote = 1;
-			fflag = 1;
-			break;
 		case 't':			/* "to" */
 			iamremote = 1;
 			tflag = 1;
@@ -245,9 +244,7 @@
 }
 
 void
-toremote(targ, argc, argv)
-	char *targ, *argv[];
-	int argc;
+toremote(char *targ, int argc, char *argv[])
 {
 	int i, len;
 	char *bp, *host, *src, *suser, *thost, *tuser;
@@ -329,9 +326,7 @@
 }
 
 void
-tolocal(argc, argv)
-	int argc;
-	char *argv[];
+tolocal(int argc, char *argv[])
 {
 	int i, len;
 	char *bp, *host, *src, *suser;
@@ -386,9 +381,7 @@
 }
 
 void
-source(argc, argv)
-	int argc;
-	char *argv[];
+source(int argc, char *argv[])
 {
 	struct stat stb;
 	static BUF buffer;
@@ -481,9 +474,7 @@
 }
 
 void
-rsource(name, statp)
-	char *name;
-	struct stat *statp;
+rsource(char *name, struct stat *statp)
 {
 	DIR *dirp;
 	struct dirent *dp;
@@ -536,9 +527,7 @@
 }
 
 void
-sink(argc, argv)
-	int argc;
-	char *argv[];
+sink(int argc, char *argv[])
 {
 	static BUF buffer;
 	struct stat stb;
@@ -547,8 +536,7 @@
 	BUF *bp;
 	off_t i, j;
 	int amt, count, exists, first, mask, mode, ofd, omode;
-	int setimes, size, targisdir;
-	int wrerrno = 0;	/* pacify gcc */
+	int setimes, size, targisdir, wrerrno;
 	char ch, *cp, *np, *targ, *why, *vect[1], buf[BUFSIZ];
 
 #define	atime	tv[0]
@@ -559,7 +547,7 @@
 	/* This outrageous construct just to shut up a GCC warning. */
 	(void) &i;
 #endif
-
+        wrerrno = 0;        /* pacify gcc */
 	setimes = targisdir = 0;
 	mask = umask(0);
 	if (!pflag)
@@ -796,8 +784,7 @@
 
 #ifdef KERBEROS
 int
-kerberos(host, bp, locuser, user)
-	char **host, *bp, *locuser, *user;
+kerberos(char **host, char *bp, char *locuser, char *user)
 {
 	struct servent *sp;
 
@@ -839,7 +826,7 @@
 #endif /* KERBEROS */
 
 int
-response()
+response(void)
 {
 	char ch, *cp, resp, rbuf[BUFSIZ];
 
@@ -872,21 +859,23 @@
 }
 
 void
-usage()
+usage(void)
 {
+	const char *progname = getprogname();
+
 #ifdef KERBEROS
 #ifdef CRYPT
 	(void)fprintf(stderr, "%s\n\t%s\n",
-	    "usage: rcp [-Kpx] [-k realm] f1 f2",
-	    "or: rcp [-Kprx] [-k realm] f1 ... fn directory");
+	    "usage: %s [-Kpx] [-k realm] f1 f2",
+	    "or: %s [-Kprx] [-k realm] f1 ... fn directory", progname, progname);
 #else
 	(void)fprintf(stderr, "%s\n\t%s\n",
-	    "usage: rcp [-Kp] [-k realm] f1 f2",
-	    "or: rcp [-Kpr] [-k realm] f1 ... fn directory");
+	    "usage: %s [-Kp] [-k realm] f1 f2",
+	    "or: %s [-Kpr] [-k realm] f1 ... fn directory", progname, progname);
 #endif
 #else
 	(void)fprintf(stderr,
-	    "usage: rcp [-p] f1 f2; or: rcp [-pr] f1 ... fn directory\n");
+	    "usage: %s [-p] f1 f2; or: rcp [-pr] f1 ... fn directory\n", progname);
 #endif
 	exit(1);
 	/* NOTREACHED */
@@ -914,9 +903,9 @@
 #else
 	va_start(ap);
 #endif
-	(void)fprintf(stderr, "rcp: ");
+	(void)fprintf(stderr, "%s: ", getprogname());
 	(void)vfprintf(stderr, fmt, ap);
-	(void)fprintf(stderr, ", using standard rcp\n");
+	(void)fprintf(stderr, ", using standard %s\n", getprogname());
 	va_end(ap);
 }
 #endif
@@ -942,7 +931,7 @@
 	if (fp == NULL && !(fp = fdopen(rem, "w")))
 		return;
 	(void)fprintf(fp, "%c", 0x01);
-	(void)fprintf(fp, "rcp: ");
+	(void)fprintf(fp, "%s: ", getprogname());
 	(void)vfprintf(fp, fmt, ap);
 	(void)fprintf(fp, "\n");
 	(void)fflush(fp);
Index: util.c
===================================================================
RCS file: /cvsroot/basesrc/bin/rcp/util.c,v
retrieving revision 1.5
diff -u -r1.5 util.c
--- util.c	1998/07/28 05:31:27	1.5
+++ util.c	2001/09/16 19:21:33
@@ -1,4 +1,4 @@
-/*	$NetBSD: util.c,v 1.5 1998/07/28 05:31:27 mycroft Exp $	*/
+/* $NetBSD: util.c,v 1.5 1998/07/28 05:31:27 mycroft Exp $ */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -59,8 +59,7 @@
 #include "extern.h"
 
 char *
-colon(cp)
-	char *cp;
+colon(char *cp)
 {
 	if (*cp == ':')		/* Leading colon is part of file name. */
 		return (0);
@@ -75,8 +74,7 @@
 }
 
 void
-verifydir(cp)
-	char *cp;
+verifydir(char *cp)
 {
 	struct stat stb;
 
@@ -91,8 +89,7 @@
 }
 
 int
-okname(cp0)
-	char *cp0;
+okname(char *cp0)
 {
 	int c;
 	char *cp;
@@ -112,8 +109,7 @@
 }
 
 int
-susystem(s)
-	char *s;
+susystem(char *s)
 {
 	sig_t istat, qstat;
 	int status;
@@ -139,9 +135,7 @@
 }
 
 BUF *
-allocbuf(bp, fd, blksize)
-	BUF *bp;
-	int fd, blksize;
+allocbuf(BUF *bp, int fd, int blksize)
 {
 	struct stat stb;
 	size_t size;
@@ -165,8 +159,7 @@
 }
 
 void
-lostconn(signo)
-	int signo;
+lostconn(int signo)
 {
 	if (!iamremote)
 		warnx("lost connection");
>Release-Note:
>Audit-Trail:
>Unformatted: