#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <ctype.h>
#include <amxc/amxc_variant.h>
#include <amxc/amxc_string.h>
#include <amxc/amxc_utils.h>
#include <amxc/amxc_macros.h>
Go to the source code of this file.
|
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 void | amxc_string_resolve_replace_var (amxc_string_t *const string, size_t pos, size_t length, const char *txt, 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) |
|
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_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 (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...
|
|
◆ amxc_string_replace_cb_t
typedef void(* amxc_string_replace_cb_t) (amxc_string_t *const string, size_t pos, size_t length, const char *txt, const void *priv) |
◆ amxc_string_generic_resolve()
Definition at line 102 of file amxc_utils.c.
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,
◆ amxc_string_resolve_replace_env()
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 |
Definition at line 72 of file amxc_utils.c.
77 char* value = getenv(txt);
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_remove_at(amxc_string_t *const string, const size_t pos, size_t length)
Removes part of the text in the string buffer.
◆ amxc_string_resolve_replace_var()
static void amxc_string_resolve_replace_var |
( |
amxc_string_t *const |
string, |
|
|
size_t |
pos, |
|
|
size_t |
length, |
|
|
const char * |
txt, |
|
|
const void * |
priv |
|
) |
| |
|
static |
Definition at line 84 of file amxc_utils.c.
#define cstring_t
Convenience macro.
#define AMXC_VAR_FLAG_DEFAULT
The default flag, do not copy, use variant as is.
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 variant struct definition.