|
|
| version 1.1.1.1.2.4, 2012/06/20 08:57:48 | version 1.1.1.1.2.5, 2012/06/20 09:17:28 |
|---|---|
| Line 77 mqtt_msgCONNECT(mqtt_msg_t * __restrict buf, const cha | Line 77 mqtt_msgCONNECT(mqtt_msg_t * __restrict buf, const cha |
| if (!buf || !csConnID) | if (!buf || !csConnID) |
| return -1; | return -1; |
| else | |
| data = buf->msg_base; | |
| if (strlen(csConnID) > 23) { | if (strlen(csConnID) > 23) { |
| mqtt_SetErr(EINVAL, "Invalid argument ConnID is too long (max 23 bytes)"); | mqtt_SetErr(EINVAL, "Invalid argument ConnID is too long (max 23 bytes)"); |
| return -1; | return -1; |
| Line 106 mqtt_msgCONNECT(mqtt_msg_t * __restrict buf, const cha | Line 104 mqtt_msgCONNECT(mqtt_msg_t * __restrict buf, const cha |
| } | } |
| if (csWillTopic && *csWillTopic) { /* will messages */ | if (csWillTopic && *csWillTopic) { /* will messages */ |
| len += sizeof(mqtt_len_t) + strlen(csWillTopic); | len += sizeof(mqtt_len_t) + strlen(csWillTopic); |
| len += sizeof(mqtt_len_t) + csWillMessage ? strlen(csWillMessage) : 0; | len += sizeof(mqtt_len_t) + (csWillMessage ? strlen(csWillMessage) : 0); |
| } | } |
| /* calculate header size */ | /* calculate header size */ |
| Line 116 mqtt_msgCONNECT(mqtt_msg_t * __restrict buf, const cha | Line 114 mqtt_msgCONNECT(mqtt_msg_t * __restrict buf, const cha |
| if (mqtt_msgRealloc(buf, siz + len) == -1) | if (mqtt_msgRealloc(buf, siz + len) == -1) |
| return -1; | return -1; |
| else | else { |
| data = buf->msg_base; | |
| hdr = (struct mqtthdr *) data; | hdr = (struct mqtthdr *) data; |
| } | |
| /* fixed header */ | /* fixed header */ |
| printf("%p - %p\n", hdr, data); | |
| MQTTHDR_MSGINIT(hdr); | MQTTHDR_MSGINIT(hdr); |
| hdr->mqtt_msg.type = MQTT_TYPE_CONNECT; | hdr->mqtt_msg.type = MQTT_TYPE_CONNECT; |
| *(u_int*) hdr->mqtt_len = n; | *(u_int*) hdr->mqtt_len = n; |