summaryrefslogtreecommitdiffstats
path: root/larn
diff options
context:
space:
mode:
authorblymn <blymn@NetBSD.org>2000-05-22 12:42:46 +0000
committerblymn <blymn@NetBSD.org>2000-05-22 12:42:46 +0000
commita2987258cb8a1c5cfe9ab775230b1513a4df6471 (patch)
tree43bac01c52b99ed7102c4f607ae581bd3b362d8f /larn
parent72c340b256dc83ba3536b8ba39d22f7890312221 (diff)
downloadbsdgames-darwin-a2987258cb8a1c5cfe9ab775230b1513a4df6471.tar.gz
bsdgames-darwin-a2987258cb8a1c5cfe9ab775230b1513a4df6471.tar.zst
bsdgames-darwin-a2987258cb8a1c5cfe9ab775230b1513a4df6471.zip
Converted games to use the new termcap interface.
Diffstat (limited to 'larn')
-rw-r--r--larn/io.c66
-rw-r--r--larn/main.c5
2 files changed, 50 insertions, 21 deletions
diff --git a/larn/io.c b/larn/io.c
index 5d9d355e..9f32da3f 100644
--- a/larn/io.c
+++ b/larn/io.c
@@ -1,4 +1,4 @@
-/* $NetBSD: io.c,v 1.8 1999/10/04 23:27:02 lukem Exp $ */
+/* $NetBSD: io.c,v 1.9 2000/05/22 12:42:46 blymn Exp $ */
/*
* io.c Larn is copyrighted 1986 by Noah Morgan.
@@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: io.c,v 1.8 1999/10/04 23:27:02 lukem Exp $");
+__RCSID("$NetBSD: io.c,v 1.9 2000/05/22 12:42:46 blymn Exp $");
#endif /* not lint */
#include "header.h"
@@ -763,7 +763,8 @@ cursors()
* obvious meanings.
*/
-static char cap[256];
+static char *cap;
+struct tinfo *info;
char *CM, *CE, *CD, *CL, *SO, *SE, *AL, *DL; /* Termcap capabilities */
static char *outbuf = 0; /* translated output buffer */
@@ -773,11 +774,11 @@ static char *outbuf = 0; /* translated output buffer */
void
init_term()
{
- char termbuf[1024];
- char *capptr = cap + 10;
+ char *capptr;
char *term;
- switch (tgetent(termbuf, term = getenv("TERM"))) {
+ *cap = NULL;
+ switch (t_getent(&info, term = getenv("TERM"))) {
case -1:
write(2, "Cannot open termcap file.\n", 26);
exit(1);
@@ -788,16 +789,16 @@ init_term()
exit(1);
};
- CM = tgetstr("cm", &capptr); /* Cursor motion */
- CE = tgetstr("ce", &capptr); /* Clear to eoln */
- CL = tgetstr("cl", &capptr); /* Clear screen */
+ CM = t_agetstr(info, "cm", &cap, &capptr); /* Cursor motion */
+ CE = t_agetstr(info, "ce", &cap, &capptr); /* Clear to eoln */
+ CL = t_agetstr(info, "cl", &cap, &capptr); /* Clear screen */
/* OPTIONAL */
- AL = tgetstr("al", &capptr); /* Insert line */
- DL = tgetstr("dl", &capptr); /* Delete line */
- SO = tgetstr("so", &capptr); /* Begin standout mode */
- SE = tgetstr("se", &capptr); /* End standout mode */
- CD = tgetstr("cd", &capptr); /* Clear to end of display */
+ AL = t_agetstr(info, "al", &cap, &capptr); /* Insert line */
+ DL = t_agetstr(info, "dl", &cap, &capptr); /* Delete line */
+ SO = t_agetstr(info, "so", &cap, &capptr); /* Begin standout mode */
+ SE = t_agetstr(info, "se", &cap, &capptr); /* End standout mode */
+ CD = t_agetstr(info, "cd", &cap, &capptr); /* Clear to end of display */
if (!CM) { /* can't find cursor motion entry */
write(2, "Sorry, for a ", 13);
@@ -936,6 +937,7 @@ lflush()
u_char *str;
static int curx = 0;
static int cury = 0;
+ char tgoto_buf[256];
if ((lpoint = lpnt - lpbuf) > 0) {
#ifdef EXTRA
@@ -978,7 +980,9 @@ lflush()
case CURSOR:
curx = *++str - 1;
cury = *++str - 1;
- tputs(tgoto(CM, curx, cury), 0, xputchar);
+ if (t_goto(info, CM, curx, cury,
+ tgoto_buf, 255) == 0)
+ tputs(tgoto_buf, 0, xputchar);
break;
case '\n':
@@ -989,17 +993,41 @@ lflush()
if (++scrline > 23)
scrline = 19;
- tputs(tgoto(CM, 0, scrline), 0, xputchar);
+ if (t_goto(info, CM, 0,
+ scrline,
+ tgoto_buf,
+ 255) == 0)
+ tputs(tgoto_buf,
+ 0,
+ xputchar);
tputs(CE, 0, xputchar);
if (--scrline < 19)
scrline = 23;
- tputs(tgoto(CM, 0, scrline), 0, xputchar);
+ if (t_goto(info, CM, 0,
+ scrline,
+ tgoto_buf,
+ 255) == 0)
+ tputs(tgoto_buf,
+ 0,
+ xputchar);
tputs(CE, 0, xputchar);
} else {
- tputs(tgoto(CM, 0, 19), 0, xputchar);
+ if (t_goto(info, CM, 0,
+ 19,
+ tgoto_buf,
+ 255) == 0)
+ tputs(tgoto_buf,
+ 0,
+ xputchar);
tputs(DL, 0, xputchar);
- tputs(tgoto(CM, 0, 23), 0, xputchar);
+ if (t_goto(info, CM, 0,
+ 23,
+ tgoto_buf,
+ 255) == 0)
+ tputs(tgoto_buf,
+ 0,
+ xputchar);
/*
* tputs (AL, 0,
* xputchar);
diff --git a/larn/main.c b/larn/main.c
index fbc0fc6f..eba8146c 100644
--- a/larn/main.c
+++ b/larn/main.c
@@ -1,9 +1,9 @@
-/* $NetBSD: main.c,v 1.14 1998/08/30 09:19:38 veego Exp $ */
+/* $NetBSD: main.c,v 1.15 2000/05/22 12:42:46 blymn Exp $ */
/* main.c */
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: main.c,v 1.14 1998/08/30 09:19:38 veego Exp $");
+__RCSID("$NetBSD: main.c,v 1.15 2000/05/22 12:42:46 blymn Exp $");
#endif /* not lint */
#include <sys/types.h>
@@ -62,6 +62,7 @@ main(argc, argv)
const char *ptr = 0;
struct passwd *pwe;
+ i = 0;
euid = geteuid();
uid = getuid();
seteuid(uid); /* give up "games" if we have it */