| 59 |
59 |
static char *game, /* requested game */
|
| 60 |
60 |
*gametty; /* from tty? */
|
| 61 |
61 |
|
| 62 |
|
void c_day (char *, char *, char *);
|
| 63 |
|
void c_tty (char *);
|
| 64 |
|
void c_game (char *, char *, char *, char *);
|
| 65 |
|
void hour (int);
|
| 66 |
|
double load (void);
|
| 67 |
|
void nogamefile (void);
|
| 68 |
|
void play (char **);
|
| 69 |
|
void read_config (void);
|
| 70 |
|
int users (void);
|
|
62 |
static void c_day(char *, char *, char *);
|
|
63 |
static void c_tty(char *);
|
|
64 |
static void c_game(char *, char *, char *, char *);
|
|
65 |
static void hour(int);
|
|
66 |
static double load(void);
|
|
67 |
static void nogamefile(void);
|
|
68 |
static void play(char **);
|
|
69 |
static void read_config(void);
|
|
70 |
static int users(void);
|
|
71 |
#ifdef LOG
|
|
72 |
static void logfile(void);
|
|
73 |
#endif
|
| 71 |
74 |
|
| 72 |
75 |
int
|
| 73 |
|
main(argc, argv)
|
| 74 |
|
int argc;
|
| 75 |
|
char *argv[];
|
|
76 |
main(__unused int argc, char *argv[])
|
| 76 |
77 |
{
|
| 77 |
78 |
char *cp;
|
| 78 |
79 |
|
| ... | ... | |
| 98 |
99 |
* play --
|
| 99 |
100 |
* play the game
|
| 100 |
101 |
*/
|
| 101 |
|
void
|
| 102 |
|
play(args)
|
| 103 |
|
char **args;
|
|
102 |
static void
|
|
103 |
play(char **args)
|
| 104 |
104 |
{
|
| 105 |
105 |
char pbuf[MAXPATHLEN];
|
| 106 |
106 |
|
| ... | ... | |
| 122 |
122 |
* read_config --
|
| 123 |
123 |
* read through config file, looking for key words.
|
| 124 |
124 |
*/
|
| 125 |
|
void
|
| 126 |
|
read_config()
|
|
125 |
static void
|
|
126 |
read_config(void)
|
| 127 |
127 |
{
|
| 128 |
128 |
FILE *cfp;
|
| 129 |
129 |
char lbuf[BUFSIZ], f1[40], f2[40], f3[40], f4[40], f5[40];
|
| ... | ... | |
| 157 |
157 |
* c_day --
|
| 158 |
158 |
* if day is today, see if okay to play
|
| 159 |
159 |
*/
|
| 160 |
|
void
|
| 161 |
|
c_day(s_day, s_start, s_stop)
|
| 162 |
|
char *s_day, *s_start, *s_stop;
|
|
160 |
static void
|
|
161 |
c_day(char *s_day, char *s_start, char *s_stop)
|
| 163 |
162 |
{
|
| 164 |
163 |
static const char *days[] = {
|
| 165 |
164 |
"sunday", "monday", "tuesday", "wednesday",
|
| ... | ... | |
| 190 |
189 |
* c_tty --
|
| 191 |
190 |
* decide if this tty can be used for games.
|
| 192 |
191 |
*/
|
| 193 |
|
void
|
| 194 |
|
c_tty(tty)
|
| 195 |
|
char *tty;
|
|
192 |
static void
|
|
193 |
c_tty(char *tty)
|
| 196 |
194 |
{
|
| 197 |
195 |
static int first = 1;
|
| 198 |
196 |
static char *p_tty;
|
| ... | ... | |
| 212 |
210 |
* c_game --
|
| 213 |
211 |
* see if game can be played now.
|
| 214 |
212 |
*/
|
| 215 |
|
void
|
| 216 |
|
c_game(s_game, s_load, s_users, s_priority)
|
| 217 |
|
char *s_game, *s_load, *s_users, *s_priority;
|
|
213 |
static void
|
|
214 |
c_game(char *s_game, char *s_load, char *s_users, char *s_priority)
|
| 218 |
215 |
{
|
| 219 |
216 |
static int found;
|
| 220 |
217 |
|
| ... | ... | |
| 239 |
236 |
* load --
|
| 240 |
237 |
* return 15 minute load average
|
| 241 |
238 |
*/
|
| 242 |
|
double
|
| 243 |
|
load()
|
|
239 |
static double
|
|
240 |
load(void)
|
| 244 |
241 |
{
|
| 245 |
242 |
double avenrun[3];
|
| 246 |
243 |
|
| ... | ... | |
| 257 |
254 |
* todo: check idle time; if idle more than X minutes, don't
|
| 258 |
255 |
* count them.
|
| 259 |
256 |
*/
|
| 260 |
|
int
|
| 261 |
|
users()
|
|
257 |
static int
|
|
258 |
users(void)
|
| 262 |
259 |
{
|
| 263 |
260 |
|
| 264 |
261 |
int nusers, utmp;
|
| ... | ... | |
| 275 |
272 |
return(nusers);
|
| 276 |
273 |
}
|
| 277 |
274 |
|
| 278 |
|
void
|
| 279 |
|
nogamefile()
|
|
275 |
static void
|
|
276 |
nogamefile(void)
|
| 280 |
277 |
{
|
| 281 |
278 |
int fd, n;
|
| 282 |
279 |
char buf[BUFSIZ];
|
| ... | ... | |
| 294 |
291 |
* hour --
|
| 295 |
292 |
* print out the hour in human form
|
| 296 |
293 |
*/
|
| 297 |
|
void
|
| 298 |
|
hour(h)
|
| 299 |
|
int h;
|
|
294 |
static void
|
|
295 |
hour(int h)
|
| 300 |
296 |
{
|
| 301 |
297 |
switch(h) {
|
| 302 |
298 |
case 0:
|
| ... | ... | |
| 318 |
314 |
* logfile --
|
| 319 |
315 |
* log play of game
|
| 320 |
316 |
*/
|
| 321 |
|
logfile()
|
|
317 |
static void
|
|
318 |
logfile(void)
|
| 322 |
319 |
{
|
| 323 |
320 |
struct passwd *pw;
|
| 324 |
321 |
FILE *lp;
|