chiark / gitweb /
Rearrange and tidy up innards of yppsc-ocr-resolver
[ypp-sc-tools.db-live.git] / pctb / convert.c
index e262b26c858b0ea0dda3da03a0549933be9d33fd..dd7f5d1b426dc32d5315ab37cb11793535f7c526 100644 (file)
@@ -51,6 +51,7 @@ static char *o_screenshot_fn;
 static int o_single_page, o_quiet;
 static const char *o_outputmode= "upload";
 
+const char *o_resolver;
 FILE *screenshot_file;
 
 
@@ -77,6 +78,10 @@ static void run_analysis(void) {
   progress("running recognition...");
   analyse(tf);
 
+  if (o_single_page && !strcmp(o_outputmode,"upload"))
+    fatal("Recognition successful, but refusing to upload partial data\n"
+         " (--single-page specified).  Specify an output mode?");
+
   sysassert( fseek(tf,0,SEEK_SET) == 0);
 
   progress_log("processing results (--%s)...", o_outputmode);
@@ -110,10 +115,14 @@ int main(int argc, char **argv) {
     else if (!strcmp(arg,"--analyse-only") ||
             !strcmp(arg,"--same"))
       o_mode= mode_analyse;
+    else if (!strcmp(arg,"--everything"))
+      o_mode= mode_all;
     else if (!strcmp(arg,"--single-page"))
       o_single_page= 1;
     else if (!strcmp(arg,"--quiet"))
       o_quiet= 1;
+    else if (!strcmp(arg,"--edit-charset"))
+      o_resolver= "./yppsc-ocr-resolver";
     else if (!strcmp(arg,"--raw-tsv"))
       o_outputmode= 0;
     else if (!strcmp(arg,"--upload") ||
@@ -157,6 +166,7 @@ int main(int argc, char **argv) {
     else read_screenshots();
   }
   if (o_mode & mf_analyse) {
+    find_islandname();
     if (o_outputmode)
       run_analysis();
     else
@@ -249,19 +259,6 @@ void sysassert_fail(const char *file, int line, const char *what) {
   _exit(16);
 }
 
-void *mmalloc(size_t sz) {
-  void *r;
-  if (!sz) return 0;
-  sysassert( r= malloc(sz) );
-  return r;
-}
-void *mrealloc(void *p, size_t sz) {
-  assert(sz);
-  void *r;
-  sysassert( r= realloc(p,sz) );
-  return r;
-}
-
 void waitpid_check_exitstatus(pid_t pid, const char *what) { 
   pid_t got;
   int st;