X-Git-Url: https://git.cameronkatri.com/bsdgames-darwin.git/blobdiff_plain/c0faadd28817c18c672c1b7b191cea09b1a91946..283621ee3b4a30d66d08567b6507c0ba1580dbf1:/dm/dm.c diff --git a/dm/dm.c b/dm/dm.c index 7c5c2549..488110d8 100644 --- a/dm/dm.c +++ b/dm/dm.c @@ -1,4 +1,4 @@ -/* $NetBSD: dm.c,v 1.9 1998/07/04 20:06:55 mrg Exp $ */ +/* $NetBSD: dm.c,v 1.15 1999/09/22 18:54:42 jsm Exp $ */ /* * Copyright (c) 1987, 1993 @@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 1993\n\ #if 0 static char sccsid[] = "@(#)dm.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: dm.c,v 1.9 1998/07/04 20:06:55 mrg Exp $"); +__RCSID("$NetBSD: dm.c,v 1.15 1999/09/22 18:54:42 jsm Exp $"); #endif #endif /* not lint */ @@ -55,7 +55,6 @@ __RCSID("$NetBSD: dm.c,v 1.9 1998/07/04 20:06:55 mrg Exp $"); #include #include #include -#include #include #include #include @@ -71,14 +70,14 @@ static int priority = 0; /* priority game runs at */ 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)); @@ -96,6 +95,7 @@ main(argc, argv) exit(0); gametty = ttyname(0); + unsetenv("TZ"); (void)time(&now); read_config(); #ifdef LOG @@ -167,9 +167,9 @@ read_config() */ 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", }; @@ -184,9 +184,13 @@ c_day(s_day, s_start, s_stop) 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)); + } } /* @@ -195,7 +199,7 @@ c_day(s_day, s_start, s_stop) */ void c_tty(tty) - char *tty; + const char *tty; { static int first = 1; static char *p_tty; @@ -215,7 +219,7 @@ c_tty(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; @@ -242,7 +246,7 @@ load() double avenrun[3]; if (getloadavg(avenrun, sizeof(avenrun)/sizeof(avenrun[0])) < 0) - err(1, "getloadavg() failed."); + err(1, "getloadavg() failed"); return (avenrun[2]); } @@ -290,13 +294,13 @@ const char * 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) + if (h < 0 || h > 24) return ("BAD TIME"); else return (hours[h]);