chiark / gitweb /
5c4b3c8b6c7b6bd7cb7c0abbea1e58d03cc530bc
[ypp-sc-tools.web-live.git] / yarrg / rscommon.h
1 #ifndef RSCOMMON_H
2 #define RSCOMMON_H
3
4 #include <sqlite3.h>
5
6 #define DEBUG_FLAG_LIST                         \
7    DF(sql)
8
9
10 #define SQL_MUST( call ) ({                                      \
11     /* `call' is an expression returning result, using  const char *sqe; \
12      * chk1 and chk2 are blocks using sqe and  int sqr; */               \
13     const char *sql_must_call_string= #call;                             \
14     int sqr;                                                             \
15     if (DEBUGP(sql)) fprintf(stderr,"SQL %s", sql_must_call_string);     \
16     sqr= (call);                                                         \
17     if (DEBUGP(sql)) fprintf(stderr," = %d\n", sqr);                     \
18     if (sqr) fatal("SQL call failed code %d: %s: %s",                    \
19                    sqr, sqlite3_errmsg(db), sql_must_call_string);       \
20   })
21
22 #define SQL_STEP(ssh) (sql_step_wrap((ssh), #ssh, __FILE__, __LINE__))
23 int sql_step_wrap(sqlite3_stmt *ssh, const char *ssh_string,
24                   const char *file, int line);
25
26 #include "common.h"
27
28 extern sqlite3 *db;
29 extern sqlite3_stmt *ss_ipair;
30
31 void setup(void);
32 void value_route(int nislands, const int *islands);
33 void setup_value(void);
34
35 #endif /*RSCOMMON_H*/