mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01: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
@ -1,3 +1,9 @@
|
||||
2003-09-18 Werner Koch <wk@gnupg.org>
|
||||
|
||||
* ttyio.c (tty_fprintf): New.
|
||||
(tty_print_string, tty_print_utf8_string2)
|
||||
(tty_print_utf8_string): Made P argument const byte*.
|
||||
|
||||
2003-08-20 Marcus Brinkmann <marcus@g10code.de>
|
||||
|
||||
* maperror.c (map_ksba_err): Map -1. Use gpg_err_make to set
|
||||
|
@ -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 );
|
||||
}
|
||||
|
@ -23,13 +23,17 @@
|
||||
const char *tty_get_ttyname (void);
|
||||
int tty_batchmode (int onoff);
|
||||
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5 )
|
||||
void tty_printf (const char *fmt, ... ) __attribute__ ((format (printf,1,2)));
|
||||
void tty_printf (const char *fmt, ... )
|
||||
__attribute__ ((format (printf,1,2)));
|
||||
void tty_fprintf (FILE *fp, const char *fmt, ... )
|
||||
__attribute__ ((format (printf,2,3)));
|
||||
#else
|
||||
void tty_printf (const char *fmt, ... );
|
||||
void tty_fprintf (FILE *fp, const char *fmt, ... );
|
||||
#endif
|
||||
void tty_print_string (unsigned char *p, size_t n);
|
||||
void tty_print_utf8_string (unsigned char *p, size_t n);
|
||||
void tty_print_utf8_string2 (unsigned char *p, size_t n, size_t max_n);
|
||||
void tty_print_string (const unsigned char *p, size_t n);
|
||||
void tty_print_utf8_string (const unsigned char *p, size_t n);
|
||||
void tty_print_utf8_string2 (const unsigned char *p, size_t n, size_t max_n);
|
||||
char *tty_get (const char *prompt);
|
||||
char *tty_get_hidden (const char *prompt);
|
||||
void tty_kill_prompt (void);
|
||||
|
Loading…
x
Reference in New Issue
Block a user