X-Git-Url: https://git.cameronkatri.com/bsdgames-darwin.git/blobdiff_plain/dfc4e173d46d915ee76e5e481a35c6ce6c385633..4cb1100e13371f1523900523aba506ae1c62e44c:/hack/hack.tty.c diff --git a/hack/hack.tty.c b/hack/hack.tty.c index aa684692..9c9bcefd 100644 --- a/hack/hack.tty.c +++ b/hack/hack.tty.c @@ -1,4 +1,4 @@ -/* $NetBSD: hack.tty.c,v 1.8 2001/02/05 00:37:43 christos Exp $ */ +/* $NetBSD: hack.tty.c,v 1.16 2011/08/06 20:42:43 dholland Exp $ */ /*- * Copyright (c) 1988, 1993 @@ -12,11 +12,7 @@ * 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. * @@ -38,11 +34,71 @@ #if 0 static char sccsid[] = "@(#)hack.tty.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: hack.tty.c,v 1.8 2001/02/05 00:37:43 christos Exp $"); +__RCSID("$NetBSD: hack.tty.c,v 1.16 2011/08/06 20:42:43 dholland Exp $"); #endif #endif /* not lint */ -/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ +/* + * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, + * Amsterdam + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - 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. + * + * - Neither the name of the Stichting Centrum voor Wiskunde en + * Informatica, 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 BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * Copyright (c) 1982 Jay Fenlason + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 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. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + /* hack.tty.c - version 1.0.3 */ /* * With thanks to the people who sent code for SYSV - hpscdi!jon, @@ -64,7 +120,9 @@ __RCSID("$NetBSD: hack.tty.c,v 1.8 2001/02/05 00:37:43 christos Exp $"); static char erase_char, kill_char; static boolean settty_needed = FALSE; -struct termios inittyb, curttyb; +static struct termios inittyb, curttyb; + +static void setctty(void); /* * Get initial state of terminal, set ospeed (for termcap routines) @@ -72,7 +130,7 @@ struct termios inittyb, curttyb; * Called by startup() in termcap.c and after returning from ! or ^Z */ void -gettty() +gettty(void) { if (tcgetattr(0, &inittyb) < 0) perror("Hack (gettty)"); @@ -92,11 +150,10 @@ gettty() /* reset terminal to original state */ void -settty(s) - char *s; +settty(const char *s) { - clear_screen(); - end_screen(); + clearscreen(); + endscreen(); if (s) printf("%s", s); (void) fflush(stdout); @@ -107,8 +164,8 @@ settty(s) setioctls(); } -void -setctty() +static void +setctty(void) { if (tcsetattr(0, TCSADRAIN, &curttyb) < 0) perror("Hack (setctty)"); @@ -116,7 +173,7 @@ setctty() void -setftty() +setftty(void) { int change = 0; flags.cbreak = ON; @@ -136,31 +193,20 @@ setftty() if (change) { setctty(); } - start_screen(); + startscreen(); } /* fatal error */ /* VARARGS1 */ void -#ifdef __STDC__ error(const char *fmt, ...) -#else -error(va_alist) - va_dcl -#endif { va_list ap; -#ifndef __STDC__ - const char *fmt; - va_start(ap); - fmt = va_arg(ap, const char *); -#else va_start(ap, fmt); -#endif if (settty_needed) - settty((char *) 0); + settty(NULL); vprintf(fmt, ap); va_end(ap); putchar('\n'); @@ -174,8 +220,7 @@ error(va_alist) * resulting string is "\033". */ void -getlin(bufp) - char *bufp; +getlin(char *bufp) { char *obufp = bufp; int c; @@ -197,7 +242,7 @@ getlin(bufp) bufp--; putstr("\b \b"); /* putsym converts \b */ } else - bell(); + sound_bell(); } else if (c == '\n') { *bufp = 0; return; @@ -218,19 +263,18 @@ getlin(bufp) putstr("\b \b"); } } else - bell(); + sound_bell(); } } void -getret() +getret(void) { cgetret(""); } void -cgetret(s) - char *s; +cgetret(const char *s) { putsym('\n'); if (flags.standout) @@ -245,9 +289,9 @@ cgetret(s) char morc; /* tell the outside world what char he used */ +/* s = chars allowed besides space or return */ void -xwaitforspace(s) - char *s; /* chars allowed besides space or return */ +xwaitforspace(const char *s) { int c; @@ -261,13 +305,13 @@ xwaitforspace(s) morc = c; break; } - bell(); + sound_bell(); } } } char * -parse() +parse(void) { static char inputline[COLNO]; int foo; @@ -303,7 +347,7 @@ parse() } char -readchar() +readchar(void) { int sym; @@ -334,7 +378,7 @@ noteof: ; } void -end_of_input() +end_of_input(void) { settty("End of input?\n"); clearlocks();