| 1 | /*
|
|---|
| 2 | * jerror.c
|
|---|
| 3 | *
|
|---|
| 4 | * Copyright (C) 1991-1998, Thomas G. Lane.
|
|---|
| 5 | * This file is part of the Independent JPEG Group's software.
|
|---|
| 6 | * For conditions of distribution and use, see the accompanying README file.
|
|---|
| 7 | *
|
|---|
| 8 | * This file contains simple error-reporting and trace-message routines.
|
|---|
| 9 | * These are suitable for Unix-like systems and others where writing to
|
|---|
| 10 | * stderr is the right thing to do. Many applications will want to replace
|
|---|
| 11 | * some or all of these routines.
|
|---|
| 12 | *
|
|---|
| 13 | * If you define USE_WINDOWS_MESSAGEBOX in jconfig.h or in the makefile,
|
|---|
| 14 | * you get a Windows-specific hack to display error messages in a dialog box.
|
|---|
| 15 | * It ain't much, but it beats dropping error messages into the bit bucket,
|
|---|
| 16 | * which is what happens to output to stderr under most Windows C compilers.
|
|---|
| 17 | *
|
|---|
| 18 | * These routines are used by both the compression and decompression code.
|
|---|
| 19 | */
|
|---|
| 20 |
|
|---|
| 21 | /* this is not a core library module, so it doesn't define JPEG_INTERNALS */
|
|---|
| 22 | #include "jinclude.h"
|
|---|
| 23 | #include "jpeglib.h"
|
|---|
| 24 | #include "jversion.h"
|
|---|
| 25 | #include "jerror.h"
|
|---|
| 26 |
|
|---|
| 27 | #ifdef USE_WINDOWS_MESSAGEBOX
|
|---|
| 28 | #include <windows.h>
|
|---|
| 29 | #endif
|
|---|
| 30 |
|
|---|
| 31 | #ifndef EXIT_FAILURE /* define exit() codes if not provided */
|
|---|
| 32 | #define EXIT_FAILURE 1
|
|---|
| 33 | #endif
|
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 | /*
|
|---|
| 37 | * Create the message string table.
|
|---|
| 38 | * We do this from the master message list in jerror.h by re-reading
|
|---|
| 39 | * jerror.h with a suitable definition for macro JMESSAGE.
|
|---|
| 40 | * The message table is made an external symbol just in case any applications
|
|---|
| 41 | * want to refer to it directly.
|
|---|
| 42 | */
|
|---|
| 43 |
|
|---|
| 44 | #ifdef NEED_SHORT_EXTERNAL_NAMES
|
|---|
| 45 | #define jpeg_std_message_table jMsgTable
|
|---|
| 46 | #endif
|
|---|
| 47 |
|
|---|
| 48 | #define JMESSAGE(code,string) string ,
|
|---|
| 49 |
|
|---|
| 50 | const char * const jpeg_std_message_table[] = {
|
|---|
| 51 | #include "jerror.h"
|
|---|
| 52 | NULL
|
|---|
| 53 | };
|
|---|
| 54 |
|
|---|
| 55 |
|
|---|
| 56 | /*
|
|---|
| 57 | * Error exit handler: must not return to caller.
|
|---|
| 58 | *
|
|---|
| 59 | * Applications may override this if they want to get control back after
|
|---|
| 60 | * an error. Typically one would longjmp somewhere instead of exiting.
|
|---|
| 61 | * The setjmp buffer can be made a private field within an expanded error
|
|---|
| 62 | * handler object. Note that the info needed to generate an error message
|
|---|
| 63 | * is stored in the error object, so you can generate the message now or
|
|---|
| 64 | * later, at your convenience.
|
|---|
| 65 | * You should make sure that the JPEG object is cleaned up (with jpeg_abort
|
|---|
| 66 | * or jpeg_destroy) at some point.
|
|---|
| 67 | */
|
|---|
| 68 |
|
|---|
| 69 | METHODDEF(void)
|
|---|
| 70 | error_exit (j_common_ptr cinfo)
|
|---|
| 71 | {
|
|---|
| 72 | /* Always display the message */
|
|---|
|
|---|