diff options
-rw-r--r-- | games/larn/Makefile | 19 | ||||
-rw-r--r-- | games/larn/config.c | 9 | ||||
-rw-r--r-- | games/larn/data.c | 8 | ||||
-rw-r--r-- | games/larn/diag.c | 6 | ||||
-rw-r--r-- | games/larn/fortune.c | 6 | ||||
-rw-r--r-- | games/larn/header.h | 25 | ||||
-rw-r--r-- | games/larn/help.c | 17 | ||||
-rw-r--r-- | games/larn/io.c | 106 | ||||
-rw-r--r-- | games/larn/larn.6 | 6 | ||||
-rw-r--r-- | games/larn/main.c | 78 | ||||
-rw-r--r-- | games/larn/scores.c | 10 | ||||
-rw-r--r-- | games/larn/tok.c | 29 |
12 files changed, 56 insertions, 263 deletions
diff --git a/games/larn/Makefile b/games/larn/Makefile index e9fd9d54c99..a89436e9c14 100644 --- a/games/larn/Makefile +++ b/games/larn/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.11 1999/03/27 03:45:49 pjanzen Exp $ +# $OpenBSD: Makefile,v 1.12 2000/06/29 07:55:39 pjanzen Exp $ # EXTRA # Incorporates code to gather additional performance statistics @@ -6,13 +6,6 @@ # Use sysv termio # TERMIOS # Use posix termios -# BSD -# Use BSD specific features (mostly timer and signal stuff) -# BSD4.1 -# Use BSD4.1 to avoid some 4.2 dependencies (must be used with -# BSD above; do not mix with SYSV) -# HIDEBYLINK -# If defined, the program attempts to hide from ps # DOCHECKPOINTS # If not defined, checkpoint files are periodically written by the # larn process (no forking) if enabled in the .larnopts description @@ -37,14 +30,6 @@ # cause player id's from the file ".playerids" to be used instead. # (.playerids is created upon demand). Only one entry per id # is # allowed in each scoreboard (winning & non-winning). -# VT100 -# Compile for using vt100 family of terminals. Omission of this -# define will cause larn to use termcap, but it will be MUCH slower -# due to an extra layer of output interpretation. Also, only VT100 -# mode allows 2 different standout modes, inverse video, and bold video. -# And only in VT100 mode is the scrolling region of the terminal used -# (much nicer than insert/delete line sequences to simulate it, if -# VT100 is omitted). # NONAP # This causes napms() to return immediately instead of delaying n # milliseconds. This define may be needed on some systems if the nap @@ -57,7 +42,7 @@ PROG= larn MAN= larn.6 -CFLAGS+=-DBSD -DVER=12 -DSUBVER=0 -DNONAP -DUIDSCORE -DTERMIOS +CFLAGS+=-DVER=12 -DSUBVER=0 -DNONAP -DUIDSCORE -DTERMIOS SRCS= main.c object.c create.c tok.c display.c global.c data.c io.c \ monster.c store.c diag.c help.c config.c nap.c bill.c scores.c \ signal.c moreobj.c movem.c regen.c fortune.c savelev.c diff --git a/games/larn/config.c b/games/larn/config.c index 77c680cff51..9e30275df74 100644 --- a/games/larn/config.c +++ b/games/larn/config.c @@ -1,4 +1,4 @@ -/* $OpenBSD: config.c,v 1.3 1998/09/15 05:12:31 pjanzen Exp $ */ +/* $OpenBSD: config.c,v 1.4 2000/06/29 07:55:40 pjanzen Exp $ */ /* $NetBSD: config.c,v 1.5 1997/10/18 20:03:08 christos Exp $ */ /* @@ -11,7 +11,7 @@ */ #include <sys/cdefs.h> #ifndef lint -static char rcsid[] = "$OpenBSD: config.c,v 1.3 1998/09/15 05:12:31 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: config.c,v 1.4 2000/06/29 07:55:40 pjanzen Exp $"; #endif /* not lint */ #include "header.h" @@ -22,7 +22,7 @@ static char rcsid[] = "$OpenBSD: config.c,v 1.3 1998/09/15 05:12:31 pjanzen Exp */ /* the game save filename */ -char savefilename[1024]; +char savefilename[PATH_MAX]; /* the logging file */ char logfile[] = _PATH_LOG; @@ -37,7 +37,7 @@ char scorefile[] = _PATH_SCORE; char larnlevels[] = _PATH_LEVELS; /* the .larnopts filename */ -char optsfile[1024] = "/.larnopts"; +char optsfile[PATH_MAX] = "/.larnopts"; /* the player id datafile name */ char playerids[] = _PATH_PLAYERIDS; @@ -45,7 +45,6 @@ char playerids[] = _PATH_PLAYERIDS; char diagfile[] = "Diagfile"; /* the diagnostic filename */ char ckpfile[] = "Larn12.0.ckp"; /* the checkpoint filename */ char *password = "pvnert(x)"; /* the wizards password <=32 */ -char psname[PSNAMESIZE] = "larn"; /* the process name */ #define WIZID 1 int wisid = 0; /* the user id of the only person who can be wizard */ diff --git a/games/larn/data.c b/games/larn/data.c index 6808170ee08..9c9a5425244 100644 --- a/games/larn/data.c +++ b/games/larn/data.c @@ -1,4 +1,4 @@ -/* $OpenBSD: data.c,v 1.7 1999/05/30 02:23:16 pjanzen Exp $ */ +/* $OpenBSD: data.c,v 1.8 2000/06/29 07:55:40 pjanzen Exp $ */ /* $NetBSD: data.c,v 1.9 1997/10/25 01:40:47 thorpej Exp $ */ /*- @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)data.c 5.3 (Berkeley) 5/13/91"; #else -static char rcsid[] = "$OpenBSD: data.c,v 1.7 1999/05/30 02:23:16 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: data.c,v 1.8 2000/06/29 07:55:40 pjanzen Exp $"; #endif #endif /* not lint */ @@ -143,8 +143,8 @@ u_char predostuff = 0; /* 2 means that the trap handling routines * means don't showplayer() 0 - we are in * create player screen 1 - we are in welcome * screen 2 - we are in the normal game */ -char loginname[20]; /* players login name */ -char logname[LOGNAMESIZE]; /* players name storage for scoring */ +char loginname[LOGIN_NAME_MAX]; /* player's login name */ +char logname[LOGNAMESIZE]; /* player's name storage for scoring */ u_char sex = 1; /* default is a man 0=woman */ u_char boldon = 1; /* 1=bold objects 0=inverse objects */ u_char ckpflag = 0; /* 1 if checkpointing of game, 0 otherwise */ diff --git a/games/larn/diag.c b/games/larn/diag.c index b51c07a1512..1572515b4d3 100644 --- a/games/larn/diag.c +++ b/games/larn/diag.c @@ -1,9 +1,9 @@ -/* $OpenBSD: diag.c,v 1.3 1998/09/15 05:12:31 pjanzen Exp $ */ +/* $OpenBSD: diag.c,v 1.4 2000/06/29 07:55:40 pjanzen Exp $ */ /* $NetBSD: diag.c,v 1.8 1997/10/18 20:03:12 christos Exp $ */ /* diag.c Larn is copyrighted 1986 by Noah Morgan. */ #ifndef lint -static char rcsid[] = "$OpenBSD: diag.c,v 1.3 1998/09/15 05:12:31 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: diag.c,v 1.4 2000/06/29 07:55:40 pjanzen Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -230,9 +230,7 @@ savegame(fname) lprint((long) statbuf.st_ino); /* inode # */ lwclose(); lastmonst[0] = 0; -#ifndef VT100 setscroll(); -#endif /* VT100 */ lcreat((char *) 0); nosignal = 0; return (0); diff --git a/games/larn/fortune.c b/games/larn/fortune.c index cbc88caf884..28b31706c28 100644 --- a/games/larn/fortune.c +++ b/games/larn/fortune.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fortune.c,v 1.2 1998/09/15 05:12:31 pjanzen Exp $ */ +/* $OpenBSD: fortune.c,v 1.3 2000/06/29 07:55:40 pjanzen Exp $ */ /* $NetBSD: fortune.c,v 1.4 1997/10/18 20:03:18 christos Exp $ */ /*- @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)fortune.c 5.5 (Berkeley) 6/10/91"; #else -static char rcsid[] = "$OpenBSD: fortune.c,v 1.2 1998/09/15 05:12:31 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: fortune.c,v 1.3 2000/06/29 07:55:40 pjanzen Exp $"; #endif #endif /* not lint */ @@ -81,7 +81,7 @@ char *flines[] = { "never enter the dungeon naked! the monsters will laugh at you!", "did someone put itching powder in your armor?", "you klutz!", - "avoid opening doors. you never know whats on the other side.", + "avoid opening doors. you never know what's on the other side.", "infinite regeneration ---> temptation", "the greatest weapon in the game has not the highest Weapon Class", "you can't buy the most powerful scroll", diff --git a/games/larn/header.h b/games/larn/header.h index 9b3ba8a8cd4..3bf94761c9b 100644 --- a/games/larn/header.h +++ b/games/larn/header.h @@ -1,9 +1,12 @@ -/* $OpenBSD: header.h,v 1.9 1999/05/30 02:23:16 pjanzen Exp $ */ +/* $OpenBSD: header.h,v 1.10 2000/06/29 07:55:40 pjanzen Exp $ */ /* $NetBSD: header.h,v 1.12 1997/10/25 01:40:48 thorpej Exp $ */ /* header.h Larn is copyrighted 1986 by Noah Morgan. */ +#include <sys/param.h> +#include <sys/syslimits.h> #include <sys/types.h> +#include <limits.h> #define MAXLEVEL 11 /* max # levels in the dungeon */ @@ -333,12 +336,12 @@ extern char VERSION, SUBVERSION; extern u_char alpha[], beenhere[], boldon, cheat, ckpflag; extern u_char *class[], course[]; extern char diagfile[], helpfile[], ckpfile[], larnlevels[], - playerids[], optsfile[], psname[], savefilename[1024], + playerids[], optsfile[PATH_MAX], savefilename[PATH_MAX], scorefile[]; extern u_char *inbuffer; extern u_char item[MAXX][MAXY], iven[], know[MAXX][MAXY]; -extern char *levelname[], logfile[], loginname[], logname[], - lastmonst[]; +extern char *levelname[], logfile[], loginname[LOGIN_NAME_MAX], + logname[LOGNAMESIZE], lastmonst[]; extern u_char *lpbuf, *lpend; extern u_char *lpnt, moved[MAXX][MAXY], mitem[MAXX][MAXY], monstlevel[]; extern char monstnamelist[], objnamelist[]; @@ -387,19 +390,6 @@ extern int rmst, maxitm, lasttime; /* macro to wipe out a monster at a location */ #define disappear(x,y) (mitem[x][y]=know[x][y]=0) -#ifdef VT100 -/* macro to turn on bold display for the terminal */ -#define setbold() (lprcat(boldon?"\33[1m":"\33[7m")) -/* macro to turn off bold display for the terminal */ -#define resetbold() (lprcat("\33[m")) -/* macro to setup the scrolling region for the terminal */ -#define setscroll() (lprcat("\33[20;24r")) -/* macro to clear the scrolling region for the terminal */ -#define resetscroll() (lprcat("\33[;24r")) -/* macro to clear the screen and home the cursor */ -#define clear() (lprcat("\33[2J\33[f"), cbak[SPELLS]= -50) -#define cltoeoln() lprcat("\33[K") -#else /* VT100 */ /* defines below are for use in the termcap mode only */ #define ST_START 1 #define ST_END 2 @@ -421,7 +411,6 @@ extern int rmst, maxitm, lasttime; #define clear() (*lpnt++ =CLEAR, cbak[SPELLS]= -50) /* macro to clear to end of line */ #define cltoeoln() (*lpnt++ = CL_LINE) -#endif /* VT100 */ /* macro to output one byte to the output buffer */ #define lprc(ch) ((lpnt>=lpend)?(*lpnt++ =(ch), lflush()):(*lpnt++ =(ch))) diff --git a/games/larn/help.c b/games/larn/help.c index 4ddcb65c4e5..71540d9ad81 100644 --- a/games/larn/help.c +++ b/games/larn/help.c @@ -1,9 +1,9 @@ -/* $OpenBSD: help.c,v 1.2 1998/09/15 05:12:32 pjanzen Exp $ */ +/* $OpenBSD: help.c,v 1.3 2000/06/29 07:55:41 pjanzen Exp $ */ /* $NetBSD: help.c,v 1.4 1997/10/18 20:03:24 christos Exp $ */ /* help.c Larn is copyrighted 1986 by Noah Morgan. */ #ifndef lint -static char rcsid[] = "$OpenBSD: help.c,v 1.2 1998/09/15 05:12:32 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: help.c,v 1.3 2000/06/29 07:55:41 pjanzen Exp $"; #endif /* not lint */ #include <unistd.h> @@ -23,10 +23,8 @@ void help() { int i, j; -#ifndef VT100 char tmbuf[128]; /* intermediate translation buffer * when not a VT100 */ -#endif /* VT100 */ if ((j = openhelp()) < 0) return; /* open the help file and get # pages */ for (i = 0; i < 23; i++) @@ -34,15 +32,10 @@ help() for (; j > 0; j--) { clear(); for (i = 0; i < 23; i++) -#ifdef VT100 - lprcat(lgetl()); /* print out each line that - * we read in */ -#else /* VT100 */ { tmcapcnv(tmbuf, lgetl()); lprcat(tmbuf); } /* intercept \33's */ -#endif /* VT100 */ if (j > 1) { lprcat(" ---- Press "); lstandout("return"); @@ -72,22 +65,16 @@ void welcome() { int i; -#ifndef VT100 char tmbuf[128]; /* intermediate translation buffer * when not a VT100 */ -#endif /* VT100 */ if (openhelp() < 0) return; /* open the help file */ clear(); for (i = 0; i < 23; i++) -#ifdef VT100 - lprcat(lgetl());/* print out each line that we read in */ -#else /* VT100 */ { tmcapcnv(tmbuf, lgetl()); lprcat(tmbuf); } /* intercept \33's */ -#endif /* VT100 */ lrclose(); retcont(); /* press return to continue */ } diff --git a/games/larn/io.c b/games/larn/io.c index 2fa92111e92..5adc9cba855 100644 --- a/games/larn/io.c +++ b/games/larn/io.c @@ -1,4 +1,4 @@ -/* $OpenBSD: io.c,v 1.6 1999/05/30 02:23:16 pjanzen Exp $ */ +/* $OpenBSD: io.c,v 1.7 2000/06/29 07:55:41 pjanzen Exp $ */ /* $NetBSD: io.c,v 1.7 1997/10/18 20:03:26 christos Exp $ */ /* @@ -61,7 +61,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: io.c,v 1.6 1999/05/30 02:23:16 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: io.c,v 1.7 2000/06/29 07:55:41 pjanzen Exp $"; #endif /* not lint */ #include "header.h" @@ -417,13 +417,8 @@ lwrite(buf, len) c[BYTESOUT] += len; #endif -#ifndef VT100 for (str = buf; len > 0; --len) lprc(*str++); -#else /* VT100 */ - lflush(); - write(lfd, buf, len); -#endif /* VT100 */ } else while (len) { if (lpnt >= lpend) @@ -621,7 +616,7 @@ lopen(str) ipoint = iepoint = MAXIBUF; if (str == NULL) return (fd = 0); - if ((fd = open(str, 0)) < 0) { + if ((fd = open(str, O_RDONLY, 0)) < 0) { lwclose(); lfd = 1; lpnt = lpbuf; @@ -645,11 +640,11 @@ lappend(str) lpend = lpbuf + BUFBIG; if (str == NULL) return (lfd = 1); - if ((lfd = open(str, 2)) < 0) { + if ((lfd = open(str, O_RDWR, 0)) < 0) { lfd = 1; return (-1); } - lseek(lfd, 0, 2); /* seek to end of file */ + lseek(lfd, 0, SEEK_END); return (lfd); } @@ -696,48 +691,6 @@ lprcat(str) lpnt = str2 - 1; } -#ifdef VT100 -/* - * cursor(x,y) Subroutine to set the cursor position - * - * x and y are the cursor coordinates, and lpbuff is the output buffer where - * escape sequence will be placed. - */ -static char *y_num[] = { -"\33[", "\33[", "\33[2", "\33[3", "\33[4", "\33[5", "\33[6", -"\33[7", "\33[8", "\33[9", "\33[10", "\33[11", "\33[12", "\33[13", "\33[14", -"\33[15", "\33[16", "\33[17", "\33[18", "\33[19", "\33[20", "\33[21", "\33[22", -"\33[23", "\33[24"}; - -static char *x_num[] = { -"H", "H", ";2H", ";3H", ";4H", ";5H", ";6H", ";7H", ";8H", ";9H", -";10H", ";11H", ";12H", ";13H", ";14H", ";15H", ";16H", ";17H", ";18H", ";19H", -";20H", ";21H", ";22H", ";23H", ";24H", ";25H", ";26H", ";27H", ";28H", ";29H", -";30H", ";31H", ";32H", ";33H", ";34H", ";35H", ";36H", ";37H", ";38H", ";39H", -";40H", ";41H", ";42H", ";43H", ";44H", ";45H", ";46H", ";47H", ";48H", ";49H", -";50H", ";51H", ";52H", ";53H", ";54H", ";55H", ";56H", ";57H", ";58H", ";59H", -";60H", ";61H", ";62H", ";63H", ";64H", ";65H", ";66H", ";67H", ";68H", ";69H", -";70H", ";71H", ";72H", ";73H", ";74H", ";75H", ";76H", ";77H", ";78H", ";79H", -";80H"}; - -void -cursor(x, y) - int x, y; -{ - char *p; - - if (lpnt >= lpend) - lflush(); - - p = y_num[y]; /* get the string to print */ - while (*p) - *lpnt++ = *p++; /* print the string */ - - p = x_num[x]; /* get the string to print */ - while (*p) - *lpnt++ = *p++; /* print the string */ -} -#else /* VT100 */ /* * cursor(x,y) Put cursor at specified coordinates staring at [1,1] (termcap) */ @@ -752,7 +705,6 @@ cursor(x, y) *lpnt++ = x; *lpnt++ = y; } -#endif /* VT100 */ /* * Routine to position cursor at beginning of 24th line @@ -763,7 +715,6 @@ cursors() cursor(1, 24); } -#ifndef VT100 /* * Warning: ringing the bell is control code 7. Don't use in defines. * Don't change the order of these defines. @@ -838,7 +789,6 @@ init_term() died(-285); /* malloc() failure */ } } -#endif /* VT100 */ /* * cl_line(x,y) Clear the whole line indicated by 'y' and leave cursor at [x,y] @@ -847,14 +797,9 @@ void cl_line(x, y) int x, y; { -#ifdef VT100 - cursor(x, y); - lprcat("\33[2K"); -#else /* VT100 */ cursor(1, y); *lpnt++ = CL_LINE; cursor(x, y); -#endif /* VT100 */ } /* @@ -864,10 +809,6 @@ void cl_up(x, y) int x, y; { -#ifdef VT100 - cursor(x, y); - lprcat("\33[1J\33[2K"); -#else /* VT100 */ int i; cursor(1, 1); for (i = 1; i <= y; i++) { @@ -875,7 +816,6 @@ cl_up(x, y) *lpnt++ = '\n'; } cursor(x, y); -#endif /* VT100 */ } /* @@ -885,10 +825,6 @@ void cl_dn(x, y) int x, y; { -#ifdef VT100 - cursor(x, y); - lprcat("\33[J\33[2K"); -#else /* VT100 */ int i; cursor(1, y); if (!CD) { @@ -902,7 +838,6 @@ cl_dn(x, y) } else *lpnt++ = CL_DOWN; cursor(x, y); -#endif /* VT100 */ } /* @@ -912,17 +847,10 @@ void lstandout(str) char *str; { -#ifdef VT100 - setbold(); - while (*str) - *lpnt++ = *str++; - resetbold(); -#else /* VT100 */ *lpnt++ = ST_START; while (*str) *lpnt++ = *str++; *lpnt++ = ST_END; -#endif /* VT100 */ } /* @@ -941,7 +869,6 @@ set_score_output() * for termcap version: Flush output in output buffer according to output * status as indicated by `enable_scroll' */ -#ifndef VT100 static int scrline = 18; /* line # for wraparound instead of scrolling * if no DL */ void @@ -1036,29 +963,7 @@ lflush() lpnt = lpbuf; flush_buf(); /* flush real output buffer now */ } -#else /* VT100 */ -/* - * lflush() flush the output buffer - * - * Returns nothing of value. - */ -void -lflush() -{ - int lpoint; - - if ((lpoint = lpnt - lpbuf) > 0) { -#ifdef EXTRA - c[BYTESOUT] += lpoint; -#endif - if (write(lfd, lpbuf, lpoint) != lpoint) - write(2, "error writing to output file\n", 29); - } - lpnt = lpbuf; /* point back to beginning of buffer */ -} -#endif /* VT100 */ -#ifndef VT100 static int vindex = 0; /* * xputchar(ch) Print one character in decoded output buffer. @@ -1138,7 +1043,6 @@ tmcapcnv(sd, ss) *sd = 0; /* NULL terminator */ return (sd); } -#endif /* VT100 */ /* * lbeep() Routine to emit a beep if enabled (see no-beep in .larnopts) diff --git a/games/larn/larn.6 b/games/larn/larn.6 index 3ce82af2b95..9c544b23837 100644 --- a/games/larn/larn.6 +++ b/games/larn/larn.6 @@ -1,4 +1,4 @@ -.\" $OpenBSD: larn.6,v 1.7 1999/05/30 02:23:16 pjanzen Exp $ +.\" $OpenBSD: larn.6,v 1.8 2000/06/29 07:55:42 pjanzen Exp $ .\" $NetBSD: larn.6,v 1.3 1995/03/23 08:33:42 cgd Exp $ .\" .\" Copyright (c) 1990 The Regents of the University of California. @@ -68,7 +68,7 @@ option shows the scoreboard for the game. .It Fl l The .Fl l -option shows the log file (wizard id only). +option shows the log file (wizards only). .It Fl i The .Fl i @@ -76,7 +76,7 @@ option shows the scoreboard with dead character inventories. .It Fl c The .Fl c -option creates a new game scoreboard (wizard id only). +option creates a new game scoreboard (wizards only). .It Fl n The .Fl n diff --git a/games/larn/main.c b/games/larn/main.c index 48a59cd75eb..b9c2fe007d7 100644 --- a/games/larn/main.c +++ b/games/larn/main.c @@ -1,9 +1,9 @@ -/* $OpenBSD: main.c,v 1.9 1998/10/01 05:31:38 pjanzen Exp $ */ +/* $OpenBSD: main.c,v 1.10 2000/06/29 07:55:42 pjanzen Exp $ */ /* $NetBSD: main.c,v 1.12 1998/02/12 08:07:49 mikel Exp $ */ /* main.c */ #ifndef lint -static char rcsid[] = "$OpenBSD: main.c,v 1.9 1998/10/01 05:31:38 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: main.c,v 1.10 2000/06/29 07:55:42 pjanzen Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -35,20 +35,15 @@ u_char restorflag = 0; /* 1 means restore has been done */ static char cmdhelp[] = "\ Cmd line format: larn [-slicnh] [-o<optsfile>] [-##] [++]\n\ -s show the scoreboard\n\ - -l show the logfile (wizard id only)\n\ + -l show the logfile (wizards only)\n\ -i show scoreboard with inventories of dead characters\n\ - -c create new scoreboard (wizard id only)\n\ + -c create new scoreboard (wizards only)\n\ -n suppress welcome message on starting game\n\ -## specify level of difficulty (example: -5)\n\ -h print this help text\n\ ++ restore game from checkpoint file\n\ -o<optsfile> specify .larnopts filename to be used instead of \"~/.larnopts\"\n\ "; -#ifdef VT100 -static char *termtypes[] = {"vt100", "vt101", "vt102", "vt103", "vt125", - "vt131", "vt140", "vt180", "vt220", "vt240", "vt241", "vt320", "vt340", -"vt341"}; -#endif /* VT100 */ /* * ************ @@ -71,17 +66,16 @@ main(argc, argv) /* * first task is to identify the player */ -#ifndef VT100 init_term(); /* setup the terminal (find out what type) * for termcap */ -#endif /* VT100 */ /* try to get login name */ if (((ptr = getlogin()) == 0) || (*ptr == 0)) { /* can we get it from /etc/passwd? */ if ((pwe = getpwuid(getuid())) != NULL) ptr = pwe->pw_name; + else #ifdef NOSPAM - else if ((ptr = getenv("LOGNAME")) == 0) + if ((ptr = getenv("LOGNAME")) == 0) if ((ptr = getenv("USER")) == 0) #endif noone: errx(1, "can't find your logname. Who Are You?"); @@ -93,10 +87,9 @@ main(argc, argv) /* * second task is to prepare the pathnames the player will need */ - strcpy(loginname, ptr); /* save loginname of the user for logging - * purposes */ - strcpy(logname, ptr); /* this will be overwritten with the players - * name */ + strlcpy(loginname, ptr, LOGIN_NAME_MAX); + /* this will be overwritten with the player's name */ + strlcpy(logname, ptr, LOGNAMESIZE); if ((ptr = getenv("HOME")) == NULL) ptr = "."; if (strlen(ptr) + 9 < sizeof(savefilename)) { @@ -130,23 +123,6 @@ main(argc, argv) newgame(); /* set the initial clock */ hard = -1; -#ifdef VT100 - /* - * check terminal type to avoid users who have not vt100 type terminals - */ - ttype = getenv("TERM"); - for (j = 1, i = 0; i < sizeof(termtypes) / sizeof(char *); i++) - if (strcmp(ttype, termtypes[i]) == 0) { - j = 0; - break; - } - if (j) { - lprcat("Sorry, Larn needs a VT100 family terminal for all it's features.\n"); - lflush(); - exit(1); - } -#endif /* VT100 */ - /* * now make scoreboard if it is not there (don't clear) */ @@ -204,8 +180,7 @@ main(argc, argv) exit(0); case 'o': /* specify a .larnopts filename */ - strncpy(optsfile, argv[i] + 2, 127); - optsfile[127] = '\0'; + strlcpy(optsfile, argv[i] + 2, PATH_MAX); break; default: @@ -237,23 +212,6 @@ main(argc, argv) write(2, "Can't obtain playerid\n", 22); exit(1); } -#ifdef HIDEBYLINK - /* - * this section of code causes the program to look like something else to ps - */ - if (strcmp(psname, argv[0])) { /* if a different process name only */ - if ((i = access(psname, 1)) < 0) { /* link not there */ - if (link(argv[0], psname) >= 0) { - argv[0] = psname; - execv(psname, argv); - } - } else - unlink(psname); - } - for (i = 1; i < argc; i++) { - szero(argv[i]); /* zero the argument to avoid ps snooping */ - } -#endif /* HIDEBYLINK */ if (access(savefilename, 0) == 0) { /* restore game if need to */ clear(); @@ -795,7 +753,8 @@ parse() clear(); lprcat("Saving . . ."); lflush(); - savegame(savefilename); + if (savegame(savefilename) < 0) + return; wizard = 1; died(-257); /* save the game - doesn't return */ @@ -1336,16 +1295,3 @@ readnum(mx) scbr(); return (amt); } - -#ifdef HIDEBYLINK -/* - * routine to zero every byte in a string - */ -void -szero(str) - char *str; -{ - while (*str) - *str++ = 0; -} -#endif /* HIDEBYLINK */ diff --git a/games/larn/scores.c b/games/larn/scores.c index 8978a21c51b..cc92637e24e 100644 --- a/games/larn/scores.c +++ b/games/larn/scores.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scores.c,v 1.6 1999/03/27 03:45:50 pjanzen Exp $ */ +/* $OpenBSD: scores.c,v 1.7 2000/06/29 07:55:42 pjanzen Exp $ */ /* $NetBSD: scores.c,v 1.10 1997/10/18 20:03:48 christos Exp $ */ /* @@ -27,7 +27,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: scores.c,v 1.6 1999/03/27 03:45:50 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: scores.c,v 1.7 2000/06/29 07:55:42 pjanzen Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -47,7 +47,7 @@ struct scofmt { /* This is the structure for the scoreboard */ short level; /* the level player was on when he died */ short hardlev;/* the level of difficulty player played at */ short order; /* the relative ordering place of this entry */ - char who[40];/* the name of the character */ + char who[LOGNAMESIZE];/* the name of the character */ char sciv[26][2]; /* the inventory list of the character */ }; struct wscofmt {/* This is the structure for the winning scoreboard */ @@ -57,7 +57,7 @@ struct wscofmt {/* This is the structure for the winning scoreboard */ long suid; /* the user id number of the player */ short hardlev;/* the level of difficulty player played at */ short order; /* the relative ordering place of this entry */ - char who[40];/* the name of the character */ + char who[LOGNAMESIZE];/* the name of the character */ }; struct log_fmt { /* 102 bytes struct for the log file */ @@ -77,7 +77,7 @@ struct log_fmt { /* 102 bytes struct for the log file */ short usage; /* usage of the cpu in % */ short lev; /* player level */ #endif - char who[12]; /* player name */ + char who[LOGIN_NAME_MAX]; /* player name */ char what[46]; /* what happened to player */ }; diff --git a/games/larn/tok.c b/games/larn/tok.c index 2b2c8d873cb..1e1c1cfcc9e 100644 --- a/games/larn/tok.c +++ b/games/larn/tok.c @@ -1,9 +1,9 @@ -/* $OpenBSD: tok.c,v 1.4 1999/05/30 02:23:17 pjanzen Exp $ */ +/* $OpenBSD: tok.c,v 1.5 2000/06/29 07:55:42 pjanzen Exp $ */ /* $NetBSD: tok.c,v 1.5 1997/10/18 20:03:54 christos Exp $ */ /* tok.c Larn is copyrighted 1986 by Noah Morgan. */ #ifndef lint -static char rcsid[] = "$OpenBSD: tok.c,v 1.4 1999/05/30 02:23:17 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: tok.c,v 1.5 2000/06/29 07:55:42 pjanzen Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -191,7 +191,7 @@ readopts() flag = 1; /* set to 0 if he specifies a name for his * character */ if (lopen(optsfile) < 0) { - strcpy(logname, loginname); + strlcpy(logname, loginname, LOGNAMESIZE); return; /* user name if no character name */ } i = " "; @@ -225,9 +225,7 @@ readopts() if (strcmp(i, "monster:") == 0) { /* name favorite monster */ if ((i = lgetw()) == 0) break; - if (strlen(i) >= MAXMNAME) - i[MAXMNAME - 1] = 0; - strcpy(usermonster[usermpoint], i); + strlcpy(usermonster[usermpoint], i, MAXMNAME); if (usermpoint >= MAXUM) break; /* defined all of em */ if (isalpha(j = usermonster[usermpoint][0])) { @@ -245,9 +243,7 @@ readopts() if (strcmp(i, "name:") == 0) { /* defining players name */ if ((i = lgetw()) == 0) break; - if (strlen(i) >= LOGNAMESIZE) - i[LOGNAMESIZE - 1] = 0; - strcpy(logname, i); + strlcpy(logname, i, LOGNAMESIZE); flag = 0; } else if (strcmp(i, "no-introduction") == 0) nowelcome = 1; @@ -255,27 +251,16 @@ readopts() nobeep = 1; break; - case 'p': - if (strcmp(i, "process-name:") == 0) { - if ((i = lgetw()) == 0) - break; - if (strlen(i) >= PSNAMESIZE) - i[PSNAMESIZE - 1] = 0; - strcpy(psname, i); - } else if (strcmp(i, "play-day-play") == 0) - dayplay = 1; - break; - case 's': if (strcmp(i, "savefile:") == 0) { /* defining savefilename */ if ((i = lgetw()) == 0) break; - strcpy(savefilename, i); + strlcpy(savefilename, i, PATH_MAX); flag = 0; } break; }; } if (flag) - strcpy(logname, loginname); + strlcpy(logname, loginname, LOGNAMESIZE); } |