Project

General

Profile

Bug #1492 ยป larn.diff

uqs, 09/08/2009 06:11 PM

View differences:

games/larn/Makefile
# EXTRA
# Incorporates code to gather additional performance statistics
# SYSV
# Use system III/V (instead of V7) type ioctl calls
# 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
......
# This is the revision of the software, example: 1
# FLUSHNO=#
# Set the input queue excess flushing threshold (default 5)
# NOVARARGS
# Define for systems that don't have varargs (a default varargs will
# be used).
# MACRORND
# Define to use macro version of rnd() and rund() (fast and big)
# UIDSCORE
......
PROG= larn
MAN= larn.6
CFLAGS+=-DBSD -DVER=12 -DSUBVER=0 -DNONAP -DUIDSCORE
CFLAGS+=-DVER=12 -DSUBVER=0 -DNONAP -DUIDSCORE
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
games/larn/io.c
* Note: ** entries are available only in termcap mode.
*/
#include <stdarg.h>
#include <termios.h>
#include "header.h"
#ifdef SYSV /* system III or system V */
#include <termio.h>
#define sgttyb termio
#define stty(_a,_b) ioctl(_a,TCSETA,_b)
#define gtty(_a,_b) ioctl(_a,TCGETA,_b)
static int rawflg = 0;
static char saveeof,saveeol;
#define doraw(_a) if(!rawflg){++rawflg;saveeof=_a.c_cc[VMIN];saveeol=_a.c_cc[VTIME];}\
_a.c_cc[VMIN]=1;_a.c_cc[VTIME]=1;_a.c_lflag &= ~(ICANON|ECHO|ECHOE|ECHOK|ECHONL)
#define unraw(_a) _a.c_cc[VMIN]=saveeof;_a.c_cc[VTIME]=saveeol;_a.c_lflag |= ICANON|ECHO|ECHOE|ECHOK|ECHONL
#else /* not SYSV */
#ifndef BSD
#define CBREAK RAW /* V7 has no CBREAK */
#endif
#define doraw(_a) (_a.sg_flags |= CBREAK,_a.sg_flags &= ~ECHO)
#define unraw(_a) (_a.sg_flags &= ~CBREAK,_a.sg_flags |= ECHO)
#include <sgtty.h>
#define stty(_a,_b) ioctl(_a,TIOCSETP,_b)
#define gtty(_a,_b) ioctl(_a,TIOCGETP,_b)
#endif /* not SYSV */
#ifndef NOVARARGS /* if we have varargs */
#include <stdarg.h>
#else /* NOVARARGS */ /* if we don't have varargs */
typedef char *va_list;
#define va_dcl int va_alist;
#define va_start(plist) plist = (char *) &va_alist
#define va_end(plist)
#define va_arg(plist,mode) ((mode *)(plist += sizeof(mode)))[-1]
#endif /* NOVARARGS */
#define LINBUFSIZE 128 /* size of the lgetw() and lgetl() buffer */
int lfd; /* output file numbers */
int fd; /* input file numbers */
static struct sgttyb ttx; /* storage for the tty modes */
static struct termios ttx; /* storage for the tty modes */
static int ipoint=MAXIBUF,iepoint=MAXIBUF; /* input buffering pointers */
static char lgetwbuf[LINBUFSIZE]; /* get line (word) buffer */
......
void
scbr(void)
{
gtty(0,&ttx); doraw(ttx); stty(0,&ttx);
tcgetattr(0,&ttx);
/* doraw */
if (!rawflg) {
++rawflg;
saveeof=ttx.c_cc[VMIN];
saveeol=ttx.c_cc[VTIME];
}
ttx.c_cc[VMIN]=1;
ttx.c_cc[VTIME]=1;
ttx.c_lflag &= ~(ICANON|ECHO|ECHOE|ECHOK|ECHONL);
tcsetattr(0,TCSANOW,&ttx);
}
/*
......
void
sncbr(void)
{
gtty(0,&ttx); unraw(ttx); stty(0,&ttx);
tcgetattr(0,&ttx);
/* unraw */
ttx.c_cc[VMIN]=saveeof;
ttx.c_cc[VTIME]=saveeol;
ttx.c_lflag |= ICANON|ECHO|ECHOE|ECHOK|ECHONL;
tcsetattr(0,TCSANOW,&ttx);
}
/*
games/larn/signal.c
#endif /* SIGTSTP */
}
#ifdef BSD /* for BSD UNIX? */
static const char *signame[NSIG] = { "",
"SIGHUP", /* 1 hangup */
"SIGINT", /* 2 interrupt */
......
"SIGXFSZ", /* 25 exceeded file size limit */
"SIGVTALRM",/* 26 virtual time alarm */
"SIGPROF", /* 27 profiling time alarm */
"","","","" };
#else /* for system V? */
static const char *signame[NSIG] = { "",
"SIGHUP", /* 1 hangup */
"SIGINT", /* 2 interrupt */
"SIGQUIT", /* 3 quit */
"SIGILL", /* 4 illegal instruction (not reset when caught) */
"SIGTRAP", /* 5 trace trap (not reset when caught) */
"SIGIOT", /* 6 IOT instruction */
"SIGEMT", /* 7 EMT instruction */
"SIGFPE", /* 8 floating point exception */
"SIGKILL", /* 9 kill (cannot be caught or ignored) */
"SIGBUS", /* 10 bus error */
"SIGSEGV", /* 11 segmentation violation */
"SIGSYS", /* 12 bad argument to system call */
"SIGPIPE", /* 13 write on a pipe with no one to read it */
"SIGALRM", /* 14 alarm clock */
"SIGTERM", /* 15 software termination signal from kill */
"SIGUSR1", /* 16 user defines signal 1 */
"SIGUSR2", /* 17 user defines signal 2 */
"SIGCLD", /* 18 child death */
"SIGPWR", /* 19 power fail */
"","","","","","","","","","","","" };
#endif /* BSD */
"SIGWINCH",/* 28 window size changes */
"SIGINFO",/* 29 information request */
"SIGUSR1",/* 30 user defined signal 1 */
"SIGUSR2",/* 31 user defined signal 2 */
};
/*
* routine to process a fatal error signal
    (1-1/1)