COSMOS core  1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems
jerror.cpp File Reference
#include "jinclude.h"
#include "jpeglib.h"
#include "jversion.h"
#include "jerror.h"
#include <stdlib.h>
Include dependency graph for jerror.cpp:

Macros

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

Functions

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

Variables

const char *const jpeg_std_message_table []
 

Macro Definition Documentation

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

Function Documentation

static void error_exit ( j_common_ptr  cinfo)
static
72 {
73  /* Always display the message */
74  (*cinfo->err->output_message) (cinfo);
75 
76  /* Let the memory manager delete any temp files before we die */
77  jpeg_destroy(cinfo);
78 
79  exit(EXIT_FAILURE);
80 }
void jpeg_destroy(j_common_ptr cinfo)
Definition: jcomapi.cpp:69
#define EXIT_FAILURE
Definition: jerror.cpp:33
void(* output_message)()
Definition: jpeglib.h:654
struct jpeg_error_mgr * err
Definition: jpeglib.h:259
static void output_message ( j_common_ptr  cinfo)
static
100 {
101  char buffer[JMSG_LENGTH_MAX];
102 
103  /* Create the message */
104  (*cinfo->err->format_message) (cinfo, buffer);
105 
106 #ifdef USE_WINDOWS_MESSAGEBOX
107  /* Display it in a message dialog box */
108  MessageBox(GetActiveWindow(), buffer, "JPEG Library Error",
109  MB_OK | MB_ICONERROR);
110 #else
111  /* Send it to stderr, adding a newline */
112  fprintf(stderr, "%s\n", buffer);
113 #endif
114 }
void(* format_message)()
Definition: jpeglib.h:656
#define JMSG_LENGTH_MAX
Definition: jpeglib.h:657
static char buffer[255]
Definition: propagator_simple.cpp:60
struct jpeg_error_mgr * err
Definition: jpeglib.h:259
static void emit_message ( j_common_ptr  cinfo,
int  msg_level 
)
static
130 {
131  struct jpeg_error_mgr * err = cinfo->err;
132 
133  if (msg_level < 0) {
134  /* It's a warning message. Since corrupt files may generate many warnings,
135  * the policy implemented here is to show only the first warning,
136  * unless trace_level >= 3.
137  */
138  if (err->num_warnings == 0 || err->trace_level >= 3)
139  (*err->output_message) (cinfo);
140  /* Always count warnings in num_warnings. */
141  err->num_warnings++;
142  } else {
143  /* It's a trace message. Show it if trace_level >= msg_level. */
144  if (err->trace_level >= msg_level)
145  (*err->output_message) (cinfo);
146  }
147 }
long num_warnings
Definition: jpeglib.h:681
Definition: jpeglib.h:648
void(* output_message)()
Definition: jpeglib.h:654
int trace_level
Definition: jpeglib.h:673
struct jpeg_error_mgr * err
Definition: jpeglib.h:259
string & err
Definition: json11.cpp:362
static void format_message ( j_common_ptr  cinfo,
char *  buffer 
)
static
159 {
160  struct jpeg_error_mgr * err = cinfo->err;
161  int msg_code = err->msg_code;
162  const char * msgtext = NULL;
163  const char * msgptr;
164  char ch;
165  boolean isstring;
166 
167  /* Look up message string in proper table */
168  if (msg_code > 0 && msg_code <= err->last_jpeg_message) {
169  msgtext = err->jpeg_message_table[msg_code];
170  } else if (err->addon_message_table != NULL &&
171  msg_code >= err->first_addon_message &&
172  msg_code <= err->last_addon_message) {
173  msgtext = err->addon_message_table[msg_code - err->first_addon_message];
174  }
175 
176  /* Defend against bogus message number */
177  if (msgtext == NULL) {
178  err->msg_parm.i[0] = msg_code;
179  msgtext = err->jpeg_message_table[0];
180  }
181 
182  /* Check for string parameter, as indicated by %s in the message text */
183  isstring = FALSE;
184  msgptr = msgtext;
185  while ((ch = *msgptr++) != '\0') {
186  if (ch == '%') {
187  if (*msgptr == 's') isstring = TRUE;
188  break;
189  }
190  }
191 
192  /* Format the message into the passed buffer */
193  if (isstring)
194  sprintf(buffer, msgtext, err->msg_parm.s);
195  else
196  sprintf(buffer, msgtext,
197  err->msg_parm.i[0], err->msg_parm.i[1],
198  err->msg_parm.i[2], err->msg_parm.i[3],
199  err->msg_parm.i[4], err->msg_parm.i[5],
200  err->msg_parm.i[6], err->msg_parm.i[7]);
201 }
union jpeg_error_mgr::@44 msg_parm
int last_jpeg_message
Definition: jpeglib.h:694
int last_addon_message
Definition: jpeglib.h:700
const char *const * addon_message_table
Definition: jpeglib.h:698
Definition: jpeglib.h:648
int msg_code
Definition: jpeglib.h:664
#define FALSE
Definition: jpleph.cpp:69
char s[80]
Definition: jpeglib.h:668
static char buffer[255]
Definition: propagator_simple.cpp:60
struct jpeg_error_mgr * err
Definition: jpeglib.h:259
int first_addon_message
Definition: jpeglib.h:699
#define TRUE
Definition: jpleph.cpp:68
string & err
Definition: json11.cpp:362
int i[8]
Definition: jpeglib.h:667
const char *const * jpeg_message_table
Definition: jpeglib.h:693
static void reset_error_mgr ( j_common_ptr  cinfo)
static
214 {
215  cinfo->err->num_warnings = 0;
216  /* trace_level is not reset since it is an application-supplied parameter */
217  cinfo->err->msg_code = 0; /* may be useful as a flag for "no error" */
218 }
long num_warnings
Definition: jpeglib.h:681
int msg_code
Definition: jpeglib.h:664
struct jpeg_error_mgr * err
Definition: jpeglib.h:259
struct jpeg_error_mgr* jpeg_std_error ( struct jpeg_error_mgr err)
233 {
234  err->error_exit = error_exit;
235  err->emit_message = emit_message;
239 
240  err->trace_level = 0; /* default = no tracing */
241  err->num_warnings = 0; /* no warnings emitted yet */
242  err->msg_code = 0; /* may be useful as a flag for "no error" */
243 
244  /* Initialize message table pointers */
246  err->last_jpeg_message = (int) JMSG_LASTMSGCODE - 1;
247 
248  err->addon_message_table = NULL;
249  err->first_addon_message = 0; /* for safety */
250  err->last_addon_message = 0;
251 
252  return err;
253 }
static void emit_message(j_common_ptr cinfo, int msg_level)
Definition: jerror.cpp:129
long num_warnings
Definition: jpeglib.h:681
int last_jpeg_message
Definition: jpeglib.h:694
int last_addon_message
Definition: jpeglib.h:700
static void format_message(j_common_ptr cinfo, char *buffer)
Definition: jerror.cpp:158
Definition: jerror.h:188
const char *const * addon_message_table
Definition: jpeglib.h:698
const char *const jpeg_std_message_table[]
Definition: jerror.cpp:51
void(* format_message)()
Definition: jpeglib.h:656
void(* output_message)()
Definition: jpeglib.h:654
int msg_code
Definition: jpeglib.h:664
int trace_level
Definition: jpeglib.h:673
int first_addon_message
Definition: jpeglib.h:699
void(* reset_error_mgr)()
Definition: jpeglib.h:659
string & err
Definition: json11.cpp:362
static void reset_error_mgr(j_common_ptr cinfo)
Definition: jerror.cpp:213
static void output_message(j_common_ptr cinfo)
Definition: jerror.cpp:99
void(* emit_message)()
Definition: jpeglib.h:652
const char *const * jpeg_message_table
Definition: jpeglib.h:693
void(* error_exit)()
Definition: jpeglib.h:650
static void error_exit(j_common_ptr cinfo)
Definition: jerror.cpp:71

Variable Documentation

const char* const jpeg_std_message_table[]