Bienvenue sur le site de la LibLapin.
Jetez un coup d'oeil en bas de la page pour choisir votre niveau de documentation en fonction de votre niveau avec la LibLapin.
Pour l'instant, c'est réglé sur 'Manuel complet'. Si c'est votre première fois avec la LibLapin, il vaudrait mieux choisir 'Débutant'.
De même, n'oubliez pas de préciser une version de la bibliothèque.

LibLapin's logo

LibLapin

Configuration





The configuration module header is lapin/configuration.h.
typedef enum e_bunny_configuration_type
{
     BC_INI,
     BC_DABSIC,
     BC_DABSIC_SEQUENCE,
     BC_DABSIC_FUNCTION,
     BC_DABSIC_EXPRESSION,
     BC_XML,
     BC_LUA,
     BC_CSV,
     BC_JSON,
     BC_LISP,
     BC_CUSTOM

} t‌_‌b‌u‌n‌n‌y‌_‌r‌g‌b;

Description

     This enumeration serves to precise the kind of grammar used into a file to load with b‌u‌n‌n‌y‌_‌l‌o‌a‌d‌_‌c‌o‌n‌f‌i‌g‌u‌r‌a‌t‌i‌o‌n.

Any value greater or equal to BC_CUSTOM trigger the call of g‌l‌_‌b‌u‌n‌n‌y‌_‌m‌y‌_‌r‌e‌a‌d‌_‌c‌o‌n‌f‌i‌g‌u‌r‌a‌t‌i‌o‌n instead of calling bunny library functions so you can extend the bunny library at runtime and still use its API.



INDEX





INDEX


Description

     Generate a configuration structure. It must be destroyed by b‌u‌n‌n‌y‌_‌d‌e‌l‌e‌t‌e‌_‌c‌o‌n‌f‌i‌g‌u‌r‌a‌t‌i‌o‌n.

Return value


Error values and logs

On error, $Vb‌u‌n‌n‌y‌_‌e‌r‌r‌n‌o is set to:


  • ENOMEM:

    Out of memory.


Logs written by this function are tagged with the "configuration" label.




INDEX


Description

     Generate a configuration structure from a file. The format of the file will be detected thanks to its extensions:
  • Dabsic file: .dab
  • INI file: .ini
  • Lisp file: .lisp
  • XML file: .xml
  • LUA file: .lua
  • CSV file: .csv
  • JSON file: .json
It must be destroyed by b‌u‌n‌n‌y‌_‌d‌e‌l‌e‌t‌e‌_‌c‌o‌n‌f‌i‌g‌u‌r‌a‌t‌i‌o‌n.

Parameters


Return value


Error values and logs

On error, $Vb‌u‌n‌n‌y‌_‌e‌r‌r‌n‌o is set to:


  • ENOMEM:

    Out of memory.


Logs written by this function are tagged with the "configuration" label.





INDEX


Description

     Generate a configuration structure from a file. It must be destroyed by b‌u‌n‌n‌y‌_‌d‌e‌l‌e‌t‌e‌_‌c‌o‌n‌f‌i‌g‌u‌r‌a‌t‌i‌o‌n.

Parameters


Return value


Error values and logs

On error, $Vb‌u‌n‌n‌y‌_‌e‌r‌r‌n‌o is set to:


  • ENOMEM:

    Out of memory.


Logs written by this function are tagged with the "configuration" label.




INDEX


Description

     Save the sent configuration structure into a file with the sent format.

Parameters


Return value

Returns true or false depending of the success or failure.


Error values and logs

On error, $Vb‌u‌n‌n‌y‌_‌e‌r‌r‌n‌o is set to:


  • ENOMEM:

    Out of memory.

  • Any errno value that can be set by open or write.

Logs written by this function are tagged with the "configuration" label.




INDEX


Description

     Generate a configuration structure from a string. It must be destroyed by b‌u‌n‌n‌y‌_‌d‌e‌l‌e‌t‌e‌_‌c‌o‌n‌f‌i‌g‌u‌r‌a‌t‌i‌o‌n.

Parameters


Return value


Error values and logs

On error, $Vb‌u‌n‌n‌y‌_‌e‌r‌r‌n‌o is set to:


  • ENOMEM:

    Out of memory.


Logs written by this function are tagged with the "configuration" label.




INDEX



Parameters




INDEX

Description

     When set, this function pointer is called by loading and reading configuration functions when the sent type of grammar is BC_CUSTOM or greater.



INDEX


Description

     Generate a string containing a written configuration that match the sent grammar and the sent configuration.

Parameters


Return value

  • On success, the function returns a string containing the generated configuration.
  • On failure, it returns NULL.

Error values and logs

On error, $Vb‌u‌n‌n‌y‌_‌e‌r‌r‌n‌o is set to:


  • ENOMEM:

    Out of memory.


Logs written by this function are tagged with the "configuration" label.




INDEX



Parameters




INDEX

Description

     When set, this function pointer is called by saving and writing configuration functions when the sent type of grammar is BC_CUSTOM or greater.



INDEX


Description

     Delete the sent configuration.

Parameters




INDEX


Description

     Delete the node at the sent address in the sent configuration. All children of this node will be destroyed as well.

Parameters




INDEX


Description

     Switch to read/write mode or to read/write/create mode. While being in create mode, nodes are automatically generated when accessed. While being in read/write mode, values can only be read or written, but nodes cannot be created.

Parameters

  • bool cmode:
         Switch to create mode or to readwrite mode.



INDEX


Description

     Get the parent node of the sent configuration node.


Return value

Returns the parent node or NULL if there is none.




INDEX


Description

     Get the root node of the sent configuration node.


Return value

Returns the root node. It can be the sent node.




INDEX


Description

     Get the name of the sent node.


Return value

Returns the name of the sent node.




INDEX


Description

     Get the address of the sent node. '.' is the character that signals a hashmap entering. '[' and ']' signals an array index.


Return value

Returns the address of the sent node. "" is the sent node is the root one.




INDEX


Description

     Return the first children node of the sent one.

Parameters


Return value

Returns the first children of configuration, it may be b‌u‌n‌n‌y‌_‌c‌o‌n‌f‌i‌g‌u‌r‌a‌t‌i‌o‌n‌_‌e‌n‌d(configuration), that would means the sent node is empty.




INDEX


Description

     Return the next children of the parent of configuration.

Parameters


Return value

Returns the next children of the parent of configuration, it may be b‌u‌n‌n‌y‌_‌c‌o‌n‌f‌i‌g‌u‌r‌a‌t‌i‌o‌n‌_‌e‌n‌d(configuration), that would means the current node is the last one.




INDEX


Description

     Return NULL.

Parameters


Return value

Returns NULL.




INDEX


Description

     Return if the sent node is the last existing children of its father.

Parameters


Return value

Returns true or false if the node is the last one or not.




INDEX


Description

     Return the type of the sent file, after its extension.
  • Dabsic file: .dab
  • INI file: .ini
  • Lisp file: .lisp
  • XML file: .xml
  • LUA file: .lua
  • CSV file: .csv
  • JSON file: .json

Parameters


Return value

Returns the found type or BC_CUSTOM if no handled format is found.



INDEX


Description

     Add a research directory to the include/insert directive resolution. The path container act as a stack so the last inserted give priority.

Parameters

  • const char *path:
         A directory to add.


INDEX


Description

     Remove the most recently added path from the path stack.


INDEX


Description

     Get a data inside the configuration tree. The address of the node is composed in a printf fashion with the pattern and variadic parameters.

This macro is only available if you are using C11 or a newer version of C. C++ does not support this macro.
Underlying functions, that you must use if you cannot use the macro, are:

Parameters


Return value

Returns true if a value was stored inside storage_space or false if it was not.





INDEX


Description

     Set a data inside the configuration tree. The address of the node is composed in a printf fashion with the pattern and variadic parameters.


This macro is only available if you are using C11 or a newer version of C. C++ does not support this macro.
Underlying functions, that you must use if you cannot use the macro, are:

Parameters


Return value

Returns true if the value was stored inside the tree or false if it was not.





INDEX


Description

     Get how many nodes are immediate children of the node at the sent address.

Parameters


Return value

Returns the amount of children the found node have. It returns -1 if the node does not exist.




INDEX


Description

     Get how many cases there is inside the array of the node at the sent address.

Parameters


Return value

Returns the length of the arrya of the found node. It returns -1 if the node does not exist.




INDEX


Description

     Execute scripts and expressions located at the sent address from the sent node or behind.
Every scripts and expressions will be executed.
They will consider the root of the sent node as the root context.
The local context as the one containing local variables.
The parameter context as the sent one for parameters.
The artifical context is the context where the node at the sent address is located, but can be modified by the "with" statement.

Parameters


Return value

  • On success, the function was correctly executed. The result of the operation can be found in nodes themselves. It returns true.
  • On failure, it returns false.

Error values and logs

Many error logs can happen when executing a script and a lot of them may not be related to the script execution itself but about what is executed. A simple error value is not enough to signify enough information, a look at logs is required.

Logs written by this function are tagged with the "syntax" label.



INDEX