Removed unneeded parameter and enum.

This commit is contained in:
2017-03-10 17:43:05 -08:00
parent a51cefc971
commit 51830a8122

20
main.c
View File

@ -4,37 +4,26 @@
#include <string.h>
#include <sqlite3.h>
typedef enum {
MAP,
PLAYER,
OVERVIEW,
NONE
} Querytype;
inline char *get_filename(const char c, Querytype *q) {
inline char *get_filename(const char c) {
char *qout;
switch(c) {
default:
qout = "queries/mranks.sql";
*q = OVERVIEW;
break;
case 'm':
qout = "queries/mleaderboard-ojoin.sql";
*q = MAP;
break;
case 'p':
qout = "queries/rplayers.sql";
*q = PLAYER;
break;
case 't':
qout = "queries/test.txt";
*q = NONE;
break;
}
return qout;
}
bool executequery(const char *sql, const char *p, int tbl) {
bool executequery(const char *sql, const char *p) {
sqlite3 *db;
char *error;
int con = sqlite3_open("db/cts.db", &db);
@ -69,8 +58,7 @@ bool executequery(const char *sql, const char *p, int tbl) {
// containing the data from query files.
void getquery(const char *qs) {
char *qf, *qp;
Querytype qt;
char *fname = get_filename(qs[0], &qt);
char *fname = get_filename(qs[0]);
if (fname != NULL) {
FILE *f = fopen(fname, "r");
if (f != NULL && qf != NULL) {
@ -86,7 +74,7 @@ void getquery(const char *qs) {
}
qp = strchr(qs, '=') + 1; // increment to exclude '='
printf("%x: \n\n%s\n", qf, qf);
executequery(qf, qp, qt);
executequery(qf, qp);
free(qf);
}