56    int append, 
const char *fmt, va_list ap,
 
   57    const char *file, 
int lineno, 
const char *function)
 
   62    int offset = (append && (*buf)->__AST_STR_LEN) ? (*buf)->__AST_STR_USED : 0;
 
   66        max_len = (*buf)->__AST_STR_LEN;    
 
   71        res = vsnprintf((*buf)->__AST_STR_STR + offset, (*buf)->__AST_STR_LEN - offset, fmt, aq);
 
   90        need = offset + added + 1;
 
   91        if (need <= (*buf)->__AST_STR_LEN
 
   92            || (max_len && max_len <= (*buf)->__AST_STR_LEN)) {
 
  103            need += 16 + need / 4;
 
  104        } 
else if (max_len < need) {
 
  111                (
int) (*buf)->__AST_STR_LEN, need);
 
  119    (*buf)->__AST_STR_USED = ((*buf)->__AST_STR_LEN <= offset + added)
 
  120        ? (*buf)->__AST_STR_LEN - 1
 
  124    (*buf)->__AST_STR_STR[(*buf)->__AST_STR_USED] = 
'\0';
 
 
  132    char *ptr = append ? &((*buf)->__AST_STR_STR[(*buf)->__AST_STR_USED]) : (*buf)->__AST_STR_STR;
 
  138        maxlen = (*buf)->__AST_STR_LEN;
 
  141    while (*src && maxsrc && maxlen && (!escapecommas || (maxlen - 1))) {
 
  142        if (escapecommas && (*src == 
'\\' || *src == 
',')) {
 
  145            (*buf)->__AST_STR_USED++;
 
  150        (*buf)->__AST_STR_USED++;
 
  152        if ((ptr >= (*buf)->__AST_STR_STR + (*buf)->__AST_STR_LEN - 3) ||
 
  153            (dynamic && (!maxlen || (escapecommas && !(maxlen - 1))))) {
 
  154            char *oldbase = (*buf)->__AST_STR_STR;
 
  155            size_t old = (*buf)->__AST_STR_LEN;
 
  163            ptr += (*buf)->__AST_STR_STR - oldbase;
 
  166    if (__builtin_expect(!maxlen, 0)) {
 
  170    return (*buf)->__AST_STR_STR;
 
 
  173static int str_hash(
const void *obj, 
const int flags)
 
 
  178static int str_sort(
const void *lhs, 
const void *rhs, 
int flags)
 
  181        return strncmp(lhs, rhs, strlen(rhs));
 
  183        return strcmp(lhs, rhs);
 
 
  187static int str_cmp(
void *lhs, 
void *rhs, 
int flags)
 
  192        cmp = strncmp(lhs, rhs, strlen(rhs));
 
  194        cmp = strcmp(lhs, rhs);
 
 
  214    strcpy(ao2_add, add);
 
 
  230    for (i = 0; i < size - 1; ++i) {
 
 
  240    if (!str1 || !str2) {
 
  244    return str1 == str2 || !strcmp(str1, str2);
 
 
  252    *
result = strtod(input, &endptr);
 
  253    if (*endptr || 
errno == ERANGE) {
 
 
  262    char *internal_op = (
char *)op;
 
  263    char *internal_right = (
char *)right;
 
  266    int scan_numeric = 0;
 
  268    if (!(left && right)) {
 
  277        if (strlen(right) >= 2 && right[0] == 
'/' && right[strlen(right) - 1] == 
'/') {
 
  278            internal_op = 
"regex";
 
  282            internal_right[strlen(internal_right) - 1] = 
'\0';
 
  290    if (!strcasecmp(op, 
"like")) {
 
  294        if (!strchr(right, 
'%')) {
 
  295            return !strcmp(left, right);
 
  297            internal_op = 
"regex";
 
  299            tok = 
strsep(&internal_right, 
"%");
 
  302            while ((tok = 
strsep(&internal_right, 
"%"))) {
 
  313    if (!strcasecmp(internal_op, 
"regex")) {
 
  317        if (regcomp(&expression, internal_right, REG_EXTENDED | REG_NOSUB)) {
 
  321        rc = regexec(&expression, left, 0, 
NULL, 0);
 
  322        regfree(&expression);
 
  330    if (internal_op[0] == 
'=') {
 
  336            return (left_num == right_num);
 
  338            return (!strcmp(left, internal_right));
 
  342    if (internal_op[0] == 
'!' && internal_op[1] == 
'=') {
 
  344            return (left_num != right_num);
 
  346            return !!strcmp(left, internal_right);
 
  350    if (internal_op[0] == 
'<') {
 
  352            if (internal_op[1] == 
'=') {
 
  353                return (left_num <= right_num);
 
  355                return (left_num < right_num);
 
  358            if (internal_op[1] == 
'=') {
 
  359                return strcmp(left, internal_right) <= 0;
 
  361                return strcmp(left, internal_right) < 0;
 
  366    if (internal_op[0] == 
'>') {
 
  368            if (internal_op[1] == 
'=') {
 
  369                return (left_num >= right_num);
 
  371                return (left_num > right_num);
 
  374            if (internal_op[1] == 
'=') {
 
  375                return strcmp(left, internal_right) >= 0;
 
  377                return strcmp(left, internal_right) > 0;
 
 
  387    char *start = *buffer;
 
  389    if (!buffer || !*buffer || *(*buffer) == 
'\0') {
 
  393    while (*(*buffer) && *(*buffer) != 
'\n' ) {
 
  398    if (*(*buffer - 1) == 
'\r') {
 
  399        *(*buffer - 1) = 
'\0';
 
 
  426    const char *input, 
const char *delim, 
int flags,
 
  427    int (*excludes_cmp)(
const char *s1, 
const char *s2))
 
 
  469    unsigned long needle_size;
 
  477    needle_size = strlen(needle);
 
  480    while ((
end = strchr(haystack, delim))) {
 
  481        if (needle_size == 
end - haystack && !strncmp(haystack, needle, needle_size)) {
 
  487    return strcmp(haystack, needle) ? 0 : -1;
 
 
char * strsep(char **str, const char *delims)
Asterisk main include file. File version handling, generic pbx functions.
#define ast_strdup(str)
A wrapper for strdup()
#define ast_strdupa(s)
duplicate a string in memory from the stack
#define ao2_link(container, obj)
Add an object to a container.
ao2_alloc_opts
Options available when allocating an ao2 object.
@ AO2_ALLOC_OPT_LOCK_NOLOCK
#define ao2_find(container, arg, flags)
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
#define ao2_alloc_options(data_size, destructor_fn, options)
@ OBJ_SEARCH_PARTIAL_KEY
The arg parameter is a partial search key similar to OBJ_SEARCH_KEY.
@ OBJ_SEARCH_MASK
Search option field mask.
@ OBJ_SEARCH_KEY
The arg parameter is a search key, but is not an object.
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
Allocate and initialize a hash container with the desired number of buckets.
static int regex(struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len)
void ast_log_safe(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message with protection against recursion.
Core PBX routines and definitions.
int ast_strings_equal(const char *str1, const char *str2)
Compare strings for equality checking for NULL.
static int str_sort(const void *lhs, const void *rhs, int flags)
char * ast_vector_string_join(struct ast_vector_string *vec, const char *delim)
Join the elements of a string vector into a single string.
static int parse_double(const char *input, double *result)
int ast_strings_match(const char *left, const char *op, const char *right)
Compares 2 strings using realtime-style operators.
int ast_in_delimited_string(const char *needle, const char *haystack, char delim)
Check if there is an exact match for 'needle' between delimiters in 'haystack'.
char * ast_read_line_from_buffer(char **buffer)
Read lines from a string buffer.
static int str_cmp(void *lhs, void *rhs, int flags)
int __ast_str_helper(struct ast_str **buf, ssize_t max_len, int append, const char *fmt, va_list ap, const char *file, int lineno, const char *function)
Core functionality of ast_str_(set|append)_va.
int ast_vector_string_split(struct ast_vector_string *dest, const char *input, const char *delim, int flags, int(*excludes_cmp)(const char *s1, const char *s2))
Append a string vector by splitting a string.
void ast_str_container_remove(struct ao2_container *str_container, const char *remove)
Removes a string from a string container allocated by ast_str_container_alloc.
char * ast_generate_random_string(char *buf, size_t size)
Create a pseudo-random string of a fixed length.
struct ao2_container * ast_str_container_alloc_options(enum ao2_alloc_opts opts, int buckets)
Allocates a hash container for bare strings.
int ast_str_container_add(struct ao2_container *str_container, const char *add)
Adds a string to a string container allocated by ast_str_container_alloc.
static int str_hash(const void *obj, const int flags)
char * __ast_str_helper2(struct ast_str **buf, ssize_t maxlen, const char *src, size_t maxsrc, int append, int escapecommas)
String manipulation functions.
char * ast_str_truncate(struct ast_str *buf, ssize_t len)
Truncates the enclosed string to the given length.
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
static force_inline int attribute_pure ast_str_hash(const char *str)
Compute a hash value on a string.
int _ast_str_make_space(struct ast_str **buf, size_t new_len, const char *file, int lineno, const char *function)
static force_inline int attribute_pure ast_strlen_zero(const char *s)
@ AST_DYNSTR_BUILD_FAILED
#define ast_str_alloca(init_len)
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
#define ast_str_make_space(buf, new_len)
char *attribute_pure ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
char * ast_strip(char *s)
Strip leading/trailing whitespace from a string.
char *attribute_pure ast_skip_blanks(const char *str)
Gets a pointer to the first non-whitespace character in a string.
Support for dynamic strings.
String vector definitions.
long int ast_random(void)
Vector container support.
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
#define AST_VECTOR_GET_CMP(vec, value, cmp)
Get an element from a vector that matches the given comparison.
@ AST_VECTOR_STRING_SPLIT_NO_TRIM
@ AST_VECTOR_STRING_SPLIT_ALLOW_EMPTY
#define AST_VECTOR_APPEND(vec, elem)
Append an element to a vector, growing the vector if needed.
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.