diff options
author | Werner Koch <[email protected]> | 2010-03-15 11:15:45 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2010-03-15 11:15:45 +0000 |
commit | fb2ba98963beea249474f5d6d7345cf9b4b7f570 (patch) | |
tree | 3c9b25d63f90a71caec5685fca945341d54bef9d /common/ttyio.c | |
parent | Use a custom log handler for libassuan. (diff) | |
download | gnupg-fb2ba98963beea249474f5d6d7345cf9b4b7f570.tar.gz gnupg-fb2ba98963beea249474f5d6d7345cf9b4b7f570.zip |
Finished the bulk of changes to use estream in most places instead of
stdio.
Diffstat (limited to 'common/ttyio.c')
-rw-r--r-- | common/ttyio.c | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/common/ttyio.c b/common/ttyio.c index ec26b06e8..4f30b4b44 100644 --- a/common/ttyio.c +++ b/common/ttyio.c @@ -1,6 +1,6 @@ /* ttyio.c - tty i/O functions * Copyright (C) 1998,1999,2000,2001,2002,2003,2004,2006,2007, - * 2009 Free Software Foundation, Inc. + * 2009, 2010 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -244,14 +244,14 @@ tty_printf( const char *fmt, ... ) /* Same as tty_printf but if FP is not NULL, behave like a regular fprintf. */ void -tty_fprintf (FILE *fp, const char *fmt, ... ) +tty_fprintf (estream_t fp, const char *fmt, ... ) { va_list arg_ptr; if (fp) { va_start (arg_ptr, fmt) ; - vfprintf (fp, fmt, arg_ptr ); + es_vfprintf (fp, fmt, arg_ptr ); va_end (arg_ptr); return; } @@ -259,32 +259,32 @@ tty_fprintf (FILE *fp, const char *fmt, ... ) if (no_terminal) return; - if( !initialized ) - init_ttyfp(); + if (!initialized) + init_ttyfp (); - va_start( arg_ptr, fmt ) ; + va_start (arg_ptr, fmt); #ifdef _WIN32 - { - char *buf = NULL; - int n; - DWORD nwritten; - - n = vasprintf(&buf, fmt, arg_ptr); - if( !buf ) - log_bug("vasprintf() failed\n"); - - if( !WriteConsoleA( con.out, buf, n, &nwritten, NULL ) ) - log_fatal("WriteConsole failed: rc=%d", (int)GetLastError() ); - if( n != nwritten ) - log_fatal("WriteConsole failed: %d != %d\n", n, (int)nwritten ); - last_prompt_len += n; - xfree (buf); - } + { + char *buf = NULL; + int n; + DWORD nwritten; + + n = vasprintf(&buf, fmt, arg_ptr); + if (!buf) + log_bug("vasprintf() failed\n"); + + if (!WriteConsoleA( con.out, buf, n, &nwritten, NULL )) + log_fatal("WriteConsole failed: rc=%d", (int)GetLastError() ); + if (n != nwritten) + log_fatal("WriteConsole failed: %d != %d\n", n, (int)nwritten ); + last_prompt_len += n; + xfree (buf); + } #else - last_prompt_len += vfprintf(ttyfp,fmt,arg_ptr) ; - fflush(ttyfp); + last_prompt_len += vfprintf(ttyfp,fmt,arg_ptr) ; + fflush(ttyfp); #endif - va_end(arg_ptr); + va_end(arg_ptr); } |