chiark / gitweb /
yarrg: with --find-window-only, print ocean and pirate parseably to stdout
[ypp-sc-tools.db-test.git] / yarrg / convert.h
index 82ea369bca2335b866ed53256a492cf2a99029fa..893008735889d94d0f345c138e8401c154bb1fc5 100644 (file)
 #ifndef CONVERT_H
 #define CONVERT_H
 
 #ifndef CONVERT_H
 #define CONVERT_H
 
+#define DEBUG_FLAG_LIST                                \
+   DF(findypp)                                 \
+   DF(pages)                                   \
+   DF(keymap)                                  \
+   DF(rect)                                    \
+   DF(pixmap)                                  \
+   DF(struct)                                  \
+   DF(ocr)                                     \
+   DF(rsync)                                   \
+   DF(structcolon)                             \
+   DF(callout)
+
+
 #include "common.h"
 #include "ocr.h"
 
 #include "common.h"
 #include "ocr.h"
 
+#include <fnmatch.h>
+#include <pcre.h>
 #include <pam.h>
 #include <time.h>
 #include <limits.h>
 #include <pam.h>
 #include <time.h>
 #include <limits.h>
@@ -76,6 +91,7 @@ void store_current_page(CanonImage *ci /*pointer saved*/,
 void adjust_colours(CanonImage *ci, const RgbImage *rgb);
 
 void select_page(int page);
 void adjust_colours(CanonImage *ci, const RgbImage *rgb);
 
 void select_page(int page);
+void check_pager_motion(int first, int stop);
 
 Rect find_sunshine_widget(void);
 
 
 Rect find_sunshine_widget(void);
 
@@ -92,18 +108,6 @@ extern FILE *screenshot_file;
 void fetch_with_rsync(const char *stem);
 void fetch_with_rsync_gz(const char *stem);
 
 void fetch_with_rsync(const char *stem);
 void fetch_with_rsync_gz(const char *stem);
 
-void vwarning(const char *fmt, va_list) FMT(1,0);
-void warning(const char *fmt, ...)      FMT(1,2);
-
-void vprogress(const char *fmt, va_list) FMT(1,0);
-void progress(const char *fmt, ...)      FMT(1,2);
-
-void vprogress_log(const char *fmt, va_list) FMT(1,0);
-void progress_log(const char *fmt, ...)      FMT(1,2);
-
-void vprogress_spinner(const char *fmt, va_list) FMT(1,0);
-void progress_spinner(const char *fmt, ...)      FMT(1,2);
-
 enum flags {
   ff_singlepage=          000002,
   ff_testservers=         000004,
 enum flags {
   ff_singlepage=          000002,
   ff_testservers=         000004,
@@ -132,16 +136,17 @@ enum flags {
 extern enum flags o_flags;
 
 enum mode {
 extern enum flags o_flags;
 
 enum mode {
-  mf_findwindow=      00001,
-  mf_screenshot=      00010,
-  mf_readscreenshot=  00020,
-  mf_analyse=         00100,
-  mfm_special=        07000,
+  mf_findwindow=        00001,
+  mf_screenshot=        00010,
+  mf_readscreenshot=    00020,
+  mf_analyse=           00100,
+  mf_printoceanpirate=  00200,
+  mfm_special=          07000,
   
   
-  mode_findwindow=    00001,
-  mode_screenshot=    00011,
-  mode_analyse=       00120,
-  mode_showcharset=   01000,
+  mode_findwindow=      00201,
+  mode_screenshot=      00011,
+  mode_analyse=         00120,
+  mode_showcharset=     01000,
 
   mode_all=           00111,
 };
 
   mode_all=           00111,
 };
@@ -150,6 +155,39 @@ extern enum mode o_mode;
 extern const char *o_ocean, *o_pirate;
 extern int o_quiet;
 
 extern const char *o_ocean, *o_pirate;
 extern int o_quiet;
 
+
+#define dbassert(x) ((x) ? (void)0 : dbfile_assertfail(__FILE__,__LINE__,#x))
+void dbfile_assertfail(const char *file, int line, const char *m) NORET;
+
+FILE *dbfile;
+void dbfile_getsline(char *lbuf, size_t lbufsz, const char *file, int line);
+int dbfile_open(const char *tpath);   /* 0: ENOENT; 1: worked */
+int dbfile_gzopen(const char *tpath); /* 0: ENOENT; 1: worked */
+void dbfile_close(void); /* idempotent */
+
+int dbfile_scanf(const char *fmt, ...) SCANFMT(1,2);
+int dbfile_vscanf(const char *fmt, va_list al) SCANFMT(1,0);
+
+int gzopen(const char *zpath, int oflags, FILE **f_r, pid_t *pid_r,
+          const char *gziplevel /* 0 for read; may be 0, or "-1" etc. */);
+  /* returns errno value from open */
+void gzclose(FILE **f, pid_t *p, const char *what);
+  /* also OK with f==0, or p==-1 */
+
+
+const char *get_vardir(void);
+const char *get_libdir(void);
+
+
+#define EXECLP_HELPER(helper, ...) do{                         \
+    char *helper_path= masprintf("%s/%s",get_libdir(),helper); \
+    execlp(helper_path,helper, __VA_ARGS__);                   \
+    sysassert(errno==ENOENT);                                  \
+    fatal("Failed to find helper program %s.\n"                        \
+         "(Are you in the correct directory?)", helper);       \
+  }while(0)
+
+
 /*----- from pages.c -----*/
 
 void screenshot_startup(void);
 /*----- from pages.c -----*/
 
 void screenshot_startup(void);
@@ -167,5 +205,4 @@ extern int npages;
 extern const char *ocean, *pirate;
 extern char *archipelago, *island;
 
 extern const char *ocean, *pirate;
 extern char *archipelago, *island;
 
-
 #endif /*CONVERT_H*/
 #endif /*CONVERT_H*/