Next: , Up: Programming with libtarot   [Contents][Index]


4.1 Basic initialization

First, let’s see how to initialize and quit the library.

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif /* HAVE_CONFIG_H */

#include <tarot.h>
#include <stdio.h>
#include <stdlib.h>

int
main ()
{
  /* The installation directories below are just an example. */
  tarot_set_datadir ("/usr/local/share");
  if (tarot_init ("/usr/local/share/locale") != 0)
    {
      fprintf (stderr, "Error: could not initialize libtarot.\n");
      return EXIT_FAILURE;
    }
  printf ("Welcome to libtarot!  The current version running is '%s'\n",
          tarot_libtarot_version ());
  tarot_quit ();
  return EXIT_SUCCESS;
}
Function: void tarot_set_datadir (const char *datadir)

Define the directory where the libtarot will look up architecture-independent data. This function should be called before ‘tarot_init’, otherwise you will not be able to call functions that were introduced after this function.

Function: int tarot_init (const char *localedir)

Initialize libtarot. The localization will use the localedir directory. Return 0 on success, or an error code. This function should be called before any other libtarot function, except the functions to set up the installation directories.

Function: void tarot_quit (void)

Quit libtarot.

Function: const char * tarot_libtarot_version (void)

Query the version of the running libtarot.