More whitespace and shut some warnings up

This commit is contained in:
2017-05-17 18:27:08 +03:00
parent ff8546bf66
commit 6d0a190c2f
7 changed files with 91 additions and 74 deletions

30
sql.c
View File

@@ -5,29 +5,31 @@
#include "sql.h"
#include "confparser.h"
int add_user()
int add_user(void)
{
MYSQL *con = mysql_init(NULL);
char sql[200];
if (con == NULL) {
log(ERROR, "Failed to add user: %s", mysql_error(con));
return -1;
log(ERROR, "Failed to add user: %s", mysql_error(con));
return -1;
}
if (mysql_real_connect(con, conf_db_hostname(), "rmps", conf_db_pass(),
if (mysql_real_connect(con, conf_db_hostname(), "rmps", conf_db_pass(),
NULL, 0, NULL, 0) == NULL) {
log(ERROR, "Failed to add user: %s", mysql_error(con));
mysql_close(con);
return -1;
log(ERROR, "Failed to add user: %s", mysql_error(con));
mysql_close(con);
return -1;
}
sprintf(sql, "call addUser(`%s`, `%s`, `%s`, `%s`, `%s`, `%s`)",
"user", "noob", "asd@asd.asd", "asdsadasdassda", "salt", "more");
if (mysql_query(con, sql)) {
//fprintf(stderr, "%s\n", mysql_error(con));
mysql_close(con);
exit(1);
//fprintf(stderr, "%s\n", mysql_error(con));
mysql_close(con);
exit(1);
}
MYSQL_RES *result = mysql_store_result(con);
if (result == NULL) {
log(ERROR, "Failed to add user: %s", mysql_error(con));
return -1;
@@ -39,12 +41,12 @@ int add_user()
while ((row = mysql_fetch_row(result))) {
int i;
for (i = 0; i < num_fields; i++) {
if (i == 0) {
while(field = mysql_fetch_field(result)) {
while ((field = mysql_fetch_field(result)))
printf("| %s ", field->name);
}
printf("\n");
printf("\n");
}
printf("| %s ", row[i] ? row[i] : "NULL");
}