--- mqtt/src/pubmqtt.c 2012/06/29 14:26:39 1.2.2.13 +++ mqtt/src/pubmqtt.c 2012/07/03 09:02:50 1.3 @@ -421,13 +421,12 @@ mqtt_rtlm_delete_topic(cfg_root_t *cfg, sqlite3 *sql, * @cfg = loaded config * @sql = SQL handle * @connid = connection id - * @msgid = MessageID * @topic = topic * @retain = retain 0 get only dynamic, >0 get only retained and -1 no matter * return: NULL error or not found and !=NULL allocated subscribe topics */ mqtt_subscr_t * -mqtt_rtlm_read_topic(cfg_root_t *cfg, sqlite3 *sql, const char *connid, u_short msgid, +mqtt_rtlm_read_topic(cfg_root_t *cfg, sqlite3 *sql, const char *connid, const char *topic, char retain) { int rowz = 0; @@ -457,9 +456,9 @@ mqtt_rtlm_read_topic(cfg_root_t *cfg, sqlite3 *sql, co mqtt_rtlm_log("Error:: not found topics table name"); return NULL; } - psStmt = sqlite3_mprintf("SELECT Retain, Topic, Value FROM %s WHERE " - "ConnID = '%q' AND MsgID = %d AND Topic LIKE '%q' %s;", - str, connid, msgid, topic, szStr); + psStmt = sqlite3_mprintf("SELECT QoS, Topic, Value FROM %s WHERE " + "ConnID LIKE '%q' AND Topic LIKE '%q' %s;", + str, connid, topic, szStr); if (sqlite3_prepare_v2(sql, psStmt, strlen(psStmt), &stmt, NULL)) { MQTT_RTLM_LOG(sql); @@ -488,6 +487,7 @@ mqtt_rtlm_read_topic(cfg_root_t *cfg, sqlite3 *sql, co s[j].sub_value.msg_base = (u_char*) malloc(s[j].sub_value.msg_len); if (s[j].sub_value.msg_base) memcpy(s[j].sub_value.msg_base, AIT_GET_PTR(&v), s[j].sub_value.msg_len); + AIT_FREE_VAL(&v); } end: sqlite3_finalize(stmt);