Merge branch 'anon'
This commit is contained in:
commit
fc69c98636
@ -34,3 +34,11 @@ static const char get_nth_id_stmt_template[] =
|
||||
"LIMIT 1 "
|
||||
"OFFSET ?;"
|
||||
;
|
||||
|
||||
static sqlite3_stmt* new_assignment_stmt;
|
||||
static const char new_assignment_stmt_template[] =
|
||||
"INSERT INTO assignment "
|
||||
"(who, project)"
|
||||
" VALUES "
|
||||
"(?, ?);"
|
||||
;
|
||||
|
15
src/api.c
15
src/api.c
@ -1,4 +1,5 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <sqlite3.h>
|
||||
|
||||
@ -164,3 +165,17 @@ get_nth_id(const int i){
|
||||
r = sqlite3_column_int(get_nth_id_stmt, 0);
|
||||
return r;
|
||||
}
|
||||
|
||||
DECL void
|
||||
new_assignment(const char * const who, const int project){
|
||||
DBERR(sqlite3_bind_text(new_assignment_stmt, 1, who, -1, SQLITE_STATIC));
|
||||
DBERR(sqlite3_bind_int(new_assignment_stmt, 2, project));
|
||||
DBERR(sqlite3_step(new_assignment_stmt));
|
||||
}
|
||||
|
||||
DECL void
|
||||
random_assign(const char * const who){
|
||||
int i = rand() % get_project_count();
|
||||
i = get_nth_id(i);
|
||||
new_assignment(who, i);
|
||||
}
|
||||
|
@ -22,6 +22,8 @@
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "irc.h"
|
||||
#include "parse.h"
|
||||
@ -120,6 +122,7 @@ event_channel(irc_session_t * session,
|
||||
int
|
||||
init(void)
|
||||
{
|
||||
srand(time(NULL));
|
||||
if(api_init())
|
||||
{ ERR(DB_ERROR, "Error initializing database."); }
|
||||
memset(&callbacks, 0, sizeof(callbacks));
|
||||
|
Reference in New Issue
Block a user