From c93bccac831e8cf397840d9b8408d954b67c70dc Mon Sep 17 00:00:00 2001 From: "7u83@mail.ru" <7u83@mail.ru@noemail.net> Date: Wed, 29 Apr 2015 17:25:09 +0000 Subject: [PATCH] Added the put_wtp_prop function. FossilOrigin-Name: da7783297233a97d0d0e5b451e6efd667d84f86b5db4db26cf6b6f83e93c8721 --- src/ac/db.c | 49 ++++++++++++++++++++++++++++++++++++++++++------- src/ac/db.h | 2 ++ 2 files changed, 44 insertions(+), 7 deletions(-) diff --git a/src/ac/db.c b/src/ac/db.c index f7f5de56..95bbbfdf 100644 --- a/src/ac/db.c +++ b/src/ac/db.c @@ -48,11 +48,11 @@ int db_init() return 1; } -/** AC Ping statement */ -static sqlite3_stmt * ping_stmt; -/** Put-WTP-Prop Statement */ +static sqlite3_stmt * ping_stmt; static sqlite3_stmt * put_wtp_prop_stmt; +static sqlite3_stmt * get_task_stmt; + int db_start() @@ -100,15 +100,50 @@ void db_ping() { int rc = sqlite3_step(ping_stmt); if (rc!=SQLITE_DONE){ - cw_log(LOG_ERR,"Error: Can't ping database, error code %d",rc); + cw_log(LOG_ERR,"Error: Can't ping database, error code %d - %s",rc,sqlite3_errmsg(handle)); } } -void db_put_wtp_prop(const char *wtp_id,int rid, int upd, const char * prop) +void db_put_wtp_prop(const char *wtp_id,int rid, const char * prop,const char * val) { int rc; - rc = sqlite3_bind_text(put_wtp_prop_stmt,1,wtp_id,-1,SQLITE_STATIC); - rc = sqlite3_bind_text(put_wtp_prop_stmt,2,wtp_id,-1,SQLITE_STATIC); + + sqlite3_reset(put_wtp_prop_stmt); + sqlite3_clear_bindings(put_wtp_prop_stmt); + + if(sqlite3_bind_text(put_wtp_prop_stmt,1,wtp_id,-1,SQLITE_STATIC)) + goto errX; + + if(sqlite3_bind_int(put_wtp_prop_stmt,2,rid)) + goto errX; + + if (sqlite3_bind_text(put_wtp_prop_stmt,3,prop,-1,SQLITE_STATIC)) + goto errX; + + if (sqlite3_bind_text(put_wtp_prop_stmt,4,val,-1,SQLITE_STATIC)) + goto errX; + + if (sqlite3_bind_int(put_wtp_prop_stmt,5,0)) + goto errX; + + + if (sqlite3_step(put_wtp_prop_stmt)) + goto errX; + return; +errX: + if (rc) { + cw_log(LOG_ERR,"Can't update database with WTP props: %d - %s", + rc,sqlite3_errmsg(handle)); + } } + +int db_get_tasks(const char * wtpid) +{ + + + +} + + diff --git a/src/ac/db.h b/src/ac/db.h index 0ae80ba4..49302a9a 100644 --- a/src/ac/db.h +++ b/src/ac/db.h @@ -1,4 +1,6 @@ extern void db_ping(); extern int db_init(); int db_start(); +void db_put_wtp_prop(const char *wtp_id,int rid, const char * prop,const char * val); +