version 1.1.1.1.2.6, 2011/11/21 16:28:05
|
version 1.1.1.1.2.10, 2011/11/22 13:03:26
|
Line 43 mqtt_SetErr(int eno, char *estr, ...)
|
Line 43 mqtt_SetErr(int eno, char *estr, ...)
|
|
|
/* |
/* |
* mqtt_msgFree() Free MQTT message |
* mqtt_msgFree() Free MQTT message |
|
* |
* @msg = Message buffer |
* @msg = Message buffer |
* @all = !=0 Destroy entire message, if MQTT Message allocated with mqtt_msgAlloc() |
* @all = !=0 Destroy entire message, if MQTT Message allocated with mqtt_msgAlloc() |
* return: none |
* return: none |
Line 65 mqtt_msgFree(mqtt_msg_t ** __restrict msg, int all)
|
Line 66 mqtt_msgFree(mqtt_msg_t ** __restrict msg, int all)
|
|
|
/* |
/* |
* mqtt_msgAlloc() Allocate memory for MQTT Message |
* mqtt_msgAlloc() Allocate memory for MQTT Message |
|
* |
* @len = >0 Allocate buffer with length |
* @len = >0 Allocate buffer with length |
* return: NULL error or Message, after use must call mqtt_msgFree() with all!=0 |
* return: NULL error or Message, after use must call mqtt_msgFree() with all!=0 |
*/ |
*/ |
Line 96 mqtt_msgAlloc(u_short len)
|
Line 98 mqtt_msgAlloc(u_short len)
|
|
|
/* |
/* |
* mqtt_msgRealloc() Reallocate MQTT message buffer |
* mqtt_msgRealloc() Reallocate MQTT message buffer |
|
* |
* @msg = MQTT message |
* @msg = MQTT message |
* @len = new length |
* @len = new length |
* return: -1 error or >-1 old buffer length |
* return: -1 error or >-1 old buffer length |
Line 127 mqtt_msgRealloc(mqtt_msg_t * __restrict msg, u_short l
|
Line 130 mqtt_msgRealloc(mqtt_msg_t * __restrict msg, u_short l
|
|
|
/* |
/* |
* mqtt_encodeLen() Encode number to MQTT length field |
* mqtt_encodeLen() Encode number to MQTT length field |
|
* |
* @num = number for encode |
* @num = number for encode |
* return: -1 error or >-1 length |
* return: -1 error or >-1 length |
*/ |
*/ |
Line 153 mqtt_encodeLen(u_int num)
|
Line 157 mqtt_encodeLen(u_int num)
|
|
|
/* |
/* |
* mqtt_decodeLen() Decode length from MQTT packet |
* mqtt_decodeLen() Decode length from MQTT packet |
|
* |
* @len = length |
* @len = length |
* @n = sizeof bytes, if !=NULL |
* @n = sizeof bytes, if !=NULL |
* return: -1 error, >-1 length of message |
* return: -1 error, >-1 length of message |
Line 182 mqtt_decodeLen(u_int len, char *n)
|
Line 187 mqtt_decodeLen(u_int len, char *n)
|
|
|
/* |
/* |
* mqtt_sizeLen Return sizeof len field |
* mqtt_sizeLen Return sizeof len field |
|
* |
* @len = length |
* @len = length |
* return: -1 error, >-1 sizeof len in bytes |
* return: -1 error, >-1 sizeof len in bytes |
*/ |
*/ |
Line 203 mqtt_sizeLen(u_int len)
|
Line 209 mqtt_sizeLen(u_int len)
|
|
|
/* |
/* |
* mqtt_str2sub Create MQTT subscribe variable from string(s) |
* mqtt_str2sub Create MQTT subscribe variable from string(s) |
|
* |
* @csStr = strings |
* @csStr = strings |
* @strnum = number of strings elements |
* @strnum = number of strings elements |
* @qoses = QoS elements applied to subscribe variable, |
* @qoses = QoS elements applied to subscribe variable, |
Line 241 mqtt_str2sub(const char **csStr, u_short strnum, u_cha
|
Line 248 mqtt_str2sub(const char **csStr, u_short strnum, u_cha
|
} |
} |
|
|
/* |
/* |
* mqtt_freeSub() Free array from subscribe variables | * mqtt_subFree() Free array from subscribe variables |
* |
* |
* @subs = Subscribe variables |
* @subs = Subscribe variables |
* return: none |
* return: none |
*/ |
*/ |
inline void |
inline void |
mqtt_freeSub(mqtt_subscr_t ** __restrict subs) | mqtt_subFree(mqtt_subscr_t ** __restrict subs) |
{ |
{ |
mqtt_subscr_t *v; |
mqtt_subscr_t *v; |
|
|
if (!subs) |
if (!subs) |
return; |
return; |
|
|
for (v = *subs; v; v++) | for (v = *subs; v->sub_data; v++) { |
free(v->sub_data); |
free(v->sub_data); |
|
v->sub_data = NULL; |
|
} |
|
|
free(*subs); |
free(*subs); |
*subs = NULL; |
*subs = NULL; |
|
} |
|
|
|
/* |
|
* mqtt_subAlloc() Create array from subscribe variables |
|
* |
|
* @num = Number of elements |
|
* return: NULL error or subscribe array, after use must call mqtt_subFree() |
|
*/ |
|
inline mqtt_subscr_t * |
|
mqtt_subAlloc(u_short num) |
|
{ |
|
mqtt_subscr_t *s = NULL; |
|
register int i; |
|
|
|
s = malloc((num + 1) * sizeof(mqtt_subscr_t)); |
|
if (!s) { |
|
LOGERR; |
|
return NULL; |
|
} else |
|
memset(s, 0, (num + 1) * sizeof(mqtt_subscr_t)); |
|
|
|
for (i = 0; i < num; i++) |
|
if (!(s[i].sub_data = malloc(0))) { |
|
LOGERR; |
|
break; |
|
} |
|
|
|
return s; |
} |
} |