chiark / gitweb /
WIP routetrade now can find trades for islandpair but FIXME need to get max islandid
[ypp-sc-tools.web-live.git] / yarrg / rscommon.h
index 6fd394ea008d7eb0829189426633106b6572a5b0..5c4b3c8b6c7b6bd7cb7c0abbea1e58d03cc530bc 100644 (file)
@@ -7,10 +7,29 @@
    DF(sql)
 
 
    DF(sql)
 
 
+#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"
 
 #include "common.h"
 
-extern struct sqlite *db;
+extern sqlite3 *db;
+extern sqlite3_stmt *ss_ipair;
 
 
+void setup(void);
 void value_route(int nislands, const int *islands);
 void value_route(int nislands, const int *islands);
+void setup_value(void);
 
 #endif /*RSCOMMON_H*/
 
 #endif /*RSCOMMON_H*/