#include <conio.h>
#include <dos.h>
#include <stdio.h>
+#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include "frotz.h"
exit(status);
}
+
+static void print_c_string (const char *s)
+{
+ zchar c;
+
+ while ((c = *s++) != 0)
+ os_display_char (c);
+} /* print_c_string */
+
+
+/*
+ * os_warn
+ *
+ * Display a warning message and continue with the game.
+ *
+ */
+void os_warn (const char *s, ...)
+{
+ va_list m;
+ char errorstring[81];
+ int style;
+
+ va_start(m, s);
+ vsnprintf(errorstring, sizeof(char) * 80, s, m);
+ va_end(m);
+
+ os_beep(BEEP_HIGH);
+ style = os_get_text_style();
+ os_set_text_style(BOLDFACE_STYLE);
+ print_c_string("Warning: ");
+ os_set_text_style(NORMAL_STYLE);
+ print_c_string(errorstring);
+ new_line();
+ os_set_text_style(style);
+
+ return;
+} /* os_warn */
+
/*
* os_fatal
*
int i;
char *tempname;
char file_name[FILENAME_MAX + 1];
+ char *ext;
/* Turn off playback and recording temporarily */
istream_replay = FALSE;
if (flag == FILE_RECORD || flag == FILE_PLAYBACK)
extension = EXT_COMMAND;
- /* Input file name (reserve four bytes for a file name extension) */
- print_string("Enter file name (\"");
- print_string(extension);
- print_string("\" will be added).\nDefault is \"");
- print_string(default_name);
- print_string("\": ");
-
- read_string(MAX_FILE_NAME - 4, (zchar *) file_name);
+ if (flag == FILE_NO_PROMPT) {
+ file_name[0] = 0;
+ } else {
+ /* Input file name (reserve four bytes for a file name extension) */
+ print_string("Enter file name (\"");
+ print_string(extension);
+ print_string("\" will be added).\nDefault is \"");
+ print_string(default_name);
+ print_string("\": ");
+ read_string(MAX_FILE_NAME - 4, (zchar *) file_name);
+ }
/* Use the default name if nothing was typed */
if (file_name[0] == 0)
strcat(file_name, tempname);
}
+ if (flag == FILE_NO_PROMPT) {
+ ext = strrchr(file_name, '.');
+ if (strncmp(ext, EXT_AUX, 4)) {
+ os_warn("Blocked unprompted access of %s. Should only be %s files.", file_name, EXT_AUX);
+ return NULL;
+ }
+ }
/* Make sure it is safe to use this file name */
result = TRUE;