2
* Copyright (c) 1991, 2002 Michael J. Roberts. All rights reserved.
4
* Please see the accompanying license file, LICENSE.TXT, for information
5
* on using and copying this software.
11
Allows TADS to read part or all of the commands from a session from a
14
Some operating systems (e.g., Mac) obtain user input in ways that don't
15
involve the command line. For these systems to work properly, the os_xxx
16
routines that invoke other input methods must be "qa scripter aware"; for
17
example, the Mac os_askfile() routine must put the filename it gets back
18
in the command log file, or must read directly from the command log file,
21
03/10/91 MJRoberts - created
31
* Globals for the script reader
33
osfildef *scrfp = (osfildef *)0; /* script file */
34
int scrquiet = 0; /* flag: true ==> script is NOT shown as read */
39
int qasopn(char *scrnam, int quiet)
41
if (scrfp) return 1; /* already reading from script */
42
if ((scrfp = osfoprt(scrnam, OSFTCMD)) == 0) return 1;
52
/* only close the script file if there's one open */
56
scrfp = 0; /* no more script file */
62
* Read the next line from the script file (this is essentially the
63
* script-redirected os_gets). Only lines starting with '>' are
64
* considered script input lines; all other lines are comments, and are
67
char *qasgets(char *buf, int bufl)
69
/* shouldn't be here at all if there's no script file */
73
/* update status line */
76
/* keep going until we find something we like */
82
* Read the next character of input. If it's not a newline,
83
* there's more on the same line, so read the rest and see what
87
if (c != '\n' && c != '\r')
89
/* read the rest of the line */
90
if (!osfgets(buf, bufl, scrfp))
92
/* end of file: close the script and return eof */
97
/* if the line started with '>', strip '\n' and return line */
102
/* remove the trailing newline */
103
if ((l = strlen(buf)) > 0
104
&& (buf[l-1] == '\n' || buf[l-1] == '\r'))
108
* if we're not in quiet mode, echo the command to the
114
/* flush the current line without adding any blank lines */
117
/* return the command */
123
/* end of file - close the script and return eof */