-/*-----------------------------------------------------------------------------
- *
- * FUNCTION IDENTIFICATION
- *
- * Name: sys_fopen Open a file for user
- * Date: 12-17-84
- * Programmer: Kevin Rosenberg
- *
- * SYNOPSIS
- * fp = sys_fopen (filename, mode, progname)
- * FILE *fp Standard pointer to 'C' file
- * char *filename Name of file to open
- * If user enters a new name, it goes here
- * char *mode Mode to open file (std. 'C')
- * char *progname Name of program calling this routine
- *
- * DESCRIPTION
- * This routine opens a file using the standard C fopen() routine. If
- * the file is not found, the user is given to option to:
- *
- * 1 - Retry opening file with same name
- * 2 - Enter new file name
- * 3 - Abort and return to DOS
- *
- * CAUTIONS
- * If the the requested file is not found, the name of the file given
- * entered at keyboard will be returned in filename. So, make sure there
- * is room for a maximum length filename (MAXFULLNAME)
- *
- *---------------------------------------------------------------------------*/
-
-FILE *
-sys_fopen (const char *filename, const char *mode, const char *progname)
-{
- FILE *fp;
- char fname[256]; /* name used for call to fopen() */
- char c; /* keyboard response */
-
- strncpy (fname, filename, sizeof(fname));
-
- do {
- if ((fp = fopen (fname, mode)) == NULL) {
- cerr << endl;
- cerr << "Can't open file " << fname << " [" << progname << "]" << endl;
- cerr << "Enter: <R> - Retry | <N> - New name | <A> - Abort program --> ";
- c = cio_kb_waitc ("RrNnAa", TRUE);
- c = tolower(c);
- cerr << c << endl;
-
- if (c == 'r') // Retry -- Nothing to do here
- ;
- else if (c == 'a') // Abort -- Exit to OS
- exit (1);
- else if (c == 'n') { // New name - get from console
- cerr << "Enter new file name -- ";
- fgets (fname, sizeof(fname), stdin);
- str_wrm_tail (fname);
- cerr << endl;
- }
- }
- } while (fp == NULL);
-
- return (fp);
-}