mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-03 22:56:33 +02:00
(tty_fprintf): New.
(tty_print_string, tty_print_utf8_string2) (tty_print_utf8_string): Made P argument const byte*.
This commit is contained in:
parent
657f9d4e5c
commit
210b725748
3 changed files with 64 additions and 7 deletions
|
@ -219,11 +219,58 @@ tty_printf( const char *fmt, ... )
|
|||
}
|
||||
|
||||
|
||||
/* Same as tty_printf but if FP is not NULL, behave like a regualr
|
||||
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 __MINGW32__
|
||||
{
|
||||
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.
|
||||
*/
|
||||
void
|
||||
tty_print_string( byte *p, size_t n )
|
||||
tty_print_string ( const byte *p, size_t n )
|
||||
{
|
||||
if (no_terminal)
|
||||
return;
|
||||
|
@ -261,7 +308,7 @@ tty_print_string( byte *p, size_t n )
|
|||
}
|
||||
|
||||
void
|
||||
tty_print_utf8_string2( byte *p, size_t n, size_t max_n )
|
||||
tty_print_utf8_string2( const byte *p, size_t n, size_t max_n )
|
||||
{
|
||||
size_t i;
|
||||
char *buf;
|
||||
|
@ -292,7 +339,7 @@ tty_print_utf8_string2( byte *p, size_t n, size_t max_n )
|
|||
}
|
||||
|
||||
void
|
||||
tty_print_utf8_string( byte *p, size_t n )
|
||||
tty_print_utf8_string( const byte *p, size_t n )
|
||||
{
|
||||
tty_print_utf8_string2( p, n, 0 );
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue