--- mqtt/example/Attic/cmds.c 2011/12/06 12:36:45 1.1.2.16 +++ mqtt/example/Attic/cmds.c 2011/12/09 09:53:54 1.1.2.17 @@ -13,7 +13,7 @@ main() mqtthdr_connflgs_t flg; u_short ka, msgID; int i, len; - char cid[BUFSIZ], user[BUFSIZ], pass[BUFSIZ], topic[BUFSIZ], message[BUFSIZ]; + char cid[BUFSIZ], user[BUFSIZ], pass[BUFSIZ], topic[BUFSIZ], message[BUFSIZ], *t, *msg; struct mqtthdr *hdr; u_char *qoses; @@ -22,8 +22,8 @@ main() printf("connect=%d/%d\n", m->msg_len, mqtt_msgCONNECT(m, "MRYN", "aaaaa", NULL, "bbb", NULL, 0, 0, 0)); for (i = 0; i < m->msg_len; i++) printf("%d\n", ((u_char*) m->msg_base)[i]); - flg = mqtt_readCONNECT(m, &ka, cid, sizeof cid, user, sizeof user, pass, sizeof pass, - topic, sizeof topic, message, sizeof message); + t = msg = NULL; + flg = mqtt_readCONNECT(m, &ka, cid, sizeof cid, user, sizeof user, pass, sizeof pass, &t, &msg); printf("read connect flags:: clean=%d will=%d qos=%d retain=%d pass=%d user=%d\n", flg.clean_sess, flg.will_flg, flg.will_qos, flg.will_retain, flg.password, flg.username); if (flg.reserved) { @@ -31,7 +31,11 @@ main() return 1; } printf("++> KA=%d sec, ConnID=%s User=%s Pass=%s Will_Topic=%s Will_Message=%s\n", ka, - cid, user, pass, topic, message); + cid, user, pass, t, msg); + if (t) + free(t); + if (msg) + free(msg); printf("connack=%d/%d\n", m->msg_len, mqtt_msgCONNACK(m, 1)); for (i = 0; i < m->msg_len; i++) printf("%d\n", ((u_char*) m->msg_base)[i]);