aboutsummaryrefslogtreecommitdiffstats
path: root/util/ttyio.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2000-07-14 17:34:53 +0000
committerWerner Koch <[email protected]>2000-07-14 17:34:53 +0000
commit92cd25550836198cf1e3a6aac239eef98364359d (patch)
tree4fad355126fae79c93535e0e7c6afd91e384552a /util/ttyio.c
parentSee ChangeLog: Thu May 25 18:39:11 CEST 2000 Werner Koch (diff)
downloadgnupg-92cd25550836198cf1e3a6aac239eef98364359d.tar.gz
gnupg-92cd25550836198cf1e3a6aac239eef98364359d.zip
See ChangeLog: Fri Jul 14 19:38:23 CEST 2000 Werner Koch
Diffstat (limited to '')
-rw-r--r--util/ttyio.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/util/ttyio.c b/util/ttyio.c
index 527d64832..6aaff000c 100644
--- a/util/ttyio.c
+++ b/util/ttyio.c
@@ -1,5 +1,5 @@
/* ttyio.c - tty i/O functions
- * Copyright (C) 1998 Free Software Foundation, Inc.
+ * Copyright (C) 1998, 2000 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
@@ -26,6 +26,16 @@
#include <unistd.h>
#ifdef HAVE_TCGETATTR
#include <termios.h>
+#else
+ #ifdef HAVE_TERMIO_H
+ /* simulate termios with termio */
+ #include <termio.h>
+ #define termios termio
+ #define tcsetattr ioctl
+ #define TCSAFLUSH TCSETAF
+ #define tcgetattr(A,B) ioctl(A,TCGETA,B)
+ #define HAVE_TCGETATTR
+ #endif
#endif
#ifdef __MINGW32__ /* use the odd Win32 functions */
#include <windows.h>
@@ -237,7 +247,7 @@ tty_print_string( byte *p, size_t n )
}
void
-tty_print_utf8_string( byte *p, size_t n )
+tty_print_utf8_string2( byte *p, size_t n, size_t max_n )
{
size_t i;
char *buf;
@@ -252,14 +262,28 @@ tty_print_utf8_string( byte *p, size_t n )
}
if( i < n ) {
buf = utf8_to_native( p, n );
+ if( strlen( buf ) > max_n ) {
+ buf[max_n] = 0;
+ }
+ /*(utf8 conversion already does the control character quoting)*/
tty_printf("%s", buf );
gcry_free( buf );
}
- else
+ else {
+ if( n > max_n ) {
+ n = max_n;
+ }
tty_print_string( p, n );
+ }
}
+void
+tty_print_utf8_string( byte *p, size_t n )
+{
+ tty_print_utf8_string2( p, n, n );
+}
+