WARNSify, use <termcap.h>

This commit is contained in:
lukem 1997-10-14 01:28:47 +00:00
parent 2ce4ef15e6
commit c72c1882ab
3 changed files with 54 additions and 39 deletions

View File

@ -1,6 +1,7 @@
# $NetBSD: Makefile,v 1.6 1995/09/28 06:57:37 tls Exp $
# $NetBSD: Makefile,v 1.7 1997/10/14 01:28:47 lukem Exp $
# @(#)Makefile 8.2 (Berkeley) 4/28/95
WARNS?= 1
PROG= msgs
DPADD= ${LIBTERM}
LDADD= -ltermlib

View File

@ -1,4 +1,4 @@
.\" $NetBSD: msgs.1,v 1.5 1995/09/28 06:57:39 tls Exp $
.\" $NetBSD: msgs.1,v 1.6 1997/10/14 01:28:50 lukem Exp $
.\"
.\" Copyright (c) 1980, 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@ -40,24 +40,24 @@
.Nm msgs
.Nd system messages and junk mail program
.Sh SYNOPSIS
.Nm msgs
.Nm
.Op Fl fhlpqr
.Op Ar number
.Op Ar \-number
.Nm msgs
.Nm ""
.Op Fl s
.Nm msgs
.Nm ""
.Op Fl c
.Op \-days
.Sh DESCRIPTION
.Nm Msgs
.Nm
is used to read system messages.
These messages are
sent by mailing to the login `msgs' and should be short
pieces of information which are suitable to be read once by most users
of the system.
.Pp
.Nm Msgs
.Nm
is normally invoked each time you login, by placing it in the file
.Pa .login
(or
@ -82,9 +82,9 @@ and go on to the next message.
Redisplay the last message.
.It Fl q
Drop out of
.Nm msgs ;
.Nm "" ;
the next time
.Nm msgs
.Nm
will pick up where it last left off.
.It Fl s
Append the current message to the file ``Messages'' in the current directory;
@ -102,7 +102,7 @@ The specified message is piped through $PAGER, or, if $PAGER is not defined,
The commands `m', `p', and `s' all accept a numeric argument in place of the `\-'.
.El
.Pp
.Nm Msgs
.Nm
keeps track of the next message you will see by a number in the file
.Pa \&.msgsrc
in your home directory.
@ -114,12 +114,12 @@ The file
.Pa /var/msgs/bounds
shows the low and high number of the messages in the directory
so that
.Nm msgs
.Nm
can quickly determine if there are no messages for you.
If the contents of
.Pa bounds
is incorrect it can be fixed by removing it;
.Nm msgs
.Nm
will make a new
.Pa bounds
file the next time it is run.
@ -169,7 +169,7 @@ Option causes only locally originated messages to be reported.
.It Ar num
A message number can be given
on the command line, causing
.Nm msgs
.Nm
to start at the specified message rather than at the next message
indicated by your
.Pa \&.msgsrc
@ -191,12 +191,12 @@ Pipe long messages through $PAGER, or, if $PAGER is not defined,
.El
.Pp
Within
.Nm msgs
.Nm
you can also go to any specific message by typing its number when
.Nm msgs
.Nm
requests input as to what to do.
.Sh ENVIRONMENT
.Nm Msgs
.Nm
uses the
.Ev HOME
and
@ -217,6 +217,6 @@ number of next message to be presented
.Xr more 1
.Sh HISTORY
The
.Nm msgs
.Nm
command appeared in
.Bx 3.0 .

View File

@ -1,4 +1,4 @@
/* $NetBSD: msgs.c,v 1.9 1997/07/24 22:45:23 phil Exp $ */
/* $NetBSD: msgs.c,v 1.10 1997/10/14 01:28:52 lukem Exp $ */
/*-
* Copyright (c) 1980, 1993
@ -33,17 +33,17 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
static char copyright[] =
"@(#) Copyright (c) 1980, 1993\n\
The Regents of the University of California. All rights reserved.\n";
__COPYRIGHT("@(#) Copyright (c) 1980, 1993\n\
The Regents of the University of California. All rights reserved.\n");
#endif /* not lint */
#ifndef lint
#if 0
static char sccsid[] = "@(#)msgs.c 8.2 (Berkeley) 4/28/95";
#else
static char rcsid[] = "$NetBSD: msgs.c,v 1.9 1997/07/24 22:45:23 phil Exp $";
__RCSID("$NetBSD: msgs.c,v 1.10 1997/10/14 01:28:52 lukem Exp $");
#endif
#endif /* not lint */
@ -70,15 +70,15 @@ static char rcsid[] = "$NetBSD: msgs.c,v 1.9 1997/07/24 22:45:23 phil Exp $";
#define V7 /* will look for TERM in the environment */
#define OBJECT /* will object to messages without Subjects */
#define REJECT /* will reject messages without Subjects
#define REJECT /* will reject messages without Subjects
(OBJECT must be defined also) */
/* #define UNBUFFERED /* use unbuffered output */
/*#define UNBUFFERED */ /* use unbuffered output */
#include <sys/param.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <dirent.h>
#include <ctype.h>
#include <dirent.h>
#include <errno.h>
#include <pwd.h>
#include <setjmp.h>
@ -86,6 +86,7 @@ static char rcsid[] = "$NetBSD: msgs.c,v 1.9 1997/07/24 22:45:23 phil Exp $";
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <termcap.h>
#include <termios.h>
#include <time.h>
#include <unistd.h>
@ -139,10 +140,15 @@ int Lpp = 0;
time_t t;
time_t keep;
char *mktemp();
char *nxtfld();
void onintr();
void onsusp();
void ask __P((char *));
void gfrsub __P((FILE *));
int linecnt __P((FILE *));
int main __P((int, char *[]));
int next __P((char *));
char *nxtfld __P((char *));
void onintr __P((int));
void onsusp __P((int));
void prmesg __P((int));
/* option initialization */
bool hdrs = NO;
@ -155,8 +161,9 @@ bool clean = NO;
bool lastcmd = NO;
jmp_buf tstpbuf;
int
main(argc, argv)
int argc; char *argv[];
int argc; char *argv[];
{
bool newrc, already;
int rcfirst = 0; /* first message to print (from .rc) */
@ -607,8 +614,9 @@ cmnd:
exit(0);
}
void
prmesg(length)
int length;
int length;
{
FILE *outf;
char *env_pager;
@ -655,7 +663,8 @@ int length;
}
void
onintr()
onintr(dummy)
int dummy;
{
signal(SIGINT, onintr);
if (mailing)
@ -680,7 +689,8 @@ onintr()
* We have just gotten a susp. Suspend and prepare to resume.
*/
void
onsusp()
onsusp(dummy)
int dummy;
{
signal(SIGTSTP, SIG_DFL);
@ -691,8 +701,9 @@ onsusp()
longjmp(tstpbuf, 0);
}
int
linecnt(f)
FILE *f;
FILE *f;
{
off_t oldpos = ftell(f);
int l = 0;
@ -705,8 +716,9 @@ FILE *f;
return (l);
}
int
next(buf)
char *buf;
char *buf;
{
int i;
sscanf(buf, "%d", &i);
@ -714,8 +726,9 @@ char *buf;
return(--i);
}
void
ask(prompt)
char *prompt;
char *prompt;
{
char inch;
int n, cmsg;
@ -778,7 +791,7 @@ char *prompt;
return;
}
while (n = fread(inbuf, 1, sizeof inbuf, cpfrom))
while ((n = fread(inbuf, 1, sizeof inbuf, cpfrom)) != 0)
fwrite(inbuf, 1, n, cpto);
fclose(cpfrom);
@ -795,8 +808,9 @@ char *prompt;
}
}
void
gfrsub(infile)
FILE *infile;
FILE *infile;
{
off_t frompos;
@ -873,7 +887,7 @@ FILE *infile;
char *
nxtfld(s)
char *s;
char *s;
{
if (*s) while (*s && *s > ' ') s++; /* skip over this field */
if (*s) while (*s && *s <= ' ') s++; /* find start of next field */