+/* $NetBSD: misc.c,v 1.12 2009/05/25 23:24:54 dholland Exp $ */
+
/*
- * Copyright (c) 1983 Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1983, 1993
+ * The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. 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.
*
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
#ifndef lint
-/*static char sccsid[] = "from: @(#)misc.c 5.6 (Berkeley) 6/1/90";*/
-static char rcsid[] = "$Id: misc.c,v 1.2 1993/08/01 18:53:59 mycroft Exp $";
+#if 0
+static char sccsid[] = "@(#)misc.c 8.1 (Berkeley) 5/31/93";
+#else
+__RCSID("$NetBSD: misc.c,v 1.12 2009/05/25 23:24:54 dholland Exp $");
+#endif
#endif /* not lint */
+#include <sys/file.h>
+#include <termios.h>
+
+#include <stdarg.h>
+
#include "mille.h"
#ifndef unctrl
#include "unctrl.h"
#endif
-# include <sys/file.h>
-
-# ifdef attron
-# include <term.h>
-# define _tty cur_term->Nttyb
-# endif attron
/*
* @(#)misc.c 1.2 (Berkeley) 3/28/83
#define NUMSAFE 4
-/* VARARGS1 */
-error(str, arg)
-char *str;
+bool
+error(const char *str, ...)
{
- stdscr = Score;
- mvprintw(ERR_Y, ERR_X, str, arg);
- clrtoeol();
+ va_list ap;
+
+ va_start(ap, str);
+ wmove(Score, ERR_Y, ERR_X);
+ vwprintw(Score, str, ap);
+ wclrtoeol(Score);
putchar('\07');
refresh();
- stdscr = Board;
+ va_end(ap);
return FALSE;
}
CARD
-getcard()
+getcard(void)
{
- reg int c, c1;
+ int c, c1;
for (;;) {
while ((c = readch()) == '\n' || c == '\r' || c == ' ')
}
}
-check_ext(forcomp)
-reg bool forcomp; {
+int
+check_ext(bool forcomp)
+{
if (End == 700)
}
}
else {
- reg PLAY *pp, *op;
- reg int i, safe, miles;
+ PLAY *pp, *op;
+ int i, safe, miles;
pp = &Player[COMP];
op = &Player[PLAYER];
* Get a yes or no answer to the given question. Saves are
* also allowed. Return TRUE if the answer was yes, FALSE if no.
*/
-getyn(promptno)
-register int promptno; {
-
- reg char c;
+int
+getyn(int promptno)
+{
+ char c;
Saved = FALSE;
for (;;) {
refresh();
Saved = save();
continue;
+ case CTRL('L'):
+ wrefresh(curscr);
+ break;
default:
addstr(unctrl(c));
refresh();
* came from a saved file, make sure that they don't want to restore
* it. Exit appropriately.
*/
-check_more() {
-
- flush_input();
-
+void
+check_more(void)
+{
On_exit = TRUE;
if (Player[PLAYER].total >= 5000 || Player[COMP].total >= 5000)
if (getyn(ANOTHERGAMEPROMPT))
if (!Saved && getyn(SAVEGAMEPROMPT))
if (!save())
return;
- die();
+ die(0);
}
-readch()
+int
+readch(void)
{
- reg int cnt;
+ int cnt;
static char c;
for (cnt = 0; read(0, &c, 1) <= 0; cnt++)
exit(1);
return c;
}
-
-flush_input()
-{
-# ifdef TIOCFLUSH
- static int ioctl_args = O_RDONLY;
-
- (void) ioctl(fileno(stdin), TIOCFLUSH, &ioctl_args);
-# else
- fflush(stdin);
-# endif
-}