77 char* value = getenv(txt);
103 const char* start_string,
104 const char* end_string,
108 size_t start_length = strlen(start_string);
109 size_t end_length = strlen(end_string);
113 for(
size_t i = 0; i <
string->last_used;) {
114 if(strncmp(string->
buffer + i, start_string, start_length) != 0) {
118 if((i > 0) && (string->
buffer[i - 1] ==
'\\')) {
125 while(i + end_length <= string->last_used) {
126 if(strncmp(string->
buffer + i, end_string, end_length) == 0) {
127 end = i + end_length;
128 string->buffer[i] = 0;
139 string->
buffer + start + start_length,
191 if(string->
buffer[i] !=
'\\') {
199 switch(string->
buffer[i + 1]) {
251 }
while(changes > 0);
270 length = strlen(text);
271 for(i = 0; i < length; i++) {
#define when_failed(x, l)
Ambiorix string API header file.
void(* amxc_string_replace_cb_t)(amxc_string_t *const string, size_t pos, size_t length, const char *txt, const void *priv)
static void amxc_string_resolve_replace_env(amxc_string_t *const string, size_t pos, size_t length, const char *txt, UNUSED const void *priv)
static int amxc_string_generic_resolve(amxc_string_t *const string, const char *start_string, const char *end_string, amxc_string_replace_cb_t fn, const void *priv)
static void amxc_string_resolve_replace_var(amxc_string_t *const string, size_t pos, size_t length, const char *txt, const void *priv)
Ambiorix variant API header file.
#define cstring_t
Convenience macro.
int amxc_llist_append(amxc_llist_t *const llist, amxc_llist_it_t *const it)
Adds an item to the end of the linked list.
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.
int amxc_string_set_resolved(amxc_string_t *string, const char *text, const amxc_var_t *const data)
Sets the resolved string.
int amxc_string_esc(amxc_string_t *const string)
Add escape characters to a string.
int amxc_string_new_resolved(amxc_string_t **string, const char *text, const amxc_var_t *const data)
Sets the resolved string.
int amxc_string_resolve_var(amxc_string_t *const string, const amxc_var_t *const data)
Resolves variant path variables.
int amxc_string_resolve(amxc_string_t *const string, const amxc_var_t *const data)
Resolves variant paths and environment variables.
void amxc_string_list_it_free(amxc_llist_it_t *it)
Helper function to delete an item in a linked list.
int amxc_string_resolve_esc(amxc_string_t *const string)
Resolves escaped characters in a string.
int amxc_string_resolve_env(amxc_string_t *const string)
Resolves environment variables.
void amxc_string_delete(amxc_string_t **string)
Frees the previously allocated string.
AMXC_INLINE size_t amxc_string_buffer_length(const amxc_string_t *const string)
Gets the current size of the allocate string buffer.
int amxc_string_push_buffer(amxc_string_t *const string, char *buffer, size_t length)
Sets the string buffer.
AMXC_INLINE int amxc_string_append(amxc_string_t *const string, const char *const text, const size_t length)
Appends text to the end of the current content of the string buffer.
#define amxc_string_from_llist_it(ll_it)
Get the pointer to a string structure from an amxc linked list iterator.
int amxc_string_replace(amxc_string_t *const string, const char *needle, const char *newstr, uint32_t max)
Replaces a number of sub-string occurrences in a string.
void amxc_string_reset(amxc_string_t *const string)
Resets the buffer, reset the content to all 0.
AMXC_INLINE int amxc_string_insert_at(amxc_string_t *const string, const size_t pos, const char *text, size_t length)
Inserts a string of the given length into a string at a certain position.
int amxc_string_new(amxc_string_t **string, const size_t length)
Allocates a string.
AMXC_INLINE size_t amxc_string_text_length(const amxc_string_t *const string)
Gets the current size of the used string buffer.
int amxc_string_init(amxc_string_t *const string, const size_t length)
Initializes a string.
int amxc_string_appendf(amxc_string_t *const string, const char *fmt,...) __attribute__((format(printf
Appends a formatted string to a string.
int amxc_string_remove_at(amxc_string_t *const string, const size_t pos, size_t length)
Removes part of the text in the string buffer.
AMXC_INLINE bool amxc_string_is_empty(const amxc_string_t *const string)
Checks if the string is empty.
void amxc_string_clean(amxc_string_t *const string)
Frees the string buffer and reset length attributes.
char * amxc_string_take_buffer(amxc_string_t *const string)
Takes the string buffer.
#define AMXC_VAR_FLAG_DEFAULT
The default flag, do not copy, use variant as is.
#define AMXC_VAR_ID_HTABLE
Ambiorix Hash Table variant id.
uint32_t amxc_var_type_of(const amxc_var_t *const var)
Gets the variant type id of a variant.
amxc_var_t * amxc_var_get_path(const amxc_var_t *const var, const char *const path, const int flags)
Retrieves the variant at the given path of a composite variant.
#define amxc_var_dyncast(type, var)
Dynamic cast a variant to a certain type.
The linked list iterator structure.
The linked list structure.
The variant struct definition.
static amxc_htable_it_t it[2000]
static amxc_llist_t * llist