version 1.2.2.6, 2012/05/05 14:51:02
|
version 1.2.2.7, 2012/05/08 13:04:02
|
Line 454 mqtt_rtlm_write_subscribe(cfg_root_t *cfg, sqlite3 *sq
|
Line 454 mqtt_rtlm_write_subscribe(cfg_root_t *cfg, sqlite3 *sq
|
* @topic = topic |
* @topic = topic |
* @user = username |
* @user = username |
* @host = hostname |
* @host = hostname |
* @qos = Subscribe QoS if -1 no matter |
|
* return: -1 error, 0 no changes or >0 deleted rows |
* return: -1 error, 0 no changes or >0 deleted rows |
*/ |
*/ |
int |
int |
mqtt_rtlm_delete_subscribe(cfg_root_t *cfg, sqlite3 *sql, const char *topic, |
mqtt_rtlm_delete_subscribe(cfg_root_t *cfg, sqlite3 *sql, const char *topic, |
const char *user, const char *host, char qos) | const char *user, const char *host) |
{ |
{ |
int ret = 0; |
int ret = 0; |
char *str, szStr[STRSIZ] = { 0 }, szStmt[BUFSIZ] = { 0 }; | char *str, szStmt[BUFSIZ] = { 0 }; |
sqlite3_stmt *stmt; |
sqlite3_stmt *stmt; |
|
|
if (!cfg || !sql || !topic) |
if (!cfg || !sql || !topic) |
Line 473 mqtt_rtlm_delete_subscribe(cfg_root_t *cfg, sqlite3 *s
|
Line 472 mqtt_rtlm_delete_subscribe(cfg_root_t *cfg, sqlite3 *s
|
mqtt_rtlm_log("Error:: not found subscribes table name"); |
mqtt_rtlm_log("Error:: not found subscribes table name"); |
return -1; |
return -1; |
} |
} |
if (qos > -1 && qos < 3) |
|
snprintf(szStr, sizeof szStr, "AND QoS = %d", qos); |
|
snprintf(szStmt, sizeof szStmt, "DELETE FROM %s WHERE Topic LIKE '%s' AND " |
snprintf(szStmt, sizeof szStmt, "DELETE FROM %s WHERE Topic LIKE '%s' AND " |
"PubUser LIKE '%s' AND PubHost LIKE '%s' %s;", str, | "PubUser LIKE '%s' AND PubHost LIKE '%s';", str, |
topic, user, host, szStr); | topic, user, host); |
|
|
if (sqlite3_prepare_v2(sql, szStmt, strlen(szStmt), &stmt, NULL)) { |
if (sqlite3_prepare_v2(sql, szStmt, strlen(szStmt), &stmt, NULL)) { |
MQTT_RTLM_LOG(sql); |
MQTT_RTLM_LOG(sql); |