Subversion Repositories IRC-Archiver

Rev

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

Rev 8 Rev 13
Line 1... Line 1...
1
/* $Id: db.c 8 2024-08-30 03:46:36Z nishi $ */
1
/* $Id: db.c 13 2024-08-30 07:33:43Z nishi $ */
2
 
2
 
3
#include "ia_db.h"
3
#include "ia_db.h"
4
 
4
 
5
#include "ia_util.h"
5
#include "ia_util.h"
6
 
6
 
Line 27... Line 27...
27
		return 1;
27
		return 1;
28
	}
28
	}
29
	return 0;
29
	return 0;
30
}
30
}
31
 
31
 
32
char* escape_sql(const char* stuff) {
32
char* ia_escape_sql(const char* stuff) {
33
	char* str = malloc(strlen(stuff) * 2 + 1);
33
	char* str = malloc(strlen(stuff) * 2 + 1);
34
	int incr = 0;
34
	int incr = 0;
35
	int i;
35
	int i;
36
	for(i = 0; stuff[i] != 0; i++) {
36
	for(i = 0; stuff[i] != 0; i++) {
37
		if(stuff[i] == '\'') {
37
		if(stuff[i] == '\'') {
Line 44... Line 44...
44
	str[incr] = 0;
44
	str[incr] = 0;
45
	return str;
45
	return str;
46
}
46
}
47
 
47
 
48
int ia_db_put(const char* user, const char* channel, const char* message) {
48
int ia_db_put(const char* user, const char* channel, const char* message) {
49
	char* eusr = escape_sql(user);
49
	char* eusr = ia_escape_sql(user);
50
	char* echn = escape_sql(channel);
50
	char* echn = ia_escape_sql(channel);
51
	char* emsg = escape_sql(message);
51
	char* emsg = ia_escape_sql(message);
52
 
52
 
53
	char* date = malloc(512);
53
	char* date = malloc(512);
54
	sprintf(date, "%llu", (unsigned long long)time(NULL));
54
	sprintf(date, "%llu", (unsigned long long)time(NULL));
55
 
55
 
56
	char* tmp;
56
	char* tmp;