Subversion Repositories RepoView

Rev

Rev 7 | Rev 15 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7 Rev 13
Line 1... Line 1...
1
/* $Id: sqlite.c 7 2024-08-21 01:12:44Z nishi $ */
1
/* $Id: sqlite.c 13 2024-08-21 12:31:40Z nishi $ */
2
 
2
 
3
#include "rv_db.h"
3
#include "rv_db.h"
4
 
4
 
5
#include "../../config.h"
5
#include "../../config.h"
6
 
6
 
Line 109... Line 109...
109
		sqlite3_free(err);
109
		sqlite3_free(err);
110
	}
110
	}
111
	return user.valid;
111
	return user.valid;
112
}
112
}
113
 
113
 
-
 
114
void rv_create_user(const char* username, const char* password) {
-
 
115
	char* err;
-
 
116
	int ret;
-
 
117
	char* sha512 = rv_sha512(password);
-
 
118
	char* esc = escape_sql(username);
-
 
119
	char* tmp = rv_strcat3("insert into users values('", esc, "', '");
-
 
120
	char* query = rv_strcat3(tmp, sha512, "')");
-
 
121
	free(sha512);
-
 
122
	free(tmp);
-
 
123
	free(esc);
-
 
124
	ret = sqlite3_exec(sql, query, NULL, NULL, &err);
-
 
125
	if(ret != SQLITE_OK) {
-
 
126
		sqlite3_free(err);
-
 
127
	}
-
 
128
}
-
 
129
 
114
void rv_save_token(const char* username, const char* token) {
130
void rv_save_token(const char* username, const char* token) {
115
	char* err;
131
	char* err;
116
	int ret;
132
	int ret;
117
	char* esc = escape_sql(username);
133
	char* esc = escape_sql(username);
118
	char* tmp = rv_strcat3("insert into tokens values('", esc, "', '");
134
	char* tmp = rv_strcat3("insert into tokens values('", esc, "', '");