Commit 149a9ea2 authored by Ian Craggs's avatar Ian Craggs

Change global init parameter to structure, issue #136

parent dd6f1b7c
......@@ -66,10 +66,10 @@
const char *client_timestamp_eye = "MQTTAsyncV3_Timestamp " BUILD_TIMESTAMP;
const char *client_version_eye = "MQTTAsyncV3_Version " CLIENT_VERSION;
void MQTTAsync_global_init(int handle_openssl_init)
void MQTTAsync_global_init(MQTTAsync_init_options* inits)
{
#if defined(OPENSSL)
SSLSocket_handleOpensslInit(handle_openssl_init);
SSLSocket_handleOpensslInit(inits->do_openssl_init);
#endif
}
......
......@@ -184,12 +184,27 @@
*/
#define MQTT_BAD_SUBSCRIBE 0x80
/**
* Initialization options
*/
typedef struct
{
/** The eyecatcher for this structure. Must be MQTG. */
char struct_id[4];
/** The version number of this structure. Must be 0 */
int struct_version;
/** 1 = we do openssl init, 0 = leave it to the application */
int do_openssl_init;
} MQTTAsync_init_options;
#define MQTTAsync_init_options_initializer { {'M', 'Q', 'T', 'G'}, 0, 0 }
/**
* Global init of mqtt library. Call once on program start to set global behaviour.
* handle_openssl_init - if mqtt library should handle openssl init (1) or rely on the caller to init it before using mqtt (0)
*/
void MQTTAsync_global_init(int handle_openssl_init);
void MQTTAsync_global_init(MQTTAsync_init_options* inits);
/**
* A handle representing an MQTT client. A valid client handle is available
......
......@@ -73,10 +73,10 @@
const char *client_timestamp_eye = "MQTTClientV3_Timestamp " BUILD_TIMESTAMP;
const char *client_version_eye = "MQTTClientV3_Version " CLIENT_VERSION;
void MQTTClient_global_init(int handle_openssl_init)
void MQTTClient_global_init(MQTTClient_init_options* inits)
{
#if defined(OPENSSL)
SSLSocket_handleOpensslInit(handle_openssl_init);
SSLSocket_handleOpensslInit(inits->do_openssl_init);
#endif
}
......
......@@ -189,11 +189,26 @@
*/
#define MQTT_BAD_SUBSCRIBE 0x80
/**
* Initialization options
*/
typedef struct
{
/** The eyecatcher for this structure. Must be MQTG. */
char struct_id[4];
/** The version number of this structure. Must be 0 */
int struct_version;
/** 1 = we do openssl init, 0 = leave it to the application */
int do_openssl_init;
} MQTTClient_init_options;
#define MQTTClient_init_options_initializer { {'M', 'Q', 'T', 'G'}, 0, 0 }
/**
* Global init of mqtt library. Call once on program start to set global behaviour.
* handle_openssl_init - if mqtt library should handle openssl init (1) or rely on the caller to init it before using mqtt (0)
* do_openssl_init - if mqtt library should initialize OpenSSL (1) or rely on the caller to do it before using the library (0)
*/
void MQTTClient_global_init(int handle_openssl_init);
void MQTTClient_global_init(MQTTClient_init_options* inits);
/**
* A handle representing an MQTT client. A valid client handle is available
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment