summaryrefslogtreecommitdiff
path: root/jerror.c
diff options
context:
space:
mode:
authorThomas G. Lane <tgl@netcom.com>1998-03-27 00:00:00 +0000
committerDRC <information@libjpeg-turbo.org>2015-07-27 13:43:00 -0500
commit5ead57a34a398aa798f35bd7a6abad19b2e453e2 (patch)
tree28613ddc542c153d85afab078c9835864ed67f11 /jerror.c
parent489583f5165e05d37302e8eeec58104ea0109127 (diff)
The Independent JPEG Group's JPEG software v6b
Diffstat (limited to 'jerror.c')
-rw-r--r--jerror.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/jerror.c b/jerror.c
index 8b89e39..3da7be8 100644
--- a/jerror.c
+++ b/jerror.c
@@ -1,7 +1,7 @@
/*
* jerror.c
*
- * Copyright (C) 1991-1996, Thomas G. Lane.
+ * Copyright (C) 1991-1998, Thomas G. Lane.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
@@ -10,6 +10,11 @@
* stderr is the right thing to do. Many applications will want to replace
* some or all of these routines.
*
+ * If you define USE_WINDOWS_MESSAGEBOX in jconfig.h or in the makefile,
+ * you get a Windows-specific hack to display error messages in a dialog box.
+ * It ain't much, but it beats dropping error messages into the bit bucket,
+ * which is what happens to output to stderr under most Windows C compilers.
+ *
* These routines are used by both the compression and decompression code.
*/
@@ -19,6 +24,10 @@
#include "jversion.h"
#include "jerror.h"
+#ifdef USE_WINDOWS_MESSAGEBOX
+#include <windows.h>
+#endif
+
#ifndef EXIT_FAILURE /* define exit() codes if not provided */
#define EXIT_FAILURE 1
#endif
@@ -74,6 +83,15 @@ error_exit (j_common_ptr cinfo)
* Actual output of an error or trace message.
* Applications may override this method to send JPEG messages somewhere
* other than stderr.
+ *
+ * On Windows, printing to stderr is generally completely useless,
+ * so we provide optional code to produce an error-dialog popup.
+ * Most Windows applications will still prefer to override this routine,
+ * but if they don't, it'll do something at least marginally useful.
+ *
+ * NOTE: to use the library in an environment that doesn't support the
+ * C stdio library, you may have to delete the call to fprintf() entirely,
+ * not just not use this routine.
*/
METHODDEF(void)
@@ -84,8 +102,14 @@ output_message (j_common_ptr cinfo)
/* Create the message */
(*cinfo->err->format_message) (cinfo, buffer);
+#ifdef USE_WINDOWS_MESSAGEBOX
+ /* Display it in a message dialog box */
+ MessageBox(GetActiveWindow(), buffer, "JPEG Library Error",
+ MB_OK | MB_ICONERROR);
+#else
/* Send it to stderr, adding a newline */
fprintf(stderr, "%s\n", buffer);
+#endif
}