+
+static void vbadusage(const char *fmt, va_list) FMT(1,0) NORET;
+static void vbadusage(const char *fmt, va_list al) {
+ fputs("bad usage: ",stderr);
+ vfprintf(stderr,fmt,al);
+ fputc('\n',stderr);
+ exit(12);
+}
+DEFINE_VWRAPPERF(static, badusage, NORET);
+
+static void open_screenshots_file(const char *mode) {
+ screenshots_file= fopen(o_screenshots_fn, mode);
+ if (!screenshots_file)
+ fatal("could not open screenshots file `%s': %s",
+ o_screenshots_fn, strerror(errno));
+}
+
+static void run_analysis(void) {
+ FILE *tf;
+
+ sysassert( tf= tmpfile() );
+ progress("running recognition...");
+ analyse(tf);
+
+ sysassert( fseek(tf,0,SEEK_SET) == 0);
+
+ progress_log("processing results (--%s)...", o_outputmode);
+ pid_t processor;
+ sysassert( (processor= fork()) != -1 );
+
+ if (!processor) {
+ sysassert( dup2(fileno(tf),0) ==0 );
+ execlp("./yppsc-commod-processor", "yppsc-commod-processor",
+ o_outputmode, (char*)0);
+ sysassert(!"execlp commod-processor failed");
+ }
+
+ waitpid_check_exitstatus(processor, "output processor/uploader");
+ fclose(tf);
+ progress_log("all complete.");
+}
+