summaryrefslogtreecommitdiff
path: root/gs/jasper
diff options
context:
space:
mode:
authorRalph Giles <ralph.giles@artifex.com>2006-09-28 05:56:04 +0000
committerRalph Giles <ralph.giles@artifex.com>2006-09-28 05:56:04 +0000
commit9bfb41f53cbb4f420d5b81a39981c8f42e7b316a (patch)
tree8d79b8eca5b215c8c6961817ad8b5169394d9325 /gs/jasper
parentd6ea7ec04fa38d7e99f5aba10c2496cdf9a99b19 (diff)
Add an error callback to the example jasper applications. Previously they
always failed (or succeeded) silently. DETAILS: The fprintf() calls were replaced with jas_eprintf() in this code along with everywhere else, but no actual callback was installed, so the applications weren't able to give any feedback at all. So we now provide a simple callback that just passes the message on to stderr as is appropriate for a library client. git-svn-id: http://svn.ghostscript.com/ghostscript/trunk@7073 a1074d23-0009-0410-80fe-cf8c14f379e6
Diffstat (limited to 'gs/jasper')
-rw-r--r--gs/jasper/src/appl/imgcmp.c21
-rw-r--r--gs/jasper/src/appl/imginfo.c13
-rw-r--r--gs/jasper/src/appl/jasper.c12
-rw-r--r--gs/jasper/src/appl/jasper_sdl.c15
-rw-r--r--gs/jasper/src/appl/jiv.c11
5 files changed, 61 insertions, 11 deletions
diff --git a/gs/jasper/src/appl/imgcmp.c b/gs/jasper/src/appl/imgcmp.c
index dc3b58714..2acc4dd2f 100644
--- a/gs/jasper/src/appl/imgcmp.c
+++ b/gs/jasper/src/appl/imgcmp.c
@@ -62,7 +62,7 @@
/*
* Image Comparison Program
*
- * $Id$
+ * $Id: $
*/
/******************************************************************************\
@@ -113,8 +113,9 @@ double pae(jas_matrix_t *x, jas_matrix_t *y);
double msen(jas_matrix_t *x, jas_matrix_t *y, int n);
double psnr(jas_matrix_t *x, jas_matrix_t *y, int depth);
jas_image_t *makediffimage(jas_matrix_t *origdata, jas_matrix_t *recondata);
-void usage(void);
-void cmdinfo(void);
+static void usage(void);
+static void cmdinfo(void);
+static void errprint(jas_error_t err, char *msg);
/******************************************************************************\
*
@@ -189,9 +190,13 @@ int main(int argc, char **argv)
minonly = 0;
if (jas_init()) {
+ errprint(0, "error: cannot initialize jasper library\n");
abort();
}
+ /* set our error callback */
+ jas_set_error_cb(errprint);
+
cmdname = argv[0];
/* Parse the command line options. */
@@ -546,7 +551,7 @@ jas_image_t *makediffimage(jas_matrix_t *origdata, jas_matrix_t *recondata)
*
\******************************************************************************/
-void cmdinfo()
+static void cmdinfo()
{
jas_eprintf("Image Comparison Utility (Version %s).\n",
JAS_VERSION);
@@ -556,7 +561,7 @@ void cmdinfo()
);
}
-void usage()
+static void usage()
{
cmdinfo();
jas_eprintf("usage:\n");
@@ -575,3 +580,9 @@ void usage()
);
exit(EXIT_FAILURE);
}
+
+static void errprint(jas_error_t err, char *msg)
+{
+ fprintf(stderr, "%s", msg);
+}
+
diff --git a/gs/jasper/src/appl/imginfo.c b/gs/jasper/src/appl/imginfo.c
index 6dd4fb972..25b151d7b 100644
--- a/gs/jasper/src/appl/imginfo.c
+++ b/gs/jasper/src/appl/imginfo.c
@@ -62,7 +62,7 @@
/*
* Image Information Program
*
- * $Id$
+ * $Id: $
*/
/******************************************************************************\
@@ -94,6 +94,7 @@ typedef enum {
static void usage(void);
static void cmdinfo(void);
+static void errprint(jas_error_t err, char *msg);
/******************************************************************************\
*
@@ -128,9 +129,13 @@ int main(int argc, char **argv)
char *fmtname;
if (jas_init()) {
+ errprint(0, "error: cannot initialize jasper library\n");
abort();
}
+ /* set our error callback */
+ jas_set_error_cb(errprint);
+
cmdname = argv[0];
infile = 0;
@@ -221,3 +226,9 @@ static void usage()
jas_eprintf("[-f image_file]\n");
exit(EXIT_FAILURE);
}
+
+static void errprint(jas_error_t err, char *msg)
+{
+ fprintf(stderr, "%s", msg);
+}
+
diff --git a/gs/jasper/src/appl/jasper.c b/gs/jasper/src/appl/jasper.c
index b8286bf7d..1c1038d60 100644
--- a/gs/jasper/src/appl/jasper.c
+++ b/gs/jasper/src/appl/jasper.c
@@ -64,7 +64,7 @@
/*
* JasPer Transcoder Program
*
- * $Id$
+ * $Id: $
*/
/******************************************************************************\
@@ -132,6 +132,7 @@ void cmdusage(void);
void badusage(void);
void cmdinfo(void);
int addopt(char *optstr, int maxlen, char *s);
+void errprint(jas_error_t err, char *msg);
/******************************************************************************\
* Global data.
@@ -164,9 +165,13 @@ int main(int argc, char **argv)
}
if (jas_init()) {
+ errprint(0, "error: cannot initialize jasper library\n");
abort();
}
+ /* set our error callback */
+ jas_set_error_cb(errprint);
+
/* Parse the command line options. */
if (!(cmdopts = cmdopts_parse(argc, argv))) {
jas_eprintf("error: cannot parse command line\n");
@@ -525,6 +530,11 @@ void badusage()
exit(EXIT_FAILURE);
}
+void errprint(jas_error_t err, char *msg)
+{
+ fprintf(stderr, "%s", msg);
+}
+
#if 0
jas_image_t *converttosrgb(jas_image_t *inimage)
{
diff --git a/gs/jasper/src/appl/jasper_sdl.c b/gs/jasper/src/appl/jasper_sdl.c
index 9dfc38ae3..bf7682688 100644
--- a/gs/jasper/src/appl/jasper_sdl.c
+++ b/gs/jasper/src/appl/jasper_sdl.c
@@ -23,8 +23,8 @@ int dump_jas_image(jas_image_t *image);
int copy_jas_image(jas_image_t * image, SDL_Surface * window);
int display_jas_image(jas_image_t * image);
-void wait_close(void);
-
+static void wait_close(void);
+static void errprint(jas_error_t err, char *msg);
/** implementation **/
@@ -141,7 +141,7 @@ int copy_jas_image(jas_image_t * image, SDL_Surface * window)
return 0;
}
-void wait_close(void)
+static void wait_close(void)
{
SDL_Event event;
@@ -226,9 +226,10 @@ int main(int argc, char *argv[])
int i;
if (jas_init()) {
- jas_eprintf("error: unable to initialize jasper library\n");
+ errprint(0, "error: unable to initialize jasper library\n");
exit(1);
}
+ jas_set_error_cb(errprint);
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
jas_eprintf("error: unable to initialize SDL: %s\n", SDL_GetError());
exit(2);
@@ -243,3 +244,9 @@ int main(int argc, char *argv[])
return 0;
}
+
+static void errprint(jas_error_t err, char *msg)
+{
+ fprintf(stderr, "%s", msg);
+}
+
diff --git a/gs/jasper/src/appl/jiv.c b/gs/jasper/src/appl/jiv.c
index bde17c311..37ee0ac0f 100644
--- a/gs/jasper/src/appl/jiv.c
+++ b/gs/jasper/src/appl/jiv.c
@@ -180,6 +180,7 @@ static void cmdinfo(void);
static void cleanupandexit(int);
static void init(void);
+static void errprint(jas_error_t err, char *msg);
/******************************************************************************\
*
@@ -219,9 +220,13 @@ int main(int argc, char **argv)
/* Initialize the JasPer library. */
if (jas_init()) {
+ errprint(0, "error: cannot initialize jasper library\n");
abort();
}
+ /* set our error callback */
+ jas_set_error_cb(errprint);
+
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGBA | GLUT_SINGLE);
glutCreateWindow(cmdname);
@@ -1044,3 +1049,9 @@ static void init()
gs.vp.data = 0;
gs.dirty = 1;
}
+
+static void errprint(jas_error_t err, char *msg)
+{
+ fprintf(stderr, "%s", msg);
+}
+