diff options
author | FreeArtMan <dos21h@gmail.com> | 2017-11-25 11:31:56 +0000 |
---|---|---|
committer | FreeArtMan <dos21h@gmail.com> | 2017-11-25 11:31:56 +0000 |
commit | 32f380fb86012c5dbc856d3c81acfde13f2803e8 (patch) | |
tree | ce1be167f5b152d9efcf660a32ea041e7b5f65b9 | |
parent | 3967218650a2c03304533c4e8b32e86c8b38a48a (diff) | |
download | agni-32f380fb86012c5dbc856d3c81acfde13f2803e8.tar.gz agni-32f380fb86012c5dbc856d3c81acfde13f2803e8.zip |
Hunting down all warnings
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | agni.c | 10 | ||||
-rw-r--r-- | cmd/cmd_lua.c | 19 | ||||
-rw-r--r-- | cmd/cmd_todo.c | 27 | ||||
-rw-r--r-- | config_all_cmds.h | 1 | ||||
-rw-r--r-- | config_cmds.h | 4 | ||||
-rw-r--r-- | config_load.c | 1 | ||||
-rw-r--r-- | config_servers.h | 2 | ||||
-rw-r--r-- | version.h | 4 |
9 files changed, 33 insertions, 37 deletions
@@ -18,7 +18,7 @@ $(PROJECT): version $(SOURCES) agni.c %.o: %.c @echo $@ - $(CC) $(CFLAGS) $(INCLUDE) -c $< -o $(subst .c,.o,$<) + @$(CC) $(CFLAGS) $(INCLUDE) -c $< -o $(subst .c,.o,$<) #autogenerate version from git commit and date when it was compiled version: @@ -330,12 +330,14 @@ int th_start_client(void *data) printf("Cant get attribute\n"); ENL(); } + in_buf = malloc(in_attr.mq_msgsize); memset(in_buf, 0, in_attr.mq_msgsize); if (in_buf == NULL) { ENL(); } + //PRINT("SERVER:%s PORT:%s USER:%s\n", cfg->server, cfg->port, cfg->user); //create irc parsing structures @@ -383,7 +385,7 @@ int th_start_client(void *data) if (mq_event == 1) { nb_init(nb_resp); - nb_load(nb_resp, in_buf); + nb_load(nb_resp, (unsigned char *)in_buf); rpc_resp_unmarsh(nb_resp, &resp); PRINT("RESP: %d-%s(%s)\n", resp->id, resp->result, resp->error); @@ -586,7 +588,7 @@ int th_start_client(void *data) irciedent_parse(qcmd->ircident, req); rpc_req_marsh(req, &nb_req); - buf_nb = nb_create(nb_req); + buf_nb = (char *)nb_create(nb_req); memcpy(out_buf, buf_nb, nb_req->size > out_attr.mq_msgsize ? out_attr.mq_msgsize : nb_req->size); mq_ntf_write(mq, MQ_OUT, out_buf, out_attr.mq_msgsize); FREE(buf_nb); @@ -829,7 +831,7 @@ int th_event_manager(void *data) if (mq_event == 1) { nb_init(nb_req); - if (0 == nb_load(nb_req, out_buf)) + if (0 == nb_load(nb_req, (unsigned char *)out_buf)) { rpc_req_unmarsh(nb_req, &req); PRINT("EVENT-REQ: %d-%s(%s) %s-%s-%s\n", req->id, req->method, req->params, req->user, req->mask, req->server); @@ -867,7 +869,7 @@ int th_event_manager(void *data) resp->server = alloc_new_str(""); rpc_resp_marsh(resp, &nb_resp); - buf_nb = nb_create(nb_resp); + buf_nb = (char *)nb_create(nb_resp); mq_ntf_write(mq_cur, MQ_IN, buf_nb, nb_resp->size > in_attr.mq_msgsize ? in_attr.mq_msgsize : nb_resp->size); stats.cnt_ipc_tx += nb_resp->size > in_attr.mq_msgsize ? in_attr.mq_msgsize : nb_resp->size; FREE(buf_nb); diff --git a/cmd/cmd_lua.c b/cmd/cmd_lua.c index 820620f..2c850be 100644 --- a/cmd/cmd_lua.c +++ b/cmd/cmd_lua.c @@ -127,28 +127,27 @@ int lua_excute(const char *fname, rpc_call_request *req, rpc_call_response **res { int t; int top = lua_gettop(L); - int len = lua_rawlen(L,1); + //int len = lua_rawlen(L,1); if (top == 1) { t = lua_type(L,1); if (t == LUA_TTABLE) { - int j; - - const char *r_result; - const char *r_error; + + char *r_result; //this care unchangable stupid C dont know what is const + char *r_error; //this unchangable stupid C dont know what is const int r_id; size_t sz; - check_table_key_string(L, "result", &r_result, &sz); + check_table_key_string(L, "result", (const char **)&r_result, &sz); //printf("RESULT:%s\n", r_result); check_table_key_integer(L, "id", &r_id); //printf("ID:%d\n", r_id); - check_table_key_string(L, "error", &r_error, &sz); + check_table_key_string(L, "error", (const char **)&r_error, &sz); //printf("ERROR:%s\n", r_error); @@ -176,12 +175,10 @@ void *cmd_lua(void *data) char *ret = NULL; char *req_data = NULL; int fret; - int rc; - int i; int count; sds params = sdsempty(); - sds out_result = sdsempty(), out_lua = sdsempty(); + sds out_result = sdsempty(); sds *tokens; rpc_call_request *req = NULL; @@ -202,7 +199,7 @@ void *cmd_lua(void *data) //prepare request nb_req = malloc(sizeof(netbyte_store)); nb_init(nb_req); - nb_load(nb_req, req_data); + nb_load(nb_req, (unsigned char *)req_data); if (nb_req == NULL) { diff --git a/cmd/cmd_todo.c b/cmd/cmd_todo.c index 079866e..c1d9e4a 100644 --- a/cmd/cmd_todo.c +++ b/cmd/cmd_todo.c @@ -4,6 +4,8 @@ //https://www.google.nl/url?sa=t&rct=j&q=&esrc=s&source=web&cd=4&cad=rja&uact=8&ved=0ahUKEwiMu9_F5ZrXAhVLOMAKHZ6NDQYQFghDMAM&url=https%3A%2F%2Fopensource.apple.com%2Fsource%2FQuickTimeStreamingServer%2FQuickTimeStreamingServer-452%2FCommonUtilitiesLib%2Fbase64.c&usg=AOvVaw3tk0M33ne4ru28Bn_R1KI3 #define TODO_MAX_PER_USER 64 +#define TODO_MAX_DB_FILE_SIZE (1024*1024) +#define TODO_DB_NAME "todo.db" static int add_todo(sqlite3 *db, char *user, char *todo) { @@ -12,11 +14,11 @@ static int add_todo(sqlite3 *db, char *user, char *todo) char *b64_user, *b64_todo; sqlite3_stmt *res=NULL; - b64_user = b64_encode(user, strlen(user)); - b64_todo = b64_encode(todo, strlen(todo)); + b64_user = b64_encode((unsigned char *)user, strlen(user)); + b64_todo = b64_encode((unsigned char *)todo, strlen(todo)); //check how many todo stuff is for single user - snprintf(sql_add_table, 1024, "SELECT COUNT(*) FROM todo WHERE user='%s';", b64_user, b64_todo); + snprintf(sql_add_table, 1024, "SELECT COUNT(*) FROM todo WHERE user='%s';", b64_user); printf("%s\n", sql_add_table); if ((rc = sqlite3_prepare_v2(db, sql_add_table, -1, &res, 0)) != SQLITE_OK) { @@ -71,7 +73,7 @@ static int cb_list_todo_table(void *param1, int argc, char **argv, char **cname) *out = sdscat(*out, " - "); } else if (strncmp(cname[i],"todo",4) == 0) { - char *b64_todo = b64_decode(argv[i], strlen(argv[i])); + char *b64_todo = (char *)b64_decode(argv[i], strlen(argv[i])); *out = sdscat(*out, b64_todo); free(b64_todo); *out = sdscat(*out, "\n"); @@ -91,7 +93,7 @@ static int list_todo(sqlite3 *db, char *user, sds *out) char sql_list_table[1024]; char *b64_user; - b64_user = b64_encode(user, strlen(user)); + b64_user = b64_encode((unsigned char *)user, strlen(user)); snprintf(sql_list_table, 1024, "SELECT * FROM todo WHERE user='%s'", b64_user); printf("%s\n",sql_list_table); free(b64_user); @@ -111,7 +113,6 @@ static int list_todo(sqlite3 *db, char *user, sds *out) static int list_total(sqlite3 *db, sds *out) { int rc; - char *err_msg = NULL; sqlite3_stmt *res=NULL; char sql_list_total[1024]; @@ -128,7 +129,7 @@ static int list_total(sqlite3 *db, sds *out) rc = sqlite3_step(res); if (rc == SQLITE_ROW) { - const char *cret = sqlite3_column_text(res, 0); + const char *cret = (char *)sqlite3_column_text(res, 0); *out = sdscat(*out, cret); } sqlite3_finalize(res); @@ -144,21 +145,18 @@ static int del_todo(sqlite3 *db, char *user, int id) char sql_del_table[1024]; char *b64_user; - b64_user = b64_encode(user, strlen(user)); + b64_user = b64_encode((unsigned char *)user, strlen(user)); snprintf(sql_del_table, 1024, "DELETE FROM todo WHERE user='%s' AND id=%d;", b64_user, id); free(b64_user); - PRINT("%s\n",sql_del_table); if ((rc = sqlite3_exec(db, sql_del_table, 0, 0, &err_msg )) != SQLITE_OK) { printf("Cant del todo: %s\n", err_msg); sqlite3_free(err_msg); - PNL(); return -1; } - PNL(); return 0; } @@ -198,7 +196,7 @@ void *cmd_todo(void *data) //prepare request nb_req = malloc(sizeof(netbyte_store)); nb_init(nb_req); - nb_load(nb_req, req_data); + nb_load(nb_req, (unsigned char *)req_data); if (nb_req == NULL) { @@ -217,13 +215,13 @@ void *cmd_todo(void *data) //main code //check if database filesize is not bigger then 1MB, consider it for now as abuse woop woop - if (file_size("todo.db")>1024*1024) + if (file_size(TODO_DB_NAME)>TODO_MAX_DB_FILE_SIZE) { printf("File should be limited to just 1MB pal\n"); return ret; } - if ((rc = sqlite3_open("todo.db", &db)) != SQLITE_OK) + if ((rc = sqlite3_open(TODO_DB_NAME, &db)) != SQLITE_OK) { printf("Cannot open todo database: %s\n", sqlite3_errmsg(db)); sqlite3_close(db); @@ -286,7 +284,6 @@ void *cmd_todo(void *data) if (count > 2) { int id = atoi(tokens[2]); - PRINT("%d\n",id); del_todo(db, req->user, id); } diff --git a/config_all_cmds.h b/config_all_cmds.h index b61a5cd..059e4e0 100644 --- a/config_all_cmds.h +++ b/config_all_cmds.h @@ -4,6 +4,7 @@ #include "cmd/cmd_rusage.h" #include "cmd/cmd_version.h" #include "cmd/cmd_stat.h" +#include "cmd/cmd_bot.h" #include "cmd/cmd_cookie.h" #include "cmd/cmd_date.h" #include "cmd/cmd_sha1.h" diff --git a/config_cmds.h b/config_cmds.h index aba780e..a14546c 100644 --- a/config_cmds.h +++ b/config_cmds.h @@ -39,13 +39,13 @@ single_cmd_def confgi_cmd_list[] = {CMD_T_SIMPLE,"HELP",cmd_help}, {CMD_T_SIMPLE,"SPI",cmd_spi}, {CMD_T_SIMPLE,"STAT",cmd_stat}, + {CMD_T_SIMPLE,"BOT",cmd_stat}, {CMD_T_SIMPLE,"!bot",cmd_stat}, //more complicated command {CMD_T_RPC,"TODO",cmd_todo}, //command that going go to lua - {CMD_T_LUA,"LUA",cmd_lua}, {CMD_T_LUA,"@", cmd_lua} - + {CMD_T_LUA,"LUA",cmd_lua}, {CMD_T_LUA,"@", cmd_lua}, {0,NULL,NULL} }; diff --git a/config_load.c b/config_load.c index df29cb7..7824501 100644 --- a/config_load.c +++ b/config_load.c @@ -2,7 +2,6 @@ int config_load_ini(char *ini_fname, config_ini **config) { - int i; config_ini *res_conf=NULL; if (!ini_fname) diff --git a/config_servers.h b/config_servers.h index 005b274..c61c053 100644 --- a/config_servers.h +++ b/config_servers.h @@ -21,7 +21,7 @@ typedef struct irc_server_conf void free_irc_server_conf(irc_server_conf *isc); -static irc_server_conf server_list[] = +static irc_server_conf server_list[] __attribute__((used)) = //default values { /* { @@ -1,5 +1,5 @@ #ifndef __VERSION_H #define __VERSION_H -#define VERSION_DATE "Sun Nov 19 11:28:46 GMT 2017" -#define VERSION_COMMIT "d23ebff New version" +#define VERSION_DATE "Sat Nov 25 11:30:56 GMT 2017" +#define VERSION_COMMIT "3967218 Bug in todo handling usernames, needed to use base64 encoded username" #endif |