#define OCR_H
-// #define DEBUG_RECTANGLES
-// #define DEBUG_OCR
-
-
#define _GNU_SOURCE
#include <string.h>
/*----- debugging arrangements, rather contingent -----*/
+#define DEBUG_FLAG_LIST \
+ DF(findypp) \
+ DF(pages) \
+ DF(rect) \
+ DF(ocr) \
+ DF(callout)
+
+enum {
+#define DF(f) dbg__shift_##f,
+ DEBUG_FLAG_LIST
+#undef DF
+};
+enum {
+#define DF(f) dbg_##f = 1 << dbg__shift_##f,
+ DEBUG_FLAG_LIST
+#undef DF
+};
+
+unsigned debug_flags;
+
+#define DEBUGP(f) (!!(debug_flags & dbg_##f))
+
void debug_flush(void);
#define eassert assert
const char *get_vardir(void);
+#define DEFINE_VWRAPPERF(decls, funcf) \
+ decls void funcf(const char *fmt, ...) { \
+ va_list al; va_start(al,fmt); v##funcf(fmt,al); va_end(al); \
+ }
+
+#define DEBUG_DEFINE_SOME_DEBUGF(fl,funcf) \
+ static void v##funcf(const char *fmt, va_list al) { \
+ if (DEBUGP(fl)) \
+ vfprintf(debug,fmt,al); \
+ } \
+ DEFINE_VWRAPPERF(static, funcf)
+
+#define DEBUG_DEFINE_DEBUGF(fl) DEBUG_DEFINE_SOME_DEBUGF(fl,debugf)
+
#endif /*OCR_H*/