com_err.c: display the error via stderr if it is a character device
authorRichard Basch <probe@mit.edu>
Tue, 11 Feb 1997 19:19:10 +0000 (19:19 +0000)
committerRichard Basch <probe@mit.edu>
Tue, 11 Feb 1997 19:19:10 +0000 (19:19 +0000)
(win32 console apps)

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@9854 dc483132-0cff-0310-8789-dd5450dbe970

src/util/et/ChangeLog
src/util/et/com_err.c

index 66daf0747de4d7d410dad12b17ee0152c886f933..e536e6a58e9f060bb5d5f81878b19e6718a4af31 100644 (file)
@@ -1,3 +1,8 @@
+Tue Feb 11 13:31:49 1997  Richard Basch  <basch@lehman.com>
+
+       * com_err.c: If the application is a console application, simply
+               display the message to stderr. (win32)
+
 Mon Feb 10 21:30:41 1997  Theodore Y. Ts'o  <tytso@mit.edu>
 
        * com_err.c, com_err.h (com_err_va): Fix broken Windows 16
index 2b1d10078d885e349be3d087e6724cf7c49a7dee..387458f9598fd594f349958654fd413774277567 100644 (file)
@@ -22,6 +22,9 @@
 #include "com_err.h"
 #include "error_table.h"
 
+#if defined(_MSDOS) || defined(_WIN32)
+#include <io.h>
+#endif
 #ifdef _MACINTOSH
 #include "icons.h"
 static void MacMessageBox(errbuf);
@@ -96,7 +99,13 @@ void KRB5_CALLCONV default_com_err_proc(ectx, priv, whoami, code, fmt, ap)
        MacMessageBox(errbuf);
 #else
        /* For Windows */
-       MessageBox ((HWND)NULL, errbuf, "Kerberos", MB_ICONEXCLAMATION);
+       if (_isatty(_fileno(stderr))) {
+           fputs(errbuf, stderr);
+           fputc('\r', stderr);
+           fputc('\n', stderr);
+           fflush(stderr);
+       } else
+           MessageBox ((HWND)NULL, errbuf, "Kerberos", MB_ICONEXCLAMATION);
 #endif
 }
 #endif