BSD 4_3_Reno release
[unix-history] / usr / src / games / cribbage / io.c
index b806852..4bb8061 100644 (file)
@@ -1,8 +1,29 @@
-static char    *sccsid = "@(#)io.c     1.11 (Berkeley) %G%";
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that: (1) source distributions retain this entire copyright
+ * notice and comment, and (2) distributions including binaries display
+ * the following acknowledgement:  ``This product includes software
+ * developed by the University of California, Berkeley and its contributors''
+ * in the documentation or other materials provided with the distribution
+ * and in all advertising materials mentioning features or use of this
+ * software. Neither the name of the University nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)io.c       5.6 (Berkeley) 6/1/90";
+#endif /* not lint */
 
 # include      <curses.h>
 # include      <ctype.h>
 
 # include      <curses.h>
 # include      <ctype.h>
-# include      <unctrl.h>
+# include      <signal.h>
 # include      "deck.h"
 # include      "cribbage.h"
 # include      "cribcur.h"
 # include      "deck.h"
 # include      "cribbage.h"
 # include      "cribcur.h"
@@ -14,10 +35,10 @@ static char *sccsid = "@(#)io.c     1.11 (Berkeley) %G%";
 # endif
 # define       CTRL(X)                 ('X' - 'A' + 1)
 
 # endif
 # define       CTRL(X)                 ('X' - 'A' + 1)
 
-# ifndef       attron
+# ifdef        notdef                          /* defined in curses.h */
 #      define  erasechar()     _tty.sg_erase
 #      define  killchar()      _tty.sg_kill
 #      define  erasechar()     _tty.sg_erase
 #      define  killchar()      _tty.sg_kill
-# endif                attron
+# endif
 
 char           linebuf[ LINESIZE ];
 
 
 char           linebuf[ LINESIZE ];
 
@@ -483,8 +504,10 @@ readchar()
 over:
     cnt = 0;
     while (read(0, &c, 1) <= 0)
 over:
     cnt = 0;
     while (read(0, &c, 1) <= 0)
-       if (cnt++ > 100)        /* if we are getting infinite EOFs */
-           bye();              /* quit the game */
+       if (cnt++ > 100) {      /* if we are getting infinite EOFs */
+               bye();          /* quit the game */
+               exit(1);
+       }
     if (c == CTRL(L)) {
        wrefresh(curscr);
        goto over;
     if (c == CTRL(L)) {
        wrefresh(curscr);
        goto over;
@@ -548,3 +571,22 @@ getline()
     stdscr = oscr;
     return linebuf;
 }
     stdscr = oscr;
     return linebuf;
 }
+
+rint()
+{
+       bye();
+       exit(1);
+}
+
+/*
+ * bye:
+ *     Leave the program, cleaning things up as we go.
+ */
+bye()
+{
+       signal(SIGINT, SIG_IGN);
+       mvcur(0, COLS - 1, LINES - 1, 0);
+       fflush(stdout);
+       endwin();
+       putchar('\n');
+}