KNF conversion

This commit is contained in:
jmc 2005-07-02 08:35:29 +00:00
parent 1f90022eca
commit 4f50e1e42e
2 changed files with 34 additions and 56 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: dm.c,v 1.21 2004/11/05 21:30:32 dsl Exp $ */
/* $NetBSD: dm.c,v 1.22 2005/07/02 08:35:29 jmc Exp $ */
/*
* Copyright (c) 1987, 1993
@ -39,7 +39,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.21 2004/11/05 21:30:32 dsl Exp $");
__RCSID("$NetBSD: dm.c,v 1.22 2005/07/02 08:35:29 jmc Exp $");
#endif
#endif /* not lint */
@ -71,16 +71,13 @@ void c_game(const char *, const char *, const char *, const char *);
void c_tty(const char *);
const char *hour(int);
double load(void);
int main(int, char *[]);
void nogamefile(void);
void play(char **) __attribute__((__noreturn__));
void read_config(void);
int users(void);
int
main(argc, argv)
int argc __attribute__((__unused__));
char *argv[];
main(int argc __attribute__((__unused__)), char *argv[])
{
char *cp;
@ -107,8 +104,7 @@ main(argc, argv)
* play the game
*/
void
play(args)
char **args;
play(char **args)
{
char pbuf[MAXPATHLEN];
@ -124,7 +120,7 @@ play(args)
* read through config file, looking for key words.
*/
void
read_config()
read_config(void)
{
FILE *cfp;
char lbuf[BUFSIZ], f1[40], f2[40], f3[40], f4[40], f5[40];
@ -159,8 +155,7 @@ read_config()
* if day is today, see if okay to play
*/
void
c_day(s_day, s_start, s_stop)
const char *s_day, *s_start, *s_stop;
c_day(const char *s_day, const char *s_start, const char *s_stop)
{
static const char *const days[] = {
"sunday", "monday", "tuesday", "wednesday",
@ -173,7 +168,8 @@ c_day(s_day, s_start, s_stop)
ct = localtime(&now);
if (strcasecmp(s_day, days[ct->tm_wday]))
return;
if (!isdigit((unsigned char)*s_start) || !isdigit((unsigned char)*s_stop))
if (!isdigit((unsigned char)*s_start) ||
!isdigit((unsigned char)*s_stop))
return;
start = atoi(s_start);
stop = atoi(s_stop);
@ -191,8 +187,7 @@ c_day(s_day, s_start, s_stop)
* decide if this tty can be used for games.
*/
void
c_tty(tty)
const char *tty;
c_tty(const char *tty)
{
static int first = 1;
static char *p_tty;
@ -211,8 +206,8 @@ c_tty(tty)
* see if game can be played now.
*/
void
c_game(s_game, s_load, s_users, s_priority)
const char *s_game, *s_load, *s_users, *s_priority;
c_game(const char *s_game, const char *s_load, const char *s_users,
const char *s_priority)
{
static int found;
@ -234,7 +229,7 @@ c_game(s_game, s_load, s_users, s_priority)
* return 15 minute load average
*/
double
load()
load(void)
{
double avenrun[3];
@ -250,7 +245,7 @@ load()
* count them.
*/
int
users()
users(void)
{
static struct utmpentry *ohead = NULL;
struct utmpentry *ep;
@ -265,7 +260,7 @@ users()
}
void
nogamefile()
nogamefile(void)
{
int fd, n;
char buf[BUFSIZ];
@ -284,8 +279,7 @@ nogamefile()
* print out the hour in human form
*/
const char *
hour(h)
int h;
hour(int h)
{
static const char *const hours[] = {
"midnight", "1am", "2am", "3am", "4am", "5am",
@ -304,7 +298,7 @@ hour(h)
* logfile --
* log play of game
*/
logfile()
logfile(void)
{
struct passwd *pw;
FILE *lp;

View File

@ -1,4 +1,4 @@
/* $NetBSD: fish.c,v 1.16 2005/02/15 12:56:20 jsm Exp $ */
/* $NetBSD: fish.c,v 1.17 2005/07/02 08:38:24 jmc Exp $ */
/*-
* Copyright (c) 1990, 1993
@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1990, 1993\n\
#if 0
static char sccsid[] = "@(#)fish.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: fish.c,v 1.16 2005/02/15 12:56:20 jsm Exp $");
__RCSID("$NetBSD: fish.c,v 1.17 2005/07/02 08:38:24 jmc Exp $");
#endif
#endif /* not lint */
@ -87,7 +87,6 @@ int gofish(int, int, int *);
void goodmove(int, int, int *, int *);
void init(void);
void instructions(void);
int main(int, char *[]);
int nrandom(int);
void printhand(const int *);
void printplayer(int);
@ -96,9 +95,7 @@ void usage(void) __attribute__((__noreturn__));
int usermove(void);
int
main(argc, argv)
int argc;
char **argv;
main(int argc, char **argv)
{
int ch, move;
@ -150,7 +147,7 @@ istart: for (;;) {
}
int
usermove()
usermove(void)
{
int n;
const char *const *p;
@ -205,7 +202,7 @@ usermove()
}
int
compmove()
compmove(void)
{
static int lmove;
@ -223,7 +220,7 @@ compmove()
}
int
promove()
promove(void)
{
int i, max;
@ -262,9 +259,7 @@ promove()
}
int
drawcard(player, hand)
int player;
int *hand;
drawcard(int player, int *hand)
{
int card;
@ -283,9 +278,7 @@ drawcard(player, hand)
}
int
gofish(askedfor, player, hand)
int askedfor, player;
int *hand;
gofish(int askedfor, int player, int *hand)
{
printplayer(OTHER(player));
(void)printf("say \"GO FISH!\"\n");
@ -300,9 +293,7 @@ gofish(askedfor, player, hand)
}
void
goodmove(player, move, hand, opphand)
int player, move;
int *hand, *opphand;
goodmove(int player, int move, int *hand, int *opphand)
{
printplayer(OTHER(player));
(void)printf("have %d %s%s.\n",
@ -324,9 +315,7 @@ goodmove(player, move, hand, opphand)
}
void
chkwinner(player, hand)
int player;
const int *hand;
chkwinner(int player, const int *hand)
{
int cb, i, ub;
@ -354,8 +343,7 @@ chkwinner(player, hand)
}
void
printplayer(player)
int player;
printplayer(int player)
{
switch (player) {
case COMPUTER:
@ -368,8 +356,7 @@ printplayer(player)
}
void
printhand(hand)
const int *hand;
printhand(const int *hand)
{
int book, i, j;
@ -389,8 +376,7 @@ printhand(hand)
}
int
countcards(hand)
const int *hand;
countcards(const int *hand)
{
int i, count;
@ -400,8 +386,7 @@ countcards(hand)
}
int
countbooks(hand)
const int *hand;
countbooks(const int *hand)
{
int i, count;
@ -417,7 +402,7 @@ countbooks(hand)
}
void
init()
init(void)
{
int i, j, temp;
@ -438,15 +423,14 @@ init()
}
int
nrandom(n)
int n;
nrandom(int n)
{
return((int)random() % n);
}
void
instructions()
instructions(void)
{
int input;
pid_t pid;
@ -487,7 +471,7 @@ instructions()
}
void
usage()
usage(void)
{
(void)fprintf(stderr, "usage: fish [-p]\n");
exit(1);