-/* $NetBSD: dm.c,v 1.23 2006/05/25 07:11:54 dan Exp $ */
+/* $NetBSD: dm.c,v 1.30 2021/05/02 12:50:44 rillig Exp $ */
/*
* Copyright (c) 1987, 1993
#include <sys/cdefs.h>
#ifndef lint
-__COPYRIGHT("@(#) Copyright (c) 1987, 1993\n\
- The Regents of the University of California. All rights reserved.\n");
+__COPYRIGHT("@(#) Copyright (c) 1987, 1993\
+ The Regents of the University of California. All rights reserved.");
#endif /* not lint */
#ifndef lint
#if 0
static char sccsid[] = "@(#)dm.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: dm.c,v 1.23 2006/05/25 07:11:54 dan Exp $");
+__RCSID("$NetBSD: dm.c,v 1.30 2021/05/02 12:50:44 rillig Exp $");
#endif
#endif /* not lint */
static char *game, /* requested game */
*gametty; /* from tty? */
-void c_day(const char *, const char *, const char *);
-void c_game(const char *, const char *, const char *, const char *);
-void c_tty(const char *);
-const char *hour(int);
-double load(void);
-void nogamefile(void);
-void play(char **) __attribute__((__noreturn__));
-void read_config(void);
-int users(void);
+static void c_day(const char *, const char *, const char *);
+static void c_game(const char *, const char *, const char *, const char *);
+static void c_tty(const char *);
+static const char *hour(int);
+static double load(void);
+static void nogamefile(void);
+static void play(char **) __dead;
+static void read_config(void);
+static int users(void);
+
+#ifdef LOG
+static void logfile(void);
+#endif
int
-main(int argc __attribute__((__unused__)), char *argv[])
+main(int argc __unused, char *argv[])
{
char *cp;
* play --
* play the game
*/
-void
+static void
play(char **args)
{
char pbuf[MAXPATHLEN];
* read_config --
* read through config file, looking for key words.
*/
-void
+static void
read_config(void)
{
FILE *cfp;
* c_day --
* if day is today, see if okay to play
*/
-void
+static void
c_day(const char *s_day, const char *s_start, const char *s_stop)
{
static const char *const days[] = {
ct = localtime(&now);
if (strcasecmp(s_day, days[ct->tm_wday]))
return;
- if (!isdigit((unsigned char)*s_start) ||
+ if (!isdigit((unsigned char)*s_start) ||
!isdigit((unsigned char)*s_stop))
return;
start = atoi(s_start);
* c_tty --
* decide if this tty can be used for games.
*/
-void
+static void
c_tty(const char *tty)
{
static int first = 1;
* c_game --
* see if game can be played now.
*/
-void
-c_game(const char *s_game, const char *s_load, const char *s_users,
+static void
+c_game(const char *s_game, const char *s_load, const char *s_users,
const char *s_priority)
{
static int found;
* load --
* return 15 minute load average
*/
-double
+static double
load(void)
{
double avenrun[3];
* todo: check idle time; if idle more than X minutes, don't
* count them.
*/
-int
+static int
users(void)
{
- static struct utmpentry *ohead = NULL;
struct utmpentry *ep;
int nusers;
nusers = getutentries(NULL, &ep);
- if (ep != ohead) {
- freeutentries(ep);
- ohead = ep;
- }
return nusers;
}
-void
+static void
nogamefile(void)
{
int fd, n;
* hour --
* print out the hour in human form
*/
-const char *
+static const char *
hour(int h)
{
static const char *const hours[] = {
* logfile --
* log play of game
*/
+static void
logfile(void)
{
struct passwd *pw;
(void)fclose(lp);
return;
}
- sleep((u_int)1);
+ sleep(1);
}
if (pw = getpwuid(uid = getuid()))
fputs(pw->pw_name, lp);
else
fprintf(lp, "%u", uid);
fprintf(lp, "\t%s\t%s\t%s", game, gametty, ctime(&now));
- (void)fclose(lp);
(void)flock(fileno(lp), LOCK_UN);
+ (void)fclose(lp);
}
}
#endif /* LOG */