|
Libecoli 0.11.3
Extensible COmmand LIne library
|
Configure nodes behavior through generic API. More...
Data Structures | |
| struct | ec_config_schema |
| struct | ec_config |
Enumerations | |
| enum | ec_config_type { EC_CONFIG_TYPE_NONE = 0 , EC_CONFIG_TYPE_BOOL , EC_CONFIG_TYPE_INT64 , EC_CONFIG_TYPE_UINT64 , EC_CONFIG_TYPE_STRING , EC_CONFIG_TYPE_NODE , EC_CONFIG_TYPE_LIST , EC_CONFIG_TYPE_DICT } |
| enum | ec_config_flags { EC_CONFIG_F_MANDATORY = 1 << 0 } |
Functions | |
| int | ec_config_schema_validate (const struct ec_config_schema *schema) |
| void | ec_config_schema_dump (FILE *out, const struct ec_config_schema *schema, const char *name) |
| const struct ec_config_schema * | ec_config_schema_lookup (const struct ec_config_schema *schema, const char *key) |
| enum ec_config_type | ec_config_schema_type (const struct ec_config_schema *schema_elt) |
| const struct ec_config_schema * | ec_config_schema_sub (const struct ec_config_schema *schema_elt) |
| bool | ec_config_key_is_reserved (const char *name) |
| enum ec_config_type | ec_config_get_type (const struct ec_config *config) |
| struct ec_config * | ec_config_bool (bool boolean) |
| struct ec_config * | ec_config_i64 (int64_t i64) |
| struct ec_config * | ec_config_u64 (uint64_t u64) |
| struct ec_config * | ec_config_string (const char *string) |
| struct ec_config * | ec_config_node (struct ec_node *node) |
| struct ec_config * | ec_config_dict (void) |
| struct ec_config * | ec_config_list (void) |
| int | ec_config_list_add (struct ec_config *list, struct ec_config *value) |
| int | ec_config_list_del (struct ec_config *list, struct ec_config *config) |
| ssize_t | ec_config_count (const struct ec_config *config) |
| int | ec_config_validate (const struct ec_config *dict, const struct ec_config_schema *schema) |
| int | ec_config_dict_set (struct ec_config *dict, const char *key, struct ec_config *value) |
| int | ec_config_dict_del (struct ec_config *dict, const char *key) |
| int | ec_config_cmp (const struct ec_config *config1, const struct ec_config *config2) |
| struct ec_config * | ec_config_dict_get (const struct ec_config *config, const char *key) |
| struct ec_config * | ec_config_list_first (struct ec_config *list) |
| struct ec_config * | ec_config_list_next (struct ec_config *list, struct ec_config *config) |
| void | ec_config_free (struct ec_config *config) |
| struct ec_config * | ec_config_dup (const struct ec_config *config) |
| void | ec_config_dump (FILE *out, const struct ec_config *config) |
| struct ec_node ** | ec_node_config_node_list_to_table (const struct ec_config *config, size_t *len) |
| struct ec_config * | ec_node_config_node_list_from_vargs (va_list ap) |
Variables | |
| const char * | ec_config_reserved_keys [] |
Configure nodes behavior through generic API.
Helpers that are commonly used in nodes.
| enum ec_config_type |
| enum ec_config_flags |
| int ec_config_schema_validate | ( | const struct ec_config_schema * | schema | ) |
Validate a configuration schema array.
| schema | Pointer to the first element of the schema array. The array must be terminated by a sentinel entry {.type = EC_CONFIG_TYPE_NONE}. |
| void ec_config_schema_dump | ( | FILE * | out, |
| const struct ec_config_schema * | schema, | ||
| const char * | name ) |
Dump a configuration schema array.
| out | Output stream on which the dump will be sent. |
| schema | Pointer to the first element of the schema array. The array must be terminated by a sentinel entry {.type == EC_CONFIG_TYPE_NONE}. |
| name | The name of the schema. |
| const struct ec_config_schema * ec_config_schema_lookup | ( | const struct ec_config_schema * | schema, |
| const char * | key ) |
Find a schema entry matching the key.
Browse the schema array and look up the given key.
| schema | Pointer to the first element of the schema array. The array must be terminated by a sentinel entry {.type == EC_CONFIG_TYPE_NONE}. |
| key | Schema key name. |
| enum ec_config_type ec_config_schema_type | ( | const struct ec_config_schema * | schema_elt | ) |
Get the type of a schema entry.
| schema_elt | Pointer to an element of the schema array. |
| const struct ec_config_schema * ec_config_schema_sub | ( | const struct ec_config_schema * | schema_elt | ) |
Get the subschema of a schema entry.
| schema_elt | Pointer to an element of the schema array. |
| bool ec_config_key_is_reserved | ( | const char * | name | ) |
Check if a key name is reserved in a config dict.
Some key names are reserved and should not be used in configs.
| name | The name of the key to test. |
| enum ec_config_type ec_config_get_type | ( | const struct ec_config * | config | ) |
Get the type of the configuration.
| config | The configuration. |
| struct ec_config * ec_config_bool | ( | bool | boolean | ) |
Create a boolean configuration value.
| boolean | The boolean value to be set. |
| struct ec_config * ec_config_i64 | ( | int64_t | i64 | ) |
Create a signed integer configuration value.
| i64 | The signed integer value to be set. |
| struct ec_config * ec_config_u64 | ( | uint64_t | u64 | ) |
Create an unsigned configuration value.
| u64 | The unsigned integer value to be set. |
| struct ec_config * ec_config_string | ( | const char * | string | ) |
Create a string configuration value.
| string | The string value to be set. The string is copied into the configuration object. |
Create a node configuration value.
| node | The node pointer to be set. The node is "consumed" by the function and should not be used by the caller, even on error. The caller can use ec_node_clone() to keep a reference on the node. |
| struct ec_config * ec_config_dict | ( | void | ) |
Create a hash table configuration value.
| struct ec_config * ec_config_list | ( | void | ) |
Create a list configuration value.
Add a config object into a list.
| list | The list configuration in which the value will be added. |
| value | The value configuration to add in the list. The value object will be freed when freeing the list object. On error, the value object is also freed. |
Remove an element from a list.
The element is freed and should not be accessed.
| list | The list configuration. |
| config | The element to remove from the list. |
| ssize_t ec_config_count | ( | const struct ec_config * | config | ) |
Count the number of elements in a list or dict.
| config | The configuration that must be a list or a dict. |
| int ec_config_validate | ( | const struct ec_config * | dict, |
| const struct ec_config_schema * | schema ) |
Validate a configuration.
| dict | A hash table configuration to validate. |
| schema | Pointer to the first element of the schema array. The array must be terminated by a sentinel entry (type == EC_CONFIG_TYPE_NONE). |
Set a value in a hash table configuration.
| dict | The hash table configuration. |
| key | The key to update. |
| value | The value to set. The value object will be freed when freeing the dict object. On error, the value object is also freed. |
| int ec_config_dict_del | ( | struct ec_config * | dict, |
| const char * | key ) |
Remove an element from a hash table configuration.
The element is freed and should not be accessed.
| dict | The hash table configuration. |
| key | The key of the configuration to delete. |
Compare two configurations.
Compare two configurations.
Get configuration value.
Get the first element of a list.
Example of use:
| list | The list configuration to iterate. |
Get next element in list.
| list | The list configuration being iterated. |
| config | The current configuration element. |
| void ec_config_free | ( | struct ec_config * | config | ) |
Free a configuration.
| config | The element to free. |
Duplicate a configuration.
| config | The configuration to duplicate. |
| void ec_config_dump | ( | FILE * | out, |
| const struct ec_config * | config ) |
Dump a configuration.
| out | Output stream on which the dump will be sent. |
| config | The configuration to dump. |
| struct ec_node ** ec_node_config_node_list_to_table | ( | const struct ec_config * | config, |
| size_t * | len ) |
Build a node table from a node list in an ec_config.
The function takes a node configuration as parameter, which must be a node list. From it, a node table is built. A reference is taken for each node.
On error, no reference is taken.
| config | The configuration (type must be a list of nodes). If it is NULL, an error is returned. |
| len | The length of the allocated table on success, or 0 on error. |
| struct ec_config * ec_node_config_node_list_from_vargs | ( | va_list | ap | ) |
Build a list of config nodes from variable arguments.
The va_list argument is a list of pointer to ec_node structures, terminated with EC_VA_END.
This helper is used by nodes that contain a list of nodes, like "seq", "or", ...
| ap | List of pointer to ec_node structures, terminated with EC_VA_END. |
|
extern |
Array of reserved key names.