more NOCWD_ASSUMPTIONS
The NOCWD_ASSUMPTIONS conditional code allows readonly parts of NetHack to be separated from areas that require write-access. This allows the recent panic log needed a prefix.
This commit is contained in:
@@ -38,7 +38,7 @@ typedef long off_t;
|
||||
|
||||
#define NOCWD_ASSUMPTIONS /* Allow paths to be specified for HACKDIR,
|
||||
LEVELDIR, SAVEDIR, BONESDIR, DATADIR,
|
||||
SCOREDIR, LOCKDIR, and CONFIGDIR. */
|
||||
SCOREDIR, LOCKDIR, CONFIGDIR, and TROUBLEDIR */
|
||||
|
||||
/* data librarian defs */
|
||||
#ifndef NOCWD_ASSUMPTIONS
|
||||
|
||||
@@ -348,11 +348,12 @@ E const char *monexplain[], *invisexplain, *objexplain[], *oclass_names[];
|
||||
#define LEVELPREFIX 1
|
||||
#define SAVEPREFIX 2
|
||||
#define BONESPREFIX 3
|
||||
#define DATAPREFIX 4
|
||||
#define DATAPREFIX 4 /* this one must match hardcoded value in dlb.c */
|
||||
#define SCOREPREFIX 5
|
||||
#define LOCKPREFIX 6
|
||||
#define CONFIGPREFIX 7
|
||||
#define PREFIX_COUNT 8
|
||||
#define TROUBLEPREFIX 8
|
||||
#define PREFIX_COUNT 9
|
||||
/* used in files.c; xxconf.h can override if needed */
|
||||
# ifndef FQN_MAX_FILENAME
|
||||
#define FQN_MAX_FILENAME 512
|
||||
|
||||
@@ -596,7 +596,7 @@ E void NDECL(makerogueghost);
|
||||
/* ### files.c ### */
|
||||
|
||||
E const char *FDECL(fqname, (const char *, int, int));
|
||||
E FILE *FDECL(fopen_datafile, (const char *,const char *,BOOLEAN_P));
|
||||
E FILE *FDECL(fopen_datafile, (const char *,const char *,int));
|
||||
E boolean FDECL(uptodate, (int,const char *));
|
||||
E void FDECL(store_version, (int));
|
||||
#ifdef MFLOPPY
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
it is defined for WIN32.
|
||||
Allow paths to be specified for HACKDIR,
|
||||
LEVELDIR, SAVEDIR, BONESDIR, DATADIR,
|
||||
SCOREDIR, LOCKDIR, and CONFIGDIR */
|
||||
SCOREDIR, LOCKDIR, CONFIGDIR, and TROUBLEDIR */
|
||||
#define NO_TERMS
|
||||
#define ASCIIGRAPH
|
||||
|
||||
|
||||
@@ -141,7 +141,7 @@
|
||||
# endif
|
||||
#define NOCWD_ASSUMPTIONS /* Allow paths to be specified for HACKDIR,
|
||||
LEVELDIR, SAVEDIR, BONESDIR, DATADIR,
|
||||
SCOREDIR, LOCKDIR, and CONFIGDIR */
|
||||
SCOREDIR, LOCKDIR, CONFIGDIR, and TROUBLEDIR. */
|
||||
|
||||
#endif /* MSDOS configuration stuff */
|
||||
|
||||
|
||||
@@ -263,12 +263,12 @@ char toplines[TBUFSZ];
|
||||
struct tc_gbl_data tc_gbl_data = { 0,0, 0,0 }; /* AS,AE, LI,CO */
|
||||
|
||||
char *fqn_prefix[PREFIX_COUNT] = { (char *)0, (char *)0, (char *)0, (char *)0,
|
||||
(char *)0, (char *)0, (char *)0, (char *)0 };
|
||||
(char *)0, (char *)0, (char *)0, (char *)0, (char *)0 };
|
||||
|
||||
#ifdef PREFIXES_IN_USE
|
||||
char *fqn_prefix_names[PREFIX_COUNT] = { "hackdir", "leveldir", "savedir",
|
||||
"bonesdir", "datadir", "scoredir",
|
||||
"lockdir", "configdir" };
|
||||
"lockdir", "configdir", "troubledir" };
|
||||
#endif
|
||||
|
||||
/* dummy routine used to force linkage */
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#define DATAPREFIX 4
|
||||
|
||||
#ifdef DLB
|
||||
/*
|
||||
* Data librarian. Present a STDIO-like interface to NetHack while
|
||||
@@ -29,7 +31,7 @@ typedef struct dlb_procs {
|
||||
} dlb_procs_t;
|
||||
|
||||
/* without extern.h via hack.h, these haven't been declared for us */
|
||||
extern FILE *FDECL(fopen_datafile, (const char *,const char *,BOOLEAN_P));
|
||||
extern FILE *FDECL(fopen_datafile, (const char *,const char *,int));
|
||||
|
||||
#ifdef DLBLIB
|
||||
/*
|
||||
@@ -199,7 +201,7 @@ open_library(lib_name, lp)
|
||||
{
|
||||
boolean status = FALSE;
|
||||
|
||||
lp->fdata = fopen_datafile(lib_name, RDBMODE, FALSE);
|
||||
lp->fdata = fopen_datafile(lib_name, RDBMODE, DATAPREFIX);
|
||||
if (lp->fdata) {
|
||||
if (readlibdir(lp)) {
|
||||
status = TRUE;
|
||||
@@ -460,7 +462,7 @@ dlb_fopen(name, mode)
|
||||
dp = (dlb *) alloc(sizeof(dlb));
|
||||
if (do_dlb_fopen(dp, name, mode))
|
||||
dp->fp = (FILE *) 0;
|
||||
else if ((fp = fopen_datafile(name, mode, FALSE)) != 0)
|
||||
else if ((fp = fopen_datafile(name, mode, DATAPREFIX)) != 0)
|
||||
dp->fp = fp;
|
||||
else {
|
||||
/* can't find anything */
|
||||
|
||||
13
src/files.c
13
src/files.c
@@ -34,7 +34,7 @@ extern int errno;
|
||||
#endif
|
||||
|
||||
#ifdef PREFIXES_IN_USE
|
||||
#define FQN_NUMBUF 3
|
||||
#define FQN_NUMBUF 4
|
||||
static char fqn_filename_buffer[FQN_NUMBUF][FQN_MAX_FILENAME];
|
||||
#endif
|
||||
|
||||
@@ -157,14 +157,13 @@ int whichprefix, buffnum;
|
||||
/* fopen a file, with OS-dependent bells and whistles */
|
||||
/* NOTE: a simpler version of this routine also exists in util/dlb_main.c */
|
||||
FILE *
|
||||
fopen_datafile(filename, mode, use_scoreprefix)
|
||||
fopen_datafile(filename, mode, prefix)
|
||||
const char *filename, *mode;
|
||||
boolean use_scoreprefix;
|
||||
int prefix;
|
||||
{
|
||||
FILE *fp;
|
||||
|
||||
filename = fqname(filename,
|
||||
use_scoreprefix ? SCOREPREFIX : DATAPREFIX, 0);
|
||||
filename = fqname(filename, prefix, prefix == TROUBLEPREFIX ? 3 : 0);
|
||||
#ifdef VMS /* essential to have punctuation, to avoid logical names */
|
||||
{
|
||||
char tmp[BUFSIZ];
|
||||
@@ -1302,6 +1301,8 @@ char *tmp_levels;
|
||||
adjust_prefix(bufp, LOCKPREFIX);
|
||||
} else if (match_varname(buf, "CONFIGDIR", 4)) {
|
||||
adjust_prefix(bufp, CONFIGPREFIX);
|
||||
} else if (match_varname(buf, "TROUBLEDIR", 4)) {
|
||||
adjust_prefix(bufp, TROUBLEPREFIX);
|
||||
#else /*NOCWD_ASSUMPTIONS*/
|
||||
# ifdef MICRO
|
||||
} else if (match_varname(buf, "HACKDIR", 4)) {
|
||||
@@ -1793,7 +1794,7 @@ const char* s;
|
||||
#ifdef PANICLOG
|
||||
FILE *lfile;
|
||||
|
||||
lfile = fopen_datafile(PANICLOG, "a", TRUE);
|
||||
lfile = fopen_datafile(PANICLOG, "a", TROUBLEPREFIX);
|
||||
if (lfile) {
|
||||
(void) fprintf(lfile, "%08ld: %s %s\n",
|
||||
yyyymmdd((time_t)0L), why, s);
|
||||
|
||||
12
src/topten.c
12
src/topten.c
@@ -340,7 +340,7 @@ int how;
|
||||
|
||||
#ifdef LOGFILE /* used for debugging (who dies of what, where) */
|
||||
if (lock_file(LOGFILE, SCOREPREFIX, 10)) {
|
||||
if(!(lfile = fopen_datafile(LOGFILE, "a", TRUE))) {
|
||||
if(!(lfile = fopen_datafile(LOGFILE, "a", SCOREPREFIX))) {
|
||||
HUP raw_print("Cannot open log file!");
|
||||
} else {
|
||||
writeentry(lfile, t0);
|
||||
@@ -366,9 +366,9 @@ int how;
|
||||
goto destroywin;
|
||||
|
||||
#ifdef UPDATE_RECORD_IN_PLACE
|
||||
rfile = fopen_datafile(RECORD, "r+", TRUE);
|
||||
rfile = fopen_datafile(RECORD, "r+", SCOREPREFIX);
|
||||
#else
|
||||
rfile = fopen_datafile(RECORD, "r", TRUE);
|
||||
rfile = fopen_datafile(RECORD, "r", SCOREPREFIX);
|
||||
#endif
|
||||
|
||||
if (!rfile) {
|
||||
@@ -445,7 +445,7 @@ int how;
|
||||
t0->fpos : final_fpos), SEEK_SET);
|
||||
#else
|
||||
(void) fclose(rfile);
|
||||
if(!(rfile = fopen_datafile(RECORD, "w", TRUE))){
|
||||
if(!(rfile = fopen_datafile(RECORD, "w", SCOREPREFIX))){
|
||||
HUP raw_print("Cannot write record file");
|
||||
unlock_file(RECORD);
|
||||
free_ttlist(tt_head);
|
||||
@@ -762,7 +762,7 @@ char **argv;
|
||||
return;
|
||||
}
|
||||
|
||||
rfile = fopen_datafile(RECORD, "r", TRUE);
|
||||
rfile = fopen_datafile(RECORD, "r", SCOREPREFIX);
|
||||
if (!rfile) {
|
||||
raw_print("Cannot open record file!");
|
||||
return;
|
||||
@@ -922,7 +922,7 @@ struct obj *otmp;
|
||||
|
||||
if (!otmp) return((struct obj *) 0);
|
||||
|
||||
rfile = fopen_datafile(RECORD, "r", TRUE);
|
||||
rfile = fopen_datafile(RECORD, "r", SCOREPREFIX);
|
||||
if (!rfile) {
|
||||
impossible("Cannot open record file!");
|
||||
return (struct obj *)0;
|
||||
|
||||
@@ -61,16 +61,34 @@ OPTIONS=time,noshowexp,number_pad,lit_corridor,rest_on_space
|
||||
#OPTIONS=suppress_alert:3.3.1
|
||||
#
|
||||
#
|
||||
# *** LOCATIONS ***
|
||||
# Some platforms allow you to change the location where various things are kept.
|
||||
# IMPORTANT: If you change any of these locations, the directories they
|
||||
# point at must exist. NetHack will not create them for you.
|
||||
#
|
||||
# The default location for everything.
|
||||
# Note: On Windows HACKDIR defaults to the location
|
||||
# of the NetHack.exe or NetHackw.exe file so
|
||||
# setting HACKDIR below to override that is
|
||||
# not usually necessary or recommended.
|
||||
#HACKDIR=c:\games\nethack
|
||||
#
|
||||
# Note: Under MSDOS ports HACKDIR defaults to the location
|
||||
# of the NetHack.exe file. Setting HACKDIR above will override that.
|
||||
#
|
||||
# LEVELS and SAVE default to HACKDIR
|
||||
# The location that level files in progress are stored (default=HACKDIR, writeable)
|
||||
#LEVELDIR=c:\nethack\levels
|
||||
#
|
||||
# The location where saved games are kept (default=HACKDIR, writeable)
|
||||
#SAVEDIR=c:\nethack\save
|
||||
#
|
||||
# The location that bones files are kept (default=HACKDIR, writeable)
|
||||
#BONESDIR=c:\nethack\save
|
||||
#
|
||||
# The location that file synchronization locks are stored (default=HACKDIR, writeable)
|
||||
#LOCKDIR=c:\nethack\levels
|
||||
#
|
||||
# The location that a record of game aborts and self-diagnosed game problems
|
||||
# is kept (default=HACKDIR, writeable)
|
||||
#TROUBLEDIR=c:\nethack\trouble
|
||||
#
|
||||
#LEVELS=c:\games\nethack\bones
|
||||
#SAVE=c:\games\nethack\bones
|
||||
|
||||
# *** CHARACTER GRAPHICS ***
|
||||
#
|
||||
# See the on-line help or the Guidebook for which symbols are in which
|
||||
|
||||
@@ -72,18 +72,33 @@ OPTIONS=hilite_pet,!toptenwin
|
||||
# window, windowframe, windowtext.
|
||||
#OPTIONS=windowcolors:status windowtext/window message windowtext/window
|
||||
|
||||
# *** LOCATIONS ***
|
||||
# IMPORTANT: If you change any of these locations, the directories they
|
||||
# point at must exist. NetHack will not create them for you.
|
||||
#
|
||||
#HACKDIR=c:\games\nethack
|
||||
#
|
||||
# HACKDIR is the default location for everything.
|
||||
# Note: On Windows HACKDIR defaults to the location
|
||||
# of the NetHack.exe or NetHackw.exe file.
|
||||
# Setting HACKDIR above will override that.
|
||||
# of the NetHack.exe or NetHackw.exe file so
|
||||
# setting HACKDIR below to override that is
|
||||
# not usually necessary or recommended.
|
||||
#HACKDIR=c:\games\nethack
|
||||
#
|
||||
# LEVELS and SAVE default to HACKDIR
|
||||
# The location that level files in progress are stored (default=HACKDIR, writeable)
|
||||
#LEVELDIR=c:\nethack\levels
|
||||
#
|
||||
# The location where saved games are kept (default=HACKDIR, writeable)
|
||||
#SAVEDIR=c:\nethack\save
|
||||
#
|
||||
# The location that bones files are kept (default=HACKDIR, writeable)
|
||||
#BONESDIR=c:\nethack\save
|
||||
#
|
||||
# The location that file synchronization locks are stored (default=HACKDIR, writeable)
|
||||
#LOCKDIR=c:\nethack\levels
|
||||
#
|
||||
# The location that a record of game aborts and self-diagnosed game problems
|
||||
# is kept (default=HACKDIR, writeable)
|
||||
#TROUBLEDIR=c:\nethack\trouble
|
||||
#
|
||||
#LEVELS=c:\games\nethack\bones
|
||||
#SAVE=c:\games\nethack\bones
|
||||
|
||||
# *** CHARACTER GRAPHICS ***
|
||||
#
|
||||
# See the on-line help or the Guidebook for which symbols are in which
|
||||
|
||||
Reference in New Issue
Block a user