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