--- xv-3.10a/xvjp2k.c.orig 2007-05-14 03:04:37.000000000 +0200 +++ xv-3.10a/xvjp2k.c 2023-03-25 17:00:59.872321637 +0100 @@ -68,53 +68,29 @@ static const char *fbasename, /* File's read_err[] = "%s: I/O error reading %s file", bad_dims[] = "%s: error in JPEG-2000 header (bad image size)"; -/* We only want to override the JasPer Library's "jas_eprintf()" subroutine in - order to make it a "wrapper" around XV's own error-reporting subroutine, but - because of the way the former is currently packaged in JasPer Library Version - 1.701, we must override everything else packaged in the "jas_debug.o" module - with it, otherwise we get "duplicate definition" messages from the linker. -*/ -int jas_getdbglevel(void) {return 0;} -int jas_setdbglevel(int n) {return 0;} -int jas_memdump(FILE *fp,void *data,size_t len) {return 0;} - -int jas_eprintf(const char *fmt,...) /* Handle JasPer Library message */ +int jasper_vlogmsgf(jas_logtype_t logtype, const char *fmt,...) /* Handle JasPer Library message */ { - static char error[] = "error: ", warning[]= "warning: "; va_list ap; int kind = ISTR_WARNING; char buffer[512]; register char *p; - /* Unlike the IJG JPEG Library, the JasPer Library current has no graceful way - for an application (= us!) to intercept its diagnostic messages and output - them using our own subroutines, so this ugly replacement for its output - subroutine will have to suffice. At Version 1.701, lthough the library's - own "jas_eprintf()" is a varargs subroutine, all calls currently pass just - 1 string with a Line Feed at the end and no "printf(3C)" arguments. Most - strings begin with "error: " or "warning: ", although a few have neither. - We try to translate these into the format preferred by XV, trimming any - trailing Line Feed character (ugh!). - */ va_start(ap, fmt); vsnprintf(p = buffer,512,fmt,ap); va_end(ap); while (*p++); if (p[-2] == '\n') p[-2] = '\0'; p = buffer; - if (strncmp(p,error,sizeof error) == 0) /* "error: ... " */ + if (jas_logtype_getclass(logtype) == JAS_LOGTYPE_CLASS_ERROR) { kind = ISTR_WARNING; - p += sizeof error; } - else /* "warning: ... " */ - if (strncmp(p,warning,sizeof warning) == 0) + else { kind = ISTR_INFO; - p += sizeof warning; }; SetISTR(kind,"%s: %s",fbasename,p); - return strlen(fmt); + return 0; } static char *SetBuf(FILE *f) @@ -185,7 +185,7 @@ int LoadJPC(char *fname,register PICINFO So, mark the stream buffer proactively: */ str->bufmode_ |= JAS_STREAM_RDBUF; /* We will only read the stream buffer */ - if (!(img = jpc_decode(str,0))) goto L2; + if (!(img = jas_image_decode(str,jas_image_strtofmt("jpc"), 0))) goto L2; if ((vstride = jas_image_numcmpts(img))) /* num. color planes */ { @@ -375,7 +375,7 @@ int LoadJP2(char *fname,register PICINFO So, mark the stream buffer proactively: */ str->bufmode_ |= JAS_STREAM_RDBUF; /* We will only read the stream buffer */ - if (!(img = jp2_decode(str,0))) goto L2; + if (!(img = jas_image_decode(str,jas_image_strtofmt("jp2"), 0))) goto L2; if ((vstride = jas_image_numcmpts(img))) /* num. color planes */ { @@ -674,6 +650,8 @@ void CreateJP2KW(void) }; static const char hstr[]={"Height"}, wstr[]={"Width"}; + jas_conf_set_vlogmsgf(jasper_vlogmsgf); + if (!(jp2kW = CreateWindow( "xvjp2k" , "XVjp2k" , 0 @@ -948,7 +948,7 @@ static void StoreJP2K(char *options) } while (++i <= 2); }; - if ( (*(format == F_JPC ? jpc_encode : jp2_encode))(img,str,options) >= 0 + if (jas_image_encode(img,str,(format == F_JPC) ? "jpc" : "jp2",options) >= 0 && jas_stream_flush(str) >= 0 ) error = 0; /* Success! */ L1: jas_image_destroy(img);