Next: The players and the cards, Up: Programming with libtarot [Contents][Index]
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; }
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.
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.
Quit libtarot.
Query the version of the running libtarot.