diff --git a/Makefile b/Makefile index 4472287..6b06542 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ all: tikker run -tikker: tikker.c - gcc tikker.c -Ofast -Wall -Wextra -pedantic -o tikker -lsqlite3 +tikker: tikker.c sormc.h + gcc tikker.c -Ofast -Wall -Werror -Wextra -o tikker -lsqlite3 run: ./tikker diff --git a/sormc.h b/sormc.h index 4fe1e00..d7c14d4 100644 --- a/sormc.h +++ b/sormc.h @@ -8549,7 +8549,6 @@ void sormd(int db); char *sormpt(char *sql, int number); unsigned int sormcq(char *sql, char *out); unsigned int sormpc(char *sql); -sqlite3_stmt *sormb(sorm_t *db, char *sql, ...); sorm_ptr sormq(int db, char *sql, ...); char *sorm_csvc(int db, sqlite3_stmt *stmt); char *sorm_csvd(int db, sqlite3_stmt *stmt); @@ -8571,18 +8570,14 @@ int sorm_instance_count = 0; int sormc(char *path) { // sorm connect - printf("HIERR\n"); sorm_instance_count++; sorm_instance_count++; sorm_instances = realloc(sorm_instances, sorm_instance_count * sizeof(sorm_t *) + sorm_instance_count * sizeof(sorm_t)); - printf("HIERR\n"); - sorm_t *db = &sorm_instances[sorm_instance_count - 1]; + sorm_t *db = (sorm_t *)&sorm_instances[sorm_instance_count - 1]; - printf("HIERR\n"); db->conn = NULL; - printf("HIERR\n"); db->csv = NULL; db->current_column = 0; db->current_row = 0; @@ -8597,10 +8592,9 @@ int sormc(char *path) { fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db->conn)); return 0; } - printf("DONE!\n"); return sorm_instance_count; } -sorm_t *sormg(int ptr) { return &sorm_instances[ptr - 1]; } +sorm_t *sormg(int ptr) { return (sorm_t *)&sorm_instances[ptr - 1]; } char *sormgcsv(int ptr) { /* sorm get csv*/ @@ -8711,9 +8705,10 @@ Execute 3.35s, Format: 36.77s Memory usage: 537 GB, 96.026 allocated, 96.024 freed, 2 in use. */ char *sorm_csvc(int db, sqlite3_stmt *stmt) { + (void)db; sormstr_t *str = sormstrn(512); unsigned int column_count = sqlite3_column_count(stmt); - for (int i = 0; i < column_count; i++) { + for (uint i = 0; i < column_count; i++) { const char *column_name = sqlite3_column_name(stmt, i); sormstra(str, column_name); sormstra(str, "("); @@ -8728,7 +8723,7 @@ char *sorm_csvc(int db, sqlite3_stmt *stmt) { return sormstrc(str); } char *sorm_csvd(int sorm, sqlite3_stmt *stmt) { - sorm_t *db = sormg(sorm); + (void)sorm; int rc = SQLITE_ROW; int column_count = sqlite3_column_count(stmt); /* @@ -8755,7 +8750,7 @@ char *sorm_csvd(int sorm, sqlite3_stmt *stmt) { sprintf(temp, "%f", sqlite3_column_double(stmt, field_index)); sormstra(str, temp); } else if (sqlite3_column_type(stmt, field_index) == SQLITE3_TEXT) { - const char *temp = sqlite3_column_text(stmt, field_index); + const char *temp = ( char *)sqlite3_column_text(stmt, field_index); sormstra(str, temp); } else { // exit(1); @@ -8774,7 +8769,6 @@ char *sorm_csvd(int sorm, sqlite3_stmt *stmt) { } char *sorm_csv(int sorm, sqlite3_stmt *stmt) { - sorm_t *db = sormg(sorm); sorm_row_count = 0; char *column_names = sorm_csvc(sorm, stmt); char *data = sorm_csvd(sorm, stmt); @@ -8789,31 +8783,16 @@ char *sorm_csv(int sorm, sqlite3_stmt *stmt) { return result; } -sqlite3_stmt *sormb(sorm_t *db, char *sql, ...) { - // Bind parameters to statement and return amount of parameters - int rc = 0; - sqlite3_stmt *stmt; - va_list args; - va_start(args, sql); - unsigned int number = 0; - char *clean_query = (char *)malloc(strlen(sql) + 1); - unsigned int parameter_count = sormcq(sql, clean_query); - free(clean_query); - return stmt; -} char *sormm(sorm_t *db) { + (void)db; /* sormmemory */ return rmalloc_stats(); } sorm_ptr sormq(int sorm, char *sql, ...) { sorm_t *db = sormg(sorm); - if (db->csv) { - // free(db->csv); - // db->csv = NULL; - } _sorm_query_start = nsecs(); db->time_query_start = nsecs(); va_list args; @@ -8821,17 +8800,16 @@ sorm_ptr sormq(int sorm, char *sql, ...) { sqlite3_stmt *stmt; sorm_ptr result = NULL; char *clean_query = malloc(strlen(sql) + 1); - unsigned int parameter_count = sormcq(sql, clean_query); + uint parameter_count = sormcq(sql, clean_query); int rc = sqlite3_prepare_v2(db->conn, clean_query, -1, &stmt, 0); if (rc != SQLITE_OK) { fprintf(stderr, "%s\n", sqlite3_errmsg(db->conn)); } free(clean_query); int number = 0; - for (int i = 0; i < parameter_count; i++) { + for (uint i = 0; i < parameter_count; i++) { number++; char *column_type = sormpt(sql, number); - int arg_index = number - 1; if (!strcmp(column_type, "int") || !strcmp(column_type, "integer") || !strcmp(column_type, "number")) { rc = sqlite3_bind_int(stmt, number, va_arg(args, int)); } else if (!strcmp(column_type, "int64")) { @@ -8845,7 +8823,7 @@ sorm_ptr sormq(int sorm, char *sql, ...) { rc = sqlite3_bind_blob(stmt, number, data, size, SQLITE_STATIC); } else if (!strcmp(column_type, "text") || !strcmp(column_type, "str") || !strcmp(column_type, "string")) { unsigned char *data = va_arg(args, unsigned char *); - rc = sqlite3_bind_text(stmt, number, data, -1, SQLITE_STATIC); + rc = sqlite3_bind_text(stmt, number, (char *)data, -1, SQLITE_STATIC); } if (rc != SQLITE_OK) { fprintf(stderr, "Failed to bind parameters: %s\n", sqlite3_errmsg(db->conn)); @@ -8904,7 +8882,7 @@ int sormlv(char *csv) { while (*csv) { char *found = strstr(csv, ";"); if (found) { - if (found - csv > longest) + if (found - csv > (long int)longest) longest = found - csv; csv = csv + (found - csv) + 1; } else { @@ -8995,7 +8973,7 @@ char *sormfmt(char *csv) { sormstr_t *str = sormstrn(longest + 2); while (*csv && (field = sormcsvn(csv))) { sormstra(str, field); - for (int i = 0; i < longest - strlen(field); i++) + for (size_t i = 0; i < longest - strlen(field); i++) sormstra(str, " "); csv += strlen(field); @@ -9049,3 +9027,5 @@ void sormfmtd(char *csv) { } #endif + + diff --git a/tikker b/tikker index e4942e1..e35ce59 100755 Binary files a/tikker and b/tikker differ diff --git a/tikker.c b/tikker.c index c658ac2..8bcd766 100644 --- a/tikker.c +++ b/tikker.c @@ -22,7 +22,7 @@ int is_keyboard(int fd) { int main() { - db = sormc("tikker.db"); + int db = sormc("tikker.db"); ulonglong times_repeated = 0; ulonglong times_pressed = 0;