]> granicus.if.org Git - nethack/commitdiff
more NOCWD_ASSUMPTIONS
authornethack.allison <nethack.allison>
Sat, 29 Jun 2002 12:44:54 +0000 (12:44 +0000)
committernethack.allison <nethack.allison>
Sat, 29 Jun 2002 12:44:54 +0000 (12:44 +0000)
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.

include/amiconf.h
include/decl.h
include/extern.h
include/ntconf.h
include/pcconf.h
src/decl.c
src/dlb.c
src/files.c
src/topten.c
sys/share/NetHack.cnf
sys/winnt/defaults.nh

index 4cc3963fa41298ee8bd23148e3b656ff7d063c92..7a7e980c06831d9ae7a8732967cc8df6a9186786 100644 (file)
@@ -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
index 717a23fddcc124bf22ba629a32ecd36431298d75..a1e3cbc4085fbbb039b2fbb1c1dfb9d0d51a83f2 100644 (file)
@@ -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
index 1a0cfa86b7aca37478b237c2a45ad341a4c30a99..938b6ca3cc993700184f3ad6c01826270da4d692 100644 (file)
@@ -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
index db358b8e13bb716ba0db0c734edbbe30ba94b4e2..a4cecf427c9a8a5bb1d106599e70bec5274f38e9 100644 (file)
@@ -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
 
index ddfa16b7e831b4d46808c55b385ab9c0ead5b468..9100df839c3b0574c84cf0ac776dd75dcc3600d9 100644 (file)
 # 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 */
 
index 69988fe864138ffadf9fc22624ba8018d1829508..349ad5064641ef634cf8bf1784ebb8dcbd656a5e 100644 (file)
@@ -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 */
index d6f2bf5e6840611f14b365b2efe427c94855e2cd..5d423263eb3f6097109ff907e388ba7a6ebae902 100644 (file)
--- a/src/dlb.c
+++ b/src/dlb.c
@@ -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 */
index 6813c250b1ae4cad92e5405484532b0524708100..6df6b955637e437e10e524bc7392c07e355c24d4 100644 (file)
@@ -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);
index 7ceb275e1d2cc24494477cc84ed148d68308ca87..03fbac4899708bb48bd1d8147adac72b8b4f30ac 100644 (file)
@@ -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;
index f8703df2e8735fd9107ac95b5a80273984b800fb..0bb022da4dfc90b80bed3c09194737bb969354dd 100644 (file)
@@ -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
index 32e057cdfc13e2dd7e25b73e691b7179942b0d44..0b437d34bc102ba4cf92d54176bbb4f9f8db09e2 100644 (file)
@@ -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