summaryrefslogtreecommitdiff
path: root/stream/filt_dctc.h
blob: 8aa6aeb7613dbd5ba82de84debba74c760de5e8b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
 * Extend libjpegs error handler to use setjmp/longjmp
 */

#include <jpeglib.h>

#include <setjmp.h>

struct myerrmgr
{
	struct jpeg_error_mgr super;
	jmp_buf jb;
	char msg[JMSG_LENGTH_MAX];
};

static void myerrexit(j_common_ptr cinfo)
{
	struct myerrmgr *err = (struct myerrmgr *)cinfo->err;
	char msgbuf[JMSG_LENGTH_MAX];
	err->super.format_message(cinfo, msgbuf);
	strlcpy(err->msg, msgbuf, sizeof err->msg);
	longjmp(err->jb, 1);
}

static void myoutmess(j_common_ptr cinfo)
{
	struct myerrmgr *err = (struct myerrmgr *)cinfo->err;
	char msgbuf[JMSG_LENGTH_MAX];
	err->super.format_message(cinfo, msgbuf);
	fprintf(stderr, "ioerror: dct: %s", msgbuf);
}

static void myiniterr(struct myerrmgr *err)
{
	jpeg_std_error(&err->super);
	err->super.error_exit = myerrexit;
	err->super.output_message = myoutmess;
}