From 9da1694e19fda1559c35c654430b78d26ce0b272 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Tue, 15 Jun 1999 12:31:07 +0000 Subject: See ChangeLog: Tue Jun 15 14:23:10 CEST 1999 Werner Koch --- util/ttyio.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'util/ttyio.c') diff --git a/util/ttyio.c b/util/ttyio.c index 0f0f144ef..3f5eb7900 100644 --- a/util/ttyio.c +++ b/util/ttyio.c @@ -58,6 +58,7 @@ static FILE *ttyfp = NULL; static int initialized; static int last_prompt_len; static int batchmode; +static int no_terminal; #ifdef HAVE_TCGETATTR static struct termios termsave; @@ -130,11 +131,22 @@ tty_batchmode( int onoff ) return old; } +int +tty_no_terminal(int onoff) +{ + int old = no_terminal; + no_terminal = onoff ? 1 : 0; + return old; +} + void tty_printf( const char *fmt, ... ) { va_list arg_ptr; + if (no_terminal) + return; + if( !initialized ) init_ttyfp(); @@ -188,6 +200,9 @@ tty_printf( const char *fmt, ... ) void tty_print_string( byte *p, size_t n ) { + if (no_terminal) + return; + if( !initialized ) init_ttyfp(); @@ -236,6 +251,11 @@ do_get( const char *prompt, int hidden ) exit(2); } + if (no_terminal) { + log_error("Sorry, no terminal at all requested - can't get input\n"); + exit(2); + } + if( !initialized ) init_ttyfp(); @@ -349,9 +369,12 @@ tty_get_hidden( const char *prompt ) void tty_kill_prompt() { + if ( no_terminal ) + return; if( !initialized ) init_ttyfp(); + if( batchmode ) last_prompt_len = 0; if( !last_prompt_len ) -- cgit v1.2.3