-+-+-+-+-+-+-+-+ START OF PART 4 -+-+-+-+-+-+-+-+ X wrefresh(board_win); X return; X`7D X X/*************************************************************************** V***/ X Xdisplay_hand(hand, max, see, whose_side) X/* X *`09 Display a hand so that we can see what we have in card format. X */ Xstruct card_hand hand;`09`09/* The hand to display. */ Xint max, see, whose_side;`09/* max -> number of cards X`09`09`09`09 * see -> ? VISIBLE : INVISIBLE X`09`09`09`09 * whose -> ? ME : YOU X`09`09`09`09 */ X`7B X /** display hand as a bunch of cards **/ X register int i; X int offset;`09/* Offset from the edge that the card will be. */ X X for (i=0;i whose side the hand is on. X */ X`7B X int i; X if (whose == ME) X for (i=0;i<4;i++) delwin(my_card_win`5Bi`5D); X else X for (i=0;i<4;i++) delwin(your_card_win`5Bi`5D); X`7D X X/*************************************************************************** V***/ X Xmake_card (win_name,card_name,y,x) X/* X *`09 This procedure will make up a card and display it on the screen. X *`09It *must* be called like: X *`09make_card (&win_name,card_name,y,x); X */ XWINDOW`09**win_name;`09/* Name of the new window. */ Xchar`09*card_name;`09/* Name of the card. */ Xint`09y,x;`09`09/* Where to put this card. */ X`7B X *win_name = newwin(5,7,y,x); X box(*win_name,'`7C','-'); X mvwaddstr(*win_name, 1, 1, card_name); X mvwaddstr(*win_name, 3, 4, card_name); X wrefresh(*win_name); X`7D X X/*************************************************************************** V***/ X Xremove_card(win_hand,num_to_pull,whose_side) X/* X *`09 This procedure will remove a card from the hand and redisplay the X *`09hand after that. It assumes that the last element in the array will X *`09be a null. X */ XWINDOW`09*win_hand`5B7`5D; Xint`09num_to_pull,whose_side;`09/* num_to_pull -> number of card in hand. X`09`09`09`09 * whose -> ? ME : YOU X`09`09`09`09 */ X`7B X int offset, i; X X delwin (win_hand`5Bnum_to_pull`5D); X for (i=num_to_pull;win_hand`5Bi`5D!=NULL;i++) win_hand`5Bi`5D = win_hand`5 VBi+1`5D; X for (i=0;win_hand`5Bi`5D!=NULL;i++) X `7B X offset = (i%2) * 3; X if (whose_side == ME) X`09mvwin(win_hand`5Bi`5D,MY_CARD_TOP+(i*2),MY_CARD_EDGE+offset); X else X`09mvwin(win_hand`5Bi`5D,YOUR_CARD_TOP+(i*2),YOUR_CARD_EDGE+offset); X wrefresh(win_hand`5Bi`5D); X `7D X`7D X X/*************************************************************************** V***/ X Xcleanup() X/* X * This procedure will cleanup the screen and set the screen back to wha Vt it X * was. X */ X`7B X sleep(5); X endwin(); X exit(1); X`7D $ CALL UNPACK CRIBBAGE.C;1 1748454548 $ create 'f' X X X XCRIBBAGE(6) UNIX Programmer's Manual CRIBBAGE(6) X X X XNAME X cribbage - play the computer in cribbage X XSYNOPSIS X cribbage `5B-v`5D `5B-l limit`5D X XHP-UX COMPATIBILITY X Level: HP-UX/STANDARD X X Origin: Hewlett Packard X XDESCRIPTION X _`08C_`08r_`08i_`08b_`08b_`08a_`08g_`08e allows the user to play a game V of cribbage against X the computer. X X All the rules of cribbage are implemented. X X The -_`08v option sets verbose mode, which allows the player to X see how the computer is counting hand points. X X The -_`08l option allows you to specify the number of points to X play up to - the default is 150 points... X XAUTHOR X Dave Taylor, Hewlett Packard Colorado Network Operation X XSEE ALSO X _`08H_`08o_`08y_`08l_`08e'_`08s _`08R_`08u_`08l_`08e_`08s _`08o_`08f _` V08t_`08h_`08e _`08G_`08a_`08m_`08e_`08s _`08f_`08o_`08r _`08i_`08n_`08s_`08t V_`08r_`08u_`08c_`08t_`08i_`08o_`08n_`08s X X X X X X X X X X X X X X X X X X X X X X X X X X X XPrinted 2/18/86 1 X X X $ CALL UNPACK CRIBBAGE.MAN;1 588407049 $ create 'f' X/* X`09I got this off net.sources from Henry Spencer. X`09It is a public domain getopt(3) like in System V. X`09I have made the following modifications: X X`09index(s,c) was added because too many people could X`09not compile getopt without it. X X`09A test main program was added, ifdeffed by STANDALONE. X`09This main program is a public domain implementation X`09of the getopt(1) program like in System V. The getopt X`09program can be used to standardize shell option handling. X`09`09e.g. cc -DSTANDALONE getopt.c -o getopt X*/ X#include X X#ifndef lint Xstatic`09char`09sccsfid`5B`5D = "@(#) getopt.c 5.0 (UTZoo) 1985"; X#endif X X#define`09ARGCH (int)':' X#define BADCH`09 (int)'?' X#define EMSG`09 "" X#define`09ENDARGS "--" X X/* this is included because index is not on some UNIX systems */ Xstatic Xchar * Xindex (s, c) Xregister`09char`09*s; Xregister`09int `09c; X`09`7B X`09while (*s) X`09`09if (c == *s) return (s); X`09`09else s++; X`09return (NULL); X`09`7D X X/* X * get option letter from argument vector X */ Xint`09opterr = 1,`09`09/* useless, never set or used */ X`09optind = 1,`09`09/* index into parent argv vector */ X`09optopt;`09`09`09/* character checked for validity */ Xchar`09*optarg;`09`09/* argument associated with option */ X X#define tell(s)`09fputs(*nargv,stderr);fputs(s,stderr); \ X`09`09fputc(optopt,stderr);fputc('\n',stderr);return(BADCH); X`0C X Xgetopt(nargc,nargv,ostr) Xint`09nargc; Xchar`09**nargv, X`09*ostr; X`7B X`09static char`09*place = EMSG;`09/* option letter processing */ X`09register char`09*oli;`09`09/* option letter list index */ X`09char`09*index(); X X`09if(!*place) `7B`09`09`09/* update scanning pointer */ X`09`09if(optind >= nargc `7C`7C *(place = nargv`5Boptind`5D) != '-' `7C`7C ! V*++place) return(EOF); X`09`09if (*place == '-') `7B`09/* found "--" */ X`09`09`09++optind; X`09`09`09return(EOF); X`09`09`7D X`09`7D`09`09`09`09/* option letter okay? */ X`09if ((optopt = (int)*place++) == ARGCH `7C`7C !(oli = index(ostr,optopt))) V `7B X`09`09if(!*place) ++optind; X`09`09tell(": illegal option -- "); X`09`7D X`09if (*++oli != ARGCH) `7B`09`09/* don't need argument */ X`09`09optarg = NULL; X`09`09if (!*place) ++optind; X`09`7D X`09else `7B`09`09`09`09/* need an argument */ X`09`09if (*place) optarg = place;`09/* no white space */ X`09`09else if (nargc <= ++optind) `7B`09/* no arg */ X`09`09`09place = EMSG; X`09`09`09tell(": option requires an argument -- "); X`09`09`7D X`09 `09else optarg = nargv`5Boptind`5D;`09/* white space */ X`09`09place = EMSG; X`09`09++optind; X`09`7D X`09return(optopt);`09`09`09/* dump back option letter */ X`7D X X`0C X#ifdef STANDALONE X X#ifndef lint Xstatic`09char`09sccspid`5B`5D = "@(#) getopt.c 5.1 (WangInst) 6/15/85"; X#endif X Xmain (argc, argv) char **argv; X`09`7B X`09char`09*optstring = argv`5B1`5D; X`09char`09*argv0 = argv`5B0`5D; X`09extern`09int `09optind; X`09extern`09char`09*optarg; X`09int `09opterr = 0; X`09int `09C; X`09char`09*opi; X`09if (argc == 1) X`09`09`7B X`09`09fprintf (stderr, "Usage: %s optstring args\n", argv0); X`09`09exit (1); X`09`09`7D X`09argv++; X`09argc--; X`09argv`5B0`5D = argv0; X`09while ((C = getopt (argc, argv, optstring)) != EOF) X`09`09`7B X`09`09if (C == BADCH) opterr++; X`09`09printf ("-%c ", C); X`09`09opi = index (optstring, C); X`09`09if (opi && opi`5B1`5D == ARGCH) X`09`09`09if (optarg) X`09`09`09`09printf ("\"%s\" ", optarg); X`09`09`09else opterr++; X`09`09`7D X`09printf ("%s", ENDARGS); X`09while (optind < argc) X`09`09printf (" \"%s\"", argv`5Boptind++`5D); X`09putchar ('\n'); X`09exit (opterr); X`09`7D X X#endif $ CALL UNPACK GETOPT.C;1 2132699549 $ v=f$verify(v) $ EXIT