Initialize and uninitialize LibGII

Name

giiInit, giiExit, giiAttach, giiDetach : Initialize and uninitialize LibGII

Synopsis

#include <ggi/gii.h>

int giiInit(void);

int giiExit(void);

int giiAttach(struct gg_stem *);

int giiDetach(struct gg_stem *);

Description

In most cases, applications initialize libgii with:

stem = ggNewStem(libgii, NULL);

But if fine-grained control and error reporting is needed or this library should be optional at compile time, then initialize libgii with giiInit and giiAttach it onto a stem.

giiInit initializes the library. This function must be called before using other LibGII functions; otherwise the results will be undefined.

giiExit uninitializes the library (after being initialized by giiInit) and automatically cleanup if necessary. This should be called after an application is finished with the library. If any GGI functions are called after the library has been uninitialized, the results will be undefined.

giiInit allows multiple invocations. A reference count is maintained, and to completely uninitialize the library, giiExit must be called as many times as giiInit has been called beforehand.

giiAttach attaches libgii on the stem.

giiDetach detaches libgii from the stem.

Return value

The return codes for giiInit and giiExit are equivalent to ggInitAPI(3) and ggExitAPI(3).

The return codes for giiAttach and giiDetach are equivalent to ggAttach(3) and ggDetach(3).

Examples

Initialize and uninitialize LibGII:

struct gg_stem *stem;

stem = ggNewStem(NULL);
if (stem == NULL) {
  exit(EXIT_FAILURE);  /* could not create a stem */
}

if (giiInit() < 0) {
  exit(EXIT_FAILURE);  /* can't start! */
}

if (giiAttach(stem) < 0) {
  exit(EXIT_FAILURE);
}

/* Do some libgii stuff */    

giiDetach(stem);
giiExit();

ggDelStem(stem);

The alternative way:

struct gg_stem *stem;

stem = ggNewStem(libgii, NULL);
if (stem == NULL) {
  exit(EXIT_FAILURE);
}

ggDelStem(stem);

See Also