Skip to content

Commit

Permalink
Add -s option for connecting console in and out to stdin and stdout
Browse files Browse the repository at this point in the history
  • Loading branch information
pzembrod committed Dec 14, 2023
1 parent 3c9dac8 commit 3953c06
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions RunCPM/abstraction_posix.h
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,7 @@ uint32 _HardwareIn(const uint32 Port) {
static struct argp_option options[] = {
{"input", 'i', "FILE", 0, "File to read console input from"},
{"output", 'o', "FILE", 0, "File to log console output to"},
{"stdio", 's', NULL, 0, "Route console in/out to stdin/out"},
{0}
};

Expand All @@ -504,6 +505,10 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state)
"error opening console log output file %s", arg);
}
break;
case 's':
console_in = stdin;
console_log = stdout;
break;
case ARGP_KEY_ARG:
case ARGP_KEY_END:
break;
Expand Down
4 changes: 3 additions & 1 deletion RunCPM/console.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ uint8 mask8bit = 0x7f; // TO be used for masking 8 bit characters (XMODEM relat

void _putcon(uint8 ch) // Puts a character
{
_putch(ch & mask8bit);
#ifdef SCRIPTCONSOLE
if (console_log != stdout) _putch(ch & mask8bit);
if (console_log) fputc(ch & mask8bit, console_log);
#else
_putch(ch & mask8bit);
#endif

}
Expand Down

0 comments on commit 3953c06

Please sign in to comment.