From 0f8da203cbd33dc3319bee8a2e8372e521d92201 Mon Sep 17 00:00:00 2001 From: "Andrey A. Chernov" Date: Wed, 24 Sep 1997 12:29:25 +0000 Subject: [PATCH] Includes cleanup Fix nonull flag detecting from termcap Use usleep to handle nonull case Prevent overflow on genocided getenv Install most files not owned by games.games to prevent data modifications Fix path for gethdate() --- games/hack/Makefile | 8 ++++---- games/hack/hack.main.c | 4 ++-- games/hack/hack.options.c | 2 +- games/hack/hack.termcap.c | 15 +++++++++++---- games/hack/hack.u_init.c | 2 +- games/hack/hack.unix.c | 14 ++++++++------ 6 files changed, 27 insertions(+), 18 deletions(-) diff --git a/games/hack/Makefile b/games/hack/Makefile index 89c26900347..2ab7d77e721 100644 --- a/games/hack/Makefile +++ b/games/hack/Makefile @@ -35,13 +35,13 @@ makedefs: makedefs.c ${CC} ${CFLAGS} -o ${.TARGET} ${.CURDIR}/${.PREFIX}.c beforeinstall: - ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 664 /dev/null \ + ${INSTALL} -c -o bin -g bin -m ${NOBINMODE} /dev/null \ ${DESTDIR}/var/games/hackdir/perm - ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 664 /dev/null \ + ${INSTALL} -c -o bin -g ${BINGRP} -m 464 /dev/null \ ${DESTDIR}/var/games/hackdir/record - ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 660 ${.CURDIR}/rumors \ + ${INSTALL} -c -o bin -g ${BINGRP} -m 440 ${.CURDIR}/rumors \ ${DESTDIR}/var/games/hackdir/rumors - ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \ + ${INSTALL} -c -o bin -g bin -m ${NOBINMODE} \ ${.CURDIR}/help ${.CURDIR}/hh ${.CURDIR}/data \ ${DESTDIR}/var/games/hackdir rm -f ${DESTDIR}/var/games/hackdir/bones* \ diff --git a/games/hack/hack.main.c b/games/hack/hack.main.c index fa66e2707c9..956b163bbe5 100644 --- a/games/hack/hack.main.c +++ b/games/hack/hack.main.c @@ -15,7 +15,7 @@ extern char plname[PL_NSIZ], pl_character[PL_CSIZ]; extern struct permonst mons[CMNUM+2]; -extern char genocided[], fut_geno[]; +extern char genocided[60], fut_geno[]; int (*afternmv)(); int (*occupation)(); @@ -234,7 +234,7 @@ char *argv[]; } *gp = 0; } else - (void) strcpy(genocided, sfoo); + (void) strncpy(genocided, sfoo, sizeof(genocided)-1); (void) strcpy(fut_geno, genocided); } } diff --git a/games/hack/hack.options.c b/games/hack/hack.options.c index 477d08ba230..1fd754ac128 100644 --- a/games/hack/hack.options.c +++ b/games/hack/hack.options.c @@ -1,6 +1,7 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.options.c - version 1.0.3 */ +#include #include "config.h" #include "hack.h" extern char *eos(); @@ -8,7 +9,6 @@ extern char *eos(); initoptions() { register char *opts; - extern char *getenv(); flags.time = flags.nonews = flags.notombstone = flags.end_own = flags.standout = flags.nonull = FALSE; diff --git a/games/hack/hack.termcap.c b/games/hack/hack.termcap.c index 6b1f9a677ca..c24dc83db70 100644 --- a/games/hack/hack.termcap.c +++ b/games/hack/hack.termcap.c @@ -2,9 +2,11 @@ /* hack.termcap.c - version 1.0.3 */ #include +#include +#include +#include #include "config.h" /* for ROWNO and COLNO */ #include "def.flag.h" /* for flags.nonull */ -extern char *tgetstr(), *tgoto(), *getenv(); extern long *alloc(); #ifndef lint @@ -30,10 +32,10 @@ startup() tbufptr = tbuf; if(!(term = getenv("TERM"))) error("Can't get TERM."); - if(!strncmp(term, "5620", 4)) - flags.nonull = 1; /* this should be a termcap flag */ if(tgetent(tptr, term) < 1) error("Unknown terminal type: %s.", term); + if(tgetflag("NP") || tgetflag("nx")) + flags.nonull = 1; if(pc = tgetstr("pc", &tbufptr)) PC = *pc; if(!(BC = tgetstr("bc", &tbufptr))) { @@ -244,7 +246,11 @@ delay_output() { /* cbosgd!cbcephus!pds for SYS V R2 */ /* is this terminfo, or what? */ /* tputs("$<50>", 1, xputc); */ - + else { + (void) fflush(stdout); + usleep(500000); + } +#if 0 else if(ospeed > 0 || ospeed < SIZE(tmspc10)) if(CM) { /* delay by sending cm(here) an appropriate number of times */ register int cmlen = strlen(tgoto(CM, curx-1, cury-1)); @@ -255,6 +261,7 @@ delay_output() { i -= cmlen*tmspc10[ospeed]; } } +#endif } cl_eos() /* free after Robert Viduya */ diff --git a/games/hack/hack.u_init.c b/games/hack/hack.u_init.c index bc06fa5ecfd..cb8a97d4e1c 100644 --- a/games/hack/hack.u_init.c +++ b/games/hack/hack.u_init.c @@ -4,6 +4,7 @@ #include "hack.h" #include #include +#include #define Strcpy (void) strcpy #define Strcat (void) strcat #define UNDEF_TYP 0 @@ -307,7 +308,6 @@ extern struct obj *mkobj(); #ifdef WIZARD wiz_inv(){ register struct trobj *trop = &Extra_objs[0]; -extern char *getenv(); register char *ep = getenv("INVENT"); register int type; while(ep && *ep) { diff --git a/games/hack/hack.unix.c b/games/hack/hack.unix.c index 88ebdd606b0..10a8198965a 100644 --- a/games/hack/hack.unix.c +++ b/games/hack/hack.unix.c @@ -85,12 +85,13 @@ struct stat buf, hbuf; gethdate(name) char *name; { /* old version - for people short of space */ -/* - * register char *np; - * if(stat(name, &hbuf)) - * error("Cannot get status of %s.", - * (np = rindex(name, '/')) ? np+1 : name); - */ +register char *np; + + name = "/usr/games/hide/hack"; + if(stat(name, &hbuf)) + error("Cannot get status of %s.", + (np = rindex(name, '/')) ? np+1 : name); +#if 0 /* version using PATH from: seismo!gregc@ucsf-cgl.ARPA (Greg Couch) */ @@ -124,6 +125,7 @@ char filename[MAXPATHLEN+1]; } error("Cannot get status of %s.", (np = rindex(name, '/')) ? np+1 : name); +#endif } uptodate(fd) {