mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
(tty_fprintf): New.
This commit is contained in:
parent
edb5762c5f
commit
7c637a098e
@ -1,3 +1,7 @@
|
||||
2003-09-28 Werner Koch <wk@gnupg.org>
|
||||
|
||||
* ttyio.c (tty_fprintf): New.
|
||||
|
||||
2003-09-21 Timo Schulz <twoaday@freakmail.de>
|
||||
|
||||
* http.c [WIN32]: Define MB_CUR_MAX.
|
||||
|
47
util/ttyio.c
47
util/ttyio.c
@ -217,6 +217,53 @@ tty_printf( const char *fmt, ... )
|
||||
}
|
||||
|
||||
|
||||
/* Same as tty_printf but if FP is not NULL, behave like the standard
|
||||
fprintf. */
|
||||
void
|
||||
tty_fprintf (FILE *fp, const char *fmt, ... )
|
||||
{
|
||||
va_list arg_ptr;
|
||||
|
||||
if (fp)
|
||||
{
|
||||
va_start (arg_ptr, fmt) ;
|
||||
vfprintf (fp, fmt, arg_ptr );
|
||||
va_end (arg_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
if (no_terminal)
|
||||
return;
|
||||
|
||||
if( !initialized )
|
||||
init_ttyfp();
|
||||
|
||||
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);
|
||||
}
|
||||
#else
|
||||
last_prompt_len += vfprintf(ttyfp,fmt,arg_ptr) ;
|
||||
fflush(ttyfp);
|
||||
#endif
|
||||
va_end(arg_ptr);
|
||||
}
|
||||
|
||||
|
||||
/****************
|
||||
* Print a string, but filter all control characters out.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user