src/java.desktop/share/native/libjavajpeg/jerror.c
author jiefu
Fri, 15 Nov 2019 20:39:26 +0800
changeset 59110 8c4c358272a9
parent 47216 71c04702a3d5
permissions -rw-r--r--
8234232: [TESTBUG] gc/shenandoah/jvmti/TestHeapDump.java fails with -Xcomp Reviewed-by: zgu
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * reserved comment block
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT REMOVE OR ALTER!
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * jerror.c
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * Copyright (C) 1991-1998, Thomas G. Lane.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * This file is part of the Independent JPEG Group's software.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 * For conditions of distribution and use, see the accompanying README file.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * This file contains simple error-reporting and trace-message routines.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * These are suitable for Unix-like systems and others where writing to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * stderr is the right thing to do.  Many applications will want to replace
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * some or all of these routines.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * If you define USE_WINDOWS_MESSAGEBOX in jconfig.h or in the makefile,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * you get a Windows-specific hack to display error messages in a dialog box.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * It ain't much, but it beats dropping error messages into the bit bucket,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 * which is what happens to output to stderr under most Windows C compilers.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * These routines are used by both the compression and decompression code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
/* this is not a core library module, so it doesn't define JPEG_INTERNALS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
#include "jinclude.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#include "jpeglib.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
#include "jversion.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#include "jerror.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
#ifdef USE_WINDOWS_MESSAGEBOX
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
#include <windows.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
#ifndef EXIT_FAILURE            /* define exit() codes if not provided */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
#define EXIT_FAILURE  1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * Create the message string table.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * We do this from the master message list in jerror.h by re-reading
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * jerror.h with a suitable definition for macro JMESSAGE.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * The message table is made an external symbol just in case any applications
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * want to refer to it directly.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
#ifdef NEED_SHORT_EXTERNAL_NAMES
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
#define jpeg_std_message_table  jMsgTable
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
#define JMESSAGE(code,string)   string ,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
const char * const jpeg_std_message_table[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
#include "jerror.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
  NULL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * Error exit handler: must not return to caller.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * Applications may override this if they want to get control back after
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * an error.  Typically one would longjmp somewhere instead of exiting.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * The setjmp buffer can be made a private field within an expanded error
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * handler object.  Note that the info needed to generate an error message
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * is stored in the error object, so you can generate the message now or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * later, at your convenience.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * You should make sure that the JPEG object is cleaned up (with jpeg_abort
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 * or jpeg_destroy) at some point.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
METHODDEF(void)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
error_exit (j_common_ptr cinfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
  /* Always display the message */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
  (*cinfo->err->output_message) (cinfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
  /* Let the memory manager delete any temp files before we die */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
  jpeg_destroy(cinfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
  /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
   * This should never happen since the Java library replaces the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
   * error_exit pointer in the error handler structs it uses.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
   *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
   * exit(EXIT_FAILURE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
 * Actual output of an error or trace message.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 * Applications may override this method to send JPEG messages somewhere
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
 * other than stderr.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
 * On Windows, printing to stderr is generally completely useless,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
 * so we provide optional code to produce an error-dialog popup.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
 * Most Windows applications will still prefer to override this routine,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
 * but if they don't, it'll do something at least marginally useful.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
 * NOTE: to use the library in an environment that doesn't support the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
 * C stdio library, you may have to delete the call to fprintf() entirely,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
 * not just not use this routine.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
METHODDEF(void)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
output_message (j_common_ptr cinfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
  char buffer[JMSG_LENGTH_MAX];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
  /* Create the message */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
  (*cinfo->err->format_message) (cinfo, buffer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
#ifdef USE_WINDOWS_MESSAGEBOX
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
  /* Display it in a message dialog box */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
  MessageBox(GetActiveWindow(), buffer, "JPEG Library Error",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
             MB_OK | MB_ICONERROR);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
  /* Send it to stderr, adding a newline */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
  fprintf(stderr, "%s\n", buffer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
 * Decide whether to emit a trace or warning message.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
 * msg_level is one of:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
 *   -1: recoverable corrupt-data warning, may want to abort.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
 *    0: important advisory messages (always display to user).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
 *    1: first level of tracing detail.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
 *    2,3,...: successively more detailed tracing messages.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
 * An application might override this method if it wanted to abort on warnings
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
 * or change the policy about which messages to display.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
METHODDEF(void)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
emit_message (j_common_ptr cinfo, int msg_level)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
  struct jpeg_error_mgr * err = cinfo->err;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
  if (msg_level < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    /* It's a warning message.  Since corrupt files may generate many warnings,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * the policy implemented here is to show only the first warning,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * unless trace_level >= 3.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    if (err->num_warnings == 0 || err->trace_level >= 3)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
      (*err->output_message) (cinfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    /* Always count warnings in num_warnings. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    err->num_warnings++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
  } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    /* It's a trace message.  Show it if trace_level >= msg_level. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    if (err->trace_level >= msg_level)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
      (*err->output_message) (cinfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
 * Format a message string for the most recent JPEG error or message.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
 * The message is stored into buffer, which should be at least JMSG_LENGTH_MAX
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
 * characters.  Note that no '\n' character is added to the string.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
 * Few applications should need to override this method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
METHODDEF(void)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
format_message (j_common_ptr cinfo, char * buffer)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
/* Had to kill this function altogether
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
   to avoid linking to VM when building the splash screen with static libjpeg */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
#ifndef SPLASHSCREEN
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
  int jio_snprintf(char *str, size_t count, const char *fmt, ...);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
  struct jpeg_error_mgr * err = cinfo->err;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
  int msg_code = err->msg_code;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
  const char * msgtext = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
  const char * msgptr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
  char ch;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
  boolean isstring;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
  /* Look up message string in proper table */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
  if (msg_code > 0 && msg_code <= err->last_jpeg_message) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    msgtext = err->jpeg_message_table[msg_code];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
  } else if (err->addon_message_table != NULL &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
             msg_code >= err->first_addon_message &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
             msg_code <= err->last_addon_message) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    msgtext = err->addon_message_table[msg_code - err->first_addon_message];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
  /* Defend against bogus message number */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
  if (msgtext == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    err->msg_parm.i[0] = msg_code;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    msgtext = err->jpeg_message_table[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
  /* Check for string parameter, as indicated by %s in the message text */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
  isstring = FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
  msgptr = msgtext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
  while ((ch = *msgptr++) != '\0') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    if (ch == '%') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
      if (*msgptr == 's') isstring = TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
      break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
  /* Format the message into the passed buffer */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
  if (isstring)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    /* Buffer size is JMSG_LENGTH_MAX, quietly truncate on overflow */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    (void) jio_snprintf(buffer, JMSG_LENGTH_MAX, msgtext, err->msg_parm.s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
  else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    /* Buffer size is JMSG_LENGTH_MAX, quietly truncate on overflow */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    (void) jio_snprintf(buffer, JMSG_LENGTH_MAX, msgtext,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
                        err->msg_parm.i[0], err->msg_parm.i[1],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
                        err->msg_parm.i[2], err->msg_parm.i[3],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
                        err->msg_parm.i[4], err->msg_parm.i[5],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
                        err->msg_parm.i[6], err->msg_parm.i[7]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
#else /* SPLASHSCREEN */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        *buffer = '\0';
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
#endif /* SPLASHSCREEN */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
 * Reset error state variables at start of a new image.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
 * This is called during compression startup to reset trace/error
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
 * processing to default state, without losing any application-specific
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
 * method pointers.  An application might possibly want to override
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
 * this method if it has additional error processing state.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
METHODDEF(void)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
reset_error_mgr (j_common_ptr cinfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
  cinfo->err->num_warnings = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
  /* trace_level is not reset since it is an application-supplied parameter */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
  cinfo->err->msg_code = 0;     /* may be useful as a flag for "no error" */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
 * Fill in the standard error-handling methods in a jpeg_error_mgr object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
 * Typical call is:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
 *      struct jpeg_compress_struct cinfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
 *      struct jpeg_error_mgr err;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
 *      cinfo.err = jpeg_std_error(&err);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
 * after which the application may override some of the methods.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
GLOBAL(struct jpeg_error_mgr *)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
jpeg_std_error (struct jpeg_error_mgr * err)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
  err->error_exit = error_exit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
  err->emit_message = emit_message;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
  err->output_message = output_message;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
  err->format_message = format_message;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
  err->reset_error_mgr = reset_error_mgr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
  err->trace_level = 0;         /* default = no tracing */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
  err->num_warnings = 0;        /* no warnings emitted yet */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
  err->msg_code = 0;            /* may be useful as a flag for "no error" */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
  /* Initialize message table pointers */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
  err->jpeg_message_table = jpeg_std_message_table;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
  err->last_jpeg_message = (int) JMSG_LASTMSGCODE - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
  err->addon_message_table = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
  err->first_addon_message = 0; /* for safety */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
  err->last_addon_message = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
  return err;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
}