chiark / gitweb /
before special kerning thing
[ypp-sc-tools.web-live.git] / pctb / ocr.h
index 60234a8e91e6028ea8f028a912f0a53d8eafbc7d..e8b5b1a1207dc3f5ebae2060718d7c0a96cba5b3 100644 (file)
@@ -7,10 +7,6 @@
 #define OCR_H
 
 
-// #define DEBUG_RECTANGLES
-// #define DEBUG_OCR
-
-
 #define _GNU_SOURCE
 
 #include <string.h>
@@ -58,6 +54,27 @@ OcrResultGlyph *ocr(OcrReader *rd, OcrCellType, int w, Pixcol cols[]);
 
 /*----- debugging arrangements, rather contingent -----*/
 
+#define DEBUG_FLAG_LIST                                \
+   DF(ocr)                                     \
+   DF(rect)                                    \
+   DF(callout)                                 \
+   DF(pages)
+
+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
@@ -65,4 +82,13 @@ void debug_flush(void);
 
 const char *get_vardir(void);
 
+#define DEBUG_DEFINE_DEBUGF(f)                                         \
+  static void vdebugf(const char *fmt, va_list al) {                   \
+    if (DEBUGP(f))                                                     \
+      vfprintf(debug,fmt,al);                                          \
+  }                                                                    \
+  static void debugf(const char *fmt, ...) {                           \
+    va_list al;  va_start(al,fmt);  vdebugf(fmt,al);  va_end(al);      \
+  }
+
 #endif /*OCR_H*/