Skip to content

Commit

Permalink
mosquitto__log_printf -> log__printf
Browse files Browse the repository at this point in the history
  • Loading branch information
ralight committed May 18, 2015
1 parent b67c90e commit 21946ac
Show file tree
Hide file tree
Showing 28 changed files with 448 additions and 443 deletions.
2 changes: 1 addition & 1 deletion lib/logging_mosq.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ and the Eclipse Distribution License is available at
#include "mosquitto.h"
#include "memory_mosq.h"

int mosquitto__log_printf(struct mosquitto *mosq, int priority, const char *fmt, ...)
int log__printf(struct mosquitto *mosq, int priority, const char *fmt, ...)
{
va_list va;
char *s;
Expand Down
2 changes: 1 addition & 1 deletion lib/logging_mosq.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ and the Eclipse Distribution License is available at

#include "mosquitto.h"

int mosquitto__log_printf(struct mosquitto *mosq, int priority, const char *fmt, ...);
int log__printf(struct mosquitto *mosq, int priority, const char *fmt, ...);

#endif
2 changes: 1 addition & 1 deletion lib/mosquitto.c
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ static int mosquitto__connect_init(struct mosquitto *mosq, const char *host, int
mosq->keepalive = keepalive;

if(mosquitto__socketpair(&mosq->sockpairR, &mosq->sockpairW)){
mosquitto__log_printf(mosq, MOSQ_LOG_WARNING,
log__printf(mosq, MOSQ_LOG_WARNING,
"Warning: Unable to open socket pair, outgoing publish commands may be delayed.");
}

Expand Down
34 changes: 17 additions & 17 deletions lib/net_mosq.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,21 +355,21 @@ int mosquitto__socket_connect(struct mosquitto *mosq, const char *host, uint16_t
}else if(!strcmp(mosq->tls_version, "tlsv1")){
mosq->ssl_ctx = SSL_CTX_new(TLSv1_client_method());
}else{
mosquitto__log_printf(mosq, MOSQ_LOG_ERR, "Error: Protocol %s not supported.", mosq->tls_version);
log__printf(mosq, MOSQ_LOG_ERR, "Error: Protocol %s not supported.", mosq->tls_version);
COMPAT_CLOSE(sock);
return MOSQ_ERR_INVAL;
}
#else
if(!mosq->tls_version || !strcmp(mosq->tls_version, "tlsv1")){
mosq->ssl_ctx = SSL_CTX_new(TLSv1_client_method());
}else{
mosquitto__log_printf(mosq, MOSQ_LOG_ERR, "Error: Protocol %s not supported.", mosq->tls_version);
log__printf(mosq, MOSQ_LOG_ERR, "Error: Protocol %s not supported.", mosq->tls_version);
COMPAT_CLOSE(sock);
return MOSQ_ERR_INVAL;
}
#endif
if(!mosq->ssl_ctx){
mosquitto__log_printf(mosq, MOSQ_LOG_ERR, "Error: Unable to create TLS context.");
log__printf(mosq, MOSQ_LOG_ERR, "Error: Unable to create TLS context.");
COMPAT_CLOSE(sock);
return MOSQ_ERR_TLS;
}
Expand All @@ -386,7 +386,7 @@ int mosquitto__socket_connect(struct mosquitto *mosq, const char *host, uint16_t
if(mosq->tls_ciphers){
ret = SSL_CTX_set_cipher_list(mosq->ssl_ctx, mosq->tls_ciphers);
if(ret == 0){
mosquitto__log_printf(mosq, MOSQ_LOG_ERR, "Error: Unable to set TLS ciphers. Check cipher list \"%s\".", mosq->tls_ciphers);
log__printf(mosq, MOSQ_LOG_ERR, "Error: Unable to set TLS ciphers. Check cipher list \"%s\".", mosq->tls_ciphers);
COMPAT_CLOSE(sock);
return MOSQ_ERR_TLS;
}
Expand All @@ -396,19 +396,19 @@ int mosquitto__socket_connect(struct mosquitto *mosq, const char *host, uint16_t
if(ret == 0){
#ifdef WITH_BROKER
if(mosq->tls_cafile && mosq->tls_capath){
mosquitto__log_printf(mosq, MOSQ_LOG_ERR, "Error: Unable to load CA certificates, check bridge_cafile \"%s\" and bridge_capath \"%s\".", mosq->tls_cafile, mosq->tls_capath);
log__printf(mosq, MOSQ_LOG_ERR, "Error: Unable to load CA certificates, check bridge_cafile \"%s\" and bridge_capath \"%s\".", mosq->tls_cafile, mosq->tls_capath);
}else if(mosq->tls_cafile){
mosquitto__log_printf(mosq, MOSQ_LOG_ERR, "Error: Unable to load CA certificates, check bridge_cafile \"%s\".", mosq->tls_cafile);
log__printf(mosq, MOSQ_LOG_ERR, "Error: Unable to load CA certificates, check bridge_cafile \"%s\".", mosq->tls_cafile);
}else{
mosquitto__log_printf(mosq, MOSQ_LOG_ERR, "Error: Unable to load CA certificates, check bridge_capath \"%s\".", mosq->tls_capath);
log__printf(mosq, MOSQ_LOG_ERR, "Error: Unable to load CA certificates, check bridge_capath \"%s\".", mosq->tls_capath);
}
#else
if(mosq->tls_cafile && mosq->tls_capath){
mosquitto__log_printf(mosq, MOSQ_LOG_ERR, "Error: Unable to load CA certificates, check cafile \"%s\" and capath \"%s\".", mosq->tls_cafile, mosq->tls_capath);
log__printf(mosq, MOSQ_LOG_ERR, "Error: Unable to load CA certificates, check cafile \"%s\" and capath \"%s\".", mosq->tls_cafile, mosq->tls_capath);
}else if(mosq->tls_cafile){
mosquitto__log_printf(mosq, MOSQ_LOG_ERR, "Error: Unable to load CA certificates, check cafile \"%s\".", mosq->tls_cafile);
log__printf(mosq, MOSQ_LOG_ERR, "Error: Unable to load CA certificates, check cafile \"%s\".", mosq->tls_cafile);
}else{
mosquitto__log_printf(mosq, MOSQ_LOG_ERR, "Error: Unable to load CA certificates, check capath \"%s\".", mosq->tls_capath);
log__printf(mosq, MOSQ_LOG_ERR, "Error: Unable to load CA certificates, check capath \"%s\".", mosq->tls_capath);
}
#endif
COMPAT_CLOSE(sock);
Expand All @@ -429,9 +429,9 @@ int mosquitto__socket_connect(struct mosquitto *mosq, const char *host, uint16_t
ret = SSL_CTX_use_certificate_chain_file(mosq->ssl_ctx, mosq->tls_certfile);
if(ret != 1){
#ifdef WITH_BROKER
mosquitto__log_printf(mosq, MOSQ_LOG_ERR, "Error: Unable to load client certificate, check bridge_certfile \"%s\".", mosq->tls_certfile);
log__printf(mosq, MOSQ_LOG_ERR, "Error: Unable to load client certificate, check bridge_certfile \"%s\".", mosq->tls_certfile);
#else
mosquitto__log_printf(mosq, MOSQ_LOG_ERR, "Error: Unable to load client certificate \"%s\".", mosq->tls_certfile);
log__printf(mosq, MOSQ_LOG_ERR, "Error: Unable to load client certificate \"%s\".", mosq->tls_certfile);
#endif
COMPAT_CLOSE(sock);
return MOSQ_ERR_TLS;
Expand All @@ -441,16 +441,16 @@ int mosquitto__socket_connect(struct mosquitto *mosq, const char *host, uint16_t
ret = SSL_CTX_use_PrivateKey_file(mosq->ssl_ctx, mosq->tls_keyfile, SSL_FILETYPE_PEM);
if(ret != 1){
#ifdef WITH_BROKER
mosquitto__log_printf(mosq, MOSQ_LOG_ERR, "Error: Unable to load client key file, check bridge_keyfile \"%s\".", mosq->tls_keyfile);
log__printf(mosq, MOSQ_LOG_ERR, "Error: Unable to load client key file, check bridge_keyfile \"%s\".", mosq->tls_keyfile);
#else
mosquitto__log_printf(mosq, MOSQ_LOG_ERR, "Error: Unable to load client key file \"%s\".", mosq->tls_keyfile);
log__printf(mosq, MOSQ_LOG_ERR, "Error: Unable to load client key file \"%s\".", mosq->tls_keyfile);
#endif
COMPAT_CLOSE(sock);
return MOSQ_ERR_TLS;
}
ret = SSL_CTX_check_private_key(mosq->ssl_ctx);
if(ret != 1){
mosquitto__log_printf(mosq, MOSQ_LOG_ERR, "Error: Client certificate/key are inconsistent.");
log__printf(mosq, MOSQ_LOG_ERR, "Error: Client certificate/key are inconsistent.");
COMPAT_CLOSE(sock);
return MOSQ_ERR_TLS;
}
Expand Down Expand Up @@ -513,7 +513,7 @@ ssize_t mosquitto__net_read(struct mosquitto *mosq, void *buf, size_t count)
}else{
e = ERR_get_error();
while(e){
mosquitto__log_printf(mosq, MOSQ_LOG_ERR, "OpenSSL Error: %s", ERR_error_string(e, ebuf));
log__printf(mosq, MOSQ_LOG_ERR, "OpenSSL Error: %s", ERR_error_string(e, ebuf));
e = ERR_get_error();
}
errno = EPROTO;
Expand Down Expand Up @@ -562,7 +562,7 @@ ssize_t mosquitto__net_write(struct mosquitto *mosq, void *buf, size_t count)
}else{
e = ERR_get_error();
while(e){
mosquitto__log_printf(mosq, MOSQ_LOG_ERR, "OpenSSL Error: %s", ERR_error_string(e, ebuf));
log__printf(mosq, MOSQ_LOG_ERR, "OpenSSL Error: %s", ERR_error_string(e, ebuf));
e = ERR_get_error();
}
errno = EPROTO;
Expand Down
4 changes: 2 additions & 2 deletions lib/read_handle.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ int mosquitto__packet_handle(struct mosquitto *mosq)
return handle__unsuback(mosq);
default:
/* If we don't recognise the command, return an error straight away. */
mosquitto__log_printf(mosq, MOSQ_LOG_ERR, "Error: Unrecognised command %d\n", (mosq->in_packet.command)&0xF0);
log__printf(mosq, MOSQ_LOG_ERR, "Error: Unrecognised command %d\n", (mosq->in_packet.command)&0xF0);
return MOSQ_ERR_PROTOCOL;
}
}
Expand Down Expand Up @@ -112,7 +112,7 @@ int handle__publish(struct mosquitto *mosq)
return rc;
}
}
mosquitto__log_printf(mosq, MOSQ_LOG_DEBUG,
log__printf(mosq, MOSQ_LOG_DEBUG,
"Client %s received PUBLISH (d%d, q%d, r%d, m%d, '%s', ... (%ld bytes))",
mosq->id, message->dup, message->msg.qos, message->msg.retain,
message->msg.mid, message->msg.topic,
Expand Down
2 changes: 1 addition & 1 deletion lib/read_handle_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ int handle__connack(struct mosquitto *mosq)
int rc;

assert(mosq);
mosquitto__log_printf(mosq, MOSQ_LOG_DEBUG, "Client %s received CONNACK", mosq->id);
log__printf(mosq, MOSQ_LOG_DEBUG, "Client %s received CONNACK", mosq->id);
rc = packet__read_byte(&mosq->in_packet, &byte); // Reserved byte, not used
if(rc) return rc;
rc = packet__read_byte(&mosq->in_packet, &result);
Expand Down
28 changes: 14 additions & 14 deletions lib/read_handle_shared.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ int handle__pingreq(struct mosquitto *mosq)
{
assert(mosq);
#ifdef WITH_BROKER
mosquitto__log_printf(NULL, MOSQ_LOG_DEBUG, "Received PINGREQ from %s", mosq->id);
log__printf(NULL, MOSQ_LOG_DEBUG, "Received PINGREQ from %s", mosq->id);
#else
mosquitto__log_printf(mosq, MOSQ_LOG_DEBUG, "Client %s received PINGREQ", mosq->id);
log__printf(mosq, MOSQ_LOG_DEBUG, "Client %s received PINGREQ", mosq->id);
#endif
return send__pingresp(mosq);
}
Expand All @@ -48,9 +48,9 @@ int handle__pingresp(struct mosquitto *mosq)
assert(mosq);
mosq->ping_t = 0; /* No longer waiting for a PINGRESP. */
#ifdef WITH_BROKER
mosquitto__log_printf(NULL, MOSQ_LOG_DEBUG, "Received PINGRESP from %s", mosq->id);
log__printf(NULL, MOSQ_LOG_DEBUG, "Received PINGRESP from %s", mosq->id);
#else
mosquitto__log_printf(mosq, MOSQ_LOG_DEBUG, "Client %s received PINGRESP", mosq->id);
log__printf(mosq, MOSQ_LOG_DEBUG, "Client %s received PINGRESP", mosq->id);
#endif
return MOSQ_ERR_SUCCESS;
}
Expand All @@ -68,14 +68,14 @@ int handle__pubackcomp(struct mosquitto *mosq, const char *type)
rc = packet__read_uint16(&mosq->in_packet, &mid);
if(rc) return rc;
#ifdef WITH_BROKER
mosquitto__log_printf(NULL, MOSQ_LOG_DEBUG, "Received %s from %s (Mid: %d)", type, mosq->id, mid);
log__printf(NULL, MOSQ_LOG_DEBUG, "Received %s from %s (Mid: %d)", type, mosq->id, mid);

if(mid){
rc = db__message_delete(db, mosq, mid, mosq_md_out);
if(rc) return rc;
}
#else
mosquitto__log_printf(mosq, MOSQ_LOG_DEBUG, "Client %s received %s (Mid: %d)", mosq->id, type, mid);
log__printf(mosq, MOSQ_LOG_DEBUG, "Client %s received %s (Mid: %d)", mosq->id, type, mid);

if(!message__delete(mosq, mid, mosq_md_out)){
/* Only inform the client the message has been sent once. */
Expand All @@ -101,11 +101,11 @@ int handle__pubrec(struct mosquitto *mosq)
rc = packet__read_uint16(&mosq->in_packet, &mid);
if(rc) return rc;
#ifdef WITH_BROKER
mosquitto__log_printf(NULL, MOSQ_LOG_DEBUG, "Received PUBREC from %s (Mid: %d)", mosq->id, mid);
log__printf(NULL, MOSQ_LOG_DEBUG, "Received PUBREC from %s (Mid: %d)", mosq->id, mid);

rc = db__message_update(mosq, mid, mosq_md_out, mosq_ms_wait_for_pubcomp);
#else
mosquitto__log_printf(mosq, MOSQ_LOG_DEBUG, "Client %s received PUBREC (Mid: %d)", mosq->id, mid);
log__printf(mosq, MOSQ_LOG_DEBUG, "Client %s received PUBREC (Mid: %d)", mosq->id, mid);

rc = message__out_update(mosq, mid, mosq_ms_wait_for_pubcomp);
#endif
Expand Down Expand Up @@ -133,14 +133,14 @@ int handle__pubrel(struct mosquitto_db *db, struct mosquitto *mosq)
rc = packet__read_uint16(&mosq->in_packet, &mid);
if(rc) return rc;
#ifdef WITH_BROKER
mosquitto__log_printf(NULL, MOSQ_LOG_DEBUG, "Received PUBREL from %s (Mid: %d)", mosq->id, mid);
log__printf(NULL, MOSQ_LOG_DEBUG, "Received PUBREL from %s (Mid: %d)", mosq->id, mid);

if(db__message_release(db, mosq, mid, mosq_md_in)){
/* Message not found. Still send a PUBCOMP anyway because this could be
* due to a repeated PUBREL after a client has reconnected. */
}
#else
mosquitto__log_printf(mosq, MOSQ_LOG_DEBUG, "Client %s received PUBREL (Mid: %d)", mosq->id, mid);
log__printf(mosq, MOSQ_LOG_DEBUG, "Client %s received PUBREL (Mid: %d)", mosq->id, mid);

if(!message__remove(mosq, mid, mosq_md_in, &message)){
/* Only pass the message on if we have removed it from the queue - this
Expand Down Expand Up @@ -172,9 +172,9 @@ int handle__suback(struct mosquitto *mosq)

assert(mosq);
#ifdef WITH_BROKER
mosquitto__log_printf(NULL, MOSQ_LOG_DEBUG, "Received SUBACK from %s", mosq->id);
log__printf(NULL, MOSQ_LOG_DEBUG, "Received SUBACK from %s", mosq->id);
#else
mosquitto__log_printf(mosq, MOSQ_LOG_DEBUG, "Client %s received SUBACK", mosq->id);
log__printf(mosq, MOSQ_LOG_DEBUG, "Client %s received SUBACK", mosq->id);
#endif
rc = packet__read_uint16(&mosq->in_packet, &mid);
if(rc) return rc;
Expand Down Expand Up @@ -212,9 +212,9 @@ int handle__unsuback(struct mosquitto *mosq)

assert(mosq);
#ifdef WITH_BROKER
mosquitto__log_printf(NULL, MOSQ_LOG_DEBUG, "Received UNSUBACK from %s", mosq->id);
log__printf(NULL, MOSQ_LOG_DEBUG, "Received UNSUBACK from %s", mosq->id);
#else
mosquitto__log_printf(mosq, MOSQ_LOG_DEBUG, "Client %s received UNSUBACK", mosq->id);
log__printf(mosq, MOSQ_LOG_DEBUG, "Client %s received UNSUBACK", mosq->id);
#endif
rc = packet__read_uint16(&mosq->in_packet, &mid);
if(rc) return rc;
Expand Down
16 changes: 8 additions & 8 deletions lib/send_client_mosq.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,10 @@ int send__connect(struct mosquitto *mosq, uint16_t keepalive, bool clean_session
mosq->keepalive = keepalive;
#ifdef WITH_BROKER
# ifdef WITH_BRIDGE
mosquitto__log_printf(mosq, MOSQ_LOG_DEBUG, "Bridge %s sending CONNECT", clientid);
log__printf(mosq, MOSQ_LOG_DEBUG, "Bridge %s sending CONNECT", clientid);
# endif
#else
mosquitto__log_printf(mosq, MOSQ_LOG_DEBUG, "Client %s sending CONNECT", clientid);
log__printf(mosq, MOSQ_LOG_DEBUG, "Client %s sending CONNECT", clientid);
#endif
return packet__queue(mosq, packet);
}
Expand All @@ -153,10 +153,10 @@ int send__disconnect(struct mosquitto *mosq)
assert(mosq);
#ifdef WITH_BROKER
# ifdef WITH_BRIDGE
mosquitto__log_printf(mosq, MOSQ_LOG_DEBUG, "Bridge %s sending DISCONNECT", mosq->id);
log__printf(mosq, MOSQ_LOG_DEBUG, "Bridge %s sending DISCONNECT", mosq->id);
# endif
#else
mosquitto__log_printf(mosq, MOSQ_LOG_DEBUG, "Client %s sending DISCONNECT", mosq->id);
log__printf(mosq, MOSQ_LOG_DEBUG, "Client %s sending DISCONNECT", mosq->id);
#endif
return send__simple_command(mosq, DISCONNECT);
}
Expand Down Expand Up @@ -196,10 +196,10 @@ int send__subscribe(struct mosquitto *mosq, int *mid, const char *topic, uint8_t

#ifdef WITH_BROKER
# ifdef WITH_BRIDGE
mosquitto__log_printf(mosq, MOSQ_LOG_DEBUG, "Bridge %s sending SUBSCRIBE (Mid: %d, Topic: %s, QoS: %d)", mosq->id, local_mid, topic, topic_qos);
log__printf(mosq, MOSQ_LOG_DEBUG, "Bridge %s sending SUBSCRIBE (Mid: %d, Topic: %s, QoS: %d)", mosq->id, local_mid, topic, topic_qos);
# endif
#else
mosquitto__log_printf(mosq, MOSQ_LOG_DEBUG, "Client %s sending SUBSCRIBE (Mid: %d, Topic: %s, QoS: %d)", mosq->id, local_mid, topic, topic_qos);
log__printf(mosq, MOSQ_LOG_DEBUG, "Client %s sending SUBSCRIBE (Mid: %d, Topic: %s, QoS: %d)", mosq->id, local_mid, topic, topic_qos);
#endif

return packet__queue(mosq, packet);
Expand Down Expand Up @@ -240,10 +240,10 @@ int send__unsubscribe(struct mosquitto *mosq, int *mid, const char *topic)

#ifdef WITH_BROKER
# ifdef WITH_BRIDGE
mosquitto__log_printf(mosq, MOSQ_LOG_DEBUG, "Bridge %s sending UNSUBSCRIBE (Mid: %d, Topic: %s)", mosq->id, local_mid, topic);
log__printf(mosq, MOSQ_LOG_DEBUG, "Bridge %s sending UNSUBSCRIBE (Mid: %d, Topic: %s)", mosq->id, local_mid, topic);
# endif
#else
mosquitto__log_printf(mosq, MOSQ_LOG_DEBUG, "Client %s sending UNSUBSCRIBE (Mid: %d, Topic: %s)", mosq->id, local_mid, topic);
log__printf(mosq, MOSQ_LOG_DEBUG, "Client %s sending UNSUBSCRIBE (Mid: %d, Topic: %s)", mosq->id, local_mid, topic);
#endif
return packet__queue(mosq, packet);
}
Expand Down
Loading

0 comments on commit 21946ac

Please sign in to comment.