From 37ecd725e58c41820e01f15c1ef4fb2c07014aa9 Mon Sep 17 00:00:00 2001 From: Timo Schulz Date: Wed, 3 Nov 2004 20:03:46 +0000 Subject: 2004-11-03 Timo Schulz * 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. --- util/ttyio.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'util/ttyio.c') 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' ) -- cgit