From 9894f3c77ae975ffd212286e38a786c73b275757 Mon Sep 17 00:00:00 2001 From: <> Date: Sun, 12 Mar 2017 20:03:51 -0700 Subject: [PATCH] got tables to display in a basic way --- main.c | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/main.c b/main.c index d49820d..f9ccc73 100644 --- a/main.c +++ b/main.c @@ -23,9 +23,9 @@ inline char *get_filename(const char c) { return qout; } -inline char *get_tblheader(const char c) { +inline void print_tblheader(const char *c) { char *out; - switch (c) { + switch (*c) { default: out = "\ \ @@ -55,23 +55,28 @@ inline char *get_tblheader(const char c) { "; break; } - return out; + printf("%s", out); } //display and format the results of the query. -void qresult(sqlite3_stmt *sp) { +void qresult(sqlite3_stmt *sp, const char *c) { int e; - unsigned int cc, i; + unsigned int i; + unsigned int cc = sqlite3_column_count(sp); + print_tblheader(c); while ((e = sqlite3_step(sp)) == SQLITE_ROW) { - cc = sqlite3_column_count(sp); + printf(""); for (i = 0; i < cc; i++) { - printf("%s", sqlite3_column_text(sp, i)); + printf("", sqlite3_column_text(sp, i)); } - printf("\n"); + printf(""); } + printf("


Map List

%s
"); } -bool executequery(const char *sql, const char *p) { +bool executequery(const char *sql, const char *str) { + const char *p = strchr(str, '=') + 1; + const char qc = str[0]; sqlite3 *db; char *error; int con = sqlite3_open("db/cts.db", &db); @@ -88,7 +93,7 @@ bool executequery(const char *sql, const char *p) { } // bind parameter with a string length that is the # of bytes to null char. con = sqlite3_bind_text(s, 1, p, -1, NULL); - qresult(s); + qresult(s, &qc); sqlite3_finalize(s); sqlite3_close(db); return true; @@ -114,7 +119,7 @@ void getquery(const char *qs) { fclose(f); } qp = strchr(qs, '=') + 1; - executequery(qf, qp); + executequery(qf, qs); free(qf); } @@ -129,12 +134,13 @@ void html(void) { In-game database is not directly synced with this web server.\

\ "; + printf("%s", html_top); // getquery(getenv("QUERY_STRING")); - - printf("%s %s", html_top, html_bot); + getquery("map=pornstar-kaine"); + printf("%s", html_bot); } int main(void) { - getquery("map=pornstar-kaine"); - getquery("player=duHTyaSGpdTk7oebwPFoo899xPoTwP9bja4DUjCjTLo="); + html(); +// getquery("player=duHTyaSGpdTk7oebwPFoo899xPoTwP9bja4DUjCjTLo="); }