2 * PaperJam -- Main program
4 * (c) 2018 Martin Mares <mj@ucw.cz>
25 void debug(const char *msg, ...)
31 fprintf(stderr, "%*s", debug_indent, "");
32 vfprintf(stderr, msg, args);
37 void warn(const char *msg, ...)
41 fprintf(stderr, "Warning: ");
42 vfprintf(stderr, msg, args);
47 void die(const char *msg, ...)
51 vfprintf(stderr, msg, args);
57 void err(const char *msg, ...)
62 vsnprintf(buf, sizeof(buf), msg, args);
64 throw paperjam_error(buf);
74 static const struct option long_opts[] = {
75 { "debug", 0, 0, 'd' },
76 { "help", 0, 0, OPT_HELP },
77 { "version", 0, 0, OPT_VERSION },
78 { "bbox", 0, 0, 'b' },
82 static const char short_opts[] = "bd";
86 printf("Usage: paperjam [<options>] <commands> <in> <out>\n\
89 -b, --bbox Recalculate bounding boxes\n\
90 -d, --debug Show debugging messages\n\
92 <command> = <name>(<args>, <named-arg>[=<value>], ...) [<pipeline>]\n\
93 <pipeline> = { <stage>, <stage>, ... }\n\
94 <stage> = <page> <page> ... [: <commands>]\n\
101 static void show_version()
103 printf("PaperJam " VERSION " -- a PDF processor\n");
104 printf("(c) " YEAR " Martin Mares, distributed under GNU GPL 2+\n");
105 printf("Built on " BUILD_DATE " from Git commit " BUILD_COMMIT "\n");
108 int main(int argc, char **argv)
111 while ((c = getopt_long(argc, argv, short_opts, long_opts, NULL)) >= 0)
130 if (optind + 3 != argc)
131 die("Exactly three positional parameters should be given");
134 parse(argv[optind], cmds);
135 in_name = argv[optind+1];
136 out_name = argv[optind+2];