Diff for /mqtt/example/Attic/cmds.c between versions 1.1.2.15 and 1.1.2.17

version 1.1.2.15, 2011/12/06 10:33:37 version 1.1.2.17, 2011/12/09 09:53:54
Line 1 Line 1
 #include <stdio.h>  #include <stdio.h>
   #include <stdlib.h>
 #include <string.h>  #include <string.h>
 #include <sys/types.h>  #include <sys/types.h>
 #include <aitmqtt.h>  #include <aitmqtt.h>
Line 12  main() Line 13  main()
         mqtthdr_connflgs_t flg;          mqtthdr_connflgs_t flg;
         u_short ka, msgID;          u_short ka, msgID;
         int i, len;          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;          struct mqtthdr *hdr;
           u_char *qoses;
   
         m = mqtt_msgAlloc(0);          m = mqtt_msgAlloc(0);
         /* conn* */          /* conn* */
         printf("connect=%d/%d\n", m->msg_len, mqtt_msgCONNECT(m, "MRYN", "aaaaa", NULL, "bbb", NULL, 0, 0, 0));          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++)          for (i = 0; i < m->msg_len; i++)
                 printf("%d\n", ((u_char*) m->msg_base)[i]);                  printf("%d\n", ((u_char*) m->msg_base)[i]);
        flg = mqtt_readCONNECT(m, &ka, cid, sizeof cid, user, sizeof user, pass, sizeof pass,         t = msg = NULL;
                        topic, sizeof topic, message, sizeof message);        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",           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);                          flg.clean_sess, flg.will_flg, flg.will_qos, flg.will_retain, flg.password, flg.username);
         if (flg.reserved) {          if (flg.reserved) {
Line 29  main() Line 31  main()
                 return 1;                  return 1;
         }          }
         printf("++> KA=%d sec, ConnID=%s User=%s Pass=%s Will_Topic=%s Will_Message=%s\n", ka,           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));          printf("connack=%d/%d\n", m->msg_len, mqtt_msgCONNACK(m, 1));
         for (i = 0; i < m->msg_len; i++)          for (i = 0; i < m->msg_len; i++)
                 printf("%d\n", ((u_char*) m->msg_base)[i]);                  printf("%d\n", ((u_char*) m->msg_base)[i]);
Line 93  main() Line 99  main()
         printf("suback=%d/%d\n", m->msg_len, mqtt_msgSUBACK(m, s, 10));          printf("suback=%d/%d\n", m->msg_len, mqtt_msgSUBACK(m, s, 10));
         for (i = 0; i < m->msg_len; i++)          for (i = 0; i < m->msg_len; i++)
                 printf("%d\n", ((u_char*) m->msg_base)[i]);                  printf("%d\n", ((u_char*) m->msg_base)[i]);
           printf("read suback=%d\n", (len = mqtt_readSUBACK(m, &msgID, &qoses)));
           for (i = 0; i < len; i++)
                   printf(" >>> QoS=%d\n", qoses[i]);
           free(qoses);
         printf("unsubscribe=%d/%d\n", m->msg_len, mqtt_msgUNSUBSCRIBE(m, s, 10, 0, 1));          printf("unsubscribe=%d/%d\n", m->msg_len, mqtt_msgUNSUBSCRIBE(m, s, 10, 0, 1));
         for (i = 0; i < m->msg_len; i++)          for (i = 0; i < m->msg_len; i++)
                 printf("%d\n", ((u_char*) m->msg_base)[i]);                  printf("%d\n", ((u_char*) m->msg_base)[i]);
           hdr = mqtt_readUNSUBSCRIBE(m, &msgID, &ss);
           if (!hdr) {
                   printf("Error:: mqtt_readUNSUBSCRIBE() #%d - %s\n", mqtt_GetErrno(), mqtt_GetError());
                   return 3;
           }
           printf("read unsubscribe: dup=%d qos=%d retain=%d\n", hdr->mqtt_msg.dup, hdr->mqtt_msg.qos, hdr->mqtt_msg.retain);
           printf("++> MessageID=%d\n", msgID);
           for (i = 0; ss[i].sub_topic._base; i++)
                   printf(" >>> Topic(%d)=%s\n", ss[i].sub_topic._size, ss[i].sub_topic._base);
           mqtt_subFree(&ss);
         printf("unsuback=%d/%d\n", m->msg_len, mqtt_msgUNSUBACK(m, 10));          printf("unsuback=%d/%d\n", m->msg_len, mqtt_msgUNSUBACK(m, 10));
         for (i = 0; i < m->msg_len; i++)          for (i = 0; i < m->msg_len; i++)
                 printf("%d\n", ((u_char*) m->msg_base)[i]);                  printf("%d\n", ((u_char*) m->msg_base)[i]);

Removed from v.1.1.2.15  
changed lines
  Added in v.1.1.2.17


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>