summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Rasmussen <sebras@gmail.com>2012-08-06 01:09:05 +0200
committerSebastian Rasmussen <sebras@gmail.com>2012-08-06 14:07:46 +0200
commit0db354a6cffc42d1d0ade2b434504b66ec8efba4 (patch)
tree4634768d5315929227265c6a63f7b140bd134c57
parent7170e67ed5636f2eaf74ea723e29b3d8c2b06467 (diff)
downloadmupdf-0db354a6cffc42d1d0ade2b434504b66ec8efba4.tar.xz
Add option to mudraw to process further files upon error
-rw-r--r--apps/mudraw.c71
1 files changed, 43 insertions, 28 deletions
diff --git a/apps/mudraw.c b/apps/mudraw.c
index 0f11a7a1..07b9e1c3 100644
--- a/apps/mudraw.c
+++ b/apps/mudraw.c
@@ -31,6 +31,7 @@ static int width = 0;
static int height = 0;
static int fit = 0;
static int errored = 0;
+static int ignore_errors = 0;
static fz_text_sheet *sheet = NULL;
static fz_colorspace *colorspace;
@@ -68,6 +69,7 @@ static void usage(void)
"\t-G gamma\tgamma correct output\n"
"\t-I\tinvert output\n"
"\t-l\tprint outline\n"
+ "\t-i\tignore errors and continue with the next file\n"
"\tpages\tcomma separated list of ranges\n");
exit(1);
}
@@ -447,7 +449,7 @@ int main(int argc, char **argv)
fz_var(doc);
- while ((c = fz_getopt(argc, argv, "lo:p:r:R:ab:dgmtx5G:Iw:h:f")) != -1)
+ while ((c = fz_getopt(argc, argv, "lo:p:r:R:ab:dgmtx5G:Iw:h:fi")) != -1)
{
switch (c)
{
@@ -469,6 +471,7 @@ int main(int argc, char **argv)
case 'h': height = atof(fz_optarg); break;
case 'f': fit = 1; break;
case 'I': invert++; break;
+ case 'i': ignore_errors = 1; break;
default: usage(); break;
}
}
@@ -531,41 +534,53 @@ int main(int argc, char **argv)
{
while (fz_optind < argc)
{
- filename = argv[fz_optind++];
- files++;
-
fz_try(ctx)
{
- doc = fz_open_document(ctx, filename);
- }
- fz_catch(ctx)
- {
- fz_throw(ctx, "cannot open document: %s", filename);
- }
+ filename = argv[fz_optind++];
+ files++;
- if (fz_needs_password(doc))
- if (!fz_authenticate_password(doc, password))
- fz_throw(ctx, "cannot authenticate password: %s", filename);
+ fz_try(ctx)
+ {
+ doc = fz_open_document(ctx, filename);
+ }
+ fz_catch(ctx)
+ {
+ fz_throw(ctx, "cannot open document: %s", filename);
+ }
- if (showxml || showtext == TEXT_XML)
- printf("<document name=\"%s\">\n", filename);
+ if (fz_needs_password(doc))
+ if (!fz_authenticate_password(doc, password))
+ fz_throw(ctx, "cannot authenticate password: %s", filename);
- if (showoutline)
- drawoutline(ctx, doc);
+ if (showxml || showtext == TEXT_XML)
+ printf("<document name=\"%s\">\n", filename);
- if (showtext || showxml || showtime || showmd5 || output)
- {
- if (fz_optind == argc || !isrange(argv[fz_optind]))
- drawrange(ctx, doc, "1-");
- if (fz_optind < argc && isrange(argv[fz_optind]))
- drawrange(ctx, doc, argv[fz_optind++]);
- }
+ if (showoutline)
+ drawoutline(ctx, doc);
+
+ if (showtext || showxml || showtime || showmd5 || output)
+ {
+ if (fz_optind == argc || !isrange(argv[fz_optind]))
+ drawrange(ctx, doc, "1-");
+ if (fz_optind < argc && isrange(argv[fz_optind]))
+ drawrange(ctx, doc, argv[fz_optind++]);
+ }
+
+ if (showxml || showtext == TEXT_XML)
+ printf("</document>\n");
- if (showxml || showtext == TEXT_XML)
- printf("</document>\n");
+ fz_close_document(doc);
+ doc = NULL;
+ }
+ fz_catch(ctx)
+ {
+ if (!ignore_errors)
+ fz_rethrow(ctx);
- fz_close_document(doc);
- doc = NULL;
+ fz_close_document(doc);
+ doc = NULL;
+ fz_warn(ctx, "ignoring error in '%s'", filename);
+ }
}
}
fz_catch(ctx)