aboutsummaryrefslogtreecommitdiff
path: root/debug.h
diff options
context:
space:
mode:
Diffstat (limited to 'debug.h')
-rw-r--r--debug.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/debug.h b/debug.h
new file mode 100644
index 0000000..96447b2
--- /dev/null
+++ b/debug.h
@@ -0,0 +1,26 @@
+#ifndef DEBUG_H
+#define DEBUG_H
+
+#include <stdio.h>
+
+#ifndef NDEBUG
+# define debug(...) fprintf(stderr, __VA_ARGS__)
+#else
+# define debug(...)
+#endif
+
+static inline char *move_str_buf(ms_move *m) {
+ static const int buf_size = 30;
+ static char buf[buf_size];
+ static char *buf_p = &buf[0];
+
+ if (m->stock) {
+ snprintf(buf_p, buf_size, "stock");
+ } else {
+ snprintf(buf_p, buf_size, "%2ux %2u->%2u", m->size, m->from, m->to);
+ }
+
+ return buf;
+}
+
+#endif /* DEBUG_H */