1*59264Sbostic /*- 2*59264Sbostic * Copyright (c) 1980 The Regents of the University of California. 333707Sbostic * All rights reserved. 433707Sbostic * 542576Sbostic * %sccs.include.redist.c% 621505Smckusick */ 712572Sarnold 821505Smckusick #ifndef lint 9*59264Sbostic static char sccsid[] = "@(#)io.c 5.13 (Berkeley) 04/26/93"; 1033707Sbostic #endif /* not lint */ 1121505Smckusick 12*59264Sbostic #include <ctype.h> 13*59264Sbostic #include <curses.h> 14*59264Sbostic #include <signal.h> 15*59264Sbostic #include <stdlib.h> 16*59264Sbostic #include <string.h> 17*59264Sbostic #include <termios.h> 18*59264Sbostic #include <unistd.h> 197709Sarnold 20*59264Sbostic #if __STDC__ 21*59264Sbostic #include <stdarg.h> 22*59264Sbostic #else 23*59264Sbostic #include <varargs.h> 24*59264Sbostic #endif 257709Sarnold 26*59264Sbostic #include "deck.h" 27*59264Sbostic #include "cribbage.h" 28*59264Sbostic #include "cribcur.h" 297709Sarnold 30*59264Sbostic #define LINESIZE 128 317872Sarnold 32*59264Sbostic #ifdef CTRL 33*59264Sbostic #undef CTRL 34*59264Sbostic #endif 35*59264Sbostic #define CTRL(X) (X - 'A' + 1) 367709Sarnold 37*59264Sbostic char linebuf[LINESIZE]; 387709Sarnold 39*59264Sbostic char *rankname[RANKS] = { 40*59264Sbostic "ACE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN", 41*59264Sbostic "EIGHT", "NINE", "TEN", "JACK", "QUEEN", "KING" 42*59264Sbostic }; 437709Sarnold 44*59264Sbostic char *rankchar[RANKS] = { 45*59264Sbostic "A", "2", "3", "4", "5", "6", "7", "8", "9", "T", "J", "Q", "K" 46*59264Sbostic }; 477709Sarnold 48*59264Sbostic char *suitname[SUITS] = {"SPADES", "HEARTS", "DIAMONDS", "CLUBS"}; 497709Sarnold 50*59264Sbostic char *suitchar[SUITS] = {"S", "H", "D", "C"}; 517709Sarnold 527709Sarnold /* 537872Sarnold * msgcard: 547872Sarnold * Call msgcrd in one of two forms 557709Sarnold */ 56*59264Sbostic int 577872Sarnold msgcard(c, brief) 58*59264Sbostic CARD c; 59*59264Sbostic BOOLEAN brief; 607709Sarnold { 617872Sarnold if (brief) 62*59264Sbostic return (msgcrd(c, TRUE, NULL, TRUE)); 637872Sarnold else 64*59264Sbostic return (msgcrd(c, FALSE, " of ", FALSE)); 657709Sarnold } 667709Sarnold 677709Sarnold /* 687872Sarnold * msgcrd: 697872Sarnold * Print the value of a card in ascii 707709Sarnold */ 71*59264Sbostic int 727872Sarnold msgcrd(c, brfrank, mid, brfsuit) 73*59264Sbostic CARD c; 74*59264Sbostic BOOLEAN brfrank, brfsuit; 75*59264Sbostic char *mid; 767872Sarnold { 777872Sarnold if (c.rank == EMPTY || c.suit == EMPTY) 78*59264Sbostic return (FALSE); 797872Sarnold if (brfrank) 80*59264Sbostic addmsg("%1.1s", rankchar[c.rank]); 817872Sarnold else 82*59264Sbostic addmsg(rankname[c.rank]); 837872Sarnold if (mid != NULL) 84*59264Sbostic addmsg(mid); 857872Sarnold if (brfsuit) 86*59264Sbostic addmsg("%1.1s", suitchar[c.suit]); 877872Sarnold else 88*59264Sbostic addmsg(suitname[c.suit]); 89*59264Sbostic return (TRUE); 907872Sarnold } 917709Sarnold 927872Sarnold /* 937872Sarnold * printcard: 947872Sarnold * Print out a card. 957872Sarnold */ 96*59264Sbostic void 978073Sarnold printcard(win, cardno, c, blank) 98*59264Sbostic WINDOW *win; 99*59264Sbostic int cardno; 100*59264Sbostic CARD c; 101*59264Sbostic BOOLEAN blank; 1027872Sarnold { 1038073Sarnold prcard(win, cardno * 2, cardno, c, blank); 1047872Sarnold } 1057709Sarnold 1067872Sarnold /* 1077872Sarnold * prcard: 1087872Sarnold * Print out a card on the window at the specified location 1097872Sarnold */ 110*59264Sbostic void 1117946Sarnold prcard(win, y, x, c, blank) 112*59264Sbostic WINDOW *win; 113*59264Sbostic int y, x; 114*59264Sbostic CARD c; 115*59264Sbostic BOOLEAN blank; 1167709Sarnold { 1177872Sarnold if (c.rank == EMPTY) 118*59264Sbostic return; 119*59264Sbostic 1207872Sarnold mvwaddstr(win, y + 0, x, "+-----+"); 1217872Sarnold mvwaddstr(win, y + 1, x, "| |"); 1227872Sarnold mvwaddstr(win, y + 2, x, "| |"); 1237872Sarnold mvwaddstr(win, y + 3, x, "| |"); 1247872Sarnold mvwaddstr(win, y + 4, x, "+-----+"); 1257946Sarnold if (!blank) { 1267946Sarnold mvwaddch(win, y + 1, x + 1, rankchar[c.rank][0]); 1277946Sarnold waddch(win, suitchar[c.suit][0]); 1287946Sarnold mvwaddch(win, y + 3, x + 4, rankchar[c.rank][0]); 1297946Sarnold waddch(win, suitchar[c.suit][0]); 1307946Sarnold } 1317709Sarnold } 1327709Sarnold 1337709Sarnold /* 1347872Sarnold * prhand: 1357872Sarnold * Print a hand of n cards 1367709Sarnold */ 137*59264Sbostic void 1388073Sarnold prhand(h, n, win, blank) 139*59264Sbostic CARD h[]; 140*59264Sbostic int n; 141*59264Sbostic WINDOW *win; 142*59264Sbostic BOOLEAN blank; 1437709Sarnold { 144*59264Sbostic register int i; 1457709Sarnold 1467872Sarnold werase(win); 1477872Sarnold for (i = 0; i < n; i++) 148*59264Sbostic printcard(win, i, *h++, blank); 1497872Sarnold wrefresh(win); 1507709Sarnold } 1517709Sarnold 1527709Sarnold /* 1537872Sarnold * infrom: 1547872Sarnold * reads a card, supposedly in hand, accepting unambigous brief 1557872Sarnold * input, returns the index of the card found... 1567709Sarnold */ 157*59264Sbostic int 1587872Sarnold infrom(hand, n, prompt) 159*59264Sbostic CARD hand[]; 160*59264Sbostic int n; 161*59264Sbostic char *prompt; 1627709Sarnold { 163*59264Sbostic register int i, j; 164*59264Sbostic CARD crd; 1657709Sarnold 1667872Sarnold if (n < 1) { 167*59264Sbostic printf("\nINFROM: %d = n < 1!!\n", n); 168*59264Sbostic exit(74); 1697872Sarnold } 1707872Sarnold for (;;) { 171*59264Sbostic msg(prompt); 172*59264Sbostic if (incard(&crd)) { /* if card is full card */ 173*59264Sbostic if (!isone(crd, hand, n)) 174*59264Sbostic msg("That's not in your hand"); 175*59264Sbostic else { 176*59264Sbostic for (i = 0; i < n; i++) 177*59264Sbostic if (hand[i].rank == crd.rank && 178*59264Sbostic hand[i].suit == crd.suit) 179*59264Sbostic break; 180*59264Sbostic if (i >= n) { 1817872Sarnold printf("\nINFROM: isone or something messed up\n"); 182*59264Sbostic exit(77); 183*59264Sbostic } 184*59264Sbostic return (i); 185*59264Sbostic } 186*59264Sbostic } else /* if not full card... */ 187*59264Sbostic if (crd.rank != EMPTY) { 188*59264Sbostic for (i = 0; i < n; i++) 189*59264Sbostic if (hand[i].rank == crd.rank) 190*59264Sbostic break; 191*59264Sbostic if (i >= n) 192*59264Sbostic msg("No such rank in your hand"); 193*59264Sbostic else { 194*59264Sbostic for (j = i + 1; j < n; j++) 195*59264Sbostic if (hand[j].rank == crd.rank) 196*59264Sbostic break; 197*59264Sbostic if (j < n) 198*59264Sbostic msg("Ambiguous rank"); 199*59264Sbostic else 200*59264Sbostic return (i); 201*59264Sbostic } 202*59264Sbostic } else 203*59264Sbostic msg("Sorry, I missed that"); 2047872Sarnold } 2057872Sarnold /* NOTREACHED */ 2067709Sarnold } 2077709Sarnold 2087709Sarnold /* 2097872Sarnold * incard: 2107872Sarnold * Inputs a card in any format. It reads a line ending with a CR 2117872Sarnold * and then parses it. 2127709Sarnold */ 213*59264Sbostic int 2147872Sarnold incard(crd) 215*59264Sbostic CARD *crd; 2167709Sarnold { 217*59264Sbostic register int i; 218*59264Sbostic int rnk, sut; 219*59264Sbostic char *line, *p, *p1; 220*59264Sbostic BOOLEAN retval; 2217709Sarnold 2227872Sarnold retval = FALSE; 2237872Sarnold rnk = sut = EMPTY; 2247872Sarnold if (!(line = getline())) 2257872Sarnold goto gotit; 2267872Sarnold p = p1 = line; 227*59264Sbostic while (*p1 != ' ' && *p1 != NULL) 228*59264Sbostic ++p1; 2297872Sarnold *p1++ = NULL; 230*59264Sbostic if (*p == NULL) 231*59264Sbostic goto gotit; 232*59264Sbostic 233*59264Sbostic /* IMPORTANT: no real card has 2 char first name */ 234*59264Sbostic if (strlen(p) == 2) { /* check for short form */ 235*59264Sbostic rnk = EMPTY; 236*59264Sbostic for (i = 0; i < RANKS; i++) { 237*59264Sbostic if (*p == *rankchar[i]) { 238*59264Sbostic rnk = i; 239*59264Sbostic break; 240*59264Sbostic } 2417872Sarnold } 242*59264Sbostic if (rnk == EMPTY) 243*59264Sbostic goto gotit; /* it's nothing... */ 244*59264Sbostic ++p; /* advance to next char */ 245*59264Sbostic sut = EMPTY; 246*59264Sbostic for (i = 0; i < SUITS; i++) { 247*59264Sbostic if (*p == *suitchar[i]) { 248*59264Sbostic sut = i; 249*59264Sbostic break; 250*59264Sbostic } 2517872Sarnold } 252*59264Sbostic if (sut != EMPTY) 253*59264Sbostic retval = TRUE; 254*59264Sbostic goto gotit; 2557872Sarnold } 2567872Sarnold rnk = EMPTY; 257*59264Sbostic for (i = 0; i < RANKS; i++) { 258*59264Sbostic if (!strcmp(p, rankname[i]) || !strcmp(p, rankchar[i])) { 259*59264Sbostic rnk = i; 260*59264Sbostic break; 261*59264Sbostic } 2627872Sarnold } 263*59264Sbostic if (rnk == EMPTY) 264*59264Sbostic goto gotit; 2657872Sarnold p = p1; 266*59264Sbostic while (*p1 != ' ' && *p1 != NULL) 267*59264Sbostic ++p1; 2687872Sarnold *p1++ = NULL; 269*59264Sbostic if (*p == NULL) 270*59264Sbostic goto gotit; 271*59264Sbostic if (!strcmp("OF", p)) { 272*59264Sbostic p = p1; 273*59264Sbostic while (*p1 != ' ' && *p1 != NULL) 274*59264Sbostic ++p1; 275*59264Sbostic *p1++ = NULL; 276*59264Sbostic if (*p == NULL) 277*59264Sbostic goto gotit; 2787872Sarnold } 2797872Sarnold sut = EMPTY; 280*59264Sbostic for (i = 0; i < SUITS; i++) { 281*59264Sbostic if (!strcmp(p, suitname[i]) || !strcmp(p, suitchar[i])) { 282*59264Sbostic sut = i; 283*59264Sbostic break; 284*59264Sbostic } 2857872Sarnold } 286*59264Sbostic if (sut != EMPTY) 287*59264Sbostic retval = TRUE; 2887709Sarnold gotit: 2897872Sarnold (*crd).rank = rnk; 2907872Sarnold (*crd).suit = sut; 291*59264Sbostic return (retval); 2927709Sarnold } 2937709Sarnold 2947709Sarnold /* 2957872Sarnold * getuchar: 2967872Sarnold * Reads and converts to upper case 2977709Sarnold */ 298*59264Sbostic int 2997709Sarnold getuchar() 3007709Sarnold { 301*59264Sbostic register int c; 3027709Sarnold 3037872Sarnold c = readchar(); 3047872Sarnold if (islower(c)) 305*59264Sbostic c = toupper(c); 30612163Sarnold waddch(Msgwin, c); 307*59264Sbostic return (c); 3087709Sarnold } 3097709Sarnold 3107709Sarnold /* 3117934Sarnold * number: 3127934Sarnold * Reads in a decimal number and makes sure it is between "lo" and 3137934Sarnold * "hi" inclusive. 3147709Sarnold */ 315*59264Sbostic int 3167934Sarnold number(lo, hi, prompt) 317*59264Sbostic int lo, hi; 318*59264Sbostic char *prompt; 3197709Sarnold { 320*59264Sbostic register char *p; 321*59264Sbostic register int sum; 3227709Sarnold 323*59264Sbostic for (sum = 0;;) { 324*59264Sbostic msg(prompt); 325*59264Sbostic if (!(p = getline()) || *p == NULL) { 326*59264Sbostic msg(quiet ? "Not a number" : 327*59264Sbostic "That doesn't look like a number"); 328*59264Sbostic continue; 3297934Sarnold } 330*59264Sbostic sum = 0; 3317934Sarnold 332*59264Sbostic if (!isdigit(*p)) 333*59264Sbostic sum = lo - 1; 334*59264Sbostic else 335*59264Sbostic while (isdigit(*p)) { 336*59264Sbostic sum = 10 * sum + (*p - '0'); 337*59264Sbostic ++p; 338*59264Sbostic } 339*59264Sbostic 340*59264Sbostic if (*p != ' ' && *p != '\t' && *p != NULL) 341*59264Sbostic sum = lo - 1; 342*59264Sbostic if (sum >= lo && sum <= hi) 343*59264Sbostic break; 344*59264Sbostic if (sum == lo - 1) 345*59264Sbostic msg("that doesn't look like a number, try again --> "); 346*59264Sbostic else 3477934Sarnold msg("%d is not between %d and %d inclusive, try again --> ", 348*59264Sbostic sum, lo, hi); 3497934Sarnold } 350*59264Sbostic return (sum); 3517709Sarnold } 3527709Sarnold 3537872Sarnold /* 3547872Sarnold * msg: 3557872Sarnold * Display a message at the top of the screen. 3567872Sarnold */ 357*59264Sbostic char Msgbuf[BUFSIZ] = {'\0'}; 358*59264Sbostic int Mpos = 0; 359*59264Sbostic static int Newpos = 0; 3607709Sarnold 36157823Storek void 36252540Storek #if __STDC__ 36357823Storek msg(const char *fmt, ...) 36452540Storek #else 36552540Storek msg(fmt, va_alist) 36646264Sbostic char *fmt; 36752540Storek va_dcl 36852540Storek #endif 3697872Sarnold { 37046264Sbostic va_list ap; 37146264Sbostic 37252540Storek #if __STDC__ 37346264Sbostic va_start(ap, fmt); 37452540Storek #else 37552540Storek va_start(ap); 37652540Storek #endif 37746743Sbostic (void)vsprintf(&Msgbuf[Newpos], fmt, ap); 37846264Sbostic va_end(ap); 37946264Sbostic endmsg(); 3807872Sarnold } 3817872Sarnold 3827709Sarnold /* 3837872Sarnold * addmsg: 3847872Sarnold * Add things to the current message 3857709Sarnold */ 38657823Storek void 38752540Storek #if __STDC__ 38857823Storek addmsg(const char *fmt, ...) 38952540Storek #else 39052540Storek addmsg(fmt, va_alist) 39146264Sbostic char *fmt; 39252540Storek va_dcl 39352540Storek #endif 3947872Sarnold { 39546264Sbostic va_list ap; 39646264Sbostic 39752540Storek #if __STDC__ 39846264Sbostic va_start(ap, fmt); 39952540Storek #else 40052540Storek va_start(ap); 40152540Storek #endif 40246743Sbostic (void)vsprintf(&Msgbuf[Newpos], fmt, ap); 40346264Sbostic va_end(ap); 4047872Sarnold } 4057709Sarnold 4067872Sarnold /* 4077872Sarnold * endmsg: 40812163Sarnold * Display a new msg. 4097872Sarnold */ 410*59264Sbostic int Lineno = 0; 41112316Sarnold 412*59264Sbostic void 4137872Sarnold endmsg() 4147709Sarnold { 415*59264Sbostic static int lastline = 0; 416*59264Sbostic register int len; 417*59264Sbostic register char *mp, *omp; 41812163Sarnold 419*59264Sbostic /* All messages should start with uppercase */ 420*59264Sbostic mvaddch(lastline + Y_MSG_START, SCORE_X, ' '); 421*59264Sbostic if (islower(Msgbuf[0]) && Msgbuf[1] != ')') 422*59264Sbostic Msgbuf[0] = toupper(Msgbuf[0]); 423*59264Sbostic mp = Msgbuf; 424*59264Sbostic len = strlen(mp); 425*59264Sbostic if (len / MSG_X + Lineno >= MSG_Y) { 426*59264Sbostic while (Lineno < MSG_Y) { 427*59264Sbostic wmove(Msgwin, Lineno++, 0); 428*59264Sbostic wclrtoeol(Msgwin); 429*59264Sbostic } 430*59264Sbostic Lineno = 0; 43112330Sarnold } 432*59264Sbostic mvaddch(Lineno + Y_MSG_START, SCORE_X, '*'); 433*59264Sbostic lastline = Lineno; 434*59264Sbostic do { 435*59264Sbostic mvwaddstr(Msgwin, Lineno, 0, mp); 436*59264Sbostic if ((len = strlen(mp)) > MSG_X) { 437*59264Sbostic omp = mp; 438*59264Sbostic for (mp = &mp[MSG_X - 1]; *mp != ' '; mp--) 439*59264Sbostic continue; 440*59264Sbostic while (*mp == ' ') 441*59264Sbostic mp--; 442*59264Sbostic mp++; 443*59264Sbostic wmove(Msgwin, Lineno, mp - omp); 444*59264Sbostic wclrtoeol(Msgwin); 445*59264Sbostic } 446*59264Sbostic if (++Lineno >= MSG_Y) 447*59264Sbostic Lineno = 0; 448*59264Sbostic } while (len > MSG_X); 449*59264Sbostic wclrtoeol(Msgwin); 450*59264Sbostic Mpos = len; 451*59264Sbostic Newpos = 0; 452*59264Sbostic wrefresh(Msgwin); 453*59264Sbostic refresh(); 454*59264Sbostic wrefresh(Msgwin); 4557872Sarnold } 4567709Sarnold 4577872Sarnold /* 45812316Sarnold * do_wait: 45912316Sarnold * Wait for the user to type ' ' before doing anything else 46012316Sarnold */ 461*59264Sbostic void 46212316Sarnold do_wait() 46312316Sarnold { 464*59264Sbostic static char prompt[] = {'-', '-', 'M', 'o', 'r', 'e', '-', '-', '\0'}; 46512316Sarnold 466*59264Sbostic if (Mpos + sizeof prompt < MSG_X) 467*59264Sbostic wmove(Msgwin, Lineno > 0 ? Lineno - 1 : MSG_Y - 1, Mpos); 468*59264Sbostic else { 469*59264Sbostic mvwaddch(Msgwin, Lineno, 0, ' '); 470*59264Sbostic wclrtoeol(Msgwin); 471*59264Sbostic if (++Lineno >= MSG_Y) 472*59264Sbostic Lineno = 0; 473*59264Sbostic } 474*59264Sbostic waddstr(Msgwin, prompt); 475*59264Sbostic wrefresh(Msgwin); 476*59264Sbostic wait_for(' '); 47712316Sarnold } 47812316Sarnold 47912316Sarnold /* 4807872Sarnold * wait_for 4817872Sarnold * Sit around until the guy types the right key 4827872Sarnold */ 483*59264Sbostic void 4847872Sarnold wait_for(ch) 485*59264Sbostic register int ch; 4867872Sarnold { 487*59264Sbostic register char c; 4887709Sarnold 489*59264Sbostic if (ch == '\n') 490*59264Sbostic while ((c = readchar()) != '\n') 491*59264Sbostic continue; 492*59264Sbostic else 493*59264Sbostic while (readchar() != ch) 494*59264Sbostic continue; 4957872Sarnold } 4967709Sarnold 4977872Sarnold /* 4987872Sarnold * readchar: 4997872Sarnold * Reads and returns a character, checking for gross input errors 5007872Sarnold */ 501*59264Sbostic int 5027872Sarnold readchar() 5037872Sarnold { 504*59264Sbostic register int cnt; 505*59264Sbostic char c; 5067709Sarnold 5077872Sarnold over: 508*59264Sbostic cnt = 0; 509*59264Sbostic while (read(STDIN_FILENO, &c, sizeof(char)) <= 0) 510*59264Sbostic if (cnt++ > 100) { /* if we are getting infinite EOFs */ 511*59264Sbostic bye(); /* quit the game */ 512*59264Sbostic exit(1); 513*59264Sbostic } 514*59264Sbostic if (c == CTRL('L')) { 515*59264Sbostic wrefresh(curscr); 516*59264Sbostic goto over; 51741186Sbostic } 518*59264Sbostic if (c == '\r') 519*59264Sbostic return ('\n'); 520*59264Sbostic else 521*59264Sbostic return (c); 5227872Sarnold } 5237872Sarnold 5247872Sarnold /* 5257872Sarnold * getline: 5267872Sarnold * Reads the next line up to '\n' or EOF. Multiple spaces are 5277872Sarnold * compressed to one space; a space is inserted before a ',' 5287872Sarnold */ 5297872Sarnold char * 5307872Sarnold getline() 5317872Sarnold { 532*59264Sbostic register char *sp; 533*59264Sbostic register int c, oy, ox; 534*59264Sbostic register WINDOW *oscr; 5357872Sarnold 536*59264Sbostic oscr = stdscr; 537*59264Sbostic stdscr = Msgwin; 538*59264Sbostic getyx(stdscr, oy, ox); 539*59264Sbostic refresh(); 540*59264Sbostic /* loop reading in the string, and put it in a temporary buffer */ 541*59264Sbostic for (sp = linebuf; (c = readchar()) != '\n'; clrtoeol(), refresh()) { 542*59264Sbostic if (c == -1) 543*59264Sbostic continue; 544*59264Sbostic else 545*59264Sbostic if (c == erasechar()) { /* process erase character */ 546*59264Sbostic if (sp > linebuf) { 547*59264Sbostic register int i; 5487872Sarnold 549*59264Sbostic sp--; 550*59264Sbostic for (i = strlen(unctrl(*sp)); i; i--) 551*59264Sbostic addch('\b'); 552*59264Sbostic } 553*59264Sbostic continue; 554*59264Sbostic } else 555*59264Sbostic if (c == killchar()) { /* process kill 556*59264Sbostic * character */ 557*59264Sbostic sp = linebuf; 558*59264Sbostic move(oy, ox); 559*59264Sbostic continue; 560*59264Sbostic } else 561*59264Sbostic if (sp == linebuf && c == ' ') 562*59264Sbostic continue; 563*59264Sbostic if (sp >= &linebuf[LINESIZE - 1] || !(isprint(c) || c == ' ')) 564*59264Sbostic putchar(CTRL('G')); 565*59264Sbostic else { 566*59264Sbostic if (islower(c)) 567*59264Sbostic c = toupper(c); 568*59264Sbostic *sp++ = c; 569*59264Sbostic addstr(unctrl(c)); 570*59264Sbostic Mpos++; 571*59264Sbostic } 5727872Sarnold } 573*59264Sbostic *sp = '\0'; 574*59264Sbostic stdscr = oscr; 575*59264Sbostic return (linebuf); 5767872Sarnold } 57714910Sarnold 578*59264Sbostic void 579*59264Sbostic rint(signo) 580*59264Sbostic int signo; 58141186Sbostic { 58241186Sbostic bye(); 58341186Sbostic exit(1); 58441186Sbostic } 58541186Sbostic 58614910Sarnold /* 58714910Sarnold * bye: 58814910Sarnold * Leave the program, cleaning things up as we go. 58914910Sarnold */ 590*59264Sbostic void 59114910Sarnold bye() 59214910Sarnold { 59314910Sarnold signal(SIGINT, SIG_IGN); 59414910Sarnold mvcur(0, COLS - 1, LINES - 1, 0); 59514910Sarnold fflush(stdout); 59614910Sarnold endwin(); 59714910Sarnold putchar('\n'); 59814910Sarnold } 599