X-Git-Url: https://git.cameronkatri.com/bsdgames-darwin.git/blobdiff_plain/ee6e757230838de21b94218e463f2d43979e3aa9..1c75ca2e2dc72d118edbb854455e602d70d80a52:/dm/dm.c diff --git a/dm/dm.c b/dm/dm.c index 24833da5..05382224 100644 --- a/dm/dm.c +++ b/dm/dm.c @@ -1,4 +1,4 @@ -/* $NetBSD: dm.c,v 1.25 2008/07/13 20:07:48 dholland Exp $ */ +/* $NetBSD: dm.c,v 1.30 2021/05/02 12:50:44 rillig Exp $ */ /* * Copyright (c) 1987, 1993 @@ -31,15 +31,15 @@ #include #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.25 2008/07/13 20:07:48 dholland Exp $"); +__RCSID("$NetBSD: dm.c,v 1.30 2021/05/02 12:50:44 rillig Exp $"); #endif #endif /* not lint */ @@ -66,15 +66,19 @@ static int priority = 0; /* priority game runs at */ 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 **) __dead; -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 __unused, char *argv[]) @@ -103,7 +107,7 @@ main(int argc __unused, char *argv[]) * play -- * play the game */ -void +static void play(char **args) { char pbuf[MAXPATHLEN]; @@ -119,7 +123,7 @@ play(char **args) * read_config -- * read through config file, looking for key words. */ -void +static void read_config(void) { FILE *cfp; @@ -154,7 +158,7 @@ read_config(void) * 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[] = { @@ -168,7 +172,7 @@ c_day(const char *s_day, const char *s_start, const char *s_stop) 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); @@ -186,7 +190,7 @@ c_day(const char *s_day, const char *s_start, const char *s_stop) * c_tty -- * decide if this tty can be used for games. */ -void +static void c_tty(const char *tty) { static int first = 1; @@ -205,8 +209,8 @@ c_tty(const char *tty) * 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; @@ -228,7 +232,7 @@ c_game(const char *s_game, const char *s_load, const char *s_users, * load -- * return 15 minute load average */ -double +static double load(void) { double avenrun[3]; @@ -244,7 +248,7 @@ load(void) * todo: check idle time; if idle more than X minutes, don't * count them. */ -int +static int users(void) { struct utmpentry *ep; @@ -254,7 +258,7 @@ users(void) return nusers; } -void +static void nogamefile(void) { int fd, n; @@ -273,7 +277,7 @@ nogamefile(void) * hour -- * print out the hour in human form */ -const char * +static const char * hour(int h) { static const char *const hours[] = { @@ -293,6 +297,7 @@ hour(int h) * logfile -- * log play of game */ +static void logfile(void) { struct passwd *pw; @@ -309,15 +314,15 @@ logfile(void) (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 */