Compare commits
2 Commits
418ea56174
...
3f8f3a227a
Author | SHA1 | Date | |
---|---|---|---|
3f8f3a227a | |||
2447bd561e |
@ -22,7 +22,7 @@ INSERT INTO project (title, body) VALUES (
|
||||
http://www.ulduzsoft.com/libircclient/'
|
||||
);
|
||||
|
||||
INSERT INTO assignment VALUES (
|
||||
INSERT INTO assignment (who, project) VALUES (
|
||||
'#/g/chad',
|
||||
1
|
||||
);
|
||||
|
@ -3,7 +3,6 @@ CREATE TABLE project (
|
||||
title VARCHAR(64) NOT NULL,
|
||||
body TEXT DEFAULT NULL,
|
||||
difficulty INT NOT NULL DEFAULT 1 REFERENCES difficulty(diff),
|
||||
repo_link VARCHAR(128) DEFAULT NULL,
|
||||
trigger_date DATE DEFAULT NULL,
|
||||
started DATE NOT NULL DEFAULT CURRENT_DATE,
|
||||
span INT NOT NULL DEFAULT 7 -- time to last for in days
|
||||
@ -28,5 +27,6 @@ CREATE TABLE project_tag (
|
||||
DROP TABLE IF EXISTS assignment;
|
||||
CREATE TABLE assignment (
|
||||
who VARCHAR(32) NOT NULL,
|
||||
repo_link VARCHAR(128) DEFAULT NULL,
|
||||
project INT NOT NULL REFERENCES project(rowid)
|
||||
);
|
||||
|
@ -4,6 +4,7 @@ DECL int api_init(void);
|
||||
DECL void api_rope(void);
|
||||
DECL void rope(void);
|
||||
DECL char * remind(char * who);
|
||||
DECL char * raw(const char * const sql);
|
||||
|
||||
#define API_H_
|
||||
#endif
|
||||
|
@ -1,3 +1,6 @@
|
||||
#define stmt_prepare(stmt) \
|
||||
sqlite3_prepare_v2(connection, stmt ## _template, -1, &stmt, NULL)
|
||||
|
||||
static sqlite3_stmt* remind_stmt;
|
||||
static const char remind_stmt_template[] =
|
||||
"SELECT "
|
||||
@ -12,5 +15,10 @@ static const char remind_stmt_template[] =
|
||||
"WHERE who = ?;"
|
||||
;
|
||||
|
||||
#define stmt_prepare(stmt) \
|
||||
sqlite3_prepare_v2(connection, stmt ## _template, -1, &stmt, NULL)
|
||||
static sqlite3_stmt* set_repo_stmt;
|
||||
static const char set_repo_stmt_template[] =
|
||||
"UPDATE assignment "
|
||||
"SET "
|
||||
"repo_link = ? "
|
||||
"WHERE who = ?;"
|
||||
;
|
||||
|
15
src/api.c
15
src/api.c
@ -33,7 +33,8 @@ DECL int
|
||||
api_init(void)
|
||||
{
|
||||
DBERR(sqlite3_open(DBFILE, &connection));
|
||||
stmt_prepare(remind_stmt);
|
||||
DBERR(stmt_prepare(remind_stmt));
|
||||
DBERR(stmt_prepare(set_repo_stmt));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -76,6 +77,16 @@ remind(char * who)
|
||||
return r;
|
||||
}
|
||||
|
||||
DECL char *
|
||||
set_repo(char* who, char* link)
|
||||
{
|
||||
char * r;
|
||||
DBERR(sqlite3_bind_text(set_repo_stmt, 1, link, -1, SQLITE_STATIC));
|
||||
DBERR(sqlite3_bind_text(set_repo_stmt, 2, who, -1, SQLITE_STATIC));
|
||||
DBERR(sqlite3_step(set_repo_stmt));
|
||||
return r;
|
||||
}
|
||||
|
||||
DECL int
|
||||
rtos(void* data,
|
||||
int argc,
|
||||
@ -101,7 +112,7 @@ rtos(void* data,
|
||||
}
|
||||
|
||||
DECL char *
|
||||
raw(char * sql)
|
||||
raw(const char * const sql)
|
||||
{
|
||||
char* errmsg;
|
||||
char* r = (char*)malloc(10000);
|
||||
|
Reference in New Issue
Block a user