libamxc
1.10.3
C Generic Data Containers
|
Functions | |
int | amxc_string_resolve_esc (amxc_string_t *const string) |
Resolves escaped characters in a string. More... | |
int | amxc_string_esc (amxc_string_t *const string) |
Add escape characters to a string. More... | |
int | amxc_string_resolve_env (amxc_string_t *const string) |
Resolves environment variables. More... | |
int | amxc_string_resolve_var (amxc_string_t *const string, const amxc_var_t *const data) |
Resolves variant path variables. More... | |
int | amxc_string_resolve (amxc_string_t *const string, const amxc_var_t *const data) |
Resolves variant paths and environment variables. More... | |
int | amxc_string_set_resolved (amxc_string_t *string, const char *text, const amxc_var_t *const data) |
Sets the resolved string. More... | |
int | amxc_string_new_resolved (amxc_string_t **string, const char *text, const amxc_var_t *const data) |
Sets the resolved string. More... | |
amxc_llist_it_t * | amxc_llist_add_string (amxc_llist_t *const llist, const char *text) |
Adds a string (char*) to a linked list of amxc_string_t structures. More... | |
void | amxc_string_list_it_free (amxc_llist_it_t *it) |
Helper function to delete an item in a linked list. More... | |
A list of utility functions and macro's that make common string manipulation easier.
amxc_llist_it_t* amxc_llist_add_string | ( | amxc_llist_t *const | llist, |
const char * | text | ||
) |
Adds a string (char*) to a linked list of amxc_string_t structures.
This function will allocate a new amxc_string_t structure and copies the provide string (char*) into the amxc_string_t structure.
The new allocated structure is appended to the provided linked list using amxc_llist_append
llist | a pointer to a linked list iterator |
text | the string |
Definition at line 306 of file amxc_utils.c.
int amxc_string_esc | ( | amxc_string_t *const | string | ) |
Add escape characters to a string.
Some characters or combinations of characters in a string can have a special purpose i.e. "$(my_env_var)". To avoid that these are replaced by functions like amxc_string_resolve_env or amxc_string_resolve_var, the characters can be escaped with a \ i.e. "\$\(my_env_var\)". This function can be used to add the escape character.
Only these characters are taken into consideration when removing the escape character: $, (, ), {, }, ", ', .
string | an amxc_string_t pointer. |
Definition at line 226 of file amxc_utils.c.
void amxc_string_list_it_free | ( | amxc_llist_it_t * | it | ) |
Helper function to delete an item in a linked list.
This function can be passed to amxc_llist_delete or amxc_llist_clean if the linked list only contains amxc_string_t structures.
it | a pointer to a linked list iterator |
Definition at line 327 of file amxc_utils.c.
int amxc_string_new_resolved | ( | amxc_string_t ** | string, |
const char * | text, | ||
const amxc_var_t *const | data | ||
) |
Sets the resolved string.
This function will allocate a new amxc_string_t structure on the heap.
If the provided text contains environment variable references or variant path references, the resolved text is put in the string. it will also remove the escape character '\' when in front of $, (, ), {, }, ", ', .
string | an amxc_string_t pointer. |
text | the text |
data | a variant containing data, preferable a htable or list. |
Definition at line 289 of file amxc_utils.c.
int amxc_string_resolve | ( | amxc_string_t *const | string, |
const amxc_var_t *const | data | ||
) |
Resolves variant paths and environment variables.
This functions calls amxc_string_resolve_var and amxc_string_resolve_env to resolve all environment variables and variant paths mentioned in the string.
The escape character '\' will be removed using amxc_string_resolve_esc when in front of $, (, ), {, }, ", ', .
string | an amxc_string_t pointer. |
data | a variant containing data, preferable a htable or list. |
Definition at line 242 of file amxc_utils.c.
int amxc_string_resolve_env | ( | amxc_string_t *const | string | ) |
Resolves environment variables.
Replaces the environment variable with its value. The name of the environment variable must be put between $( and ). This function will get the value of the environment variable and replaces the $(<NAME>) with the value.
If the environment variable does not exist, it will be replaced with an empty string. If no environment variables are available in the string, the string is not changed.
string | an amxc_string_t pointer. |
Definition at line 148 of file amxc_utils.c.
int amxc_string_resolve_esc | ( | amxc_string_t *const | string | ) |
Resolves escaped characters in a string.
Some characters or combinations of characters in a string can have a special purpose i.e. "$(my_env_var)". To avoid that these are replaced by functions like amxc_string_resolve_env or amxc_string_resolve_var, the characters can be escaped with a \ i.e. "\$\(my_env_var\)". This function can be used to remove the escape character from the string.
Only these characters are taken into consideration when removing the escape character: $, (, ), {, }, ", ', .
string | an amxc_string_t pointer. |
Definition at line 183 of file amxc_utils.c.
int amxc_string_resolve_var | ( | amxc_string_t *const | string, |
const amxc_var_t *const | data | ||
) |
Resolves variant path variables.
Replaces the variant path with its value. The variant path must be put between ${ and }. This function will get the value of that path and replaces the ${<PATH>} with the value.
If the path does not exist, it will be replaced with an empty string. If no variant paths are available in the string, the string is not changed.
string | an amxc_string_t pointer. |
data | a variant containing data, preferable a htable or list. |
Definition at line 164 of file amxc_utils.c.
int amxc_string_set_resolved | ( | amxc_string_t * | string, |
const char * | text, | ||
const amxc_var_t *const | data | ||
) |
Sets the resolved string.
This function will always clear the content of the provided amxc_string_t structure (resets it to an empty string).
If the provided text contains environment variable references or variant path references, the resolved text is put in the string, it will also remove the escape character '\' when in front of $, (, ), {, }, ", ', .
string | an amxc_string_t pointer. |
text | the text |
data | a variant containing data, preferable a htable or list. |
Definition at line 258 of file amxc_utils.c.