From: David Griffith Date: Sat, 29 Apr 2023 05:58:01 +0000 (-0700) Subject: Added save-restore prompt option to dos interface with restriction to .aux. X-Git-Url: https://scope-eye.net/git/?a=commitdiff_plain;h=1470bc24b2bb1d3b442a641c9936f654621c6c61;p=liskon_frotz.git Added save-restore prompt option to dos interface with restriction to .aux. --- diff --git a/src/dos/dosinit.c b/src/dos/dosinit.c index 130c664..465e01d 100644 --- a/src/dos/dosinit.c +++ b/src/dos/dosinit.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include "frotz.h" @@ -237,6 +238,44 @@ void os_quit(int status) 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 * diff --git a/src/dos/dosinput.c b/src/dos/dosinput.c index 2aba604..17c7fd0 100644 --- a/src/dos/dosinput.c +++ b/src/dos/dosinput.c @@ -889,6 +889,7 @@ char *os_read_file_name (const char *default_name, int flag) int i; char *tempname; char file_name[FILENAME_MAX + 1]; + char *ext; /* Turn off playback and recording temporarily */ istream_replay = FALSE; @@ -904,14 +905,17 @@ char *os_read_file_name (const char *default_name, int flag) 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) @@ -935,6 +939,13 @@ char *os_read_file_name (const char *default_name, int flag) 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; diff --git a/src/dos/dostext.c b/src/dos/dostext.c index 527f12e..193048f 100644 --- a/src/dos/dostext.c +++ b/src/dos/dostext.c @@ -495,6 +495,23 @@ void os_set_colour(int new_foreground, int new_background) } /* os_set_colour */ +/* + * 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_get_text_style */ + + /* * os_set_text_style *