6 #define DEBUG_FLAG_LIST \
15 #define DEBUG_DEV "/dev/stdout"
20 #define SQL_MUST( call ) ({ \
21 /* `call' is an expression returning result, using const char *sqe; \
22 * chk1 and chk2 are blocks using sqe and int sqr; */ \
23 const char *sql_must_call_string= #call; \
25 if (DEBUGP(sql2)) fprintf(stderr,"SQL %s", sql_must_call_string); \
27 if (DEBUGP(sql2)) fprintf(stderr," = %d\n", sqr); \
28 if (sqr) sql_fatal("(unknown)", sqr, sql_must_call_string); \
31 void sql_fatal(const char *stmt_what, int sqr, const char *act_what) NORET;
33 #define SQL_STEP(ssh) (sql_step((ssh), #ssh, __FILE__, __LINE__))
34 int sql_step(sqlite3_stmt *ssh, const char *ssh_string,
35 const char *file, int line);
37 #define SQL_DISTINCT_DECL(cols, nintcols) \
40 #define SQL_DISTINCT_STEP(ssh, cols, nkeycols) \
41 (sql_step_distinct((ssh), #ssh, __FILE__, __LINE__, \
42 (cols), sizeof((cols))/sizeof((cols)[0]), nkeycols))
43 int sql_step_distinct(sqlite3_stmt *ssh, const char *ssh_string,
44 const char *file, int line,
45 int *cols, int ncols, int nkeycols);
46 /* These work if we're making a query whose columns consist of:
47 * - keys: integer column(s) on which the results are sorted by the query
48 * - consequences: zero or more integer cols strictly dependent on the keys
49 * - extra: zero or more further (possibly non-integer) columns
51 * Call SQL_DISTINCT_DECL, passing intcols = the total number of keys and
52 * consequences; it will declare int cols[intfields];
54 * Then each SQL_DISTINCT_STEP is like SQL_STEP only you have to
55 * pass the number of key columns and it only returns rows with
56 * distinct keys. Rows with all-identical keys are asserted to
57 * have identical consequences. After each call to
58 * SQL_DISTINCT_STEP the keys and consequences will be stored in
62 int sql_single_int(const char *stmt);
64 #define SQL_PREPARE(ss,stmt) ((ss)= sql_prepare((stmt),#ss))
65 sqlite3_stmt *sql_prepare(const char *stmt, const char *what);
67 #define SQL_BIND(ss,index,value) (sql_bind((ss),(index),(value),#ss,#value))
68 void sql_bind(sqlite3_stmt *ss, int index, int value,
69 const char *ss_what, const char *val_what);
71 #define MAX_ROUTELEN 20
79 double distance_loss_factor;
81 struct TradesBlock *trades;
82 double route_tail_value;
85 IslandPair *ipair_get(int si, int di);
87 double value_route(int nislands, const int *islands, int exclude_arbitrage);
88 void setup_value(void);
90 void setup_search(void);
91 void search(int start_isle);
93 extern double max_mass, max_volu, max_capi;
94 extern double distance_loss_factor_per_league;
97 #define LOSS_FACTOR_PER_DELAY_SLOT (1-1e-8)
99 extern int islandtablesz;
102 #endif /*RSCOMMON_H*/