aboutsummaryrefslogtreecommitdiffstats
path: root/util/ttyio.c
diff options
context:
space:
mode:
authorTimo Schulz <[email protected]>2004-11-03 20:03:46 +0000
committerTimo Schulz <[email protected]>2004-11-03 20:03:46 +0000
commit37ecd725e58c41820e01f15c1ef4fb2c07014aa9 (patch)
treed5b9174d9498fdb12e27b85d28bc31456fc56354 /util/ttyio.c
parent* strgutil.c (load_libiconv): Use log_info to avoid failures when (diff)
downloadgnupg-37ecd725e58c41820e01f15c1ef4fb2c07014aa9.tar.gz
gnupg-37ecd725e58c41820e01f15c1ef4fb2c07014aa9.zip
2004-11-03 Timo Schulz <[email protected]>
* strgutil.c (w32_strerror): New. * ttyio.c (init_ttyfp, tty_printf, do_get): Use it here. * iobuf.c (fd_cache_open, file_filter): Likewise. (iobuf_seek, translate_file_handle): Likewise.
Diffstat (limited to '')
-rw-r--r--util/ttyio.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/util/ttyio.c b/util/ttyio.c
index add7467ce..f5b761f14 100644
--- a/util/ttyio.c
+++ b/util/ttyio.c
@@ -140,15 +140,15 @@ init_ttyfp(void)
FILE_SHARE_READ|FILE_SHARE_WRITE,
&sa, OPEN_EXISTING, 0, 0 );
if( con.out == INVALID_HANDLE_VALUE )
- log_fatal("open(CONOUT$) failed: rc=%d", (int)GetLastError() );
+ log_fatal ("open(CONOUT$) failed: %s", w32_strerror (0));
memset(&sa, 0, sizeof(sa));
sa.nLength = sizeof(sa);
sa.bInheritHandle = TRUE;
con.in = CreateFileA( "CONIN$", GENERIC_READ|GENERIC_WRITE,
FILE_SHARE_READ|FILE_SHARE_WRITE,
&sa, OPEN_EXISTING, 0, 0 );
- if( con.in == INVALID_HANDLE_VALUE )
- log_fatal("open(CONIN$) failed: rc=%d", (int)GetLastError() );
+ if (con.in == INVALID_HANDLE_VALUE)
+ log_fatal ("open(CONIN$) failed: %s", w32_strerror (0));
}
SetConsoleMode(con.in, DEF_INPMODE );
SetConsoleMode(con.out, DEF_OUTMODE );
@@ -212,10 +212,10 @@ tty_printf( const char *fmt, ... )
if( !buf )
log_bug("vasprintf() failed\n");
- if( !WriteConsoleA( con.out, buf, n, &nwritten, NULL ) )
- log_fatal("WriteConsole failed: rc=%d", (int)GetLastError() );
+ if (!WriteConsoleA (con.out, buf, n, &nwritten, NULL))
+ log_fatal ("WriteConsole failed: %s", w32_strerror (0));
if( n != nwritten )
- log_fatal("WriteConsole failed: %d != %d\n", n, (int)nwritten );
+ log_fatal ("WriteConsole failed: %d != %d\n", n, (int)nwritten );
last_prompt_len += n;
m_free (buf);
}
@@ -259,10 +259,10 @@ tty_fprintf (FILE *fp, const char *fmt, ... )
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 );
+ if (!WriteConsoleA (con.out, buf, n, &nwritten, NULL))
+ log_fatal ("WriteConsole failed: %s", w32_strerror (0));
+ if (n != nwritten)
+ log_fatal ("WriteConsole failed: %d != %d\n", n, (int)nwritten);
last_prompt_len += n;
xfree (buf);
}
@@ -387,8 +387,8 @@ do_get( const char *prompt, int hidden )
for(;;) {
DWORD nread;
- if( !ReadConsoleA( con.in, cbuf, 1, &nread, NULL ) )
- log_fatal("ReadConsole failed: rc=%d", (int)GetLastError() );
+ if (!ReadConsoleA (con.in, cbuf, 1, &nread, NULL))
+ log_fatal ("ReadConsole failed: %s", w32_strerror (0));
if( !nread )
continue;
if( *cbuf == '\n' )