chiark / gitweb /
Fix up nislands; use BEGIN
[ypp-sc-tools.main.git] / yarrg / rscommon.h
index 658bbdd71404bbc2bc2f61dbef9a30591050a860..8bfe3e1ed1b6f9dd70c9980496ec97e6f2741103 100644 (file)
@@ -1,14 +1,36 @@
 #ifndef RSCOMMON_H
 #define RSCOMMON_H
 
-#include <stdio.h>
-
 #include <sqlite3.h>
-#include <assert.h>
-#include <stdlib.h>
 
-extern struct sqlite *db;
+#define DEBUG_FLAG_LIST                                \
+   DF(sql)                                     \
+   DF(value)
+
+
+#define SQL_MUST( call ) ({                                     \
+    /* `call' is an expression returning result, using  const char *sqe; \
+     * chk1 and chk2 are blocks using sqe and  int sqr; */              \
+    const char *sql_must_call_string= #call;                            \
+    int sqr;                                                            \
+    if (DEBUGP(sql)) fprintf(stderr,"SQL %s", sql_must_call_string);    \
+    sqr= (call);                                                        \
+    if (DEBUGP(sql)) fprintf(stderr," = %d\n", sqr);                    \
+    if (sqr) fatal("SQL call failed code %d: %s: %s",                   \
+                  sqr, sqlite3_errmsg(db), sql_must_call_string);       \
+  })
+
+#define SQL_STEP(ssh) (sql_step_wrap((ssh), #ssh, __FILE__, __LINE__))
+int sql_step_wrap(sqlite3_stmt *ssh, const char *ssh_string,
+                 const char *file, int line);
+
+#include "common.h"
+
+extern sqlite3 *db;
+extern sqlite3_stmt *ss_ipair;
 
+void setup(void);
 void value_route(int nislands, const int *islands);
+void setup_value(void);
 
 #endif /*RSCOMMON_H*/