General library facilities

## General library facilities General library facilities — Startup and shutdown, memory handling, version checks and misc functions. |

## Synopsis

    typedef             rasqal_world;
    void                rasqal_free_world                   (rasqal_world *world);
    rasqal_world*       rasqal_new_world                    (void);
    extern              const unsigned int rasqal_version_decimal;
    extern              const unsigned int rasqal_version_major;
    extern              const unsigned int rasqal_version_minor;
    extern              const unsigned int rasqal_version_release;
    enum                rasqal_feature;
    int                 rasqal_language_name_check          (rasqal_world *world,
                                                             const char *name);
    int                 rasqal_languages_enumerate          (rasqal_world *world,
                                                             unsigned int counter,
                                                             const char **name,
                                                             const char **label,
                                                             unsigned char **uri_string);
    void*               rasqal_alloc_memory                 (size_t size);
    void*               rasqal_calloc_memory                (size_t nmemb,
                                                             size_t size);
    void                rasqal_free_memory                  (void *ptr);
    rasqal_feature      rasqal_feature_from_uri             (raptor_uri *uri);
    int                 rasqal_feature_value_type           (const rasqal_feature feature);
    int                 rasqal_features_enumerate           (const rasqal_feature feature,
                                                             const char **name,
                                                             raptor_uri **uri,
                                                             const char **label);
    unsigned int        rasqal_get_feature_count            (void);
    #define             RASQAL_DEPRECATED

## Description

The functions in this section cover general library features such as startup and shutdown, checking the current library version and dealing with memory allocation and freeing. It also provides functions to enumerate and check the supported query languages, their names, labels and URI.

## Details

### rasqal_world

    rasqal_world* world;

Rasqal world class.

### rasqal_free_world ()

    void                rasqal_free_world                   (rasqal_world *world);

Terminate the rasqal library.

Destroys a rasqal_world object and all static information.

`world` : | rasqal_world object

### rasqal_new_world ()

    rasqal_world*       rasqal_new_world                    (void);

Initialise the rasqal library.

Creates a rasqal_world object and initializes it.

The returned world object is used with subsequent rasqal API calls.

Returns : | rasqal_world object or NULL on failure

### rasqal_version_decimal

    extern const unsigned int rasqal_version_decimal;

Library full version as a decimal integer.

See also rasqal_version_string.

### rasqal_version_major

    extern const unsigned int rasqal_version_major;

Library major version number as a decimal integer.

### rasqal_version_minor

    extern const unsigned int rasqal_version_minor;

Library minor version number as a decimal integer.

### rasqal_version_release

    extern const unsigned int rasqal_version_release;

Library release version number as a decimal integer.

### enum rasqal_feature

    typedef enum {
      RASQAL_FEATURE_NO_NET,
      RASQAL_FEATURE_LAST = RASQAL_FEATURE_NO_NET
    } rasqal_feature;

Query features.

None currently defined.

`RASQAL_FEATURE_NO_NET` | Deny network requests.
`RASQAL_FEATURE_LAST` | Internal.

### rasqal_language_name_check ()

    int                 rasqal_language_name_check          (rasqal_world *world,
                                                             const char *name);

Check name of a query language.

`world` : | rasqal_world object
`name` : | the query language name
Returns : | non 0 if name is a known query language

### rasqal_languages_enumerate ()

    int                 rasqal_languages_enumerate          (rasqal_world *world,
                                                             unsigned int counter,
                                                             const char **name,
                                                             const char **label,
                                                             unsigned char **uri_string);

Get information on query languages.

`world` : | rasqal_world object
`counter` : | index into the list of syntaxes
`name` : | pointer to store the name of the syntax (or NULL)
`label` : | pointer to store syntax readable label (or NULL)
`uri_string` : | pointer to store syntax URI string (or NULL)
Returns : | non 0 on failure of if counter is out of range

### rasqal_alloc_memory ()

    void*               rasqal_alloc_memory                 (size_t size);

Allocate memory inside rasqal.

Some systems require memory allocated in a library to be deallocated in that library. This function allows memory to be allocated inside the rasqal shared library that can be freed inside rasqal either internally or via `rasqal_free_memory()`.

`size` : | size of memory to allocate
Returns : | the address of the allocated memory or NULL on failure

### rasqal_calloc_memory ()

    void*               rasqal_calloc_memory                (size_t nmemb,
                                                             size_t size);

Allocate zeroed array of items inside rasqal.

Some systems require memory allocated in a library to be deallocated in that library. This function allows memory to be allocated inside the rasqal shared library that can be freed inside rasqal either internally or via `rasqal_free_memory()`.

`nmemb` : | number of members
`size` : | size of item
Returns : | the address of the allocated memory or NULL on failure

### rasqal_free_memory ()

    void                rasqal_free_memory                  (void *ptr);

Free memory allocated inside rasqal.

Some systems require memory allocated in a library to be deallocated in that library. This function allows memory allocated by rasqal to be freed.

`ptr` : | memory pointer

### rasqal_feature_from_uri ()

    rasqal_feature      rasqal_feature_from_uri             (raptor_uri *uri);

Turn a feature URI into an feature enum.

The allowed feature URIs are available via `rasqal_features_enumerate()`.

`uri` : | feature URI
Returns : | < 0 if the feature is unknown

### rasqal_feature_value_type ()

    int                 rasqal_feature_value_type           (const rasqal_feature feature);

Get the type of a features.

The type of the `feature` is 0=integer , 1=string. Other values are undefined. Most features are integer values and use rasqal_query_set_feature `rasqal_query_get_feature()`

`feature` : | rasqal query feature
Returns : | the type of the feature or <0 if `feature` is unknown

### rasqal_features_enumerate ()

    int                 rasqal_features_enumerate           (const rasqal_feature feature,
                                                             const char **name,
                                                             raptor_uri **uri,
                                                             const char **label);

Get list of rasqal features.

If uri is not NULL, a pointer to a new raptor_uri is returned that must be freed by the caller with `raptor_free_uri()`.

`feature` : | feature enumeration (0+)
`name` : | pointer to store feature short name (or NULL)
`uri` : | pointer to store feature URI (or NULL)
`label` : | pointer to feature label (or NULL)
Returns : | 0 on success, <0 on failure, >0 if feature is unknown

### rasqal_get_feature_count ()

    unsigned int        rasqal_get_feature_count            (void);

Get the count of features defined.

This is prefered to the compile time-only symbol RASQAL_FEATURE_LAST and returns a count of the number of features which is RASQAL_FEATURE_LAST+1.

Returns : | count of features in the rasqal_feature enumeration

### RASQAL_DEPRECATED

    #define             RASQAL_DEPRECATED

When defined before a function, indicates that the function has been deprecated and may be replaced in a future release. With some versions of gcc this may give a compilation warning.