+const char *get_libdir(void) { return "."; }
+
+
+enum mode {
+ mf_findwindow= 00001,
+ mf_screenshot= 00010,
+ mf_readscreenshot= 00020,
+ mf_analyse= 00100,
+ mfm_special= 07000,
+
+ mode_findwindow= 00001,
+ mode_screenshot= 00011,
+ mode_analyse= 00120,
+ mode_showcharset= 01000,
+
+ mode_all= 00111,
+};
+
+enum outmodekind {
+ omk_unset, omk_upload, omk_str, omk_raw, omk_none
+};
+static enum outmodekind o_outmode_kind;
+static const char *o_outmode_str= 0;
+
+static enum mode o_mode= mode_all;
+static char *o_screenshot_fn;
+static const char *o_serv_pctb, *o_serv_dict_fetch, *o_serv_dict_submit;
+
+const char *o_resolver= "./dictionary-manager";
+FILE *screenshot_file;
+const char *o_ocean, *o_pirate;
+int o_quiet;
+
+enum flags o_flags=
+ ff_charset_allowedit |
+ ff_dict_fetch|ff_dict_submit|ff_dict_pirate;
+
+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_screenshot_file(const char *mode) {
+ screenshot_file= fopen(o_screenshot_fn, mode);
+ if (!screenshot_file)
+ fatal("could not open screenshots file `%s': %s",
+ o_screenshot_fn, strerror(errno));
+}
+
+static void run_analysis(void) {
+ FILE *tf;
+
+ sysassert( tf= tmpfile() );
+ progress("running recognition...");
+ analyse(tf);
+
+ if (o_flags & ff_upload) {
+ if (npages<=1)
+ fatal("Recognition successful, but refusing to upload partial data\n"
+ " (--single-page specified). Specify an output mode?");
+ }
+
+ sysassert( fseek(tf,0,SEEK_SET) == 0);