This commit is contained in:
Meutel 2016-12-18 18:28:00 +01:00
parent 02886595dd
commit bcd62429b8
2 changed files with 8 additions and 13 deletions

4
db.c
View File

@ -74,7 +74,7 @@ again:
goto again; goto again;
} else if (SQLITE_OK == rc) { } else if (SQLITE_OK == rc) {
sqlite3_busy_timeout(db, 500); sqlite3_busy_timeout(db, 500);
r->arg = sql; r->arg = db;
return(1); return(1);
} }
} }
@ -89,5 +89,5 @@ db_close(struct kreq *r)
r->arg = NULL; r->arg = NULL;
return; return;
} }
fprintf(stderr, "sqlite3_close: %s\n", sqlite3_errmsg(db)); fprintf(stderr, "sqlite3_close: %s\n", sqlite3_errmsg(r->arg));
} }

17
main.c
View File

@ -85,7 +85,7 @@ sendbooks(struct kreq *r)
http_open(r, KHTTP_200); http_open(r, KHTTP_200);
kjson_open(&req, r); kjson_open(&req, r);
kjson_obj_open(&req); kjson_obj_open(&req);
kjson_putstringp($req, "data", "books"); kjson_putstringp(&req, "data", "books");
kjson_obj_close(&req); kjson_obj_close(&req);
kjson_close(&req); kjson_close(&req);
} }
@ -98,7 +98,7 @@ sendauthors(struct kreq *r)
http_open(r, KHTTP_200); http_open(r, KHTTP_200);
kjson_open(&req, r); kjson_open(&req, r);
kjson_obj_open(&req); kjson_obj_open(&req);
kjson_putstringp($req, "data", "authors"); kjson_putstringp(&req, "data", "authors");
kjson_obj_close(&req); kjson_obj_close(&req);
kjson_close(&req); kjson_close(&req);
} }
@ -111,7 +111,7 @@ sendseries(struct kreq *r)
http_open(r, KHTTP_200); http_open(r, KHTTP_200);
kjson_open(&req, r); kjson_open(&req, r);
kjson_obj_open(&req); kjson_obj_open(&req);
kjson_putstringp($req, "data", "series"); kjson_putstringp(&req, "data", "series");
kjson_obj_close(&req); kjson_obj_close(&req);
kjson_close(&req); kjson_close(&req);
} }
@ -124,7 +124,7 @@ sendindex(struct kreq *r)
http_open(r, KHTTP_200); http_open(r, KHTTP_200);
kjson_open(&req, r); kjson_open(&req, r);
kjson_obj_open(&req); kjson_obj_open(&req);
kjson_putstringp($req, "data", "index"); kjson_putstringp(&req, "data", "index");
kjson_obj_close(&req); kjson_obj_close(&req);
kjson_close(&req); kjson_close(&req);
} }
@ -134,15 +134,10 @@ main(void)
{ {
struct kreq r; struct kreq r;
enum kcgi_err er; enum kcgi_err er;
struct user *u;
/* Log into a separate logfile (not system log). */
kutil_openlog(LOGFILE);
/* Actually parse HTTP document. */ /* Actually parse HTTP document. */
er = khttp_parse(&r, keys, KEY__MAX, er = khttp_parse(&r, NULL, 0,
pages, PAGE__MAX, PAGE_INDEX); pages, PAGE__MAX, PAGE_INDEX);
if (KCGI_OK != er) { if (KCGI_OK != er) {
@ -152,7 +147,7 @@ main(void)
#ifdef __OpenBSD__ #ifdef __OpenBSD__
if (-1 == pledge("stdio rpath cpath wpath flock fattr", NULL)) { if (-1 == pledge("stdio rpath cpath wpath flock fattr", NULL)) {
kutil_warn(&r, NULL, "pledge"); fputs("pledge", stderr);
khttp_free(&r); khttp_free(&r);
return(EXIT_FAILURE); return(EXIT_FAILURE);
} }