Skip to content

Commit

Permalink
Add function for checking init status
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnoStiefvater committed Jul 20, 2021
1 parent 4a18ae5 commit 79ea166
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
26 changes: 24 additions & 2 deletions util/mqtt.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@

#include "uuidutils.h" /* gvm_uuid_make */

#include <glib.h>

#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "lib mqtt"

Expand All @@ -58,6 +56,29 @@ typedef struct

static const char *global_server_uri = NULL;
static mqtt_t *global_mqtt_client = NULL;
static gboolean mqtt_initialized = FALSE;

/**
* @brief Set the global init status.
* @param Status Status of initialization.
*/
static void
mqtt_set_initialized_status (gboolean status)
{
mqtt_initialized = status;
}

/**
* @brief Get the global init status.
*
* @return Initialization status of mqtt handling.
*/
gboolean
mqtt_is_initialized ()
{
return mqtt_initialized;
}

/**
* @brief Set the global mqtt server URI.
Expand Down Expand Up @@ -324,6 +345,7 @@ mqtt_init (const char *server_uri)
mqtt_connect (mqtt, global_server_uri);

mqtt_set_global_client (mqtt);
mqtt_set_initialized_status (TRUE);

g_debug ("%s: end", __func__);
return 0;
Expand Down
4 changes: 4 additions & 0 deletions util/mqtt.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@
#define _GVM_MQTT_H

#include <MQTTClient.h>
#include <glib.h>

int
mqtt_init (const char *);

gboolean
mqtt_is_initialized ();

void
mqtt_reset ();

Expand Down

0 comments on commit 79ea166

Please sign in to comment.