Subversion Repositories RepoView

Rev

Rev 31 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 31 Rev 35
Line 1... Line 1...
1
/* $Id: sqlite.c 31 2024-08-21 19:30:16Z nishi $ */
1
/* $Id: sqlite.c 35 2024-08-22 02:53:30Z 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 151... Line 151...
151
}
151
}
152
 
152
 
153
char* rv_who_has_token(const char* token) {
153
char* rv_who_has_token(const char* token) {
154
	char* err;
154
	char* err;
155
	count = 0;
155
	count = 0;
-
 
156
	char* esc = escape_sql(token);
156
	char* query = rv_strcat3("select * from tokens where token = '", token, "'");
157
	char* query = rv_strcat3("select * from tokens where token = '", esc, "'");
-
 
158
	free(esc);
157
	int ret;
159
	int ret;
158
	has_username = NULL;
160
	has_username = NULL;
159
	ret = sqlite3_exec(sql, query, sqlget, (void*)token, &err);
161
	ret = sqlite3_exec(sql, query, sqlget, (void*)token, &err);
160
	free(query);
162
	free(query);
161
	if(ret != SQLITE_OK) {
163
	if(ret != SQLITE_OK) {
Line 165... Line 167...
165
	return has_username;
167
	return has_username;
166
}
168
}
167
 
169
 
168
bool rv_has_token(const char* token) {
170
bool rv_has_token(const char* token) {
169
	char* err;
171
	char* err;
-
 
172
	char* esc = escape_sql(token);
170
	char* query = rv_strcat3("select * from tokens where token = '", token, "'");
173
	char* query = rv_strcat3("select * from tokens where token = '", esc, "'");
-
 
174
	free(esc);
171
	int ret;
175
	int ret;
172
	count = 0;
176
	count = 0;
173
	ret = sqlite3_exec(sql, query, sqlcount, NULL, &err);
177
	ret = sqlite3_exec(sql, query, sqlcount, NULL, &err);
174
	free(query);
178
	free(query);
175
	if(ret != SQLITE_OK) {
179
	if(ret != SQLITE_OK) {
Line 178... Line 182...
178
	return count > 0;
182
	return count > 0;
179
}
183
}
180
 
184
 
181
void rv_remove_token(const char* token) {
185
void rv_remove_token(const char* token) {
182
	char* err;
186
	char* err;
-
 
187
	char* esc = escape_sql(token);
183
	char* query = rv_strcat3("delete from tokens where token = '", token, "'");
188
	char* query = rv_strcat3("delete from tokens where token = '", esc, "'");
-
 
189
	free(esc);
184
	int ret;
190
	int ret;
185
	ret = sqlite3_exec(sql, query, sqlcount, NULL, &err);
191
	ret = sqlite3_exec(sql, query, sqlcount, NULL, &err);
186
	free(query);
192
	free(query);
187
	if(ret != SQLITE_OK) {
193
	if(ret != SQLITE_OK) {
188
		sqlite3_free(err);
194
		sqlite3_free(err);