summaryrefslogtreecommitdiff
path: root/foomaticrip.c
diff options
context:
space:
mode:
authorDidier Raboud <odyx@debian.org>2011-01-27 15:45:50 +0100
committerDidier Raboud <odyx@debian.org>2011-01-27 15:45:50 +0100
commitd1cf03383a481675a2458d6ffc95bca7f495eff8 (patch)
tree8031752b202ad5a1b26e6560361fc5a12be8b280 /foomaticrip.c
parent1a03de334fd4e6aafb91b806ea35092a7774a8d7 (diff)
Imported Upstream version 4.0.6
Diffstat (limited to 'foomaticrip.c')
-rw-r--r--foomaticrip.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/foomaticrip.c b/foomaticrip.c
index b548b1e..089e4ff 100644
--- a/foomaticrip.c
+++ b/foomaticrip.c
@@ -946,16 +946,22 @@ enum FileType {
int guess_file_type(const char *begin, size_t len, int *startpos)
{
- const char * p;
-
- p = memchr(begin, '%', len);
- if (!p)
- return UNKNOWN_FILE;
- *startpos = p - begin;
- if (!memcmp(p, "%!", 2))
- return PS_FILE;
- else if (!memcmp(p, "%PDF-1.", 7))
- return PDF_FILE;
+ const char * p, * end;
+ p = begin;
+ end = begin + len;
+
+ while (p < end)
+ {
+ p = memchr(p, '%', end - p);
+ if (!p)
+ return UNKNOWN_FILE;
+ *startpos = p - begin;
+ if ((end - p) > 2 && !memcmp(p, "%!", 2))
+ return PS_FILE;
+ else if ((end - p) > 7 && !memcmp(p, "%PDF-1.", 7))
+ return PDF_FILE;
+ ++ p;
+ }
*startpos = 0;
return UNKNOWN_FILE;
}
@@ -1602,7 +1608,8 @@ int main(int argc, char** argv)
PostScript file (all before the first page begins). */
optionset_copy_values(optionset("userval"), optionset("header"));
- print_file(filename, 1);
+ if (!print_file(filename, 1))
+ rip_die(EXIT_PRNERR_NORETRY, "Could not print file %s\n", filename);
filename = strtok_r(NULL, " ", &p);
}
@@ -1639,6 +1646,6 @@ int main(int argc, char** argv)
list_free(arglist);
- return 0;
+ return EXIT_PRINTED;
}