sprinkle static
This commit is contained in:
parent
f59d107e64
commit
e0ba63fe83
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: cards.c,v 1.8 2005/07/02 08:32:32 jmc Exp $ */
|
||||
/* $NetBSD: cards.c,v 1.9 2009/08/12 05:48:04 dholland Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1980, 1993
|
||||
@ -34,7 +34,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)cards.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: cards.c,v 1.8 2005/07/02 08:32:32 jmc Exp $");
|
||||
__RCSID("$NetBSD: cards.c,v 1.9 2009/08/12 05:48:04 dholland Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -87,7 +87,7 @@ shuffle(CARD d[])
|
||||
/*
|
||||
* return true if the two cards are equal...
|
||||
*/
|
||||
int
|
||||
static int
|
||||
eq(CARD a, CARD b)
|
||||
{
|
||||
return ((a.rank == b.rank) && (a.suit == b.suit));
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: crib.c,v 1.23 2009/07/13 19:05:40 roy Exp $ */
|
||||
/* $NetBSD: crib.c,v 1.24 2009/08/12 05:48:04 dholland Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1980, 1993
|
||||
@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1993\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)crib.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: crib.c,v 1.23 2009/07/13 19:05:40 roy Exp $");
|
||||
__RCSID("$NetBSD: crib.c,v 1.24 2009/08/12 05:48:04 dholland Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -56,6 +56,18 @@ __RCSID("$NetBSD: crib.c,v 1.23 2009/07/13 19:05:40 roy Exp $");
|
||||
#include "cribcur.h"
|
||||
#include "pathnames.h"
|
||||
|
||||
static void makeboard(void);
|
||||
static void gamescore(void);
|
||||
static void game(void);
|
||||
static int playhand(BOOLEAN);
|
||||
static int deal(BOOLEAN);
|
||||
static void discard(BOOLEAN);
|
||||
static int cut(BOOLEAN, int);
|
||||
static void prcrib(BOOLEAN, BOOLEAN);
|
||||
static int peg(BOOLEAN);
|
||||
static void prtable(int);
|
||||
static int score(BOOLEAN);
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
@ -158,7 +170,7 @@ main(int argc, char *argv[])
|
||||
* makeboard:
|
||||
* Print out the initial board on the screen
|
||||
*/
|
||||
void
|
||||
static void
|
||||
makeboard(void)
|
||||
{
|
||||
mvaddstr(SCORE_Y + 0, SCORE_X,
|
||||
@ -186,7 +198,7 @@ makeboard(void)
|
||||
* gamescore:
|
||||
* Print out the current game score
|
||||
*/
|
||||
void
|
||||
static void
|
||||
gamescore(void)
|
||||
{
|
||||
if (pgames || cgames) {
|
||||
@ -202,7 +214,7 @@ gamescore(void)
|
||||
* Play one game up to glimit points. Actually, we only ASK the
|
||||
* player what card to turn. We do a random one, anyway.
|
||||
*/
|
||||
void
|
||||
static void
|
||||
game(void)
|
||||
{
|
||||
int i, j;
|
||||
@ -296,7 +308,7 @@ game(void)
|
||||
* playhand:
|
||||
* Do up one hand of the game
|
||||
*/
|
||||
int
|
||||
static int
|
||||
playhand(BOOLEAN mycrib)
|
||||
{
|
||||
int deckpos;
|
||||
@ -327,7 +339,7 @@ playhand(BOOLEAN mycrib)
|
||||
/*
|
||||
* deal cards to both players from deck
|
||||
*/
|
||||
int
|
||||
static int
|
||||
deal(BOOLEAN mycrib)
|
||||
{
|
||||
int i, j;
|
||||
@ -349,7 +361,7 @@ deal(BOOLEAN mycrib)
|
||||
* Handle players discarding into the crib...
|
||||
* Note: we call cdiscard() after prining first message so player doesn't wait
|
||||
*/
|
||||
void
|
||||
static void
|
||||
discard(BOOLEAN mycrib)
|
||||
{
|
||||
const char *prompt;
|
||||
@ -378,7 +390,7 @@ discard(BOOLEAN mycrib)
|
||||
* Cut the deck and set turnover. Actually, we only ASK the
|
||||
* player what card to turn. We do a random one, anyway.
|
||||
*/
|
||||
int
|
||||
static int
|
||||
cut(BOOLEAN mycrib, int pos)
|
||||
{
|
||||
int i;
|
||||
@ -420,7 +432,7 @@ cut(BOOLEAN mycrib, int pos)
|
||||
* prcrib:
|
||||
* Print out the turnover card with crib indicator
|
||||
*/
|
||||
void
|
||||
static void
|
||||
prcrib(BOOLEAN mycrib, BOOLEAN blank)
|
||||
{
|
||||
int y, cardx;
|
||||
@ -450,7 +462,7 @@ prcrib(BOOLEAN mycrib, BOOLEAN blank)
|
||||
static CARD Table[14];
|
||||
static int Tcnt;
|
||||
|
||||
int
|
||||
static int
|
||||
peg(BOOLEAN mycrib)
|
||||
{
|
||||
static CARD ch[CINHAND], ph[CINHAND];
|
||||
@ -609,7 +621,7 @@ peg(BOOLEAN mycrib)
|
||||
* prtable:
|
||||
* Print out the table with the current score
|
||||
*/
|
||||
void
|
||||
static void
|
||||
prtable(int curscore)
|
||||
{
|
||||
prhand(Table, Tcnt, Tablewin, FALSE);
|
||||
@ -621,7 +633,7 @@ prtable(int curscore)
|
||||
* score:
|
||||
* Handle the scoring of the hands
|
||||
*/
|
||||
int
|
||||
static int
|
||||
score(BOOLEAN mycrib)
|
||||
{
|
||||
sorthand(crib, CINHAND);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: cribbage.h,v 1.14 2009/07/13 19:05:40 roy Exp $ */
|
||||
/* $NetBSD: cribbage.h,v 1.15 2009/08/12 05:48:04 dholland Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1993
|
||||
@ -60,52 +60,30 @@ void addmsg(const char *, ...)
|
||||
__attribute__((__format__(__printf__, 1, 2)));
|
||||
int adjust(const CARD [], CARD);
|
||||
int anymove(const CARD [], int, int);
|
||||
int anysumto(const CARD [], int, int, int);
|
||||
void bye(void);
|
||||
int cchose(const CARD [], int, int);
|
||||
void cdiscard(BOOLEAN);
|
||||
int chkscr(int *, int);
|
||||
int comphand(const CARD [], const char *);
|
||||
void cremove(CARD, CARD [], int);
|
||||
int cut(BOOLEAN, int);
|
||||
int deal(BOOLEAN);
|
||||
void discard(BOOLEAN);
|
||||
void do_wait(void);
|
||||
void endmsg(void);
|
||||
int eq(CARD, CARD);
|
||||
int fifteens(const CARD [], int);
|
||||
void game(void);
|
||||
void gamescore(void);
|
||||
char *get_line(void);
|
||||
int getuchar(void);
|
||||
int incard(CARD *);
|
||||
int infrom(const CARD [], int, const char *);
|
||||
void instructions(void);
|
||||
int is_one(CARD, const CARD [], int);
|
||||
void makeboard(void);
|
||||
void makedeck(CARD []);
|
||||
void makeknown(const CARD [], int);
|
||||
void msg(const char *, ...)
|
||||
__attribute__((__format__(__printf__, 1, 2)));
|
||||
int msgcard(CARD, BOOLEAN);
|
||||
int msgcrd(CARD, BOOLEAN, const char *, BOOLEAN);
|
||||
int number(int, int, const char *);
|
||||
int numofval(const CARD [], int, int);
|
||||
int pairuns(const CARD [], int);
|
||||
int peg(BOOLEAN);
|
||||
int pegscore(CARD, const CARD [], int, int);
|
||||
int playhand(BOOLEAN);
|
||||
int plyrhand(const CARD [], const char *);
|
||||
void prcard(WINDOW *, int, int, CARD, BOOLEAN);
|
||||
void prcrib(BOOLEAN, BOOLEAN);
|
||||
void prhand(const CARD [], int, WINDOW *, BOOLEAN);
|
||||
void printcard(WINDOW *, int, CARD, BOOLEAN);
|
||||
void prpeg(int, int, BOOLEAN);
|
||||
void prtable(int);
|
||||
int readchar(void);
|
||||
void receive_intr(int) __attribute__((__noreturn__));
|
||||
int score(BOOLEAN);
|
||||
int scorehand(const CARD [], CARD, int, BOOLEAN, BOOLEAN);
|
||||
void shuffle(CARD []);
|
||||
void sorthand(CARD [], int);
|
||||
void wait_for(int);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: io.c,v 1.23 2009/07/13 19:05:40 roy Exp $ */
|
||||
/* $NetBSD: io.c,v 1.24 2009/08/12 05:48:04 dholland Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1980, 1993
|
||||
@ -34,7 +34,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)io.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: io.c,v 1.23 2009/07/13 19:05:40 roy Exp $");
|
||||
__RCSID("$NetBSD: io.c,v 1.24 2009/08/12 05:48:04 dholland Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -58,20 +58,28 @@ __RCSID("$NetBSD: io.c,v 1.23 2009/07/13 19:05:40 roy Exp $");
|
||||
#endif
|
||||
#define CTRL(X) (X - 'A' + 1)
|
||||
|
||||
char linebuf[LINESIZE];
|
||||
static int msgcrd(CARD, BOOLEAN, const char *, BOOLEAN);
|
||||
static void printcard(WINDOW *, int, CARD, BOOLEAN);
|
||||
static int incard(CARD *);
|
||||
static void wait_for(int);
|
||||
static int readchar(void);
|
||||
|
||||
const char *const rankname[RANKS] = {
|
||||
static char linebuf[LINESIZE];
|
||||
|
||||
static const char *const rankname[RANKS] = {
|
||||
"ACE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN",
|
||||
"EIGHT", "NINE", "TEN", "JACK", "QUEEN", "KING"
|
||||
};
|
||||
|
||||
const char *const rankchar[RANKS] = {
|
||||
static const char *const rankchar[RANKS] = {
|
||||
"A", "2", "3", "4", "5", "6", "7", "8", "9", "T", "J", "Q", "K"
|
||||
};
|
||||
|
||||
const char *const suitname[SUITS] = {"SPADES", "HEARTS", "DIAMONDS", "CLUBS"};
|
||||
static const char *const suitname[SUITS] = {
|
||||
"SPADES", "HEARTS", "DIAMONDS", "CLUBS"
|
||||
};
|
||||
|
||||
const char *const suitchar[SUITS] = {"S", "H", "D", "C"};
|
||||
static const char *const suitchar[SUITS] = {"S", "H", "D", "C"};
|
||||
|
||||
/*
|
||||
* msgcard:
|
||||
@ -92,7 +100,7 @@ msgcard(c, brief)
|
||||
* msgcrd:
|
||||
* Print the value of a card in ascii
|
||||
*/
|
||||
int
|
||||
static int
|
||||
msgcrd(CARD c, BOOLEAN brfrank, const char *mid, BOOLEAN brfsuit)
|
||||
{
|
||||
if (c.rank == EMPTY || c.suit == EMPTY)
|
||||
@ -114,7 +122,7 @@ msgcrd(CARD c, BOOLEAN brfrank, const char *mid, BOOLEAN brfsuit)
|
||||
* printcard:
|
||||
* Print out a card.
|
||||
*/
|
||||
void
|
||||
static void
|
||||
printcard(WINDOW *win, int cardno, CARD c, BOOLEAN blank)
|
||||
{
|
||||
prcard(win, cardno * 2, cardno, c, blank);
|
||||
@ -216,7 +224,7 @@ infrom(const CARD hand[], int n, const char *prompt)
|
||||
* Inputs a card in any format. It reads a line ending with a CR
|
||||
* and then parses it.
|
||||
*/
|
||||
int
|
||||
static int
|
||||
incard(CARD *crd)
|
||||
{
|
||||
int i;
|
||||
@ -357,8 +365,8 @@ number(int lo, int hi, const char *prompt)
|
||||
* msg:
|
||||
* Display a message at the top of the screen.
|
||||
*/
|
||||
char Msgbuf[BUFSIZ] = {'\0'};
|
||||
int Mpos = 0;
|
||||
static char Msgbuf[BUFSIZ] = {'\0'};
|
||||
static int Mpos = 0;
|
||||
static int Newpos = 0;
|
||||
|
||||
void
|
||||
@ -392,7 +400,7 @@ addmsg(const char *fmt, ...)
|
||||
* endmsg:
|
||||
* Display a new msg.
|
||||
*/
|
||||
int Lineno = 0;
|
||||
static int Lineno = 0;
|
||||
|
||||
void
|
||||
endmsg(void)
|
||||
@ -465,7 +473,7 @@ do_wait(void)
|
||||
* wait_for
|
||||
* Sit around until the guy types the right key
|
||||
*/
|
||||
void
|
||||
static void
|
||||
wait_for(int ch)
|
||||
{
|
||||
int c;
|
||||
@ -482,7 +490,7 @@ wait_for(int ch)
|
||||
* readchar:
|
||||
* Reads and returns a character, checking for gross input errors
|
||||
*/
|
||||
int
|
||||
static int
|
||||
readchar(void)
|
||||
{
|
||||
int cnt;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: score.c,v 1.14 2009/06/04 04:48:04 dholland Exp $ */
|
||||
/* $NetBSD: score.c,v 1.15 2009/08/12 05:48:04 dholland Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1980, 1993
|
||||
@ -34,7 +34,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)score.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: score.c,v 1.14 2009/06/04 04:48:04 dholland Exp $");
|
||||
__RCSID("$NetBSD: score.c,v 1.15 2009/08/12 05:48:04 dholland Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -46,13 +46,16 @@ __RCSID("$NetBSD: score.c,v 1.14 2009/06/04 04:48:04 dholland Exp $");
|
||||
#include "deck.h"
|
||||
#include "cribbage.h"
|
||||
|
||||
static int fifteens(const CARD [], int);
|
||||
static int pairuns(const CARD [], int);
|
||||
|
||||
/*
|
||||
* the following arrays give the sum of the scores of the (50 2)*48 = 58800
|
||||
* hands obtainable for the crib given the two cards whose ranks index the
|
||||
* array. the two arrays are for the case where the suits are equal and
|
||||
* not equal respectively
|
||||
*/
|
||||
const long crbescr[169] = {
|
||||
static const long crbescr[169] = {
|
||||
-10000, 271827, 278883, 332319, 347769, 261129, 250653, 253203, 248259,
|
||||
243435, 256275, 237435, 231051, -10000, -10000, 412815, 295707, 349497,
|
||||
267519, 262521, 259695, 254019, 250047, 262887, 244047, 237663, -10000,
|
||||
@ -74,7 +77,7 @@ const long crbescr[169] = {
|
||||
-10000, -10000, -10000, -10000, -10000, -10000, -10000
|
||||
};
|
||||
|
||||
const long crbnescr[169] = {
|
||||
static const long crbnescr[169] = {
|
||||
325272, 260772, 267828, 321264, 336714, 250074, 239598, 242148, 237204,
|
||||
232380, 246348, 226380, 219996, -10000, 342528, 401760, 284652, 338442,
|
||||
256464, 251466, 248640, 242964, 238992, 252960, 232992, 226608, -10000,
|
||||
@ -177,7 +180,7 @@ scorehand(const CARD hand[], CARD starter, int n, BOOLEAN crb,
|
||||
* fifteens:
|
||||
* Return number of fifteens in hand of n cards
|
||||
*/
|
||||
int
|
||||
static int
|
||||
fifteens(const CARD hand[], int n)
|
||||
{
|
||||
int *sp, *np;
|
||||
@ -218,7 +221,7 @@ fifteens(const CARD hand[], int n)
|
||||
* this routine only works if n is strictly less than 6
|
||||
* sets the globals pairpoints and runpoints appropriately
|
||||
*/
|
||||
int
|
||||
static int
|
||||
pairuns(const CARD h[], int n)
|
||||
{
|
||||
int i;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: support.c,v 1.13 2009/06/04 04:48:04 dholland Exp $ */
|
||||
/* $NetBSD: support.c,v 1.14 2009/08/12 05:48:04 dholland Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1980, 1993
|
||||
@ -34,7 +34,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)support.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: support.c,v 1.13 2009/06/04 04:48:04 dholland Exp $");
|
||||
__RCSID("$NetBSD: support.c,v 1.14 2009/08/12 05:48:04 dholland Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -49,7 +49,11 @@ __RCSID("$NetBSD: support.c,v 1.13 2009/06/04 04:48:04 dholland Exp $");
|
||||
#define NTV 10 /* number scores to test */
|
||||
|
||||
/* score to test reachability of, and order to test them in */
|
||||
const int tv[NTV] = {8, 7, 9, 6, 11, 12, 13, 14, 10, 5};
|
||||
static const int tv[NTV] = {8, 7, 9, 6, 11, 12, 13, 14, 10, 5};
|
||||
|
||||
static int anysumto(const CARD[], int, int, int);
|
||||
static void prpeg(int, int, BOOLEAN);
|
||||
static int numofval(const CARD[], int, int);
|
||||
|
||||
/*
|
||||
* computer chooses what to play in pegging...
|
||||
@ -199,7 +203,7 @@ chkscr(int *scr, int inc)
|
||||
* Put out the peg character on the score board and put the
|
||||
* score up on the board.
|
||||
*/
|
||||
void
|
||||
static void
|
||||
prpeg(int curscore, int pegc, BOOLEAN myturn)
|
||||
{
|
||||
int y, x;
|
||||
@ -306,7 +310,7 @@ anymove(const CARD hand[], int n, int sum)
|
||||
* anysumto returns the index (0 <= i < n) of the card in hand that brings
|
||||
* the s up to t, or -1 if there is none
|
||||
*/
|
||||
int
|
||||
static int
|
||||
anysumto(const CARD hand[], int n, int s, int t)
|
||||
{
|
||||
int i;
|
||||
@ -321,7 +325,7 @@ anysumto(const CARD hand[], int n, int s, int t)
|
||||
/*
|
||||
* return the number of cards in h having the given rank value
|
||||
*/
|
||||
int
|
||||
static int
|
||||
numofval(const CARD h[], int n, int v)
|
||||
{
|
||||
int i, j;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: dm.c,v 1.27 2009/08/06 17:55:18 dholland Exp $ */
|
||||
/* $NetBSD: dm.c,v 1.28 2009/08/12 05:51:59 dholland Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1987, 1993
|
||||
@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 1993\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)dm.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: dm.c,v 1.27 2009/08/06 17:55:18 dholland Exp $");
|
||||
__RCSID("$NetBSD: dm.c,v 1.28 2009/08/12 05:51:59 dholland 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[] = {
|
||||
@ -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,7 +209,7 @@ c_tty(const char *tty)
|
||||
* c_game --
|
||||
* see if game can be played now.
|
||||
*/
|
||||
void
|
||||
static void
|
||||
c_game(const char *s_game, const char *s_load, const char *s_users,
|
||||
const char *s_priority)
|
||||
{
|
||||
@ -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;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: factor.c,v 1.18 2008/07/20 01:03:21 lukem Exp $ */
|
||||
/* $NetBSD: factor.c,v 1.19 2009/08/12 05:54:31 dholland Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1993
|
||||
@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1993\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)factor.c 8.4 (Berkeley) 5/4/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: factor.c,v 1.18 2008/07/20 01:03:21 lukem Exp $");
|
||||
__RCSID("$NetBSD: factor.c,v 1.19 2009/08/12 05:54:31 dholland Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -78,7 +78,7 @@ __RCSID("$NetBSD: factor.c,v 1.18 2008/07/20 01:03:21 lukem Exp $");
|
||||
#else
|
||||
typedef long BIGNUM;
|
||||
typedef u_long BN_ULONG;
|
||||
int BN_dec2bn(BIGNUM **a, const char *str);
|
||||
static int BN_dec2bn(BIGNUM **a, const char *str);
|
||||
#define BN_new() ((BIGNUM *)calloc(sizeof(BIGNUM), 1))
|
||||
#define BN_is_zero(v) (*(v) == 0)
|
||||
#define BN_is_one(v) (*(v) == 1)
|
||||
@ -102,23 +102,22 @@ extern const ubig *pr_limit; /* largest prime in the prime array */
|
||||
#define PRIME_CHECKS 5
|
||||
|
||||
#ifdef HAVE_OPENSSL
|
||||
BN_CTX *ctx; /* just use a global context */
|
||||
static BN_CTX *ctx; /* just use a global context */
|
||||
#endif
|
||||
|
||||
int main(int, char *[]);
|
||||
void pr_fact(BIGNUM *); /* print factors of a value */
|
||||
void BN_print_dec_fp(FILE *, const BIGNUM *);
|
||||
void usage(void) __dead;
|
||||
static void pr_fact(BIGNUM *); /* print factors of a value */
|
||||
static void BN_print_dec_fp(FILE *, const BIGNUM *);
|
||||
static void usage(void) __dead;
|
||||
#ifdef HAVE_OPENSSL
|
||||
void pollard_pminus1(BIGNUM *); /* print factors for big numbers */
|
||||
static void pollard_pminus1(BIGNUM *); /* print factors for big numbers */
|
||||
#else
|
||||
char *BN_bn2dec(const BIGNUM *);
|
||||
BN_ULONG BN_div_word(BIGNUM *, BN_ULONG);
|
||||
static char *BN_bn2dec(const BIGNUM *);
|
||||
static BN_ULONG BN_div_word(BIGNUM *, BN_ULONG);
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef HAVE_OPENSSL
|
||||
int
|
||||
static int
|
||||
BN_dec2bn(BIGNUM **a, const char *str)
|
||||
{
|
||||
char *p;
|
||||
@ -196,7 +195,7 @@ main(int argc, char *argv[])
|
||||
*
|
||||
* Factors are printed with leading tabs.
|
||||
*/
|
||||
void
|
||||
static void
|
||||
pr_fact(BIGNUM *val)
|
||||
{
|
||||
const ubig *fact; /* The factor found. */
|
||||
@ -256,7 +255,7 @@ pr_fact(BIGNUM *val)
|
||||
/*
|
||||
* Sigh.. No _decimal_ output to file functions in BN.
|
||||
*/
|
||||
void
|
||||
static void
|
||||
BN_print_dec_fp(FILE *fp, const BIGNUM *num)
|
||||
{
|
||||
char *buf;
|
||||
@ -281,7 +280,7 @@ usage(void)
|
||||
#ifdef HAVE_OPENSSL
|
||||
/* pollard p-1, algorithm from Jim Gillogly, May 2000 */
|
||||
|
||||
void
|
||||
static void
|
||||
pollard_pminus1(BIGNUM *val)
|
||||
{
|
||||
BIGNUM *base, *rbase, *num, *i, *x;
|
||||
@ -344,7 +343,7 @@ BN_bn2dec(const BIGNUM *val)
|
||||
return buf;
|
||||
}
|
||||
|
||||
BN_ULONG
|
||||
static BN_ULONG
|
||||
BN_div_word(BIGNUM *a, BN_ULONG b)
|
||||
{
|
||||
BN_ULONG mod;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: fish.c,v 1.19 2008/07/20 01:03:21 lukem Exp $ */
|
||||
/* $NetBSD: fish.c,v 1.20 2009/08/12 05:55:53 dholland Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993
|
||||
@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1990, 1993\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)fish.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: fish.c,v 1.19 2008/07/20 01:03:21 lukem Exp $");
|
||||
__RCSID("$NetBSD: fish.c,v 1.20 2009/08/12 05:55:53 dholland Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -67,32 +67,32 @@ __RCSID("$NetBSD: fish.c,v 1.19 2008/07/20 01:03:21 lukem Exp $");
|
||||
#define COMPUTER 0
|
||||
#define OTHER(a) (1 - (a))
|
||||
|
||||
const char *const cards[] = {
|
||||
static const char *const cards[] = {
|
||||
"A", "2", "3", "4", "5", "6", "7",
|
||||
"8", "9", "10", "J", "Q", "K", NULL,
|
||||
};
|
||||
#define PRC(card) (void)printf(" %s", cards[card])
|
||||
|
||||
int promode;
|
||||
int asked[RANKS], comphand[RANKS], deck[TOTCARDS];
|
||||
int userasked[RANKS], userhand[RANKS];
|
||||
int curcard = TOTCARDS;
|
||||
static int promode;
|
||||
static int asked[RANKS], comphand[RANKS], deck[TOTCARDS];
|
||||
static int userasked[RANKS], userhand[RANKS];
|
||||
static int curcard = TOTCARDS;
|
||||
|
||||
void chkwinner(int, const int *);
|
||||
int compmove(void);
|
||||
int countbooks(const int *);
|
||||
int countcards(const int *);
|
||||
int drawcard(int, int *);
|
||||
int gofish(int, int, int *);
|
||||
void goodmove(int, int, int *, int *);
|
||||
void init(void);
|
||||
void instructions(void);
|
||||
int nrandom(int);
|
||||
void printhand(const int *);
|
||||
void printplayer(int);
|
||||
int promove(void);
|
||||
void usage(void) __dead;
|
||||
int usermove(void);
|
||||
static void chkwinner(int, const int *);
|
||||
static int compmove(void);
|
||||
static int countbooks(const int *);
|
||||
static int countcards(const int *);
|
||||
static int drawcard(int, int *);
|
||||
static int gofish(int, int, int *);
|
||||
static void goodmove(int, int, int *, int *);
|
||||
static void init(void);
|
||||
static void instructions(void);
|
||||
static int nrandom(int);
|
||||
static void printhand(const int *);
|
||||
static void printplayer(int);
|
||||
static int promove(void);
|
||||
static void usage(void) __dead;
|
||||
static int usermove(void);
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
@ -146,7 +146,7 @@ istart: for (;;) {
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
usermove(void)
|
||||
{
|
||||
int n;
|
||||
@ -201,7 +201,7 @@ usermove(void)
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
compmove(void)
|
||||
{
|
||||
static int lmove;
|
||||
@ -219,7 +219,7 @@ compmove(void)
|
||||
return(lmove);
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
promove(void)
|
||||
{
|
||||
int i, max;
|
||||
@ -258,7 +258,7 @@ promove(void)
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
drawcard(int player, int *hand)
|
||||
{
|
||||
int card;
|
||||
@ -277,7 +277,7 @@ drawcard(int player, int *hand)
|
||||
return(card);
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
gofish(int askedfor, int player, int *hand)
|
||||
{
|
||||
printplayer(OTHER(player));
|
||||
@ -292,7 +292,7 @@ gofish(int askedfor, int player, int *hand)
|
||||
return(0);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
goodmove(int player, int move, int *hand, int *opphand)
|
||||
{
|
||||
printplayer(OTHER(player));
|
||||
@ -314,7 +314,7 @@ goodmove(int player, int move, int *hand, int *opphand)
|
||||
(void)printf("get another guess!\n");
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
chkwinner(int player, const int *hand)
|
||||
{
|
||||
int cb, i, ub;
|
||||
@ -342,7 +342,7 @@ chkwinner(int player, const int *hand)
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
printplayer(int player)
|
||||
{
|
||||
switch (player) {
|
||||
@ -355,7 +355,7 @@ printplayer(int player)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
printhand(const int *hand)
|
||||
{
|
||||
int book, i, j;
|
||||
@ -375,7 +375,7 @@ printhand(const int *hand)
|
||||
(void)putchar('\n');
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
countcards(const int *hand)
|
||||
{
|
||||
int i, count;
|
||||
@ -385,7 +385,7 @@ countcards(const int *hand)
|
||||
return(count);
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
countbooks(const int *hand)
|
||||
{
|
||||
int i, count;
|
||||
@ -401,7 +401,7 @@ countbooks(const int *hand)
|
||||
return(count);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
init(void)
|
||||
{
|
||||
int i, j, temp;
|
||||
@ -422,14 +422,14 @@ init(void)
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
nrandom(int n)
|
||||
{
|
||||
|
||||
return((int)random() % n);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
instructions(void)
|
||||
{
|
||||
int input;
|
||||
@ -470,7 +470,7 @@ instructions(void)
|
||||
while ((input = getchar()) != EOF && input != '\n');
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
(void)fprintf(stderr, "usage: fish [-p]\n");
|
||||
|
Loading…
Reference in New Issue
Block a user