Back to index

plt-scheme  4.2.1
Defines | Functions | Variables
jerror.c File Reference
#include "jinclude.h"
#include "jpeglib.h"
#include "jversion.h"
#include "jerror.h"

Go to the source code of this file.

Defines

#define EXIT_FAILURE   1
#define JMESSAGE(code, string)   string ,

Functions

 error_exit (j_common_ptr cinfo)
 output_message (j_common_ptr cinfo)
 emit_message (j_common_ptr cinfo, int msg_level)
 format_message (j_common_ptr cinfo, char *buffer)
 reset_error_mgr (j_common_ptr cinfo)
 jpeg_std_error (struct jpeg_error_mgr *err)

Variables

const char *const jpeg_std_message_table []

Define Documentation

#define EXIT_FAILURE   1

Definition at line 32 of file jerror.c.

#define JMESSAGE (   code,
  string 
)    string ,

Definition at line 48 of file jerror.c.


Function Documentation

emit_message ( j_common_ptr  cinfo,
int  msg_level 
)

Definition at line 128 of file jerror.c.

{
  struct jpeg_error_mgr * err = cinfo->err;

  if (msg_level < 0) {
    /* It's a warning message.  Since corrupt files may generate many warnings,
     * the policy implemented here is to show only the first warning,
     * unless trace_level >= 3.
     */
    if (err->num_warnings == 0 || err->trace_level >= 3)
      (*err->output_message) (cinfo);
    /* Always count warnings in num_warnings. */
    err->num_warnings++;
  } else {
    /* It's a trace message.  Show it if trace_level >= msg_level. */
    if (err->trace_level >= msg_level)
      (*err->output_message) (cinfo);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 70 of file jerror.c.

{
  /* Always display the message */
  (*cinfo->err->output_message) (cinfo);

  /* Let the memory manager delete any temp files before we die */
  jpeg_destroy(cinfo);

  exit(EXIT_FAILURE);
}

Here is the call graph for this function:

Here is the caller graph for this function:

format_message ( j_common_ptr  cinfo,
char *  buffer 
)

Definition at line 157 of file jerror.c.

{
  struct jpeg_error_mgr * err = cinfo->err;
  int msg_code = err->msg_code;
  const char * msgtext = NULL;
  const char * msgptr;
  char ch;
  boolean isstring;

  /* Look up message string in proper table */
  if (msg_code > 0 && msg_code <= err->last_jpeg_message) {
    msgtext = err->jpeg_message_table[msg_code];
  } else if (err->addon_message_table != NULL &&
            msg_code >= err->first_addon_message &&
            msg_code <= err->last_addon_message) {
    msgtext = err->addon_message_table[msg_code - err->first_addon_message];
  }

  /* Defend against bogus message number */
  if (msgtext == NULL) {
    err->msg_parm.i[0] = msg_code;
    msgtext = err->jpeg_message_table[0];
  }

  /* Check for string parameter, as indicated by %s in the message text */
  isstring = FALSE;
  msgptr = msgtext;
  while ((ch = *msgptr++) != '\0') {
    if (ch == '%') {
      if (*msgptr == 's') isstring = TRUE;
      break;
    }
  }

  /* Format the message into the passed buffer */
  if (isstring)
    sprintf(buffer, msgtext, err->msg_parm.s);
  else
    sprintf(buffer, msgtext,
           err->msg_parm.i[0], err->msg_parm.i[1],
           err->msg_parm.i[2], err->msg_parm.i[3],
           err->msg_parm.i[4], err->msg_parm.i[5],
           err->msg_parm.i[6], err->msg_parm.i[7]);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 231 of file jerror.c.

{
  err->error_exit = error_exit;
  err->emit_message = emit_message;
  err->output_message = output_message;
  err->format_message = format_message;
  err->reset_error_mgr = reset_error_mgr;

  err->trace_level = 0;            /* default = no tracing */
  err->num_warnings = 0;    /* no warnings emitted yet */
  err->msg_code = 0;        /* may be useful as a flag for "no error" */

  /* Initialize message table pointers */
  err->jpeg_message_table = jpeg_std_message_table;
  err->last_jpeg_message = (int) JMSG_LASTMSGCODE - 1;

  err->addon_message_table = NULL;
  err->first_addon_message = 0;    /* for safety */
  err->last_addon_message = 0;

  return err;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 98 of file jerror.c.

{
  char buffer[JMSG_LENGTH_MAX];

  /* 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
}

Here is the caller graph for this function:

Definition at line 212 of file jerror.c.

{
  cinfo->err->num_warnings = 0;
  /* trace_level is not reset since it is an application-supplied parameter */
  cinfo->err->msg_code = 0; /* may be useful as a flag for "no error" */
}

Here is the caller graph for this function:


Variable Documentation

Definition at line 50 of file jerror.c.