misc cleanup by jimj and myself.

This commit is contained in:
jtc 1994-12-21 07:11:00 +00:00
parent 2ca7c91a3e
commit 5720e226ae
3 changed files with 55 additions and 21 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: vacation.c,v 1.5 1994/11/17 07:55:51 jtc Exp $ */
/* $NetBSD: vacation.c,v 1.6 1994/12/21 07:19:52 jtc Exp $ */
/*
* Copyright (c) 1983, 1987, 1993
@ -43,7 +43,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)vacation.c 8.2 (Berkeley) 1/26/94";
#endif
static char rcsid[] = "$NetBSD: vacation.c,v 1.5 1994/11/17 07:55:51 jtc Exp $";
static char rcsid[] = "$NetBSD: vacation.c,v 1.6 1994/12/21 07:19:52 jtc Exp $";
#endif /* not lint */
/*
@ -88,9 +88,18 @@ typedef struct alias {
ALIAS *names;
DB *db;
char from[MAXLINE];
int junkmail __P((void));
int nsearch __P((char *, char *));
void readheaders __P((void));
int recent __P((void));
void sendmessage __P((char *));
void setinterval __P((time_t));
void setreply __P((void));
void usage __P((void));
int
main(argc, argv)
int argc;
char **argv;
@ -189,6 +198,7 @@ main(argc, argv)
* readheaders --
* read mail headers
*/
void
readheaders()
{
register ALIAS *cur;
@ -256,6 +266,7 @@ findme: for (cur = names; !tome && cur; cur = cur->next)
* nsearch --
* do a nice, slow, search of a string for a substring.
*/
int
nsearch(name, str)
register char *name, *str;
{
@ -271,6 +282,7 @@ nsearch(name, str)
* junkmail --
* read the header and return if automagic/junk/bulk/list mail
*/
int
junkmail()
{
static struct ignore {
@ -315,6 +327,7 @@ junkmail()
* find out if user has gotten a vacation message recently.
* use bcopy for machines with alignment restrictions
*/
int
recent()
{
DBT key, data;
@ -343,6 +356,7 @@ recent()
* setinterval --
* store the reply interval
*/
void
setinterval(interval)
time_t interval;
{
@ -359,6 +373,7 @@ setinterval(interval)
* setreply --
* store that this user knows about the vacation.
*/
void
setreply()
{
DBT key, data;
@ -376,6 +391,7 @@ setreply()
* sendmessage --
* exec sendmail to send the vacation file to sender
*/
void
sendmessage(myname)
char *myname;
{
@ -417,6 +433,7 @@ sendmessage(myname)
fclose(sfp);
}
void
usage()
{
syslog(LOG_NOTICE, "uid %u: usage: vacation [-i] [-a alias] login\n",

View File

@ -57,13 +57,16 @@ static char sccsid[] = "@(#)whatis.c 8.5 (Berkeley) 11/26/93";
static int *found, foundman;
void dashtrunc __P((char *, char *));
int match __P((char *, char *));
void usage __P((void));
void whatis __P((char **, char *, int));
int
main(argc, argv)
int argc;
char *argv[];
{
extern char *optarg;
extern int optind;
ENTRY *ep;
TAG *tp;
int ch, rv;
@ -98,7 +101,7 @@ main(argc, argv)
memset(found, 0, argc * sizeof(int));
for (p = argv; *p; ++p) /* trim full paths */
if (beg = rindex(*p, '/'))
if (beg = strrchr(*p, '/'))
*p = beg + 1;
if (p_augment)
@ -126,6 +129,7 @@ main(argc, argv)
exit(rv);
}
void
whatis(argv, path, buildpath)
char **argv, *path;
int buildpath;
@ -134,7 +138,7 @@ whatis(argv, path, buildpath)
char buf[MAXLINELEN + 1], wbuf[MAXLINELEN + 1];
for (name = path; name; name = end) { /* through name list */
if (end = index(name, ':'))
if (end = strchr(name, ':'))
*end++ = '\0';
if (buildpath) {
@ -171,6 +175,7 @@ whatis(argv, path, buildpath)
* match --
* match a full word
*/
int
match(bp, str)
register char *bp, *str;
{
@ -195,6 +200,7 @@ match(bp, str)
* dashtrunc --
* truncate a string at " - "
*/
void
dashtrunc(from, to)
register char *from, *to;
{
@ -210,6 +216,7 @@ dashtrunc(from, to)
* usage --
* print usage message and die
*/
void
usage()
{
(void)fprintf(stderr,

View File

@ -42,24 +42,31 @@ static char copyright[] =
#ifndef lint
/*static char sccsid[] = "from: @(#)write.c 8.1 (Berkeley) 6/6/93";*/
static char *rcsid = "$Id: write.c,v 1.3 1994/09/19 08:18:24 mycroft Exp $";
static char *rcsid = "$Id: write.c,v 1.4 1994/12/21 07:11:00 jtc Exp $";
#endif /* not lint */
#include <sys/types.h>
#include <sys/param.h>
#include <sys/signal.h>
#include <sys/stat.h>
#include <sys/file.h>
#include <sys/time.h>
#include <err.h>
#include <utmp.h>
#include <ctype.h>
#include <pwd.h>
#include <stdio.h>
#include <string.h>
#include <signal.h>
#include <time.h>
#include <fcntl.h>
#include <pwd.h>
#include <unistd.h>
#include <utmp.h>
#include <err.h>
extern int errno;
void done();
void do_write __P((char *, char *, uid_t));
void wr_fputs __P((char *));
void search_utmp __P((char *, char *, char *, uid_t));
int term_chk __P((char *, int *, time_t *, int));
int utmp_chk __P((char *, char *));
int
main(argc, argv)
int argc;
char **argv;
@ -68,8 +75,7 @@ main(argc, argv)
time_t atime;
uid_t myuid;
int msgsok, myttyfd;
char tty[MAXPATHLEN], *mytty, *ttyname();
void done();
char tty[MAXPATHLEN], *mytty;
/* check that sender has write enabled */
if (isatty(fileno(stdin)))
@ -122,6 +128,7 @@ main(argc, argv)
* utmp_chk - checks that the given user is actually logged in on
* the given tty
*/
int
utmp_chk(user, tty)
char *user, *tty;
{
@ -153,6 +160,7 @@ utmp_chk(user, tty)
* Special case for writing to yourself - ignore the terminal you're
* writing from, unless that's the only terminal with messages enabled.
*/
void
search_utmp(user, tty, mytty, myuid)
char *user, *tty, *mytty;
uid_t myuid;
@ -206,6 +214,7 @@ search_utmp(user, tty, mytty, myuid)
* term_chk - check that a terminal exists, and get the message bit
* and the access time
*/
int
term_chk(tty, msgsokP, atimeP, showerror)
char *tty;
int *msgsokP, showerror;
@ -228,15 +237,15 @@ term_chk(tty, msgsokP, atimeP, showerror)
/*
* do_write - actually make the connection
*/
void
do_write(tty, mytty, myuid)
char *tty, *mytty;
uid_t myuid;
{
register char *login, *nows;
register struct passwd *pwd;
time_t now, time();
char *getlogin(), path[MAXPATHLEN], host[MAXHOSTNAMELEN], line[512];
void done();
time_t now;
char path[MAXPATHLEN], host[MAXHOSTNAMELEN], line[512];
/* Determine our login name before the we reopen() stdout */
if ((login = getlogin()) == NULL)
@ -279,6 +288,7 @@ done()
* wr_fputs - like fputs(), but makes control characters visible and
* turns \n into \r\n
*/
void
wr_fputs(s)
register char *s;
{