-/* $OpenBSD: tty_subs.c,v 1.5 1997/07/25 18:58:39 mickey Exp $ */
+/* $OpenBSD: tty_subs.c,v 1.12 2003/06/02 23:32:09 millert Exp $ */
/* $NetBSD: tty_subs.c,v 1.5 1995/03/21 09:07:52 cgd Exp $ */
/*-
* 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
#ifndef lint
#if 0
-static char sccsid[] = "@(#)tty_subs.c 8.2 (Berkeley) 4/18/94";
+static const char sccsid[] = "@(#)tty_subs.c 8.2 (Berkeley) 4/18/94";
#else
-static char rcsid[] = "$OpenBSD: tty_subs.c,v 1.5 1997/07/25 18:58:39 mickey Exp $";
+static const char rcsid[] = "$OpenBSD: tty_subs.c,v 1.12 2003/06/02 23:32:09 millert Exp $";
#endif
#endif /* not lint */
#include <string.h>
#include "pax.h"
#include "extern.h"
-#ifdef __STDC__
#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
/*
* routines that deal with I/O to and from the user
/*
* tty_init()
- * try to open the controlling termina (if any) for this process. if the
+ * try to open the controlling terminal (if any) for this process. if the
* open fails, future ops that require user input will get an EOF
*/
-#ifdef __STDC__
int
tty_init(void)
-#else
-int
-tty_init()
-#endif
{
int ttyfd;
* if there is no controlling terminal, just return.
*/
-#ifdef __STDC__
void
-tty_prnt(char *fmt, ...)
-#else
-void
-tty_prnt(fmt, va_alist)
- char *fmt;
- va_dcl
-#endif
+tty_prnt(const char *fmt, ...)
{
va_list ap;
-# ifdef __STDC__
+
va_start(ap, fmt);
-# else
- va_start(ap);
-# endif
- if (ttyoutf == NULL)
+ if (ttyoutf == NULL) {
+ va_end(ap);
return;
+ }
(void)vfprintf(ttyoutf, fmt, ap);
va_end(ap);
(void)fflush(ttyoutf);
* 0 if data was read, -1 otherwise.
*/
-#ifdef __STDC__
int
tty_read(char *str, int len)
-#else
-int
-tty_read(str, len)
- char *str;
- int len;
-#endif
{
- register char *pt;
+ char *pt;
if ((--len <= 0) || (ttyinf == NULL) || (fgets(str,len,ttyinf) == NULL))
return(-1);
* will be non-zero.
*/
-#ifdef __STDC__
void
-paxwarn(int set, char *fmt, ...)
-#else
-void
-paxwarn(set, fmt, va_alist)
- int set;
- char *fmt;
- va_dcl
-#endif
+paxwarn(int set, const char *fmt, ...)
{
va_list ap;
-# ifdef __STDC__
+
va_start(ap, fmt);
-# else
- va_start(ap);
-# endif
if (set)
exit_val = 1;
/*
* line by itself
*/
if (vflag && vfpart) {
+ (void)fflush(listf);
(void)fputc('\n', stderr);
vfpart = 0;
}
* will be non-zero.
*/
-#ifdef __STDC__
-void
-syswarn(int set, int errnum, char *fmt, ...)
-#else
void
-syswarn(set, errnum, fmt, va_alist)
- int set;
- int errnum;
- char *fmt;
- va_dcl
-#endif
+syswarn(int set, int errnum, const char *fmt, ...)
{
va_list ap;
-# ifdef __STDC__
+
va_start(ap, fmt);
-# else
- va_start(ap);
-# endif
if (set)
exit_val = 1;
/*
* line by itself
*/
if (vflag && vfpart) {
+ (void)fflush(listf);
(void)fputc('\n', stderr);
vfpart = 0;
}
* format and print the errno
*/
if (errnum > 0)
- (void)fprintf(stderr, " <%s>", strerror(errnum));
+ (void)fprintf(stderr, ": %s", strerror(errnum));
(void)fputc('\n', stderr);
}