Skip to content

Commit

Permalink
Rename property__free_all->mosquitto_property_free_all
Browse files Browse the repository at this point in the history
Make public function.
  • Loading branch information
ralight committed Oct 30, 2018
1 parent be5602b commit 9eebcf6
Show file tree
Hide file tree
Showing 22 changed files with 80 additions and 56 deletions.
2 changes: 1 addition & 1 deletion lib/handle_auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
4 changes: 2 additions & 2 deletions lib/handle_connack.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion lib/handle_pubackcomp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/handle_publish.c
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down
2 changes: 1 addition & 1 deletion lib/handle_pubrec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/handle_pubrel.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/handle_suback.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/handle_unsuback.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions lib/linker.version
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,5 @@ MOSQ_1.5 {
MOSQ_1.6 {
global:
mosquitto_subscribe_multiple;
mosquitto_property_free_all;
} MOSQ_1.5;
24 changes: 24 additions & 0 deletions lib/mosquitto.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ struct mosquitto_message{
};

struct mosquitto;
typedef struct mqtt5__property mosquitto_property;

/*
* Topic: Threads
Expand Down Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions lib/property_mosq.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}
}
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;

Expand Down
1 change: 0 additions & 1 deletion lib/property_mosq.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/context.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/database.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -661,7 +661,7 @@ int db__message_store(struct mosquitto_db *db, const char *source, uint16_t sour
mosquitto__free(temp->topic);
mosquitto__free(temp);
}
property__free_all(&properties);
mosquitto_property_free_all(&properties);
return rc;
}

Expand Down
2 changes: 1 addition & 1 deletion src/handle_auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
4 changes: 2 additions & 2 deletions src/handle_connack.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 6 additions & 6 deletions src/handle_connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -709,7 +709,7 @@ int handle__connect(struct mosquitto_db *db, struct mosquitto *context)
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
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/handle_publish.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/handle_subscribe.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/handle_unsubscribe.c
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down
Loading

0 comments on commit 9eebcf6

Please sign in to comment.