-/* $NetBSD: dm.c,v 1.7 1997/10/10 12:49:49 lukem Exp $ */
+/* $NetBSD: dm.c,v 1.15 1999/09/22 18:54:42 jsm Exp $ */
/*
* Copyright (c) 1987, 1993
#if 0
static char sccsid[] = "@(#)dm.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: dm.c,v 1.7 1997/10/10 12:49:49 lukem Exp $");
+__RCSID("$NetBSD: dm.c,v 1.15 1999/09/22 18:54:42 jsm Exp $");
#endif
#endif /* not lint */
#include <err.h>
#include <ctype.h>
#include <errno.h>
-#include <nlist.h>
#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
static char *game, /* requested game */
*gametty; /* from tty? */
-void c_day __P((char *, char *, char *));
-void c_game __P((char *, char *, char *, char *));
-void c_tty __P((char *));
+void c_day __P((const char *, const char *, const char *));
+void c_game __P((const char *, const char *, const char *, const char *));
+void c_tty __P((const char *));
const char *hour __P((int));
double load __P((void));
int main __P((int, char *[]));
void nogamefile __P((void));
-void play __P((char **));
+void play __P((char **)) __attribute__((__noreturn__));
void read_config __P((void));
int users __P((void));
exit(0);
gametty = ttyname(0);
+ unsetenv("TZ");
(void)time(&now);
read_config();
#ifdef LOG
#endif
play(argv);
/*NOTREACHED*/
- return(0);
+ return (0);
}
/*
pbuf[sizeof(pbuf) - 1] = '\0';
if (priority > 0) /* < 0 requires root */
(void)setpriority(PRIO_PROCESS, 0, priority);
- setgid(getgid()); /* we run setgid kmem; lose it */
execv(pbuf, args);
err(1, "%s", pbuf);
}
if (!(cfp = fopen(_PATH_CONFIG, "r")))
return;
while (fgets(lbuf, sizeof(lbuf), cfp))
- switch(*lbuf) {
+ switch (*lbuf) {
case 'b': /* badtty */
if (sscanf(lbuf, "%s%s", f1, f2) != 2 ||
strcasecmp(f1, "badtty"))
*/
void
c_day(s_day, s_start, s_stop)
- char *s_day, *s_start, *s_stop;
+ const char *s_day, *s_start, *s_stop;
{
- static char *days[] = {
+ static const char *const days[] = {
"sunday", "monday", "tuesday", "wednesday",
"thursday", "friday", "saturday",
};
return;
start = atoi(s_start);
stop = atoi(s_stop);
- if (ct->tm_hour >= start && ct->tm_hour < stop)
- errx(0, "Sorry, games are not available from %s to %s today.",
- hour(start), hour(stop));
+ if (ct->tm_hour >= start && ct->tm_hour < stop) {
+ if (start == 0 && stop == 24)
+ errx(0, "Sorry, games are not available today.");
+ else
+ errx(0, "Sorry, games are not available from %s to %s today.",
+ hour(start), hour(stop));
+ }
}
/*
*/
void
c_tty(tty)
- char *tty;
+ const char *tty;
{
static int first = 1;
static char *p_tty;
*/
void
c_game(s_game, s_load, s_users, s_priority)
- char *s_game, *s_load, *s_users, *s_priority;
+ const char *s_game, *s_load, *s_users, *s_priority;
{
static int found;
double avenrun[3];
if (getloadavg(avenrun, sizeof(avenrun)/sizeof(avenrun[0])) < 0)
- err(1, "getloadavg() failed.");
- return(avenrun[2]);
+ err(1, "getloadavg() failed");
+ return (avenrun[2]);
}
/*
for (nusers = 0; read(utmp, (char *)&buf, sizeof(struct utmp)) > 0;)
if (buf.ut_name[0] != '\0')
++nusers;
- return(nusers);
+ return (nusers);
}
void
hour(h)
int h;
{
- static char *hours[] = {
+ static const char *const hours[] = {
"midnight", "1am", "2am", "3am", "4am", "5am",
"6am", "7am", "8am", "9am", "10am", "11am",
"noon", "1pm", "2pm", "3pm", "4pm", "5pm",
- "6pm", "7pm", "8pm", "9pm", "10pm", "11pm" };
+ "6pm", "7pm", "8pm", "9pm", "10pm", "11pm", "midnight" };
- if (h < 0 || h > 23)
- return "BAD TIME";
+ if (h < 0 || h > 24)
+ return ("BAD TIME");
else
- return hours[h];
+ return (hours[h]);
}
#ifdef LOG