Rename property__free_all->mosquitto_property_free_all

Make public function.
pull/1022/head
Roger A. Light 7 years ago
parent be5602be28
commit 9eebcf6704

@ -43,7 +43,7 @@ int handle__auth(struct mosquitto *mosq)
rc = property__read_all(AUTH, &mosq->in_packet, &properties);
if(rc) return rc;
property__free_all(&properties); /* FIXME - TEMPORARY UNTIL PROPERTIES PROCESSED */
mosquitto_property_free_all(&properties); /* FIXME - TEMPORARY UNTIL PROPERTIES PROCESSED */
return MOSQ_ERR_SUCCESS;
}

@ -44,9 +44,9 @@ int handle__connack(struct mosquitto *mosq)
if(mosq->protocol == mosq_p_mqtt5){
rc = property__read_all(CONNACK, &mosq->in_packet, &properties);
if(rc) return rc;
property__free_all(&properties);
mosquitto_property_free_all(&properties);
}
property__free_all(&properties); /* FIXME - TEMPORARY UNTIL PROPERTIES PROCESSED */
mosquitto_property_free_all(&properties); /* FIXME - TEMPORARY UNTIL PROPERTIES PROCESSED */
log__printf(mosq, MOSQ_LOG_DEBUG, "Client %s received CONNACK (%d)", mosq->id, reason_code);
pthread_mutex_lock(&mosq->callback_mutex);

@ -55,7 +55,7 @@ int handle__pubackcomp(struct mosquitto *mosq, const char *type)
rc = property__read_all(PUBACK, &mosq->in_packet, &properties);
if(rc) return rc;
/* Immediately free, we don't do anything with Reason String or User Property at the moment */
property__free_all(&properties);
mosquitto_property_free_all(&properties);
}
#ifdef WITH_BROKER

@ -77,9 +77,9 @@ int handle__publish(struct mosquitto *mosq)
if(mosq->protocol == mosq_p_mqtt5){
rc = property__read_all(PUBLISH, &mosq->in_packet, &properties);
if(rc) return rc;
property__free_all(&properties);
mosquitto_property_free_all(&properties);
}
property__free_all(&properties); /* FIXME - TEMPORARY UNTIL PROPERTIES PROCESSED */
mosquitto_property_free_all(&properties); /* FIXME - TEMPORARY UNTIL PROPERTIES PROCESSED */
message->msg.payloadlen = mosq->in_packet.remaining_length - mosq->in_packet.pos;
if(message->msg.payloadlen){

@ -50,7 +50,7 @@ int handle__pubrec(struct mosquitto *mosq)
rc = property__read_all(PUBREC, &mosq->in_packet, &properties);
if(rc) return rc;
/* Immediately free, we don't do anything with Reason String or User Property at the moment */
property__free_all(&properties);
mosquitto_property_free_all(&properties);
}
#ifdef WITH_BROKER

@ -59,7 +59,7 @@ int handle__pubrel(struct mosquitto_db *db, struct mosquitto *mosq)
rc = property__read_all(PUBREL, &mosq->in_packet, &properties);
if(rc) return rc;
/* Immediately free, we don't do anything with Reason String or User Property at the moment */
property__free_all(&properties);
mosquitto_property_free_all(&properties);
}
#ifdef WITH_BROKER

@ -55,7 +55,7 @@ int handle__suback(struct mosquitto *mosq)
rc = property__read_all(SUBACK, &mosq->in_packet, &properties);
if(rc) return rc;
/* Immediately free, we don't do anything with Reason String or User Property at the moment */
property__free_all(&properties);
mosquitto_property_free_all(&properties);
}
qos_count = mosq->in_packet.remaining_length - mosq->in_packet.pos;

@ -57,7 +57,7 @@ int handle__unsuback(struct mosquitto *mosq)
rc = property__read_all(UNSUBACK, &mosq->in_packet, &properties);
if(rc) return rc;
/* Immediately free, we don't do anything with Reason String or User Property at the moment */
property__free_all(&properties);
mosquitto_property_free_all(&properties);
}
#ifndef WITH_BROKER

@ -95,4 +95,5 @@ MOSQ_1.5 {
MOSQ_1.6 {
global:
mosquitto_subscribe_multiple;
mosquitto_property_free_all;
} MOSQ_1.5;

@ -114,6 +114,7 @@ struct mosquitto_message{
};
struct mosquitto;
typedef struct mqtt5__property mosquitto_property;
/*
* Topic: Threads
@ -1874,6 +1875,29 @@ libmosq_EXPORT int mosquitto_subscribe_callback(
libmosq_EXPORT int mosquitto_validate_utf8(const char *str, int len);
/* =============================================================================
*
* Section: Properties
*
* =============================================================================
*/
/*
* Function: mosquitto_property_free_all
*
* Free all properties from a list of properties. Frees the list and sets *properties to NULL.
*
* Parameters:
* properties - list of properties to free
*
* Example:
* mosquitto_properties *properties = NULL;
* // Add properties
* mosquitto_property_free_all(&properties);
*/
libmosq_EXPORT void mosquitto_property_free_all(mosquitto_property **properties);
#ifdef __cplusplus
}
#endif

@ -161,7 +161,7 @@ int property__read_all(int command, struct mosquitto__packet *packet, struct mqt
rc = property__read(packet, &proplen, p);
if(rc){
mosquitto__free(p);
property__free_all(properties);
mosquitto_property_free_all(properties);
return rc;
}
@ -182,19 +182,19 @@ int property__read_all(int command, struct mosquitto__packet *packet, struct mqt
|| p->identifier == PROP_SHARED_SUB_AVAILABLE){
if(p->value.i8 > 1){
property__free_all(properties);
mosquitto_property_free_all(properties);
return MOSQ_ERR_PROTOCOL;
}
}else if(p->identifier == PROP_MAXIMUM_PACKET_SIZE){
if( p->value.i32 == 0){
property__free_all(properties);
mosquitto_property_free_all(properties);
return MOSQ_ERR_PROTOCOL;
}
}else if(p->identifier == PROP_RECEIVE_MAXIMUM
|| p->identifier == PROP_TOPIC_ALIAS){
if(p->value.i16 == 0){
property__free_all(properties);
mosquitto_property_free_all(properties);
return MOSQ_ERR_PROTOCOL;
}
}
@ -208,7 +208,7 @@ int property__read_all(int command, struct mosquitto__packet *packet, struct mqt
if(current->identifier == tail->identifier
&& current->identifier != PROP_USER_PROPERTY){
property__free_all(properties);
mosquitto_property_free_all(properties);
return MOSQ_ERR_PROTOCOL;
}
tail = tail->next;
@ -218,7 +218,7 @@ int property__read_all(int command, struct mosquitto__packet *packet, struct mqt
/* Check for properties on incorrect commands */
if(property__command_check(command, *properties)){
property__free_all(properties);
mosquitto_property_free_all(properties);
return MOSQ_ERR_PROTOCOL;
}
return MOSQ_ERR_SUCCESS;
@ -276,7 +276,7 @@ void property__free(struct mqtt5__property **property)
}
void property__free_all(struct mqtt5__property **property)
void mosquitto_property_free_all(struct mqtt5__property **property)
{
struct mqtt5__property *p, *next;

@ -42,7 +42,6 @@ struct mqtt5__property {
int property__read_all(int command, struct mosquitto__packet *packet, struct mqtt5__property **property);
int property__write_all(struct mosquitto__packet *packet, struct mqtt5__property *property);
void property__free(struct mqtt5__property **property);
void property__free_all(struct mqtt5__property **property);
int property__get_length(struct mqtt5__property *property);
int property__get_length_all(struct mqtt5__property *property);

@ -226,7 +226,7 @@ void context__send_will(struct mosquitto_db *db, struct mosquitto *ctxt)
}
}
if(ctxt->will){
property__free_all(&ctxt->will->properties);
mosquitto_property_free_all(&ctxt->will->properties);
mosquitto__free(ctxt->will->msg.topic);
mosquitto__free(ctxt->will->msg.payload);
mosquitto__free(ctxt->will);

@ -207,7 +207,7 @@ void db__msg_store_remove(struct mosquitto_db *db, struct mosquitto_msg_store *s
mosquitto__free(store->dest_ids);
}
mosquitto__free(store->topic);
property__free_all(&store->properties);
mosquitto_property_free_all(&store->properties);
UHPA_FREE_PAYLOAD(store);
mosquitto__free(store);
}
@ -661,7 +661,7 @@ error:
mosquitto__free(temp->topic);
mosquitto__free(temp);
}
property__free_all(&properties);
mosquitto_property_free_all(&properties);
return rc;
}

@ -42,7 +42,7 @@ int handle__auth(struct mosquitto_db *db, struct mosquitto *context)
rc = property__read_all(AUTH, &context->in_packet, &properties);
if(rc) return rc;
property__free_all(&properties); /* FIXME - TEMPORARY UNTIL PROPERTIES PROCESSED */
mosquitto_property_free_all(&properties); /* FIXME - TEMPORARY UNTIL PROPERTIES PROCESSED */
return MOSQ_ERR_SUCCESS;
}

@ -47,9 +47,9 @@ int handle__connack(struct mosquitto_db *db, struct mosquitto *context)
if(context->protocol == mosq_p_mqtt5){
rc = property__read_all(CONNACK, &context->in_packet, &properties);
if(rc) return rc;
property__free_all(&properties);
mosquitto_property_free_all(&properties);
}
property__free_all(&properties); /* FIXME - TEMPORARY UNTIL PROPERTIES PROCESSED */
mosquitto_property_free_all(&properties); /* FIXME - TEMPORARY UNTIL PROPERTIES PROCESSED */
switch(reason_code){
case CONNACK_ACCEPTED:

@ -244,9 +244,9 @@ int handle__connect(struct mosquitto_db *db, struct mosquitto *context)
if(protocol_version == PROTOCOL_VERSION_v5){
rc = property__read_all(CONNECT, &context->in_packet, &properties);
if(rc) return rc;
property__free_all(&properties);
mosquitto_property_free_all(&properties);
}
property__free_all(&properties); /* FIXME - TEMPORARY UNTIL PROPERTIES PROCESSED */
mosquitto_property_free_all(&properties); /* FIXME - TEMPORARY UNTIL PROPERTIES PROCESSED */
if(packet__read_string(&context->in_packet, &client_id, &slen)){
rc = 1;
@ -304,7 +304,7 @@ int handle__connect(struct mosquitto_db *db, struct mosquitto *context)
if(protocol_version == PROTOCOL_VERSION_v5){
rc = property__read_all(CMD_WILL, &context->in_packet, &will_struct->properties);
if(rc) return rc;
property__free_all(&properties); /* FIXME - TEMPORARY UNTIL PROPERTIES PROCESSED */
mosquitto_property_free_all(&properties); /* FIXME - TEMPORARY UNTIL PROPERTIES PROCESSED */
}
if(packet__read_string(&context->in_packet, &will_topic, &slen)){
rc = 1;
@ -709,7 +709,7 @@ handle_connect_error:
mosquitto__free(will_payload);
mosquitto__free(will_topic);
if(will_struct){
property__free_all(&will_struct->properties);
mosquitto_property_free_all(&will_struct->properties);
}
mosquitto__free(will_struct);
#ifdef WITH_TLS
@ -731,9 +731,9 @@ int handle__disconnect(struct mosquitto_db *db, struct mosquitto *context)
if(context->protocol == mosq_p_mqtt5){
rc = property__read_all(DISCONNECT, &context->in_packet, &properties);
if(rc) return rc;
property__free_all(&properties);
mosquitto_property_free_all(&properties);
}
property__free_all(&properties); /* FIXME - TEMPORARY UNTIL PROPERTIES PROCESSED */
mosquitto_property_free_all(&properties); /* FIXME - TEMPORARY UNTIL PROPERTIES PROCESSED */
if(context->in_packet.remaining_length != 0){
return MOSQ_ERR_PROTOCOL;

@ -194,7 +194,7 @@ int handle__publish(struct mosquitto_db *db, struct mosquitto *context)
}
}
}
property__free_all(&properties);
mosquitto_property_free_all(&properties);
payloadlen = context->in_packet.remaining_length - context->in_packet.pos;
G_PUB_BYTES_RECEIVED_INC(payloadlen);

@ -55,9 +55,9 @@ int handle__subscribe(struct mosquitto_db *db, struct mosquitto *context)
if(context->protocol == mosq_p_mqtt5){
rc = property__read_all(SUBSCRIBE, &context->in_packet, &properties);
if(rc) return rc;
property__free_all(&properties);
mosquitto_property_free_all(&properties);
}
property__free_all(&properties); /* FIXME - TEMPORARY UNTIL PROPERTIES PROCESSED */
mosquitto_property_free_all(&properties); /* FIXME - TEMPORARY UNTIL PROPERTIES PROCESSED */
while(context->in_packet.pos < context->in_packet.remaining_length){
sub = NULL;

@ -48,7 +48,7 @@ int handle__unsubscribe(struct mosquitto_db *db, struct mosquitto *context)
rc = property__read_all(UNSUBSCRIBE, &context->in_packet, &properties);
if(rc) return rc;
/* Immediately free, we don't do anything with User Property at the moment */
property__free_all(&properties);
mosquitto_property_free_all(&properties);
}
if(context->protocol == mosq_p_mqtt311 || context->protocol == mosq_p_mqtt5){

@ -29,7 +29,7 @@ static void byte_prop_read_helper(
CU_ASSERT_EQUAL(properties->value.i8, value_expected);
CU_ASSERT_PTR_EQUAL(properties->next, NULL);
CU_ASSERT_EQUAL(property__get_length_all(properties), 2);
property__free_all(&properties);
mosquitto_property_free_all(&properties);
}
CU_ASSERT_PTR_EQUAL(properties, NULL);
}
@ -85,7 +85,7 @@ static void int32_prop_read_helper(
CU_ASSERT_EQUAL(properties->value.i32, value_expected);
CU_ASSERT_PTR_EQUAL(properties->next, NULL);
CU_ASSERT_EQUAL(property__get_length_all(properties), 5);
property__free_all(&properties);
mosquitto_property_free_all(&properties);
}
CU_ASSERT_PTR_EQUAL(properties, NULL);
}
@ -135,7 +135,7 @@ static void int16_prop_read_helper(
CU_ASSERT_EQUAL(properties->value.i16, value_expected);
CU_ASSERT_PTR_EQUAL(properties->next, NULL);
CU_ASSERT_EQUAL(property__get_length_all(properties), 3);
property__free_all(&properties);
mosquitto_property_free_all(&properties);
}
CU_ASSERT_PTR_EQUAL(properties, NULL);
}
@ -181,7 +181,7 @@ static void string_prop_read_helper(
CU_ASSERT_STRING_EQUAL(properties->value.s.v, value_expected);
CU_ASSERT_PTR_EQUAL(properties->next, NULL);
CU_ASSERT_EQUAL(property__get_length_all(properties), 1+2+strlen(value_expected));
property__free_all(&properties);
mosquitto_property_free_all(&properties);
}
CU_ASSERT_PTR_EQUAL(properties, NULL);
}
@ -246,7 +246,7 @@ static void binary_prop_read_helper(
CU_ASSERT_EQUAL(memcmp(properties->value.bin.v, value_expected, len_expected), 0);
CU_ASSERT_PTR_EQUAL(properties->next, NULL);
CU_ASSERT_EQUAL(property__get_length_all(properties), 1+2+len_expected);
property__free_all(&properties);
mosquitto_property_free_all(&properties);
}
CU_ASSERT_PTR_EQUAL(properties, NULL);
}
@ -301,7 +301,7 @@ static void string_pair_prop_read_helper(
CU_ASSERT_PTR_NULL(properties->next);
CU_ASSERT_EQUAL(property__get_length_all(properties), 1+2+strlen(name_expected)+2+strlen(value_expected));
}
property__free_all(&properties);
mosquitto_property_free_all(&properties);
}
CU_ASSERT_PTR_NULL(properties);
}
@ -328,7 +328,7 @@ static void varint_prop_read_helper(
CU_ASSERT_EQUAL(properties->value.varint, value_expected);
CU_ASSERT_PTR_NULL(properties->next);
CU_ASSERT_EQUAL(property__get_length_all(properties), packet__varint_bytes(value_expected)+1);
property__free_all(&properties);
mosquitto_property_free_all(&properties);
}
CU_ASSERT_PTR_NULL(properties);
}
@ -367,7 +367,7 @@ static void packet_helper_reason_string_user_property(int command)
CU_ASSERT_STRING_EQUAL(p->name.v, "name");
CU_ASSERT_EQUAL(p->name.len, strlen("name"));
property__free_all(&properties);
mosquitto_property_free_all(&properties);
}
}
@ -1273,7 +1273,7 @@ static void TEST_packet_connect(void)
CU_ASSERT_EQUAL(p->value.bin.v[1], 2);
CU_ASSERT_EQUAL(p->value.s.len, 2);
property__free_all(&properties);
mosquitto_property_free_all(&properties);
}
static void TEST_packet_connack(void)
@ -1406,7 +1406,7 @@ static void TEST_packet_connack(void)
CU_ASSERT_EQUAL(p->value.bin.v[1], 2);
CU_ASSERT_EQUAL(p->value.s.len, 2);
property__free_all(&properties);
mosquitto_property_free_all(&properties);
}
static void TEST_packet_publish(void)
@ -1482,7 +1482,7 @@ static void TEST_packet_publish(void)
CU_ASSERT_STRING_EQUAL(p->value.s.v, "empty");
CU_ASSERT_EQUAL(p->value.s.len, strlen("empty"));
property__free_all(&properties);
mosquitto_property_free_all(&properties);
}
static void TEST_packet_puback(void)
@ -1538,7 +1538,7 @@ static void TEST_packet_subscribe(void)
CU_ASSERT_EQUAL(p->identifier, PROP_SUBSCRIPTION_IDENTIFIER);
CU_ASSERT_EQUAL(p->value.varint, 0x00000004);
property__free_all(&properties);
mosquitto_property_free_all(&properties);
}
static void TEST_packet_suback(void)
@ -1572,7 +1572,7 @@ static void TEST_packet_unsubscribe(void)
CU_ASSERT_STRING_EQUAL(p->name.v, "name");
CU_ASSERT_EQUAL(p->name.len, strlen("name"));
property__free_all(&properties);
mosquitto_property_free_all(&properties);
}
static void TEST_packet_unsuback(void)
@ -1620,7 +1620,7 @@ static void TEST_packet_disconnect(void)
CU_ASSERT_STRING_EQUAL(p->name.v, "name");
CU_ASSERT_EQUAL(p->name.len, strlen("name"));
property__free_all(&properties);
mosquitto_property_free_all(&properties);
}
static void TEST_packet_auth(void)
@ -1672,7 +1672,7 @@ static void TEST_packet_auth(void)
CU_ASSERT_STRING_EQUAL(p->name.v, "name");
CU_ASSERT_EQUAL(p->name.len, strlen("name"));
property__free_all(&properties);
mosquitto_property_free_all(&properties);
}

@ -39,7 +39,7 @@ static void byte_prop_write_helper(
CU_ASSERT_EQUAL(properties->value.i8, value_expected);
CU_ASSERT_PTR_EQUAL(properties->next, NULL);
CU_ASSERT_EQUAL(property__get_length_all(properties), 2);
property__free_all(&properties);
mosquitto_property_free_all(&properties);
}
CU_ASSERT_PTR_EQUAL(properties, NULL);
}
@ -79,7 +79,7 @@ static void int32_prop_write_helper(
CU_ASSERT_EQUAL(properties->value.i32, value_expected);
CU_ASSERT_PTR_EQUAL(properties->next, NULL);
CU_ASSERT_EQUAL(property__get_length_all(properties), 5);
property__free_all(&properties);
mosquitto_property_free_all(&properties);
}
CU_ASSERT_PTR_EQUAL(properties, NULL);
}
@ -119,7 +119,7 @@ static void int16_prop_write_helper(
CU_ASSERT_EQUAL(properties->value.i16, value_expected);
CU_ASSERT_PTR_EQUAL(properties->next, NULL);
CU_ASSERT_EQUAL(property__get_length_all(properties), 3);
property__free_all(&properties);
mosquitto_property_free_all(&properties);
}
CU_ASSERT_PTR_EQUAL(properties, NULL);
}
@ -160,7 +160,7 @@ static void string_prop_write_helper(
CU_ASSERT_STRING_EQUAL(properties->value.s.v, value_expected);
CU_ASSERT_PTR_EQUAL(properties->next, NULL);
CU_ASSERT_EQUAL(property__get_length_all(properties), 1+2+strlen(value_expected));
property__free_all(&properties);
mosquitto_property_free_all(&properties);
}
CU_ASSERT_PTR_EQUAL(properties, NULL);
free(property.value.s.v);
@ -205,7 +205,7 @@ static void binary_prop_write_helper(
CU_ASSERT_EQUAL(memcmp(properties->value.bin.v, value_expected, len_expected), 0);
CU_ASSERT_PTR_EQUAL(properties->next, NULL);
CU_ASSERT_EQUAL(property__get_length_all(properties), 1+2+len_expected);
property__free_all(&properties);
mosquitto_property_free_all(&properties);
}
CU_ASSERT_PTR_EQUAL(properties, NULL);
free(property.value.bin.v);
@ -256,7 +256,7 @@ static void string_pair_prop_write_helper(
CU_ASSERT_PTR_NULL(properties->next);
CU_ASSERT_EQUAL(property__get_length_all(properties), 1+2+strlen(name_expected)+2+strlen(value_expected));
}
property__free_all(&properties);
mosquitto_property_free_all(&properties);
}
CU_ASSERT_PTR_NULL(properties);
free(property.value.s.v);
@ -305,7 +305,7 @@ static void varint_prop_write_helper(
}else{
CU_FAIL("Incorrect varint value.");
}
property__free_all(&properties);
mosquitto_property_free_all(&properties);
}
CU_ASSERT_PTR_NULL(properties);
}

Loading…
Cancel
Save