]> granicus.if.org Git - nethack/commitdiff
update files.c with testinglog
authornhmall <nhmall@nethack.org>
Thu, 10 May 2018 22:54:58 +0000 (18:54 -0400)
committernhmall <nhmall@nethack.org>
Thu, 10 May 2018 22:54:58 +0000 (18:54 -0400)
src/files.c

index 8a490d09e76f524620b1eee5c4aa7c6576d4d400..cd5277acbf97db0b3066d507863188b2b193930f 100644 (file)
@@ -3542,7 +3542,7 @@ const char *dir UNUSED_if_not_OS2_CODEVIEW;
 
 /* ----------  END SCOREBOARD CREATION ----------- */
 
-/* ----------  BEGIN PANIC/IMPOSSIBLE LOG ----------- */
+/* ----------  BEGIN PANIC/IMPOSSIBLE/TESTING LOG ----------- */
 
 /*ARGSUSED*/
 void
@@ -3579,7 +3579,31 @@ const char *reason; /* explanation */
     return;
 }
 
-/* ----------  END PANIC/IMPOSSIBLE LOG ----------- */
+/*ARGSUSED*/
+void
+testinglog(filenm, type, reason)
+const char *filenm;   /* ad hoc file name */
+const char *type; 
+const char *reason;   /* explanation */
+{
+    FILE *lfile;
+    char fnbuf[BUFSZ];
+
+    if (!filenm) return;
+    Strcpy(fnbuf, filenm);
+    if (index(fnbuf, '.') == 0)
+        Strcat(fnbuf, ".log");
+    lfile = fopen_datafile(fnbuf, "a", TROUBLEPREFIX);
+    if (lfile) {
+        time_t now = getnow();
+        int uid = getuid();
+        (void) fprintf(lfile, "%s\n%s\n", type, reason);
+        (void) fclose(lfile);
+    }
+    return;
+}
+
+/* ----------  END PANIC/IMPOSSIBLE/TESTING LOG ----------- */
 
 #ifdef SELF_RECOVER