jbig2dec
Ralph Giles <[email protected]> Tue, 16 Jul 2002 14:19:11 -0700
| Newsgroups | gmane.comp.printing.ghostscript.jbig2dec.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/jbig2dec/jbig2dec
In directory usw-pr-cvs1:/tmp/cvs-serv20986
Modified Files:
jbig2dec.c
Log Message:
implement --quiet and --verbose. Verbosity now defaults to '1', which
only warnings and fatal errors. -v recovers the old behavior. intermediate
levels can be set with --verbose=n. -q/--quiet is the same as --verbose=0;
it should supress all messages.
Index: jbig2dec.c
===================================================================
RCS file: /cvsroot/jbig2dec/jbig2dec/jbig2dec.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- jbig2dec.c 15 Jul 2002 23:50:47 -0000 1.33
+++ jbig2dec.c 16 Jul 2002 21:19:09 -0000 1.34
@@ -113,9 +113,10 @@
parse_options(int argc, char *argv[], jbig2dec_params_t *params)
{
static struct option long_options[] = {
- {"quiet", 0, NULL, 'q'},
{"version", 0, NULL, 'V'},
{"help", 0, NULL, 'h'},
+ {"quiet", 0, NULL, 'q'},
+ {"verbose", 2, NULL, 'v'},
{"dump", 0, NULL, 'd'},
{"hash", 0, NULL, 'm'},
{"output", 1, NULL, 'o'},
@@ -126,7 +127,7 @@
while (1) {
option = getopt_long(argc, argv,
- "qVh?do:", long_options, &option_idx);
+ "Vh?qvdo:", long_options, &option_idx);
if (option == -1) break;
//fprintf(stderr, "option '%c' value '%s'\n", option, optarg);
@@ -139,6 +140,10 @@
case 'q':
params->verbose = 0;
break;
+ case 'v':
+ if (optarg) params->verbose = atoi(optarg);
+ else params->verbose = 9;
+ break;
case 'h':
case '?':
params->mode = usage;
@@ -190,6 +195,7 @@
" available options:\n"
" -h --help this usage summary\n"
" -q --quiet suppress diagnostic output\n"
+ " -v --verbose set the verbosity level\n"
" -d --dump print the structure of the jbig2 file\n"
" rather than explicitly decoding\n"
" --version program name and version information\n"
@@ -207,13 +213,20 @@
error_callback(void *error_callback_data, const char *buf, Jbig2Severity severity,
int32_t seg_idx)
{
+ jbig2dec_params_t *params = error_callback_data;
char *type;
char segment[22];
switch (severity) {
- case JBIG2_SEVERITY_DEBUG: type = "DEBUG"; break;;
- case JBIG2_SEVERITY_INFO: type = "info"; break;;
- case JBIG2_SEVERITY_WARNING: type = "WARNING"; break;;
+ case JBIG2_SEVERITY_DEBUG:
+ if (params->verbose < 3) return 0;
+ type = "DEBUG"; break;;
+ case JBIG2_SEVERITY_INFO:
+ if (params->verbose < 2) return 0;
+ type = "info"; break;;
+ case JBIG2_SEVERITY_WARNING:
+ if (params->verbose < 1) return 0;
+ type = "WARNING"; break;;
case JBIG2_SEVERITY_FATAL: type = "FATAL ERROR"; break;;
default: type = "unknown message"; break;;
}
@@ -289,7 +302,8 @@
}
else
{
- fprintf(stderr, "saving decoded page as '%s'\n", params->output_file);
+ if (params->verbose > 1)
+ fprintf(stderr, "saving decoded page as '%s'\n", params->output_file);
#ifdef HAVE_LIBPNG
jbig2_image_write_png_file(image, params->output_file);
#else
@@ -385,7 +399,7 @@
ctx = jbig2_ctx_new(NULL, f_page != NULL ? JBIG2_OPTIONS_EMBEDDED : 0,
NULL,
- error_callback, NULL);
+ error_callback, ¶ms);
// pull the whole file/global stream into memory
for (;;)