comparison src/cjr_print.sml @ 432:5de838fb0950

Avoid using libpq when unneeded
author Adam Chlipala <adamc@hcoop.net>
date Sun, 26 Oct 2008 08:41:17 -0400
parents 7009b0ac1501
children 659c17441250
comparison
equal deleted inserted replaced
431:24d22b843729 432:5de838fb0950
1339 string "return 0;", 1339 string "return 0;",
1340 newline, 1340 newline,
1341 string "}", 1341 string "}",
1342 newline] 1342 newline]
1343 1343
1344 | DPreparedStatements [] => box []
1344 | DPreparedStatements ss => 1345 | DPreparedStatements ss =>
1345 box [string "static void uw_db_prepare(uw_context ctx) {", 1346 box [string "static void uw_db_prepare(uw_context ctx) {",
1346 newline, 1347 newline,
1347 string "PGconn *conn = uw_get_db(ctx);", 1348 string "PGconn *conn = uw_get_db(ctx);",
1348 newline, 1349 newline,
2180 string "PQclear(res);", 2181 string "PQclear(res);",
2181 newline] 2182 newline]
2182 end) sequences, 2183 end) sequences,
2183 2184
2184 string "}"] 2185 string "}"]
2186
2187 val hasDb = List.exists (fn (DDatabase _, _) => true | _ => false) ds
2185 in 2188 in
2186 box [string "#include <stdio.h>", 2189 box [string "#include <stdio.h>",
2187 newline, 2190 newline,
2188 string "#include <stdlib.h>", 2191 string "#include <stdlib.h>",
2189 newline, 2192 newline,
2190 string "#include <string.h>", 2193 string "#include <string.h>",
2191 newline, 2194 newline,
2192 string "#include <math.h>", 2195 string "#include <math.h>",
2193 newline, 2196 newline,
2194 string "#include <postgresql/libpq-fe.h>", 2197 if hasDb then
2195 newline, 2198 box [string "#include <postgresql/libpq-fe.h>",
2199 newline]
2200 else
2201 box [],
2196 newline, 2202 newline,
2197 string "#include \"", 2203 string "#include \"",
2198 string (OS.Path.joinDirFile {dir = Config.includ, 2204 string (OS.Path.joinDirFile {dir = Config.includ,
2199 file = "urweb.h"}), 2205 file = "urweb.h"}),
2200 string "\"", 2206 string "\"",
2220 string "uw_error(ctx, FATAL, \"Unknown page\");", 2226 string "uw_error(ctx, FATAL, \"Unknown page\");",
2221 newline, 2227 newline,
2222 string "}", 2228 string "}",
2223 newline, 2229 newline,
2224 newline, 2230 newline,
2225 validate, 2231 if hasDb then
2232 validate
2233 else
2234 box [],
2226 newline, 2235 newline,
2227 if List.exists (fn (DDatabase _, _) => true | _ => false) ds then 2236 if List.exists (fn (DDatabase _, _) => true | _ => false) ds then
2228 box [] 2237 box []
2229 else 2238 else
2230 box [newline, 2239 box [newline,