ReactOS 0.4.16-dev-303-g11d5cb8
jerror.c File Reference
#include "jinclude.h"
#include "jpeglib.h"
#include "jversion.h"
#include "jerror.h"
Include dependency graph for jerror.c:

Go to the source code of this file.

Macros

#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 []
 

Macro Definition Documentation

◆ EXIT_FAILURE

#define EXIT_FAILURE   1

Definition at line 33 of file jerror.c.

◆ JMESSAGE

#define JMESSAGE (   code,
  string 
)    string ,

Definition at line 49 of file jerror.c.

Function Documentation

◆ emit_message()

emit_message ( j_common_ptr  cinfo,
int  msg_level 
)

Definition at line 129 of file jerror.c.

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}
#define err(...)

Referenced by jpeg_std_error().

◆ error_exit()

error_exit ( j_common_ptr  cinfo)

Definition at line 71 of file jerror.c.

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
80}
jpeg_destroy(j_common_ptr cinfo)
Definition: jcomapi.c:70
#define EXIT_FAILURE
Definition: jerror.c:33
#define exit(n)
Definition: config.h:202

Referenced by jpeg_std_error().

◆ format_message()

format_message ( j_common_ptr  cinfo,
char buffer 
)

Definition at line 158 of file jerror.c.

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}
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
GLuint buffer
Definition: glext.h:5915
#define sprintf(buf, format,...)
Definition: sprintf.c:55
int last_jpeg_message
Definition: jpeglib.h:748
int last_addon_message
Definition: jpeglib.h:754

Referenced by BtrfsSend::AddClone(), BtrfsSend::BrowseParent(), BtrfsRecv::cmd_chmod(), BtrfsRecv::cmd_chown(), BtrfsRecv::cmd_clone(), BtrfsRecv::cmd_link(), BtrfsRecv::cmd_mkfile(), BtrfsRecv::cmd_removexattr(), BtrfsRecv::cmd_rename(), BtrfsRecv::cmd_rmdir(), BtrfsRecv::cmd_setxattr(), BtrfsRecv::cmd_snapshot(), BtrfsRecv::cmd_subvol(), BtrfsRecv::cmd_truncate(), BtrfsRecv::cmd_unlink(), BtrfsRecv::cmd_utimes(), BtrfsRecv::cmd_write(), BtrfsRecv::do_recv(), jpeg_std_error(), BtrfsRecv::recv_thread(), BtrfsRecv::RecvProgressDlgProc(), and BtrfsSend::Thread().

◆ jpeg_std_error()

jpeg_std_error ( struct jpeg_error_mgr err)

Definition at line 232 of file jerror.c.

233{
234 err->error_exit = error_exit;
235 err->emit_message = emit_message;
236 err->output_message = output_message;
237 err->format_message = format_message;
238 err->reset_error_mgr = reset_error_mgr;
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 */
245 err->jpeg_message_table = jpeg_std_message_table;
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}
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
emit_message(j_common_ptr cinfo, int msg_level)
Definition: jerror.c:129
format_message(j_common_ptr cinfo, char *buffer)
Definition: jerror.c:158
error_exit(j_common_ptr cinfo)
Definition: jerror.c:71
output_message(j_common_ptr cinfo)
Definition: jerror.c:99
reset_error_mgr(j_common_ptr cinfo)
Definition: jerror.c:213
const char *const jpeg_std_message_table[]
Definition: jerror.c:51

Referenced by main(), read_JPEG_file(), and write_JPEG_file().

◆ output_message()

output_message ( j_common_ptr  cinfo)

Definition at line 99 of file jerror.c.

100{
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",
110#else
111 /* Send it to stderr, adding a newline */
112 fprintf(stderr, "%s\n", buffer);
113#endif
114}
#define stderr
Definition: stdio.h:100
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
#define JMSG_LENGTH_MAX
Definition: jpeglib.h:711
HWND WINAPI GetActiveWindow(void)
Definition: winpos.c:138
#define MB_ICONERROR
Definition: winuser.h:790
#define MB_OK
Definition: winuser.h:793
#define MessageBox
Definition: winuser.h:5834

Referenced by jpeg_std_error().

◆ reset_error_mgr()

reset_error_mgr ( j_common_ptr  cinfo)

Definition at line 213 of file jerror.c.

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}

Referenced by jpeg_std_error().

Variable Documentation

◆ jpeg_std_message_table

const char* const jpeg_std_message_table[]
Initial value:
= {
}

Definition at line 51 of file jerror.c.

Referenced by jpeg_std_error().