chiark / gitweb /
Cope with commas in numerical fields from the scraper; deal properly with qty in...
[ypp-sc-tools.db-test.git] / yarrg / convert.h
index fadfe931ea40a9880d933feee85c35bcdadba674..75f61793e8fb9b25434fefd17ce39ef46128998f 100644 (file)
 #ifndef CONVERT_H
 #define CONVERT_H
 
+#define DEBUG_FLAG_LIST                                \
+   DF(findypp)                                 \
+   DF(pages)                                   \
+   DF(rect)                                    \
+   DF(pixmap)                                  \
+   DF(struct)                                  \
+   DF(ocr)                                     \
+   DF(rsync)                                   \
+   DF(structcolon)                             \
+   DF(callout)
+
+
 #include "common.h"
 #include "ocr.h"
 
+#include <fnmatch.h>
+#include <pcre.h>
 #include <pam.h>
 #include <time.h>
 #include <limits.h>
@@ -93,18 +107,6 @@ extern FILE *screenshot_file;
 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,
@@ -151,6 +153,39 @@ extern enum mode o_mode;
 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);
@@ -168,5 +203,4 @@ extern int npages;
 extern const char *ocean, *pirate;
 extern char *archipelago, *island;
 
-
 #endif /*CONVERT_H*/