* Or visit http://www.fsf.org/
*/
+#include <stdarg.h>
+
#include "dfrotz.h"
#include "dblorb.h"
void os_restart_game (int UNUSED (stage)) {}
+/*
+ * os_warn
+ *
+ * Display a warning message and continue with the game.
+ *
+ */
+void os_warn (const char *s, ...)
+{
+ va_list m;
+ int style;
+
+ os_beep(BEEP_HIGH);
+ style = os_get_text_style();
+ os_set_text_style(BOLDFACE_STYLE);
+ fprintf(stderr, "Warning: ");
+ os_set_text_style(NORMAL_STYLE);
+ va_start(m, s);
+ vfprintf(stderr, s, m);
+ va_end(m);
+ fprintf(stderr, "\n");
+ os_set_text_style(style);
+ return;
+}
+
+
+/*
+ * os_fatal
+ *
+ * Display error message and exit program.
+ *
+ */
void os_fatal (const char *s, ...)
{
fprintf(stderr, "\nFatal error: %s\n", s);
fprintf(stderr, "Continuing anyway...\n");
else
os_quit(EXIT_FAILURE);
-}
+} /* os_fatal */
FILE *os_load_story(void)
char *tempname;
char path_separator[2];
int i;
+ char *ext;
path_separator[0] = PATH_SEPARATOR;
path_separator[1] = 0;
*/
if (f_setup.restore_mode) {
return strdup(default_name);
+ } else if (flag == FILE_NO_PROMPT) {
+ ext = strrchr(default_name, '.');
+ if (strncmp(ext, EXT_AUX, 4)) {
+ os_warn("Blocked unprompted access of %s. Should only be %s files.", default_name, EXT_AUX);
+ return NULL;
+ }
+ buf = strndup(default_name, MAX_FILE_NAME);
} else {
if (f_setup.restricted_path) {
for (i = strlen(default_name); i > 0; i--) {
}
}
- if (buf[0])
- strncpy(file_name, fullpath, FILENAME_MAX);
- else
+ if (buf == NULL || flag == FILE_NO_PROMPT)
strncpy(file_name, default_name, FILENAME_MAX);
+ else
+ strncpy(file_name, fullpath, FILENAME_MAX);
/* Check if we're restricted to one directory. */
if (f_setup.restricted_path != NULL) {
}
+/*
+ * os_get_text_style
+ *
+ * Return the current text style. Following flags can be set:
+ *
+ * REVERSE_STYLE
+ * BOLDFACE_STYLE
+ * EMPHASIS_STYLE (aka underline aka italics)
+ * FIXED_WIDTH_STYLE
+ *
+ */
+int os_get_text_style(void)
+{
+ return current_style;
+}
+
+
+/*
+ * os_set_text_style
+ *
+ * Set the current text style. Following flags can be set:
+ *
+ * REVERSE_STYLE
+ * BOLDFACE_STYLE
+ * EMPHASIS_STYLE (aka underline aka italics)
+ * FIXED_WIDTH_STYLE
+ *
+ */
void os_set_text_style(int x)
{
current_style = x;