Initialization

Initialization — Initialization and cleanup of Libdexter

Synopsis

#include <dexter.h>

#define             DEXTER_TLS_ENABLED

#define             DEXTER_ERROR
enum                DexterError;

enum                DexterState;

gboolean            dexter_init                         (const gchar *config,
                                                         GError **error);
void                dexter_exit                         (void);
gint                dexter_get_state                    (void);

Description

Libdexter must be initialized with dexter_init() prior to use.

This function causes Libdexter to read the configuration file; load the specified plugins and register authorized services; initialize the thread pool and set up the interfaces needed for plugins to interact with the library.

When you are done using Libdexter, you should issue dexter_exit() to free up the resources it uses; shutdown its thread pool, etc.

Example of how to initialize and shutdown Libdexter:

#include <dexter.h>

GError    *local_error = NULL;

/* Init the library from a default configuration file. */
dexter_init (NULL, &local_error);
if (local_error) {
    /* deal with error */
    g_error ("failed to init libdexter: %s", local_error->message);
}

/* ----------------
   Use the library.
   ---------------- */
...

/* Release library resources. */
dexter_exit();
...

Details

DEXTER_TLS_ENABLED

#define DEXTER_TLS_ENABLED

This macro is defined if TLS is enabled on this installation of Libdexter.

Since 0.2.0


DEXTER_ERROR

#define DEXTER_ERROR dexter_error_quark()

The error domain of the libdexter initialization subsystem.


enum DexterError

typedef enum {
  DEXTER_ERROR_NO_CONFIG_FILE,
  DEXTER_ERROR_MODULES_NOT_SUPPORTED,
  DEXTER_ERROR_NOT_ABSOLUTE_PATH,
  DEXTER_ERROR_FAILED
} DexterError;

Error codes for dexter operations.

DEXTER_ERROR_NO_CONFIG_FILE

no configuration file was indicated or found.

DEXTER_ERROR_MODULES_NOT_SUPPORTED

installation does not support loadable modules.

DEXTER_ERROR_NOT_ABSOLUTE_PATH

operation requires specification of an absolute path.

DEXTER_ERROR_FAILED

other failure.

enum DexterState

typedef enum {
  DEXTER_STATE_UP,
  DEXTER_STATE_STARTING,
  DEXTER_STATE_STOPPING,
  DEXTER_STATE_DOWN
} DexterState;

All possible states for the Libdexter library.

DEXTER_STATE_UP

the library is up and available for use.

DEXTER_STATE_STARTING

the library is starting, i.e. dexter_init() is in progress.

DEXTER_STATE_STOPPING

the library is shutting down, i.e. dexter_exit() is in progress.

DEXTER_STATE_DOWN

the library is down and not available for use.

dexter_init ()

gboolean            dexter_init                         (const gchar *config,
                                                         GError **error);

Initialize libdexter using the indicated config file. If NULL is specified for config, the library will try to use:

$HOME/.dexterrc or /etc/libdexter/dexter.conf, in that order.

config :

full path to config file or NULL for library defaults

error :

return location for optional GError

Returns :

a gboolean indicating success or failure.

dexter_exit ()

void                dexter_exit                         (void);

Shuts down libdexter and frees its resources.

Note: Do not issue dexter_exit() from within any asynchronous callback generated by the library.


dexter_get_state ()

gint                dexter_get_state                    (void);

Returns the current state of the Libdexter library.

Returns :

gint from DexterState indicating current state of the library.

Since 0.1.3