Asterisk - The Open Source Telephony Project GIT-master-85241bd
Data Structures | Macros | Enumerations | Functions
strings.h File Reference

String manipulation functions. More...

#include <ctype.h>
#include <limits.h>
#include "asterisk/utils.h"
#include "asterisk/threadstorage.h"
#include "asterisk/astobj2.h"
Include dependency graph for strings.h:

Go to the source code of this file.

Data Structures

struct  ast_str
 Support for dynamic strings. More...
 

Macros

#define __AST_STR_LEN   len
 
#define __AST_STR_STR   str
 
#define __AST_STR_TS   ts
 
#define __AST_STR_USED   used
 
#define _ast_str_helper(buf, max_len, append, fmt, ap)    __ast_str_helper(buf, max_len, append, fmt, ap, __FILE__, __LINE__, __PRETTY_FUNCTION__)
 
#define _DB1(x)
 
#define AS_OR(a, b)   (a && ast_str_strlen(a)) ? ast_str_buffer(a) : (b)
 
#define ast_join(s, len, w)   ast_join_delim(s, len, w, -1, ' ')
 Join an array of strings into a single string. More...
 
#define ast_str_alloca(init_len)
 
#define ast_str_container_alloc(buckets)   ast_str_container_alloc_options(AO2_ALLOC_OPT_LOCK_MUTEX, buckets)
 Allocates a hash container for bare strings. More...
 
#define ast_str_create(init_len)    _ast_str_create(init_len, __FILE__, __LINE__, __PRETTY_FUNCTION__)
 Create a malloc'ed dynamic length string. More...
 
#define ast_str_make_space(buf, new_len)    _ast_str_make_space(buf, new_len, __FILE__, __LINE__, __PRETTY_FUNCTION__)
 
#define ast_str_tmp(init_len, __expr)
 Provides a temporary ast_str and returns a copy of its buffer. More...
 
#define ast_to_camel_case(s)   ast_to_camel_case_delim(s, "_")
 Attempts to convert the given string to camel case using an underscore as the specified delimiter. More...
 
#define AST_YESNO(x)   ((x) ? "Yes" : "No")
 return Yes or No depending on the argument. More...
 
#define DS_ALLOCA   ((struct ast_threadstorage *)2)
 
#define DS_MALLOC   ((struct ast_threadstorage *)1)
 
#define DS_STATIC   ((struct ast_threadstorage *)3) /* not supported yet */
 
#define S_COR(a, b, c)   ({typeof(&((b)[0])) __x = (b); (a) && !ast_strlen_zero(__x) ? (__x) : (c);})
 returns the equivalent of logic or for strings, with an additional boolean check: second one if not empty and first one is true, otherwise third one. example: S_COR(usewidget, widget, "<no widget>") More...
 
#define S_OR(a, b)   ({typeof(&((a)[0])) __x = (a); ast_strlen_zero(__x) ? (b) : __x;})
 returns the equivalent of logic or for strings: first one if not empty, otherwise second one. More...
 

Enumerations

enum  { AST_DYNSTR_BUILD_FAILED = -1 , AST_DYNSTR_BUILD_RETRY = -2 }
 Error codes from __ast_str_helper() The underlying processing to manipulate dynamic string is done by __ast_str_helper(), which can return a success or a permanent failure (e.g. no memory). More...
 
enum  ast_strsep_flags { AST_STRSEP_STRIP = 0x01 , AST_STRSEP_TRIM = 0x02 , AST_STRSEP_UNESCAPE = 0x04 , AST_STRSEP_ALL = 0x07 }
 Flags for ast_strsep. More...
 

Functions

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 *func)
 Core functionality of ast_str_(set|append)_va. More...
 
char * __ast_str_helper2 (struct ast_str **buf, ssize_t max_len, const char *src, size_t maxsrc, int append, int escapecommas)
 
struct ast_str_ast_str_create (size_t init_len, const char *file, int lineno, const char *func)
 
int _ast_str_make_space (struct ast_str **buf, size_t new_len, const char *file, int lineno, const char *function)
 
static int force_inline attribute_pure ast_begins_with (const char *str, const char *prefix)
 Checks whether a string begins with another. More...
 
int ast_build_string (char **buffer, size_t *space, const char *fmt,...)
 Build a string in a buffer, designed to be called repeatedly. More...
 
int ast_build_string_va (char **buffer, size_t *space, const char *fmt, va_list ap)
 Build a string in a buffer, designed to be called repeatedly. More...
 
int ast_check_digits (const char *arg)
 Check if a string is only digits. More...
 
void ast_copy_string (char *dst, const char *src, size_t size)
 Size-limited null-terminating string copy. More...
 
static int force_inline attribute_pure ast_ends_with (const char *str, const char *suffix)
 Checks whether a string ends with another. More...
 
char * ast_escape (char *dest, const char *s, size_t size, const char *to_escape)
 Escape the 'to_escape' characters in the given string. More...
 
char * ast_escape_alloc (const char *s, const char *to_escape)
 Escape the 'to_escape' characters in the given string. More...
 
char * ast_escape_c (char *dest, const char *s, size_t size)
 Escape standard 'C' sequences in the given string. More...
 
char * ast_escape_c_alloc (const char *s)
 Escape standard 'C' sequences in the given string. More...
 
int attribute_pure ast_false (const char *val)
 Make sure something is false. Determine if a string containing a boolean value is "false". This function checks to see whether a string passed to it is an indication of an "false" value. It checks to see if the string is "no", "false", "n", "f", "off" or "0". More...
 
char * ast_generate_random_string (char *buf, size_t size)
 Create a pseudo-random string of a fixed length. More...
 
int ast_get_time_t (const char *src, time_t *dst, time_t _default, int *consumed)
 Parse a time (integer) string. More...
 
int ast_get_timeval (const char *src, struct timeval *tv, struct timeval _default, int *consumed)
 Parse a time (float) string. More...
 
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'. More...
 
void ast_join_delim (char *s, size_t len, const char *const w[], unsigned int size, char delim)
 Join an array of strings into a single string. More...
 
char * ast_read_line_from_buffer (char **buffer)
 Read lines from a string buffer. More...
 
int ast_regex_string_to_regex_pattern (const char *regex_string, struct ast_str **regex_pattern)
 Given a string regex_string in the form of "/regex/", convert it into the form of "regex". More...
 
char * ast_skip_blanks (const char *str)
 Gets a pointer to the first non-whitespace character in a string. More...
 
char * ast_skip_nonblanks (const char *str)
 Gets a pointer to first whitespace character in a string. More...
 
int ast_str_append (struct ast_str **buf, ssize_t max_len, const char *fmt,...)
 Append to a thread local dynamic string. More...
 
char * ast_str_append_escapecommas (struct ast_str **buf, ssize_t maxlen, const char *src, size_t maxsrc)
 Append a non-NULL terminated substring to the end of a dynamic string, with escaping of commas. More...
 
char * ast_str_append_substr (struct ast_str **buf, ssize_t maxlen, const char *src, size_t maxsrc)
 Append a non-NULL terminated substring to the end of a dynamic string. More...
 
int ast_str_append_va (struct ast_str **buf, ssize_t max_len, const char *fmt, va_list ap)
 Append to a dynamic string using a va_list. More...
 
char * ast_str_buffer (const struct ast_str *buf)
 Returns the string buffer within the ast_str buf. More...
 
static force_inline int attribute_pure ast_str_case_hash (const char *str)
 Compute a hash value on a case-insensitive string. More...
 
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. More...
 
struct ao2_containerast_str_container_alloc_options (enum ao2_alloc_opts opts, int buckets)
 Allocates a hash container for bare strings. More...
 
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. More...
 
int ast_str_copy_string (struct ast_str **dst, struct ast_str *src)
 
static force_inline int attribute_pure ast_str_hash (const char *str)
 Compute a hash value on a string. More...
 
static force_inline int ast_str_hash_add (const char *str, int seed)
 Compute a hash value on a string. More...
 
static force_inline int attribute_pure ast_str_hash_restrict (unsigned int hash)
 Restrict hash value range. More...
 
void ast_str_reset (struct ast_str *buf)
 Reset the content of a dynamic string. Useful before a series of ast_str_append. More...
 
int ast_str_set (struct ast_str **buf, ssize_t max_len, const char *fmt,...)
 Set a dynamic string using variable arguments. More...
 
char * ast_str_set_escapecommas (struct ast_str **buf, ssize_t maxlen, const char *src, size_t maxsrc)
 Set a dynamic string to a non-NULL terminated substring, with escaping of commas. More...
 
char * ast_str_set_substr (struct ast_str **buf, ssize_t maxlen, const char *src, size_t maxsrc)
 Set a dynamic string to a non-NULL terminated substring. More...
 
int ast_str_set_va (struct ast_str **buf, ssize_t max_len, const char *fmt, va_list ap)
 Set a dynamic string from a va_list. More...
 
size_t ast_str_size (const struct ast_str *buf)
 Returns the current maximum length (without reallocation) of the current buffer. More...
 
size_t ast_str_strlen (const struct ast_str *buf)
 Returns the current length of the string stored within buf. More...
 
struct ast_strast_str_thread_get (struct ast_threadstorage *ts, size_t init_len)
 Retrieve a thread locally stored dynamic string. More...
 
static force_inline char * ast_str_to_lower (char *str)
 Convert a string to all lower-case. More...
 
static force_inline char * ast_str_to_upper (char *str)
 Convert a string to all upper-case. More...
 
void ast_str_trim_blanks (struct ast_str *buf)
 Trims trailing whitespace characters from an ast_str string. More...
 
char * ast_str_truncate (struct ast_str *buf, ssize_t len)
 Truncates the enclosed string to the given length. More...
 
void ast_str_update (struct ast_str *buf)
 Update the length of the buffer, after using ast_str merely as a buffer. More...
 
int ast_strings_equal (const char *str1, const char *str2)
 Compare strings for equality checking for NULL. More...
 
int ast_strings_match (const char *left, const char *op, const char *right)
 Compares 2 strings using realtime-style operators. More...
 
char * ast_strip (char *s)
 Strip leading/trailing whitespace from a string. More...
 
char * ast_strip_quoted (char *s, const char *beg_quotes, const char *end_quotes)
 Strip leading/trailing whitespace and quotes from a string. More...
 
static force_inline int attribute_pure ast_strlen_zero (const char *s)
 
char * ast_strsep (char **s, const char sep, uint32_t flags)
 Act like strsep but ignore separators inside quotes. More...
 
char * ast_strsep_quoted (char **s, const char sep, const char quote, uint32_t flags)
 Like ast_strsep() except you can specify a specific quote character. More...
 
char * ast_tech_to_upper (char *dev_str)
 Convert the tech portion of a device string to upper case. More...
 
char * ast_to_camel_case_delim (const char *s, const char *delim)
 Attempts to convert the given string to camel case using the specified delimiter. More...
 
char * ast_trim_blanks (char *str)
 Trims trailing whitespace characters from a string. More...
 
int attribute_pure ast_true (const char *val)
 Make sure something is true. Determine if a string containing a boolean value is "true". This function checks to see whether a string passed to it is an indication of an "true" value. It checks to see if the string is "yes", "true", "y", "t", "on" or "1". More...
 
char * ast_unescape_c (char *s)
 Convert some C escape sequences. More...
 
char * ast_unescape_semicolon (char *s)
 Strip backslash for "escaped" semicolons, the string to be stripped (will be modified). More...
 

Detailed Description

String manipulation functions.

Definition in file strings.h.

Macro Definition Documentation

◆ __AST_STR_LEN

#define __AST_STR_LEN   len

Definition at line 42 of file strings.h.

◆ __AST_STR_STR

#define __AST_STR_STR   str

Definition at line 43 of file strings.h.

◆ __AST_STR_TS

#define __AST_STR_TS   ts

Definition at line 44 of file strings.h.

◆ __AST_STR_USED

#define __AST_STR_USED   used

Definition at line 41 of file strings.h.

◆ _ast_str_helper

#define _ast_str_helper (   buf,
  max_len,
  append,
  fmt,
  ap 
)     __ast_str_helper(buf, max_len, append, fmt, ap, __FILE__, __LINE__, __PRETTY_FUNCTION__)

Definition at line 976 of file strings.h.

◆ _DB1

#define _DB1 (   x)

Definition at line 799 of file strings.h.

◆ AS_OR

#define AS_OR (   a,
  b 
)    (a && ast_str_strlen(a)) ? ast_str_buffer(a) : (b)

Definition at line 49 of file strings.h.

◆ ast_join

#define ast_join (   s,
  len,
 
)    ast_join_delim(s, len, w, -1, ' ')

Join an array of strings into a single string.

Parameters
sthe resulting string buffer
lenthe length of the result buffer, s
wan array of strings to join.

This function will join all of the strings in the array 'w' into a single string. It will also place a space in the result buffer in between each string from 'w'.

Definition at line 520 of file strings.h.

◆ ast_str_alloca

#define ast_str_alloca (   init_len)

Definition at line 848 of file strings.h.

◆ ast_str_container_alloc

#define ast_str_container_alloc (   buckets)    ast_str_container_alloc_options(AO2_ALLOC_OPT_LOCK_MUTEX, buckets)

Allocates a hash container for bare strings.

Since
12
Parameters
bucketsThe number of buckets to use for the hash container
Returns
AO2 container for strings
Return values
NULLif allocation failed

Definition at line 1365 of file strings.h.

◆ ast_str_create

#define ast_str_create (   init_len)     _ast_str_create(init_len, __FILE__, __LINE__, __PRETTY_FUNCTION__)

Create a malloc'ed dynamic length string.

Parameters
init_lenThis is the initial length of the string buffer
Returns
This function returns a pointer to the dynamic string length. The result will be NULL in the case of a memory allocation error.
Note
The result of this function is dynamically allocated memory, and must be free()'d after it is no longer needed.

Definition at line 659 of file strings.h.

◆ ast_str_make_space

#define ast_str_make_space (   buf,
  new_len 
)     _ast_str_make_space(buf, new_len, __FILE__, __LINE__, __PRETTY_FUNCTION__)

Definition at line 828 of file strings.h.

◆ ast_str_tmp

#define ast_str_tmp (   init_len,
  __expr 
)

Provides a temporary ast_str and returns a copy of its buffer.

Since
16.12
17.6
18.0
Parameters
init_lenThe initial length of the temporary ast_str needed.
__exprAn expression that needs the temporary ast_str and returns a char *.
Returns
A copy of __expr's return buffer allocated on the stack.

There are a few query functions scattered around that need an ast_str in which to assemble the results but it's not always convenient to create an ast_str and ensure it's freed just to print a log message. For example:

struct ast_str *temp = ast_str_create(128);
ast_log(LOG_INFO, "Format caps: %s\n", ast_format_cap_get_names(caps, &temp));
ast_free(temp);
#define ast_free(a)
Definition: astmm.h:180
#define ast_log
Definition: astobj2.c:42
const char * ast_format_cap_get_names(const struct ast_format_cap *cap, struct ast_str **buf)
Get the names of codecs of a set of formats.
Definition: format_cap.c:734
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
Definition: strings.h:659
Support for dynamic strings.
Definition: strings.h:623

That's not bad if you only have to do it once but some of our code that deals with streams and codecs is pretty complex and good instrumentation is essential. The aim of this function is to make that easier.

With this macro, the above code can be simplified:

ast_log(LOG_INFO, "Format caps: %s\n",
ast_str_tmp(128, ast_format_cap_get_names(caps, &STR_TMP));
#define ast_str_tmp(init_len, __expr)
Provides a temporary ast_str and returns a copy of its buffer.
Definition: strings.h:1189

STR_TMP will always be a reference to the temporary ast_str created by the macro. Its scope is limited by the macro so you can use it multiple times without conflict:

ast_log(LOG_INFO, "Format caps in: %s Format caps out: %s\n",
ast_str_tmp(128, ast_format_cap_get_names(caps_in, &STR_TMP),
ast_str_tmp(128, ast_format_cap_get_names(caps_out, &STR_TMP)
);
Warning
The returned string is stack allocated so don't go overboard.

Definition at line 1189 of file strings.h.

◆ ast_to_camel_case

#define ast_to_camel_case (   s)    ast_to_camel_case_delim(s, "_")

Attempts to convert the given string to camel case using an underscore as the specified delimiter.

note - returned string needs to be freed

Parameters
sthe string to convert
Returns
The string converted to "CamelCase"

Definition at line 546 of file strings.h.

◆ AST_YESNO

#define AST_YESNO (   x)    ((x) ? "Yes" : "No")

return Yes or No depending on the argument.

Note that this macro is used my AMI, where a literal "Yes" and "No" are expected, and translations would cause problems.

Parameters
xBoolean value
Return values
Yesif x is true (non-zero)
Noif x is false (zero)

Definition at line 143 of file strings.h.

◆ DS_ALLOCA

#define DS_ALLOCA   ((struct ast_threadstorage *)2)

Definition at line 628 of file strings.h.

◆ DS_MALLOC

#define DS_MALLOC   ((struct ast_threadstorage *)1)

Definition at line 627 of file strings.h.

◆ DS_STATIC

#define DS_STATIC   ((struct ast_threadstorage *)3) /* not supported yet */

Definition at line 629 of file strings.h.

◆ S_COR

#define S_COR (   a,
  b,
  c 
)    ({typeof(&((b)[0])) __x = (b); (a) && !ast_strlen_zero(__x) ? (__x) : (c);})

returns the equivalent of logic or for strings, with an additional boolean check: second one if not empty and first one is true, otherwise third one. example: S_COR(usewidget, widget, "<no widget>")

Definition at line 87 of file strings.h.

◆ S_OR

#define S_OR (   a,
  b 
)    ({typeof(&((a)[0])) __x = (a); ast_strlen_zero(__x) ? (b) : __x;})

returns the equivalent of logic or for strings: first one if not empty, otherwise second one.

Definition at line 80 of file strings.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Error codes from __ast_str_helper() The underlying processing to manipulate dynamic string is done by __ast_str_helper(), which can return a success or a permanent failure (e.g. no memory).

Enumerator
AST_DYNSTR_BUILD_FAILED 

An error has occurred and the contents of the dynamic string are undefined

AST_DYNSTR_BUILD_RETRY 

The buffer size for the dynamic string had to be increased, and __ast_str_helper() needs to be called again after a va_end() and va_start(). This return value is legacy and will no longer be used.

Definition at line 940 of file strings.h.

940 {
941 /*! An error has occurred and the contents of the dynamic string
942 * are undefined */
944 /*! The buffer size for the dynamic string had to be increased, and
945 * __ast_str_helper() needs to be called again after
946 * a va_end() and va_start(). This return value is legacy and will
947 * no longer be used.
948 */
950};
@ AST_DYNSTR_BUILD_FAILED
Definition: strings.h:943
@ AST_DYNSTR_BUILD_RETRY
Definition: strings.h:949

◆ ast_strsep_flags

Flags for ast_strsep.

Enumerator
AST_STRSEP_STRIP 

Trim, then strip quotes. You may want to trim again

AST_STRSEP_TRIM 

Trim leading and trailing whitespace

AST_STRSEP_UNESCAPE 

Unescape '\'

AST_STRSEP_ALL 

Trim, strip, unescape

Definition at line 254 of file strings.h.

254 {
255 AST_STRSEP_STRIP = 0x01, /*!< Trim, then strip quotes. You may want to trim again */
256 AST_STRSEP_TRIM = 0x02, /*!< Trim leading and trailing whitespace */
257 AST_STRSEP_UNESCAPE = 0x04, /*!< Unescape '\' */
258 AST_STRSEP_ALL = 0x07, /*!< Trim, strip, unescape */
259};
@ AST_STRSEP_ALL
Definition: strings.h:258
@ AST_STRSEP_TRIM
Definition: strings.h:256
@ AST_STRSEP_UNESCAPE
Definition: strings.h:257
@ AST_STRSEP_STRIP
Definition: strings.h:255

Function Documentation

◆ __ast_str_helper()

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.

The arguments to this function are the same as those described for ast_str_set_va except for an addition argument, append. If append is non-zero, this will append to the current string instead of writing over it.

AST_DYNSTR_BUILD_RETRY is a legacy define. It should probably never again be used.

A return of AST_DYNSTR_BUILD_FAILED indicates a memory allocation error.

A return value greater than or equal to zero indicates the number of characters that have been written, not including the terminating '\0'. In the append case, this only includes the number of characters appended.

Note
This function should never need to be called directly. It should through calling one of the other functions or macros defined in this file.

core handler for dynamic strings. This is not meant to be called directly, but rather through the various wrapper macros ast_str_set(...) ast_str_append(...) ast_str_set_va(...) ast_str_append_va(...)

Definition at line 55 of file strings.c.

58{
59 int res;
60 int added;
61 int need;
62 int offset = (append && (*buf)->__AST_STR_LEN) ? (*buf)->__AST_STR_USED : 0;
63 va_list aq;
64
65 if (max_len < 0) {
66 max_len = (*buf)->__AST_STR_LEN; /* don't exceed the allocated space */
67 }
68
69 do {
70 va_copy(aq, ap);
71 res = vsnprintf((*buf)->__AST_STR_STR + offset, (*buf)->__AST_STR_LEN - offset, fmt, aq);
72 va_end(aq);
73
74 if (res < 0) {
75 /*
76 * vsnprintf write to string failed.
77 * I don't think this is possible with a memory buffer.
78 */
80 added = 0;
81 break;
82 }
83
84 /*
85 * vsnprintf returns how much space we used or would need.
86 * Remember that vsnprintf does not count the nil terminator
87 * so we must add 1.
88 */
89 added = res;
90 need = offset + added + 1;
91 if (need <= (*buf)->__AST_STR_LEN
92 || (max_len && max_len <= (*buf)->__AST_STR_LEN)) {
93 /*
94 * There was enough room for the string or we are not
95 * allowed to try growing the string buffer.
96 */
97 break;
98 }
99
100 /* Reallocate the buffer and try again. */
101 if (max_len == 0) {
102 /* unbounded, give more room for next time */
103 need += 16 + need / 4;
104 } else if (max_len < need) {
105 /* truncate as needed */
106 need = max_len;
107 }
108
109 if (_ast_str_make_space(buf, need, file, lineno, function)) {
110 ast_log_safe(LOG_VERBOSE, "failed to extend from %d to %d\n",
111 (int) (*buf)->__AST_STR_LEN, need);
112
114 break;
115 }
116 } while (1);
117
118 /* Update space used, keep in mind truncation may be necessary. */
119 (*buf)->__AST_STR_USED = ((*buf)->__AST_STR_LEN <= offset + added)
120 ? (*buf)->__AST_STR_LEN - 1
121 : offset + added;
122
123 /* Ensure that the string is terminated. */
124 (*buf)->__AST_STR_STR[(*buf)->__AST_STR_USED] = '\0';
125
126 return res;
127}
if(!yyg->yy_init)
Definition: ast_expr2f.c:854
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
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.
Definition: logger.c:2475
#define LOG_VERBOSE
int _ast_str_make_space(struct ast_str **buf, size_t new_len, const char *file, int lineno, const char *function)
Definition: strings.h:827

References _ast_str_make_space(), AST_DYNSTR_BUILD_FAILED, ast_log_safe(), buf, make_ari_stubs::file, if(), and LOG_VERBOSE.

◆ __ast_str_helper2()

char * __ast_str_helper2 ( struct ast_str **  buf,
ssize_t  max_len,
const char *  src,
size_t  maxsrc,
int  append,
int  escapecommas 
)

Definition at line 129 of file strings.c.

130{
131 int dynamic = 0;
132 char *ptr = append ? &((*buf)->__AST_STR_STR[(*buf)->__AST_STR_USED]) : (*buf)->__AST_STR_STR;
133
134 if (maxlen < 1) {
135 if (maxlen == 0) {
136 dynamic = 1;
137 }
138 maxlen = (*buf)->__AST_STR_LEN;
139 }
140
141 while (*src && maxsrc && maxlen && (!escapecommas || (maxlen - 1))) {
142 if (escapecommas && (*src == '\\' || *src == ',')) {
143 *ptr++ = '\\';
144 maxlen--;
145 (*buf)->__AST_STR_USED++;
146 }
147 *ptr++ = *src++;
148 maxsrc--;
149 maxlen--;
150 (*buf)->__AST_STR_USED++;
151
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;
156 if (ast_str_make_space(buf, (*buf)->__AST_STR_LEN * 2)) {
157 /* If the buffer can't be extended, end it. */
158 break;
159 }
160 /* What we extended the buffer by */
161 maxlen = old;
162
163 ptr += (*buf)->__AST_STR_STR - oldbase;
164 }
165 }
166 if (__builtin_expect(!maxlen, 0)) {
167 ptr--;
168 }
169 *ptr = '\0';
170 return (*buf)->__AST_STR_STR;
171}
#define ast_str_make_space(buf, new_len)
Definition: strings.h:828

References ast_str_make_space, buf, and if().

Referenced by ast_str_append_substr(), ast_str_append_va(), ast_str_set_escapecommas(), and ast_str_set_substr().

◆ _ast_str_create()

struct ast_str * _ast_str_create ( size_t  init_len,
const char *  file,
int  lineno,
const char *  func 
)
inline

Definition at line 677 of file strings.h.

685{

References buf.

◆ _ast_str_make_space()

int _ast_str_make_space ( struct ast_str **  buf,
size_t  new_len,
const char *  file,
int  lineno,
const char *  function 
)
inline

Make space in a new string (e.g. to read in data from a file)

Definition at line 827 of file strings.h.

833{

Referenced by __ast_str_helper().

◆ ast_begins_with()

static int force_inline attribute_pure ast_begins_with ( const char *  str,
const char *  prefix 
)
static

◆ ast_build_string()

int ast_build_string ( char **  buffer,
size_t *  space,
const char *  fmt,
  ... 
)

Build a string in a buffer, designed to be called repeatedly.

Note
This method is not recommended. New code should use ast_str_*() instead.

This is a wrapper for snprintf, that properly handles the buffer pointer and buffer space available.

Parameters
buffercurrent position in buffer to place string into (will be updated on return)
spaceremaining space in buffer (will be updated on return)
fmtprintf-style format string
Return values
0on success
non-zeroon failure.

Definition at line 2167 of file utils.c.

2168{
2169 va_list ap;
2170 int result;
2171
2172 va_start(ap, fmt);
2173 result = ast_build_string_va(buffer, space, fmt, ap);
2174 va_end(ap);
2175
2176 return result;
2177}
static PGresult * result
Definition: cel_pgsql.c:84
int ast_build_string_va(char **buffer, size_t *space, const char *fmt, va_list ap)
Build a string in a buffer, designed to be called repeatedly.
Definition: utils.c:2148

References ast_build_string_va(), and result.

Referenced by ast_fax_caps_to_str(), generate_filenames_string(), handle_speechrecognize(), pp_each_extension_helper(), and pp_each_user_helper().

◆ ast_build_string_va()

int ast_build_string_va ( char **  buffer,
size_t *  space,
const char *  fmt,
va_list  ap 
)

Build a string in a buffer, designed to be called repeatedly.

This is a wrapper for snprintf, that properly handles the buffer pointer and buffer space available.

Return values
zeroon success.
non-zeroon failure.
Parameters
buffercurrent position in buffer to place string into (will be updated on return)
spaceremaining space in buffer (will be updated on return)
fmtprintf-style format string
apvarargs list of arguments for format

Definition at line 2148 of file utils.c.

2149{
2150 int result;
2151
2152 if (!buffer || !*buffer || !space || !*space)
2153 return -1;
2154
2155 result = vsnprintf(*buffer, *space, fmt, ap);
2156
2157 if (result < 0)
2158 return -1;
2159 else if (result > *space)
2160 result = *space;
2161
2162 *buffer += result;
2163 *space -= result;
2164 return 0;
2165}

References result.

Referenced by ast_build_string().

◆ ast_check_digits()

int ast_check_digits ( const char *  arg)
inline

Check if a string is only digits.

Return values
1The string contains only digits
0The string contains non-digit characters

Definition at line 1216 of file strings.h.

1225{

◆ ast_copy_string()

void ast_copy_string ( char *  dst,
const char *  src,
size_t  size 
)
inline

Size-limited null-terminating string copy.

Parameters
dstThe destination buffer.
srcThe source string
sizeThe size of the destination buffer

This is similar to strncpy, with two important differences:

  • the destination buffer will always be null-terminated
  • the destination buffer is not filled with zeros past the copied string length These differences make it slightly more efficient, and safer to use since it will not leave the destination buffer unterminated. There is no need to pass an artificially reduced buffer size to this function (unlike strncpy), and the buffer does not need to be initialized to zeroes prior to calling this function.

Definition at line 425 of file strings.h.

623{

Referenced by __allocate_taskprocessor(), __analog_handle_event(), __analog_ss_thread(), __ast_channel_internal_alloc(), __ast_context_destroy(), __ast_http_load(), __ast_http_post_load(), __ast_pbx_run(), __ast_play_and_record(), __ast_sorcery_object_field_register(), __init_manager(), __schedule_action(), _ast_var_assign(), _get_mohbyname(), _iax2_show_peers_one(), acf_channel_read(), acf_curlopt_helper(), acf_cut_exec(), acf_exception_read(), acf_faxopt_read(), acf_fetch(), acf_iaxvar_read(), acf_if(), acf_isexten_exec(), acf_jabberreceive_read(), acf_odbc_read(), acf_sprintf(), acf_transaction_read(), acf_version_exec(), acf_vm_info(), acl_new(), action_confbridgestartrecord(), action_originate(), action_playback_and_continue(), actual_load_config(), add_action_to_menu_entry(), add_email_attachment(), add_exten_to_pattern_tree(), add_menu_entry(), add_msid_to_stream(), add_redirect(), add_to_queue(), add_vm_recipients_from_string(), adsi_load(), adsi_message(), adsi_process(), aes_helper(), agent_function_read(), alarmreceiver_exec(), alias_mailbox_mapping_create(), alloc_profile(), alloc_signal(), analog_call(), analog_hangup(), analog_ss_thread(), announce_request(), announce_thread(), answer_exec_enable(), aoc_create_ie_data(), aoc_create_ie_data_charging_rate(), aoc_parse_ie_charging_rate(), app_exec(), append_mailbox(), applicationmap_item_alloc(), apply_general_options(), apply_option(), apply_options_full(), ari_channels_handle_originate_with_id(), ast_aoc_s_add_rate_duration(), ast_aoc_s_add_rate_flat(), ast_aoc_s_add_rate_volume(), ast_aoc_set_association_number(), ast_aoc_set_currency_info(), ast_app_group_split_group(), ast_apply_ha(), ast_attended_transfer_message_add_app(), ast_attended_transfer_message_add_merge(), ast_blind_transfer_message_create(), ast_bridge_dtmf_hook(), ast_bridge_features_register(), ast_bucket_alloc(), ast_bucket_file_alloc(), ast_call_forward(), ast_callerid_merge(), ast_callerid_parse(), ast_callerid_split(), ast_category_rename(), ast_cc_extension_monitor_add_dialstring(), ast_cc_get_param(), ast_cdr_format_var(), ast_cdr_setuserfield(), ast_channel_context_set(), ast_channel_destructor(), ast_channel_exten_set(), ast_channel_get_cc_agent_type(), ast_channel_get_device_name(), ast_channel_internal_set_fake_ids(), ast_devstate_prov_add(), ast_eivr_getvariable(), ast_escape(), ast_expr(), ast_frame_subclass2str(), ast_frame_type2str(), ast_func_read(), ast_get_enum(), ast_get_extension_data(), ast_get_feature(), ast_get_hint(), ast_get_indication_zone(), ast_get_srv(), ast_get_txt(), ast_http_prefix(), ast_init_logger_for_socket_console(), ast_jb_conf_default(), ast_linear_stream(), ast_makesocket(), ast_media_cache_retrieve(), ast_media_cache_retrieve_metadata(), ast_merge_contexts_and_delete(), ast_moh_files_next(), ast_msg_data_alloc(), ast_multi_channel_blob_add_channel(), ast_presence_state_prov_add(), ast_privacy_check(), ast_privacy_set(), ast_read_image(), ast_remove_hint(), ast_rtp_instance_set_channel_id(), ast_say_date_th(), ast_say_date_with_format_da(), ast_say_date_with_format_de(), ast_say_date_with_format_en(), ast_say_date_with_format_es(), ast_say_date_with_format_fr(), ast_say_date_with_format_gr(), ast_say_date_with_format_is(), ast_say_date_with_format_it(), ast_say_date_with_format_nl(), ast_say_date_with_format_pl(), ast_say_date_with_format_th(), ast_say_date_with_format_vi(), ast_say_date_with_format_zh(), ast_say_datetime_from_now_pt(), ast_say_datetime_th(), ast_say_enumeration_full_da(), ast_say_enumeration_full_de(), ast_say_enumeration_full_en(), ast_say_enumeration_full_is(), ast_say_enumeration_full_vi(), ast_say_number_full_cs(), ast_say_number_full_da(), ast_say_number_full_de(), ast_say_number_full_en_GB(), ast_say_number_full_es(), ast_say_number_full_fr(), ast_say_number_full_gr(), ast_say_number_full_hu(), ast_say_number_full_is(), ast_say_number_full_it(), ast_say_number_full_ja(), ast_say_number_full_nl(), ast_say_number_full_no(), ast_say_number_full_pt(), ast_say_number_full_ru(), ast_say_number_full_se(), ast_say_number_full_th(), ast_say_number_full_vi(), ast_say_number_full_zh(), ast_set_cc_agent_dialstring(), ast_set_cc_callback_sub(), ast_setstate(), ast_sip_cli_traverse_objects(), ast_sip_create_rdata_with_contact(), ast_sip_dtmf_to_str(), ast_sip_get_default_from_user(), ast_sip_get_default_realm(), ast_sip_get_transport_name(), ast_sip_publish_client_get_user_from_uri(), ast_sip_publish_client_get_user_to_uri(), ast_sip_sched_task_get_name(), ast_sorcery_alloc(), ast_sorcery_object_fields_register(), AST_TEST_DEFINE(), ast_to_camel_case_delim(), ast_tryconnect(), ast_tzset(), ast_unregister_indication_country(), ast_var_channels_table(), ast_var_indications(), ast_var_indications_table(), ast_xmldoc_printable(), asterisk_daemon(), audiosocket_request(), auth_http_callback(), authenticate(), authenticate_verify(), begin_dial_channel(), blr_ebl(), bridge_agent_hold_push(), bridge_channel_internal_queue_attended_transfer(), bridge_channel_internal_queue_blind_transfer(), bridge_parking_push(), bridge_profile_alloc(), bridges_scrape_cb(), bucket_file_update_path(), bucket_file_wizard_retrieve(), bucket_wizard_retrieve(), build_conf(), build_context(), build_device(), build_mapping(), build_peer(), build_user(), cache_lookup(), cache_lookup_internal(), calendar_event_read(), calendar_join_attendees(), calendar_query_result_exec(), callerid_feed(), callerid_feed_jp(), callerid_read(), category_set_sublevels(), cc_build_payload(), cc_generic_agent_init(), cdata(), cdr_generic_register(), cdr_object_create_public_records(), cdr_object_format_property(), cdr_object_format_var_internal(), cdr_object_update_party_b_userfield_cb(), cdr_read_callback(), chan_pjsip_add_hold(), chan_pjsip_incoming_response_update_cause(), change_password_realtime(), channel_do_masquerade(), channel_read_pjsip(), channel_read_rtp(), channel_snapshot_connected_create(), channel_snapshot_peer_create(), channels_scrape_cb(), chararray_handler_fn(), check_match(), check_password(), cli_channelstats_print_body(), cli_list_subscriptions_detail(), cli_show_subscriptions_detail(), common_exec(), compile_script(), complete_dpreply(), complete_indications(), conf_exec(), conf_run(), config_function_read(), config_pgsql(), config_text_file_load(), configure_local_rtp(), connectedline_read(), context_table_create_autohints(), copy_error(), copy_menu_entry(), copy_message(), coreshowchannelmap_add_connected_channels(), create_addr(), create_followme_number(), create_parked_subscription_full(), create_queue_member(), create_vmaccount(), crement_function_read(), csv_quote(), curl_header_cb(), cut_internal(), dahdi_call(), dahdi_func_read(), dahdi_handle_event(), dahdi_hangup(), dahdi_new(), dahdi_queryoption(), dahdi_show_channel(), dahdi_show_channels(), db_get_common(), device_state_cb(), device_state_notify_callbacks(), devstate_read(), dial_exec_full(), dialgroup_read(), dialgroup_write(), dialout(), dictate_exec(), disa_exec(), dispatch_thread_handler(), dns_srv_alloc(), do_forward(), dtls_handler(), dtmf_store_framehook(), dump_addr(), dump_byte(), dump_datetime(), dump_int(), dump_ipaddr(), dump_prov_flags(), dump_prov_ies(), dump_samprate(), dump_short(), dump_versioned_codec(), dundi_answer_entity(), dundi_answer_query(), dundi_do_lookup(), dundi_do_precache(), dundi_do_query(), dundi_exec(), dundi_lookup_internal(), dundi_lookup_local(), dundi_precache_internal(), dundi_prop_precache(), dundi_query_eid_internal(), dundi_query_thread(), ebl_callback(), endpoints_scrape_cb(), enum_query_read(), enum_result_read(), env_read(), epoch_to_exchange_time(), evt_gen_auth_method_not_allowed(), evt_gen_chal_resp_failed(), evt_gen_chal_sent(), evt_gen_failed_acl(), evt_gen_inval_acct_id(), evt_gen_inval_password(), evt_gen_inval_transport(), evt_gen_load_avg(), evt_gen_mem_limit(), evt_gen_req_bad_format(), evt_gen_req_no_support(), evt_gen_req_not_allowed(), evt_gen_session_limit(), evt_gen_successful_auth(), evt_gen_unexpected_addr(), extstate_read(), featuremap_get(), fetch_callerid_num(), file_basename(), file_dirname(), file_extension_from_string(), filename_parse(), find_account(), find_agent_callbacks(), find_cache(), find_conf(), find_conf_realtime(), find_engine(), find_or_create(), find_queue_by_name_rt(), find_subchannel_by_name(), find_user_realtime(), findmeexec(), format_log_json(), forward_message(), func_channel_read(), func_get_parkingslot_channel(), func_mixmonitor_read(), func_read(), function_enum(), function_iaxpeer(), function_ltrim(), function_ooh323_read(), function_realtime_read(), function_realtime_readdestroy(), function_rtrim(), function_trim(), gen_header(), general_get(), get_date(), get_destination(), get_ipaddress(), get_name_from_resource(), get_number_str_en(), get_ordinal_str_en(), getdisplaybyname(), getflagbyname(), getkeybyname(), getstatebyname(), getsubbyname(), global_read(), gosub_allocate_frame(), grab_transfer(), group_count_function_read(), group_function_read(), group_function_write(), group_list_function_read(), h264_getjoint(), handle_cli_confbridge_show_bridge_profile(), handle_cli_confbridge_start_record(), handle_cli_iax2_show_cache(), handle_cli_iax2_show_users(), handle_cli_indication_add(), handle_cli_indication_show(), handle_cli_keys_init(), handle_cli_presencestate_list(), handle_cli_test_locales(), handle_cli_ulimit(), handle_command_response(), handle_dial_page(), handle_export_primitives(), handle_select_codec(), handle_select_language(), handle_setcallerid(), handle_setting(), hangupcause_keys_read(), hangupcause_read(), has_voicemail(), hash_read(), headers_to_vars(), iax2_ack_registry(), iax2_append_register(), iax2_exec(), iax2_getpeername(), iax2_register(), iax2_transfer(), iax_frame_subclass2str(), iax_parse_ies(), iax_process_template(), iax_show_provisioning(), iax_template_copy(), iax_template_parse(), ifmodule_read(), iftime(), inboxcount2(), incoming_in_dialog_request(), init_acf_query(), init_logger_chain(), init_profile(), init_state(), inprocess_count(), jb_helper(), jingle_action_session_terminate(), jingle_alloc(), jingle_outgoing_hook(), jingle_request(), join_conference_bridge(), join_queue(), key_dial_page(), key_favorite(), key_history(), key_main_page(), key_select_extension(), key_select_language(), leave_voicemail(), link_topic_proxy(), listfilter(), load_asterisk_conf(), load_config(), load_module(), load_modules(), load_moh_classes(), load_mysql_config(), load_odbc_config(), load_password(), load_realtime_rules(), load_values_config(), load_zonemessages(), local_alloc(), local_read(), lock_read(), log_events(), lookup_iface(), make_email_file(), make_filename(), make_fn(), manager_set_defaults(), math(), mbl_load_adapter(), mbl_load_device(), media_request_helper(), menu_alloc(), message_template_build(), message_template_create(), message_template_parse_filebody(), minivm_accmess_exec(), minivm_account_func_read(), minivm_delete_exec(), minivm_greet_exec(), minivm_mwi_exec(), minivm_notify_exec(), mkintf(), moh_files_alloc(), moh_parse_options(), moh_scan_files(), msg_create_from_file(), msg_data_func_read(), msg_func_read(), my_distinctive_ring(), my_get_callerid(), named_acl_alloc(), named_acl_find(), netconsole(), new_category(), notify_new_message(), notify_option_alloc(), notify_option_handler(), odbc_log(), onOutgoingCall(), ooh323_alloc(), ooh323_call(), ooh323_onReceivedSetup(), ooh323_request(), open_mailbox(), page_exec(), parking_park_call(), parse_bookmark(), parse_config(), parse_naptr(), parse_node(), parse_options(), parse_tag(), parse_tone_zone(), party_id_read(), party_name_read(), party_number_read(), party_subaddress_read(), pbx_builtin_saynumber(), pbx_builtin_sayordinal(), pbx_extension_helper(), pbx_load_config(), pbx_load_users(), pbx_outgoing_attempt(), pbx_retrieve_variable(), pbx_substitute_variables_helper_full_location(), peek_read(), peer_status(), pgsql_reconnect(), pickup_get(), pjsip_acf_dial_contacts_read(), pjsip_set_logger_pcap(), play_message_by_id(), play_record_review(), populate_defaults(), presence_read(), presence_state_notify_callbacks(), private_enum_init(), process_dahdi(), process_precache(), process_request(), profile_set_param(), prometheus_metric_create(), publisher_start(), queue_exec(), queue_function_queuegetchannel(), queue_set_param(), quote(), rcv_mac_addr(), read_exec(), read_header(), read_headers(), read_param(), read_password_from_file(), realtime_common(), realtime_switch_common(), realtimefield_read(), receive_ademco_event(), record_exec(), redirecting_read(), refer_incoming_blind_request(), register_peer_exten(), register_verify(), registrar_contact_delete(), registry_rerequest(), reload_config(), reload_followme(), reload_module(), reload_queue_rules(), reload_single_member(), remove_from_queue(), reschedule_precache(), reset_user_pw(), ring_entry(), rt_extend_conf(), rt_handle_member_record(), run_externnotify(), save_dialstatus(), send_signal(), sendmail(), sendpage(), set(), set_asterisk_conf_path(), set_config(), set_next_mime_type(), set_queue_member_pause(), set_socket_path(), setup_bridge_role(), setup_filestack(), setup_mixmonitor(), setup_privacy_args(), shared_read(), show_entry_history(), show_phone_number(), sip_subscription_to_ami(), smdi_load(), smdi_msg_read(), smdi_read(), sms_exec(), sms_handleincoming(), sms_handleincoming_proto2(), sms_writefile(), socket_process_helper(), socket_read(), softhangup_exec(), sorcery_object_type_alloc(), spawn_dp_lookup(), spawn_mp3(), speech_grammar(), speech_read(), speech_score(), speech_text(), srv_query_read(), srv_result_read(), stasis_app_control_continue(), stat_read(), store_tone_zone_ring_cadence(), subscription_change_alloc(), subscription_established(), subscription_get_generator_from_rdata(), subscription_persistence_update(), substring(), term_color(), timeout_read(), timezone_add(), try_calling(), try_load_key(), trylock_read(), txt_callback(), unistim_request(), unistim_sp(), unistim_ss(), unlock_read(), update_our_aliases(), uridecode(), user_profile_alloc(), vm_authenticate(), vm_change_password(), vm_change_password_shell(), vm_execmain(), vm_mailbox_snapshot_create(), vm_msg_forward(), vm_msg_move(), vm_msg_play(), vm_msg_remove(), vmauthenticate(), wait_for_answer(), wait_for_winner(), while(), write_history(), write_metadata(), xfer_get(), xmpp_client_alloc(), xmpp_client_create_buddy(), xmpp_pak_message(), and xmpp_pak_presence().

◆ ast_ends_with()

static int force_inline attribute_pure ast_ends_with ( const char *  str,
const char *  suffix 
)
static

Checks whether a string ends with another.

Since
12.0.0
Parameters
strString to check.
suffixSuffix to look for.
Return values
1if str ends with suffix
0otherwise.

Definition at line 116 of file strings.h.

117{
118 size_t str_len;
119 size_t suffix_len;
120
121 ast_assert(str != NULL);
122 ast_assert(suffix != NULL);
123 str_len = strlen(str);
124 suffix_len = strlen(suffix);
125
126 if (suffix_len > str_len) {
127 return 0;
128 }
129
130 return strcmp(str + str_len - suffix_len, suffix) == 0;
131}

References ast_assert, NULL, and str.

Referenced by ast_ari_callback(), ast_sip_cli_traverse_objects(), AST_TEST_DEFINE(), coreshowchannelmap_add_connected_channels(), and format_log_message_ap().

◆ ast_escape()

char * ast_escape ( char *  dest,
const char *  s,
size_t  size,
const char *  to_escape 
)

Escape the 'to_escape' characters in the given string.

Note
The given output buffer will contain a truncated escaped version of the source string if the given buffer is not large enough.
Parameters
destthe escaped string
sthe source string to escape
sizeThe size of the destination buffer
to_escapean array of characters to escape
Returns
Pointer to the destination.

Definition at line 2034 of file utils.c.

2035{
2036 char *p;
2037 char *c;
2038
2039 if (!dest || !size) {
2040 return dest;
2041 }
2042 if (ast_strlen_zero(s)) {
2043 *dest = '\0';
2044 return dest;
2045 }
2046
2047 if (ast_strlen_zero(to_escape)) {
2048 ast_copy_string(dest, s, size);
2049 return dest;
2050 }
2051
2052 for (p = dest; *s && --size; ++s, ++p) {
2053 /* If in the list of characters to escape then escape it */
2054 if (strchr(to_escape, *s)) {
2055 if (!--size) {
2056 /* Not enough room left for the escape sequence. */
2057 break;
2058 }
2059
2060 /*
2061 * See if the character to escape is part of the standard escape
2062 * sequences. If so we'll have to use its mapped counterpart
2063 * otherwise just use the current character.
2064 */
2065 c = strchr(escape_sequences, *s);
2066 *p++ = '\\';
2068 } else {
2069 *p = *s;
2070 }
2071 }
2072 *p = '\0';
2073
2074 return dest;
2075}
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:425
static struct test_val c
char escape_sequences[]
Definition: utils.c:2022
static char escape_sequences_map[]
Definition: utils.c:2030

References ast_copy_string(), ast_strlen_zero(), c, escape_sequences, and escape_sequences_map.

Referenced by ast_escape_alloc().

◆ ast_escape_alloc()

char * ast_escape_alloc ( const char *  s,
const char *  to_escape 
)

Escape the 'to_escape' characters in the given string.

Note
Caller is responsible for freeing the returned string
Parameters
sthe source string to escape
to_escapean array of characters to escape
Returns
Pointer to the escaped string or NULL.

Definition at line 2132 of file utils.c.

2133{
2134 size_t size = 0;
2135 char *dest = escape_alloc(s, &size);
2136
2137 return ast_escape(dest, s, size, to_escape);
2138}
static char * escape_alloc(const char *s, size_t *size)
Definition: utils.c:2118
char * ast_escape(char *dest, const char *s, size_t size, const char *to_escape)
Escape the 'to_escape' characters in the given string.
Definition: utils.c:2034

References ast_escape(), and escape_alloc().

◆ ast_escape_c()

char * ast_escape_c ( char *  dest,
const char *  s,
size_t  size 
)

Escape standard 'C' sequences in the given string.

Note
The given output buffer will contain a truncated escaped version of the source string if the given buffer is not large enough.
Parameters
destthe escaped string
sthe source string to escape
sizeThe size of the destination buffer
Returns
Pointer to the escaped string.

Definition at line 2077 of file utils.c.

2078{
2079 /*
2080 * Note - This is an optimized version of ast_escape. When looking only
2081 * for escape_sequences a couple of checks used in the generic case can
2082 * be left out thus making it slightly more efficient.
2083 */
2084 char *p;
2085 char *c;
2086
2087 if (!dest || !size) {
2088 return dest;
2089 }
2090 if (ast_strlen_zero(s)) {
2091 *dest = '\0';
2092 return dest;
2093 }
2094
2095 for (p = dest; *s && --size; ++s, ++p) {
2096 /*
2097 * See if the character to escape is part of the standard escape
2098 * sequences. If so use its mapped counterpart.
2099 */
2100 c = strchr(escape_sequences, *s);
2101 if (c) {
2102 if (!--size) {
2103 /* Not enough room left for the escape sequence. */
2104 break;
2105 }
2106
2107 *p++ = '\\';
2109 } else {
2110 *p = *s;
2111 }
2112 }
2113 *p = '\0';
2114
2115 return dest;
2116}

References ast_strlen_zero(), c, escape_sequences, and escape_sequences_map.

Referenced by ast_escape_c_alloc().

◆ ast_escape_c_alloc()

char * ast_escape_c_alloc ( const char *  s)

Escape standard 'C' sequences in the given string.

Note
Caller is responsible for freeing the returned string
Parameters
sthe source string to escape
Returns
Pointer to the escaped string or NULL.

Definition at line 2140 of file utils.c.

2141{
2142 size_t size = 0;
2143 char *dest = escape_alloc(s, &size);
2144
2145 return ast_escape_c(dest, s, size);
2146}
char * ast_escape_c(char *dest, const char *s, size_t size)
Escape standard 'C' sequences in the given string.
Definition: utils.c:2077

References ast_escape_c(), and escape_alloc().

Referenced by ast_manager_build_channel_state_string_prefix(), channel_new_callerid(), presence_state_to_ami(), and varset_to_ami().

◆ ast_false()

int attribute_pure ast_false ( const char *  val)

Make sure something is false. Determine if a string containing a boolean value is "false". This function checks to see whether a string passed to it is an indication of an "false" value. It checks to see if the string is "no", "false", "n", "f", "off" or "0".

Return values
-1if "true".
0otherwise, like NUL pointer.

Definition at line 2216 of file utils.c.

2217{
2218 if (ast_strlen_zero(s))
2219 return 0;
2220
2221 /* Determine if this is a false value */
2222 if (!strcasecmp(s, "no") ||
2223 !strcasecmp(s, "false") ||
2224 !strcasecmp(s, "n") ||
2225 !strcasecmp(s, "f") ||
2226 !strcasecmp(s, "0") ||
2227 !strcasecmp(s, "off"))
2228 return -1;
2229
2230 return 0;
2231}

References ast_strlen_zero().

Referenced by acf_faxopt_write(), acf_transaction_write(), action_updateconfig(), actual_load_config(), announce_user_count_all_handler(), aoc_cli_debug_enable(), bool_handler_fn(), boolflag_handler_fn(), build_peer(), build_user(), check_debug(), dahdi_set_dnd(), dahdi_set_mwi(), find_realtime(), function_ooh323_write(), handle_queue_set_member_ringinuse(), hook_write(), init_acf_query(), load_config(), manager_mute_mixmonitor(), manager_queue_member_ringinuse(), parking_feature_flag_cfg(), parse_empty_options(), parse_playtone(), prack_handler(), process_config(), process_dahdi(), read_pjproject_startup_options(), reload_config(), reload_single_member(), rt_handle_member_record(), rtp_reload(), run_agi(), set_config(), sla_build_trunk(), strings_to_mask(), and timers_handler().

◆ ast_generate_random_string()

char * ast_generate_random_string ( char *  buf,
size_t  size 
)

Create a pseudo-random string of a fixed length.

This function is useful for generating a string whose randomness does not need to be across all time and space, does not need to be cryptographically secure, and needs to fit in a limited space.

This function will write a null byte at the final position in the buffer (buf[size - 1]). So if you pass in a size of 10, then this will generate a random 9-character string.

Parameters
bufBuffer to write random string into.
sizeThe size of the buffer.
Returns
A pointer to buf

Definition at line 226 of file strings.c.

227{
228 int i;
229
230 for (i = 0; i < size - 1; ++i) {
231 buf[i] = 'a' + (ast_random() % 26);
232 }
233 buf[i] = '\0';
234
235 return buf;
236}
long int ast_random(void)
Definition: utils.c:2312

References ast_random(), and buf.

Referenced by add_eprofile_to_tdata(), add_rlmi_resource(), create_multipart_body(), generate_content_id_hdr(), and sip_outbound_registration_regc_alloc().

◆ ast_get_time_t()

int ast_get_time_t ( const char *  src,
time_t *  dst,
time_t  _default,
int *  consumed 
)

Parse a time (integer) string.

Parameters
srcString to parse
dstDestination
_defaultValue to use if the string does not contain a valid time
consumedThe number of characters 'consumed' in the string by the parse (see 'man sscanf' for details)
Return values
zeroon success.
non-zeroon failure.

Parse a time (integer) string.

Definition at line 2446 of file utils.c.

2447{
2448 long t;
2449 int scanned;
2450
2451 if (dst == NULL)
2452 return -1;
2453
2454 *dst = _default;
2455
2456 if (ast_strlen_zero(src))
2457 return -1;
2458
2459 /* only integer at the moment, but one day we could accept more formats */
2460 if (sscanf(src, "%30ld%n", &t, &scanned) == 1) {
2461 *dst = t;
2462 if (consumed)
2463 *consumed = scanned;
2464 return 0;
2465 } else
2466 return -1;
2467}

References ast_strlen_zero(), and NULL.

Referenced by cache_lookup_internal(), dundi_show_cache(), dundi_show_hints(), handle_saydatetime(), load_password(), play_message_datetime(), process_clearcache(), realtime_peer(), and sayunixtime_exec().

◆ ast_get_timeval()

int ast_get_timeval ( const char *  src,
struct timeval *  dst,
struct timeval  _default,
int *  consumed 
)

Parse a time (float) string.

Parameters
srcString to parse
dstDestination
_defaultValue to use if the string does not contain a valid time
consumedThe number of characters 'consumed' in the string by the parse (see 'man sscanf' for details)
Return values
zeroon success.
non-zeroon failure.

Parse a time (float) string.

Definition at line 2419 of file utils.c.

2420{
2421 long double dtv = 0.0;
2422 int scanned;
2423
2424 if (dst == NULL)
2425 return -1;
2426
2427 *dst = _default;
2428
2429 if (ast_strlen_zero(src))
2430 return -1;
2431
2432 /* only integer at the moment, but one day we could accept more formats */
2433 if (sscanf(src, "%30Lf%n", &dtv, &scanned) > 0) {
2434 dst->tv_sec = dtv;
2435 dst->tv_usec = (dtv - dst->tv_sec) * 1000000.0;
2436 if (consumed)
2437 *consumed = scanned;
2438 return 0;
2439 } else
2440 return -1;
2441}

References ast_strlen_zero(), and NULL.

Referenced by acf_strftime(), expiration_str2struct(), persistence_expires_str2struct(), and timeval_str2struct().

◆ ast_in_delimited_string()

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'.

Note
This will skip extra leading spaces between delimiters.
Parameters
needleThe string to search for
haystackThe string searched in
delimThe haystack delimiter
Return values
trueIf an exact match for needle is in haystack.
falseotherwise

Definition at line 433 of file strings.c.

434{
435 const char *end;
436 unsigned long needle_size;
437
438 ast_assert(haystack != NULL);
439
440 if (!needle) {
441 return 0;
442 }
443
444 needle_size = strlen(needle);
445 haystack = ast_skip_blanks(haystack);
446
447 while ((end = strchr(haystack, delim))) {
448 if (needle_size == end - haystack && !strncmp(haystack, needle, needle_size)) {
449 return 1;
450 }
451 haystack = ast_skip_blanks(end + 1);
452 }
453
454 return strcmp(haystack, needle) ? 0 : -1;
455}
char * end
Definition: eagi_proxy.c:73
char * ast_skip_blanks(const char *str)
Gets a pointer to the first non-whitespace character in a string.
Definition: strings.h:161

References ast_assert, ast_skip_blanks(), end, and NULL.

Referenced by __manager_event_sessions_va(), ast_json_object_create_vars(), and AST_TEST_DEFINE().

◆ ast_join_delim()

void ast_join_delim ( char *  s,
size_t  len,
const char *const  w[],
unsigned int  size,
char  delim 
)

Join an array of strings into a single string.

Parameters
sthe resulting string buffer
lenthe length of the result buffer, s
wan array of strings to join.
sizethe number of elements to join
delimdelimiter between elements

This function will join all of the strings in the array 'w' into a single string. It will also place 'delim' in the result buffer in between each string from 'w'.

Since
12

Definition at line 2378 of file utils.c.

2379{
2380 int x, ofs = 0;
2381 const char *src;
2382
2383 /* Join words into a string */
2384 if (!s)
2385 return;
2386 for (x = 0; ofs < len && x < size && w[x] ; x++) {
2387 if (x > 0)
2388 s[ofs++] = delim;
2389 for (src = w[x]; *src && ofs < len; src++)
2390 s[ofs++] = *src;
2391 }
2392 if (ofs == len)
2393 ofs--;
2394 s[ofs] = '\0';
2395}
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)

References len().

Referenced by ast_sip_auths_to_str().

◆ ast_read_line_from_buffer()

char * ast_read_line_from_buffer ( char **  buffer)

Read lines from a string buffer.

Since
13.18.0
Parameters
[in,out]bufferA pointer to a char * string with either Unix or Windows line endings
Returns
The "next" line
Warning
The original string and *buffer will be modified.

Both '\n' and '\r\n' are treated as single delimiters but consecutive occurrences of the delimiters are NOT considered to be a single delimiter. This preserves blank lines in the input.

macOS line endings ('\r') are not supported at this time.

Definition at line 371 of file strings.c.

372{
373 char *start = *buffer;
374
375 if (!buffer || !*buffer || *(*buffer) == '\0') {
376 return NULL;
377 }
378
379 while (*(*buffer) && *(*buffer) != '\n' ) {
380 (*buffer)++;
381 }
382
383 *(*buffer) = '\0';
384 if (*(*buffer - 1) == '\r') {
385 *(*buffer - 1) = '\0';
386 }
387 (*buffer)++;
388
389 return start;
390}

References NULL.

Referenced by crypto_get_cert_subject(), and parse_simple_message_summary().

◆ ast_regex_string_to_regex_pattern()

int ast_regex_string_to_regex_pattern ( const char *  regex_string,
struct ast_str **  regex_pattern 
)

Given a string regex_string in the form of "/regex/", convert it into the form of "regex".

This function will trim one leading / and one trailing / from a given input string ast_str regex_pattern must be preallocated before calling this function

Return values
0on success, non-zero on failure.
1if we only stripped a leading /
2if we only stripped a trailing /
3if we did not strip any / characters
Parameters
regex_stringthe string containing /regex/
regex_patternthe destination ast_str which will contain "regex" after execution

Definition at line 2179 of file utils.c.

2180{
2181 int regex_len = strlen(regex_string);
2182 int ret = 3;
2183
2184 /* Chop off the leading / if there is one */
2185 if ((regex_len >= 1) && (regex_string[0] == '/')) {
2186 ast_str_set(regex_pattern, 0, "%s", regex_string + 1);
2187 ret -= 2;
2188 }
2189
2190 /* Chop off the ending / if there is one */
2191 if ((regex_len > 1) && (regex_string[regex_len - 1] == '/')) {
2192 ast_str_truncate(*regex_pattern, -1);
2193 ret -= 1;
2194 }
2195
2196 return ret;
2197}
char * ast_str_truncate(struct ast_str *buf, ssize_t len)
Truncates the enclosed string to the given length.
Definition: strings.h:786
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
Definition: strings.h:1113

References ast_str_set(), and ast_str_truncate().

Referenced by ast_manager_hangup_helper(), mwi_mailbox_delete(), and mwi_mailbox_get().

◆ ast_skip_blanks()

char * ast_skip_blanks ( const char *  str)
inline

◆ ast_skip_nonblanks()

char * ast_skip_nonblanks ( const char *  str)
inline

Gets a pointer to first whitespace character in a string.

Parameters
strthe input string
Returns
a pointer to the first whitespace character

Definition at line 204 of file strings.h.

217{

References ast_skip_blanks(), and ast_trim_blanks().

Referenced by __ast_cli_register(), httpd_process_request(), and remove_excess_lws().

◆ ast_str_append()

int ast_str_append ( struct ast_str **  buf,
ssize_t  max_len,
const char *  fmt,
  ... 
)
inline

Append to a thread local dynamic string.

Note
Care should be taken when using this function. The function can result in reallocating the ast_str. If a pointer to the ast_str is passed by value to a function that calls ast_str_append(), then the original ast_str pointer may be invalidated due to a reallocation.

The arguments, return values, and usage of this function are the same as ast_str_set(), but the new data is appended to the current value.

Definition at line 1139 of file strings.h.

1190{ \

Referenced by __ast_format_cap_get_names(), __manager_event_sessions_va(), __test_cel_generate_peer_str(), _ast_xmldoc_build_seealso(), acf_curl_helper(), acf_odbc_read(), action_agents(), action_createconfig(), action_userevent(), active_channels_to_str_cb(), add_allow_header(), add_bundle_groups(), add_ice_to_stream(), agent_handle_show_specific(), ami_outbound_registration_task(), ami_registrations_aor(), aoc_amount_str(), aoc_d_event(), aoc_display_decoded_debug(), aoc_e_event(), aoc_request_event(), aoc_s_event(), aoc_time_str(), app_exec(), append_channel_vars(), append_event_str_single(), append_json_single(), append_var_and_value_to_filter(), ari_channels_handle_originate_with_id(), ast_aoc_decoded2str(), ast_ari_callback(), ast_ari_channels_create(), ast_ari_get_docs(), ast_ari_recordings_get_stored_file(), ast_ari_response_created(), ast_category_get_templates(), ast_cdr_serialize_variables(), ast_eivr_getvariable(), ast_geoloc_eprofile_to_uri(), ast_get_character_str(), ast_get_digit_str(), ast_get_money_en_dollars_str(), ast_get_phonetic_str(), ast_ha_join(), ast_ha_join_cidr(), ast_json_ipaddr(), ast_log_backtrace(), ast_logger_get_channels(), ast_manager_build_bridge_state_string_prefix(), ast_manager_build_channel_state_string_prefix(), ast_odbc_print_errors(), ast_print_namedgroups(), ast_realtime_encode_chunk(), ast_rtp_lookup_mime_multiple2(), ast_sched_report(), ast_sip_cli_print_sorcery_objectset(), ast_sip_cli_traverse_objects(), ast_sip_contact_to_str(), ast_sip_create_ami_event(), ast_sip_format_contact_ami(), ast_sip_sorcery_object_to_ami(), ast_statsd_log_string(), ast_str_append_event_header(), ast_str_encode_mime(), ast_str_quote(), ast_str_substitute_variables_full2(), ast_stream_codec_prefs_parse(), ast_stream_codec_prefs_to_str(), ast_stream_create_resolved(), ast_stream_to_str(), ast_stream_topology_to_str(), ast_strings_match(), ast_term_color_code(), AST_TEST_DEFINE(), ast_translate_path_to_str(), ast_variable_list_join(), ast_xmldoc_printable(), astman_send_list_complete(), astman_send_list_complete_start_common(), astman_send_response_full(), attended_transfer_to_ami(), auth_http_callback(), authority_to_str(), build_nonce(), build_notify(), build_path_data(), caldav_get_events_between(), caldav_write_event(), calendar_join_attendees(), CB_ADD(), CB_ADD_LEN(), cc_unique_append(), cdata(), cel_generate_peer_str(), celt_generate_sdp_fmtp(), chanavail_exec(), channel_fax_cb(), channel_hangup_request_cb(), channel_mixmonitor_mute_cb(), cli_alias_passthrough(), cli_aor_print_body(), cli_aor_print_header(), cli_channel_print_body(), cli_channel_print_header(), cli_channelstats_print_body(), cli_channelstats_print_header(), cli_contact_print_body(), cli_contact_print_header(), cli_endpoint_print_body(), cli_endpoint_print_header(), cli_print_body(), cli_print_header(), cli_prompt(), cli_show_subscription_common(), cli_unid_print_body(), cli_unid_print_header(), codec_append_name(), collect_names_cb(), config_odbc(), contactstatus_to_ami(), create_lookup_filter(), curl_write_string_callback(), cut_internal(), dbl_list_expect_forward(), dbl_list_expect_reverse(), derive_category_text(), destroy_curl(), destroy_mysql(), destroy_odbc(), destroy_pgsql(), detect_disconnect(), dump_queue_members(), encmethods_to_str(), epoch_to_exchange_time(), ewscal_write_event(), exchangecal_get_events_between(), exchangecal_write_event(), fetch_response_reader(), file2display(), format_ami_aor_handler(), format_ami_auth_handler(), format_ami_contactlist_handler(), format_ami_endpoint_transport(), format_ami_endpoints(), format_log_message_ap(), format_str_append_auth(), function_db_keys(), function_realtime_read(), function_realtime_readdestroy(), g729_generate_sdp_fmtp(), generate_status(), generic_http_callback(), geoloc_profile_read(), get_number_str_en(), get_ordinal_str_en(), h263_generate_sdp_fmtp(), h264_generate_sdp_fmtp(), handle_characters(), handle_cli_indication_show(), handle_manager_show_events(), handle_missing_table(), handle_options(), handle_show_translation_path(), handle_show_translation_table(), handle_showchan(), hashkeys_read2(), http_callback(), httpstatus_callback(), ilbc_generate_sdp_fmtp(), jack_str(), list_expect(), list_item_to_str(), listfilter(), load_column_config(), load_config(), load_modules(), local_message_to_ami(), log_action(), log_jack_status(), logger_add_verbose_magic(), manager_json_value_str_append(), meetme_cmd_helper(), multi_object_blob_to_ami(), mwi_generate_body_content(), mwi_subscription_mailboxes_str(), mwi_to_ami(), odbc_log(), opus_generate_sdp_fmtp(), pbx_builtin_serialize_variables(), peerstatus_to_ami(), pgsql_log(), pgsql_reconnect(), phoneprov_callback(), pjsip_acf_dial_contacts_read(), pjsip_aor_function_read(), pjsip_enable_logger_method(), pp_each_extension_helper(), pp_each_user_helper(), print_queue(), print_uptimestr(), process_cors_request(), process_description_file(), process_output(), process_text_line(), prometheus_metric_full_to_string(), prometheus_metric_to_string(), realtime_curl(), realtime_directory(), realtime_ldap_status(), realtime_multi_curl(), realtime_multi_mysql(), realtime_multi_odbc(), realtime_multi_pgsql(), realtime_mysql(), realtime_odbc(), realtime_pgsql(), realtime_sqlite3_destroy(), realtime_sqlite3_helper(), realtime_sqlite3_store(), realtime_sqlite3_update(), realtime_sqlite3_update2(), realtimefield_read(), require_curl(), rtcp_report_to_ami(), send_eivr_event(), send_identify_ami_event(), set_outbound_authentication_credentials(), set_rec_filename(), set_var_to_str(), silk_generate_sdp_fmtp(), sip_aor_to_ami(), sip_cli_print_global(), sip_cli_print_system(), sip_endpoint_to_ami(), sip_endpoints_aors_ami(), sip_sorcery_object_ami_set_type_name(), sip_subscription_to_ami(), siren14_generate_sdp_fmtp(), siren7_generate_sdp_fmtp(), sorcery_function_read(), spandsp_manager_fax_session(), stasis_app_control_snoop(), store_curl(), store_mysql(), store_odbc(), store_pgsql(), str_appender(), strbetween(), strreplace(), substitute_escapes(), test_core_format_generate_sdp_fmtp(), to_ami(), update2_curl(), update2_mysql(), update2_pgsql(), update2_prepare(), update_curl(), update_mysql(), update_odbc(), update_pgsql(), user_authority_to_str(), varlist_to_str(), vp8_generate_sdp_fmtp(), websocket_client_parse_uri(), write_cdr(), write_cel(), xml_copy_escape(), xml_encode_str(), xml_translate(), xmldoc_get_syntax_cmd(), xmldoc_get_syntax_config_object(), xmldoc_get_syntax_manager(), xmldoc_parse_argument(), xmldoc_parse_cmd_enumlist(), xmldoc_parse_enumlist(), xmldoc_parse_example(), xmldoc_parse_info(), xmldoc_parse_option(), xmldoc_parse_optionlist(), xmldoc_parse_para(), xmldoc_parse_parameter(), xmldoc_parse_specialtags(), xmldoc_parse_variable(), xmldoc_parse_variablelist(), xmldoc_string_cleanup(), and xmldoc_string_wrap().

◆ ast_str_append_escapecommas()

char * ast_str_append_escapecommas ( struct ast_str **  buf,
ssize_t  maxlen,
const char *  src,
size_t  maxsrc 
)
inline

Append a non-NULL terminated substring to the end of a dynamic string, with escaping of commas.

Definition at line 1076 of file strings.h.

1103{

References ast_str_set_va(), and buf.

Referenced by acf_odbc_read(), and function_db_keys().

◆ ast_str_append_substr()

char * ast_str_append_substr ( struct ast_str **  buf,
ssize_t  maxlen,
const char *  src,
size_t  maxsrc 
)
inline

Append a non-NULL terminated substring to the end of a dynamic string.

Definition at line 1062 of file strings.h.

1066{

References __ast_str_helper2(), and buf.

Referenced by ast_str_substitute_variables_full2(), file_read(), listfilter(), logger_add_verbose_magic(), write_to_ast_str(), and WriteMemoryCallback().

◆ ast_str_append_va()

int ast_str_append_va ( struct ast_str **  buf,
ssize_t  max_len,
const char *  fmt,
va_list  ap 
)
inline

Append to a dynamic string using a va_list.

Same as ast_str_set_va(), but append to the current content.

Note
Care should be taken when using this function. The function can result in reallocating the ast_str. If a pointer to the ast_str is passed by value to a function that calls ast_str_append_va(), then the original ast_str pointer may be invalidated due to a reallocation.
Parameters
buf,max_len,fmt,ap

Definition at line 1048 of file strings.h.

1052{

References __ast_str_helper2(), and buf.

Referenced by __manager_event_sessions_va(), and ast_str_set().

◆ ast_str_buffer()

char * ast_str_buffer ( const struct ast_str buf)
inline

Returns the string buffer within the ast_str buf.

Parameters
bufA pointer to the ast_str structure.
Returns
A pointer to the enclosed string.

Definition at line 761 of file strings.h.

773{

References buf, len(), and typeof().

Referenced by __ast_format_cap_get_names(), __manager_event_sessions_va(), __queues_show(), _ast_xmldoc_build_arguments(), _ast_xmldoc_build_seealso(), _iax2_show_peers_one(), _xmldoc_build_field(), acf_curl_exec(), acf_curl_helper(), acf_cut_exec(), acf_odbc_read(), acf_odbc_write(), action_agents(), action_confbridgelist_item(), action_coreshowchannels(), action_createconfig(), action_getconfig(), action_getconfigjson(), action_userevent(), add_bundle_groups(), add_crypto_to_stream(), add_eprofile_to_channel(), add_eprofile_to_tdata(), add_hintdevice(), add_ice_to_stream(), add_user_extension(), agent_handle_show_specific(), agent_login_to_ami(), agent_logoff_to_ami(), agent_show_requested(), agi_channel_to_ami(), ALLOC_COMMENT(), ami_outbound_registration_task(), ami_registrations_aor(), ami_subscription_detail(), analog_publish_dnd_state(), aoc_display_decoded_debug(), aoc_to_ami(), aocmessage_get_unit_entry(), ari_channel_thread(), ari_channels_handle_originate_with_id(), ast_agi_send(), ast_ari_callback(), ast_ari_channels_get_channel_var(), ast_ari_get_docs(), ast_cc_agent_set_interfaces_chanvar(), ast_cli(), ast_eivr_getvariable(), ast_func_read(), ast_func_read2(), ast_geoloc_eprofile_to_pidf(), ast_geoloc_eprofile_to_uri(), ast_geoloc_eprofiles_to_pidf(), ast_get_money_en_dollars_str(), ast_http_create_response(), ast_http_send(), ast_json_ipaddr(), ast_json_load_str(), ast_log_backtrace(), ast_logger_get_channels(), ast_manager_hangup_helper(), ast_odbc_ast_str_SQLGetData(), ast_parse_digest(), ast_pbx_exec_application(), ast_print_namedgroups(), ast_realtime_encode_chunk(), ast_rtp_lookup_mime_multiple2(), ast_set_cc_interfaces_chanvar(), ast_sip_append_body(), ast_sip_format_contact_ami(), ast_sockaddr_stringify_fmt(), ast_sounds_get_index_for_file(), ast_statsd_log_full_va(), ast_statsd_log_string(), ast_statsd_log_string_va(), ast_str_encode_mime(), ast_str_get_encoded_str(), ast_str_quote(), ast_str_retrieve_variable(), ast_str_substitute_variables_full2(), ast_str_substring(), ast_stream_codec_prefs_to_str(), ast_stream_create_resolved(), ast_stream_to_str(), ast_stream_topology_to_str(), ast_strings_match(), AST_TEST_DEFINE(), ast_translate_path_to_str(), ast_var_channels_table(), ast_xmldoc_printable(), ast_xmldoc_query(), astman_append(), astman_flush(), astman_send_error_va(), attended_transfer_to_ami(), authority_to_str(), base64_helper(), blacklist_read2(), blind_transfer_to_ami(), bridge_merge_cb(), bridge_snapshot_update(), build_nonce(), build_notify_body(), build_user_routes(), caldav_request(), calendar_join_attendees(), call_pickup_to_ami(), cc_extension_monitor_init(), cc_unique_append(), cdata(), cel_bridge_enter_cb(), cel_bridge_leave_cb(), challenge(), chanavail_exec(), channel_chanspy_start_cb(), channel_chanspy_stop_cb(), channel_dial_cb(), channel_dtmf_begin_cb(), channel_dtmf_end_cb(), channel_enter_cb(), channel_fax_cb(), channel_flash_cb(), channel_get_external_vars(), channel_hangup_handler_cb(), channel_hangup_request_cb(), channel_hold_cb(), channel_leave_cb(), channel_mixmonitor_mute_cb(), channel_moh_start_cb(), channel_snapshot_update(), channel_unhold_cb(), channel_wink_cb(), check_nonce(), cli_alias_passthrough(), cli_list_subscriptions_detail(), cli_match_char_tree(), cli_odbc_read(), cli_odbc_write(), cli_prompt(), cli_show_module_options(), cli_show_module_type(), cli_show_module_types(), cli_show_settings(), cli_show_subscription_common(), cli_show_subscriptions_detail(), codec_prefs_handler(), commit_exec(), conf_start_record(), confbridge_publish_manager_event(), config_curl(), config_mysql(), config_odbc(), config_pgsql(), config_text_file_load(), contacts_to_str(), contactstatus_to_ami(), create_channel_name(), custom_log(), cut_internal(), dahdi_cc_callback(), dahdi_new(), dahdichannel_to_ami(), dbl_list_expect_forward(), dbl_list_expect_reverse(), destroy_curl(), destroy_mysql(), destroy_odbc(), destroy_pgsql(), detect_disconnect(), dialog_info_to_string(), digest_create_request_with_auth(), do_notify(), dump_queue_members(), dump_str_and_free(), dumpchan_exec(), eivr_comm(), endelm(), exchangecal_get_events_between(), exchangecal_request(), exchangecal_write_event(), exec_exec(), exten_state_publisher_cb(), fetch_icalendar(), file2display(), find_realtime(), find_table(), format_ami_aor_handler(), format_ami_aorlist_handler(), format_ami_auth_handler(), format_ami_authlist_handler(), format_ami_contactlist_handler(), format_ami_endpoint(), format_ami_endpoint_transport(), format_ami_endpoints(), format_ami_resource_lists(), format_log_message_ap(), function_fieldnum_helper(), function_fieldqty_helper(), function_iaxpeer(), function_realtime_read(), function_realtime_readdestroy(), generate_fmtp_attr(), generate_notify_body(), generate_status(), geoloc_config_list_locations(), geoloc_config_show_profiles(), geoloc_eprofile_resolve_varlist(), get_key(), get_languages(), get_number_str_en(), get_ordinal_str_en(), handle_aor(), handle_call_token(), handle_cli_iax2_show_peer(), handle_cli_indication_show(), handle_dbget(), handle_end_element(), handle_exec(), handle_getvariablefull(), handle_manager_show_events(), handle_missing_table(), handle_options(), handle_outgoing_request(), handle_registrations(), handle_show_translation_path(), handle_show_translation_table(), handle_showchan(), hangupcause_keys_read(), hashkeys_read2(), http_callback(), http_post_callback(), iax2_getformatname_multiple(), iax_parse_ies(), is_new_rec_file(), is_valid_uuid(), jack_str(), json_decode_read(), leave_voicemail(), list_expect(), list_item_to_str(), listfilter(), load_column_config(), load_dlopen(), load_modules(), local_message_to_ami(), localnet_to_str(), log_action(), log_attended_transfer(), log_jack_status(), logger_add_verbose_magic(), make_email_file(), manager_bridge_info(), manager_bridge_tech_list(), manager_build_parked_call_string(), manager_generic_msg_cb(), manager_json_array_with_key(), manager_json_obj_with_key(), manager_log(), manager_parking_status_all_lots(), manager_parking_status_single_lot(), match_to_str(), meetme_cmd_helper(), meetme_show_cmd(), meetme_stasis_cb(), module_load_error(), multi_object_blob_to_ami(), multi_user_event_to_ami(), mwi_app_event_cb(), mwi_mailbox_delete(), mwi_mailbox_get(), mwi_to_string(), named_callgroups_to_str(), named_pickupgroups_to_str(), odbc_log(), parked_call_message_response(), parking_lot_cfg_create_extensions(), parse_hint_device(), parse_hint_presence(), pbx_find_extension(), pbx_retrieve_variable(), peerstatus_to_ami(), pgsql_log(), pgsql_reconnect(), phoneprov_callback(), pidf_to_string(), pjsip_acf_dial_contacts_read(), pjsip_enable_logger_method(), pp_each_extension_helper(), pp_each_user_helper(), print_event_instance(), print_queue(), print_uptimestr(), process_description_file(), process_text_line(), prometheus_show_metrics(), publish_basic_channel_event(), publish_channel_alarm(), publish_channel_alarm_clear(), publish_dnd_state(), queue_channel_to_ami(), queue_member_to_ami(), queue_multi_channel_to_ami(), realtime_curl(), realtime_directory(), realtime_ldap_base_ap(), realtime_ldap_status(), realtime_multi_curl(), realtime_multi_mysql(), realtime_multi_odbc(), realtime_multi_pgsql(), realtime_mysql(), realtime_odbc(), realtime_pgsql(), realtime_sqlite3_destroy(), realtime_sqlite3_helper(), realtime_sqlite3_store(), realtime_sqlite3_update(), realtime_sqlite3_update2(), realtimefield_read(), refer_blind_callback(), refer_on_tx_request(), replace(), require_curl(), require_pgsql(), resource_list_recursive_decline(), rm_file(), rollback_exec(), rtcp_report_to_ami(), run_station(), say_filenames(), say_periodic_announcement(), sayfile_exec(), search_directory_sub(), security_event_stasis_cb(), security_event_to_ami_blob(), send_bridge_info_item_cb(), send_bridge_list_item_cb(), send_eivr_event(), send_ews_request_and_parse(), send_identify_ami_event(), send_unsolicited_mwi_notify_to_contact(), sendmail(), sendpage(), sendtext_exec(), set2(), set_format(), shift_pop(), snoop_stasis_thread(), spandsp_manager_fax_session(), sqlite3_escape_column_op(), sqlite3_escape_string_helper(), start_resource_list(), startelm(), statsmaker(), store_curl(), store_mysql(), store_odbc(), store_pgsql(), str_appender(), strbetween(), string_tolower2(), string_toupper2(), strreplace(), substitute_escapes(), system_exec_helper(), system_registry_to_ami(), talking_start_to_ami(), talking_stop_to_ami(), test_2way_function(), test_chan_function(), test_chan_integer(), test_chan_integer_accessor(), test_chan_string(), test_chan_variable(), test_expected_result(), test_files_create(), test_files_get_one(), threadpool_alloc(), transmit_info_dtmf(), try_calling(), tryexec_exec(), unshift_push(), update2_curl(), update2_ldap(), update2_mysql(), update2_odbc(), update2_pgsql(), update2_prepare(), update_caldav(), update_curl(), update_ewscal(), update_exchangecal(), update_mysql(), update_odbc(), update_pgsql(), user_authority_to_str(), validate_location_info(), var_list_from_confidence(), var_list_from_loc_info(), var_list_from_node(), varset_to_ami(), websocket_client_handshake(), write_cdr(), write_cel(), xmldoc_get_formatted(), xmldoc_get_syntax_cmd(), xmldoc_get_syntax_config_object(), xmldoc_get_syntax_config_option(), xmldoc_get_syntax_manager(), xmldoc_parse_cmd_enumlist(), xmldoc_parse_example(), xmldoc_parse_para(), xmldoc_parse_variable(), xmldoc_string_wrap(), xmldoc_update_config_type(), and xpidf_to_string().

◆ ast_str_case_hash()

static force_inline int attribute_pure ast_str_case_hash ( const char *  str)
static

Compute a hash value on a case-insensitive string.

Uses the same hash algorithm as ast_str_hash, but converts all characters to lowercase prior to computing a hash. This allows for easy case-insensitive lookups in a hash table.

Examples
app_skel.c.

Definition at line 1303 of file strings.h.

1304{
1305 unsigned int hash = 5381;
1306
1307 while (*str) {
1308 hash = hash * 33 ^ (unsigned char) tolower(*str++);
1309 }
1310
1311 return ast_str_hash_restrict(hash);
1312}
static force_inline int attribute_pure ast_str_hash_restrict(unsigned int hash)
Restrict hash value range.
Definition: strings.h:1246

References ast_str_hash_restrict(), and str.

Referenced by ast_channel_hash_cb(), ast_tone_zone_hash(), ast_xml_doc_item_hash(), autohint_hash_cb(), bridge_hash_cb(), cache_hash(), calendar_hash_fn(), cdr_all_hash_fn(), cdr_master_hash_fn(), channel_role_hash_cb(), channel_snapshot_hash_cb(), channel_snapshot_uniqueid_hash_cb(), conference_bridge_hash_cb(), config_opt_hash(), featuregroup_hash(), format_hash_cb(), hint_hash(), hintdevice_hash_cb(), media_info_hash(), media_variant_hash(), menu_hash_cb(), moh_class_hash(), notify_option_hash(), pending_members_hash(), protocol_hash_fn(), pvt_hash_cb(), queue_hash_cb(), skel_level_hash(), topic_pool_entry_hash(), tps_hash_cb(), and user_hash_cb().

◆ ast_str_container_add()

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.

Since
12
Parameters
str_containerThe container to which to add a string
addThe string to add to the container
Return values
zeroon success
non-zeroif the operation failed

Definition at line 205 of file strings.c.

206{
207 char *ao2_add;
208
209 /* The ao2_add object is immutable so it doesn't need a lock of its own. */
210 ao2_add = ao2_alloc_options(strlen(add) + 1, NULL, AO2_ALLOC_OPT_LOCK_NOLOCK);
211 if (!ao2_add) {
212 return -1;
213 }
214 strcpy(ao2_add, add);/* Safe */
215
216 ao2_link(str_container, ao2_add);
217 ao2_ref(ao2_add, -1);
218 return 0;
219}
#define ao2_link(container, obj)
Add an object to a container.
Definition: astobj2.h:1532
@ AO2_ALLOC_OPT_LOCK_NOLOCK
Definition: astobj2.h:367
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
#define ao2_alloc_options(data_size, destructor_fn, options)
Definition: astobj2.h:404

References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_alloc_options, ao2_link, ao2_ref, and NULL.

Referenced by add_media_cb(), add_variant_cb(), append_name(), apps_handler(), ast_bridge_snapshot_create(), ast_dns_get_nameservers(), ast_endpoint_add_channel(), AST_TEST_DEFINE(), complete_ari_app(), coreshowchannelmap_add_to_map(), custom_nameserver_handler(), declined_handler(), event_session_alloc(), get_languages(), ip_identify_match_handler(), load_module(), test_cel_peer_strings_match(), and topic_add_subscription().

◆ ast_str_container_alloc_options()

struct ao2_container * ast_str_container_alloc_options ( enum ao2_alloc_opts  opts,
int  buckets 
)

Allocates a hash container for bare strings.

Since
12
Parameters
optsOptions to be provided to the container
bucketsThe number of buckets to use for the hash container
Returns
AO2 container for strings
Return values
NULLif allocation failed

Definition at line 200 of file strings.c.

201{
202 return ao2_container_alloc_hash(opts, 0, buckets, str_hash, str_sort, str_cmp);
203}
#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.
Definition: astobj2.h:1303
static int str_sort(const void *lhs, const void *rhs, int flags)
Definition: strings.c:178
static int str_cmp(void *lhs, void *rhs, int flags)
Definition: strings.c:187
static int str_hash(const void *obj, const int flags)
Definition: strings.c:173

References ao2_container_alloc_hash, str_cmp(), str_hash(), and str_sort().

Referenced by action_coreshowchannelmap(), ast_dns_get_nameservers(), custom_nameserver_handler(), endpoint_internal_create(), and ip_identify_match_handler().

◆ ast_str_container_remove()

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.

Since
12
Parameters
str_containerThe container from which to remove a string
removeThe string to remove from the container

Definition at line 221 of file strings.c.

222{
224}
#define ao2_find(container, arg, flags)
Definition: astobj2.h:1736
@ OBJ_NODATA
Definition: astobj2.h:1044
@ OBJ_UNLINK
Definition: astobj2.h:1039
@ OBJ_SEARCH_KEY
The arg parameter is a search key, but is not an object.
Definition: astobj2.h:1101
#define remove

References ao2_find, OBJ_NODATA, OBJ_SEARCH_KEY, OBJ_UNLINK, and remove.

Referenced by endpoint_cache_clear(), test_cel_peer_strings_match(), and topic_remove_subscription().

◆ ast_str_copy_string()

int ast_str_copy_string ( struct ast_str **  dst,
struct ast_str src 
)
inline

Definition at line 846 of file strings.h.

849{ \

◆ ast_str_hash()

static force_inline int attribute_pure ast_str_hash ( const char *  str)
static

Compute a hash value on a string.

This famous hash algorithm was written by Dan Bernstein and is commonly used.

http://www.cse.yorku.ca/~oz/hash.html

Definition at line 1259 of file strings.h.

1260{
1261 unsigned int hash = 5381;
1262
1263 while (*str) {
1264 hash = hash * 33 ^ (unsigned char) *str++;
1265 }
1266
1267 return ast_str_hash_restrict(hash);
1268}

References ast_str_hash_restrict(), and str.

Referenced by alias_hash_cb(), app_hash(), ast_event_append_ie_str(), ast_get_namedgroups(), ast_sorcery_object_id_hash(), bridges_channel_hash_fn(), bridges_hash(), channel_hash(), control_hash(), datastore_hash(), db_hash_fn(), device_state_subscriptions_hash(), dsn_hash(), entry_hash_fn(), event_hash_fn(), event_session_hash(), exten_state_publisher_hash(), formatter_hash(), group_hash_fn(), hook_hash(), internal_state_hash(), jingle_add_ice_udp_candidates_to_transport(), jingle_endpoint_hash(), jingle_session_hash(), lang_hash_fn(), message_subscription_hash_cb(), monitored_transport_hash_fn(), mwi_sub_hash(), outbound_publish_state_hash(), parking_lot_cfg_hash_fn(), peer_hash_cb(), persistent_endpoint_hash(), playback_hash(), pvt_cause_hash_fn(), recording_hash(), registration_state_hash(), sdp_handler_list_hash(), sorcery_memory_cache_hash(), sorcery_memory_cached_object_hash(), sorcery_memory_hash(), stasis_sub_hash(), str_hash(), str_hash_fn(), suspects_hash(), test_vm_api_create_mock_snapshot(), transport_state_hash(), uid_hold_hash_fn(), user_hash_cb(), variable_count_hash_fn(), wait_bridge_hash_fn(), and xmpp_buddy_hash().

◆ ast_str_hash_add()

static force_inline int ast_str_hash_add ( const char *  str,
int  seed 
)
static

Compute a hash value on a string.

Parameters
[in]strThe string to add to the hash
[in]seedThe hash value to start with

This version of the function is for when you need to compute a string hash of more than one string.

This famous hash algorithm was written by Dan Bernstein and is commonly used.

See also
http://www.cse.yorku.ca/~oz/hash.html

Definition at line 1285 of file strings.h.

1286{
1287 unsigned int hash = (unsigned int) seed;
1288
1289 while (*str) {
1290 hash = hash * 33 ^ (unsigned char) *str++;
1291 }
1292
1293 return ast_str_hash_restrict(hash);
1294}

References ast_str_hash_restrict(), and str.

◆ ast_str_hash_restrict()

static force_inline int attribute_pure ast_str_hash_restrict ( unsigned int  hash)
static

Restrict hash value range.

Hash values used all over asterisk are expected to be non-negative (signed) int values. This function restricts an unsigned int hash value to the positive half of the (signed) int values.

Definition at line 1246 of file strings.h.

1247{
1248 return (int) (hash & (unsigned int) INT_MAX);
1249}

Referenced by ast_sip_get_distributor_serializer(), ast_str_case_hash(), ast_str_hash(), ast_str_hash_add(), and dialog_associations_hash().

◆ ast_str_reset()

void ast_str_reset ( struct ast_str buf)
inline

◆ ast_str_set()

int ast_str_set ( struct ast_str **  buf,
ssize_t  max_len,
const char *  fmt,
  ... 
)
inline

Set a dynamic string using variable arguments.

Note
Care should be taken when using this function. The function can result in reallocating the ast_str. If a pointer to the ast_str is passed by value to a function that calls ast_str_set(), then the original ast_str pointer may be invalidated due to a reallocation.
Parameters
bufThis is the address of a pointer to a struct ast_str which should have been retrieved using ast_str_thread_get. It will need to be updated in the case that the buffer has to be reallocated to accomodate a longer string than what it currently has space for.
max_lenThis is the maximum length to allow the string buffer to grow to. If this is set to 0, then there is no maximum length. If set to -1, we are bound to the current maximum length.
fmtThis is the format string (printf style)
Returns
The return value of this function is the same as that of the printf family of functions.

All the rest is the same as ast_str_set_va()

Definition at line 1113 of file strings.h.

1129{

References ast_str_append_va(), and buf.

Referenced by __ast_format_cap_get_names(), __ast_http_post_load(), __manager_event_sessions_va(), __queues_show(), acf_curl_exec(), acf_curl_helper(), acf_curlopt_helper(), action_agents(), action_createconfig(), add_bundle_groups(), add_crypto_to_stream(), add_eprofile_to_tdata(), add_hintdevice(), add_ice_to_stream(), agent_handle_show_specific(), agent_show_requested(), analog_publish_dnd_state(), aocmessage_get_unit_entry(), ari_channels_handle_originate_with_id(), ast_ari_callback(), ast_extension_state2(), ast_geoloc_eprofile_to_pidf(), ast_geoloc_eprofiles_to_pidf(), ast_http_auth(), ast_http_create_response(), ast_http_error(), ast_http_send(), ast_json_ipaddr(), ast_manager_build_bridge_state_string_prefix(), ast_manager_build_channel_state_string_prefix(), ast_parse_digest(), ast_realtime_encode_chunk(), ast_regex_string_to_regex_pattern(), ast_sched_report(), ast_sip_append_body(), ast_sip_create_ami_event(), ast_sockaddr_stringify_fmt(), ast_sounds_get_index_for_file(), ast_str_encode_mime(), ast_str_expr(), ast_str_get_encoded_str(), ast_str_get_hint(), ast_str_quote(), ast_str_retrieve_variable(), ast_stream_create_resolved(), ast_strings_match(), AST_TEST_DEFINE(), ast_xmldoc_regenerate_doc_item(), astman_send_list_complete_start_common(), astman_send_response_full(), bs_to_exchange_bs(), build_notify(), build_path_data(), caldav_write_event(), cc_extension_monitor_init(), cc_generic_agent_start_monitoring(), cdata(), channel_hold_cb(), cli_list_subscriptions_detail(), cli_match_char_tree(), cli_odbc_read(), cli_prompt(), cli_show_subscriptions_detail(), config_curl(), config_mysql(), config_odbc(), config_pgsql(), create_channel_name(), derive_category_text(), destroy_curl(), destroy_mysql(), destroy_odbc(), destroy_pgsql(), device_state_notify_callbacks(), do_notify(), encmethods_to_str(), ewscal_write_event(), exchangecal_write_event(), extension_presence_state_helper(), file_count_line(), file_format(), find_realtime(), find_table(), function_fieldnum_helper(), function_fieldqty_helper(), generate_exchange_uuid(), get_ewscal_ids_for(), get_languages(), handle_call_token(), handle_cli_indication_show(), handle_manager_show_events(), handle_missing_table(), handle_outgoing_request(), handle_show_translation_path(), handle_show_translation_table(), handle_uri(), hashkeys_read(), hashkeys_read2(), iax_parse_ies(), init_queue(), is_new_rec_file(), leave_voicemail(), listfilter(), log_attended_transfer(), log_jack_status(), make_email_file(), manager_bridge_info(), manager_bridge_tech_list(), manager_bridges_list(), manager_build_parked_call_string(), manager_json_array_with_key(), manager_json_obj_with_key(), meetme_cmd_helper(), meetme_show_cmd(), meetme_stasis_cb(), mwi_to_string(), odbc_log(), parking_lot_cfg_create_extensions(), parse_ewscal_id(), parse_hint_device(), parse_hint_presence(), passthru(), pgsql_log(), pgsql_reconnect(), phoneprov_callback(), pjsip_aor_function_read(), pjsip_contact_function_read(), pjsip_endpoint_function_read(), presence_state_notify_callbacks(), print_queue(), process_description_file(), process_text_line(), publish_channel_alarm(), publish_channel_alarm_clear(), publish_dnd_state(), queue_set_param(), realtime_curl(), realtime_directory(), realtime_multi_curl(), realtime_multi_mysql(), realtime_multi_odbc(), realtime_multi_pgsql(), realtime_mysql(), realtime_odbc(), realtime_pgsql(), realtime_sqlite3_destroy(), realtime_sqlite3_helper(), realtime_sqlite3_store(), realtime_sqlite3_update(), realtime_sqlite3_update2(), refer_blind_callback(), replace(), require_curl(), require_pgsql(), run_station(), search_directory_sub(), security_event_stasis_cb(), sendmail(), sendpage(), set_rec_filename(), shift_pop(), sorcery_function_read(), stackpeek_read(), startelm(), stasis_app_control_snoop(), static_callback(), statsmaker(), store_curl(), store_mysql(), store_odbc(), store_pgsql(), system_registry_to_ami(), test_2way_function(), test_chan_variable(), test_files_create(), threadpool_alloc(), transmit_info_dtmf(), try_calling(), unshift_push(), update2_curl(), update2_mysql(), update2_pgsql(), update2_prepare(), update_curl(), update_mysql(), update_odbc(), update_pgsql(), varset_to_ami(), websocket_bad_request(), websocket_client_parse_uri(), xmldoc_build_documentation_item(), xmldoc_get_syntax_config_object(), and xmldoc_get_syntax_config_option().

◆ ast_str_set_escapecommas()

char * ast_str_set_escapecommas ( struct ast_str **  buf,
ssize_t  maxlen,
const char *  src,
size_t  maxsrc 
)
inline

Set a dynamic string to a non-NULL terminated substring, with escaping of commas.

Definition at line 1069 of file strings.h.

1073{

References __ast_str_helper2(), and buf.

Referenced by acf_curl_helper(), and realtimefield_read().

◆ ast_str_set_substr()

char * ast_str_set_substr ( struct ast_str **  buf,
ssize_t  maxlen,
const char *  src,
size_t  maxsrc 
)
inline

Set a dynamic string to a non-NULL terminated substring.

Definition at line 1055 of file strings.h.

1059{

References __ast_str_helper2(), and buf.

Referenced by ast_str_substitute_variables_full2(), and set_rec_filename().

◆ ast_str_set_va()

int ast_str_set_va ( struct ast_str **  buf,
ssize_t  max_len,
const char *  fmt,
va_list  ap 
)
inline

Set a dynamic string from a va_list.

Parameters
bufThis is the address of a pointer to a struct ast_str. If it is retrieved using ast_str_thread_get, the struct ast_threadstorage pointer will need to be updated in the case that the buffer has to be reallocated to accommodate a longer string than what it currently has space for.
max_lenThis is the maximum length to allow the string buffer to grow to. If this is set to 0, then there is no maximum length.
fmtThis is the format string (printf style)
apThis is the va_list
Returns
The return value of this function is the same as that of the printf family of functions.

Example usage (the first part is only for thread-local storage)

AST_THREADSTORAGE(my_str, my_str_init);
#define MY_STR_INIT_SIZE 128
...
void my_func(const char *fmt, ...)
{
struct ast_str *buf;
va_list ap;
if (!(buf = ast_str_thread_get(&my_str, MY_STR_INIT_SIZE)))
return;
...
va_start(fmt, ap);
ast_str_set_va(&buf, 0, fmt, ap);
va_end(ap);
printf("This is the string we just built: %s\n", buf->str);
...
}
int ast_str_set_va(struct ast_str **buf, ssize_t max_len, const char *fmt, va_list ap)
Set a dynamic string from a va_list.
Definition: strings.h:1030
struct ast_str * ast_str_thread_get(struct ast_threadstorage *ts, size_t init_len)
Retrieve a thread locally stored dynamic string.
Definition: strings.h:909
#define AST_THREADSTORAGE(name)
Define a thread storage variable.
Definition: threadstorage.h:86
Note
Care should be taken when using this function. The function can result in reallocating the ast_str. If a pointer to the ast_str is passed by value to a function that calls ast_str_set_va(), then the original ast_str pointer may be invalidated due to a reallocation.

Definition at line 1030 of file strings.h.

1045{

References _ast_str_helper, and buf.

Referenced by ast_agi_send(), ast_cli(), ast_statsd_log_full_va(), ast_statsd_log_string_va(), ast_str_append_escapecommas(), ast_xmldoc_query(), astman_append(), astman_send_error_va(), format_log_message_ap(), and module_load_error().

◆ ast_str_size()

size_t ast_str_size ( const struct ast_str buf)
inline

◆ ast_str_strlen()

size_t ast_str_strlen ( const struct ast_str buf)
inline

Returns the current length of the string stored within buf.

Parameters
bufA pointer to the ast_str structure.

Definition at line 730 of file strings.h.

739{

References buf.

Referenced by _ast_xmldoc_build_arguments(), _xmldoc_build_field(), acf_curl_helper(), acf_odbc_read(), action_getconfig(), action_getconfigjson(), ALLOC_COMMENT(), ast_agi_send(), ast_cli(), ast_get_character_str(), ast_get_digit_str(), ast_get_phonetic_str(), ast_http_send(), ast_odbc_print_errors(), ast_statsd_log_string(), ast_str_encode_mime(), ast_str_expr(), ast_str_substitute_variables_full2(), ast_str_substring(), AST_TEST_DEFINE(), ast_var_channels_table(), authority_to_str(), base64_helper(), blacklist_read2(), build_cc_interfaces_chanvar(), build_notify(), caldav_get_events_between(), caldav_request(), cc_extension_monitor_init(), cdata(), chanavail_exec(), cli_show_module_options(), cli_show_module_type(), cli_show_module_types(), collect_names_cb(), config_mysql(), config_text_file_load(), cut_internal(), destroy_mysql(), detect_disconnect(), dump_queue_members(), encmethods_to_str(), endelm(), exchangecal_request(), fetch_icalendar(), find_table(), function_fieldnum_helper(), function_fieldqty_helper(), generate_fmtp_attr(), get_key(), handle_dbget(), handle_end_element(), handle_showchan(), hangupcause_keys_read(), hashkeys_read2(), http_callback(), json_decode_read(), listfilter(), load_column_config(), load_config(), load_dlopen(), load_modules(), manager_log(), odbc_log(), opus_generate_sdp_fmtp(), pgsql_log(), pgsql_reconnect(), pjsip_acf_dial_contacts_read(), pjsip_enable_logger_method(), print_uptimestr(), realtime_multi_mysql(), realtime_multi_odbc(), realtime_mysql(), realtime_odbc(), replace(), say_filenames(), say_periodic_announcement(), send_ews_request_and_parse(), set_outbound_authentication_credentials(), set_rec_filename(), shift_pop(), store_mysql(), system_exec_helper(), test_create_joint(), unshift_push(), update2_mysql(), update_caldav(), update_exchangecal(), update_mysql(), user_authority_to_str(), write_cdr(), write_cel(), write_to_ast_str(), xmldoc_get_formatted(), and xmldoc_parse_variable().

◆ ast_str_thread_get()

struct ast_str * ast_str_thread_get ( struct ast_threadstorage ts,
size_t  init_len 
)
inline

Retrieve a thread locally stored dynamic string.

Parameters
tsThis is a pointer to the thread storage structure declared by using the AST_THREADSTORAGE macro. If declared with AST_THREADSTORAGE(my_buf, my_buf_init), then this argument would be (&my_buf).
init_lenThis is the initial length of the thread's dynamic string. The current length may be bigger if previous operations in this thread have caused it to increase.
Returns
This function will return the thread locally stored dynamic string associated with the thread storage management variable passed as the first argument. The result will be NULL in the case of a memory allocation error.

Example usage:

AST_THREADSTORAGE(my_str, my_str_init);
#define MY_STR_INIT_SIZE 128
...
void my_func(const char *fmt, ...)
{
struct ast_str *buf;
if (!(buf = ast_str_thread_get(&my_str, MY_STR_INIT_SIZE)))
return;
...
}

Definition at line 909 of file strings.h.

914{

References buf, make_ari_stubs::file, and NULL.

Referenced by __manager_event_sessions_va(), acf_curl_helper(), acf_odbc_read(), acf_odbc_write(), action_userevent(), add_hintdevice(), ast_agi_send(), ast_cli(), ast_extension_state2(), ast_odbc_print_errors(), ast_sockaddr_stringify_fmt(), ast_statsd_log_full_va(), ast_statsd_log_string_va(), astman_append(), astman_send_error_va(), astman_send_list_complete_start_common(), astman_send_response_full(), cli_odbc_read(), cli_odbc_write(), config_curl(), config_mysql(), config_odbc(), config_pgsql(), custom_log(), destroy_curl(), destroy_mysql(), destroy_odbc(), destroy_pgsql(), dumpchan_exec(), extension_presence_state_helper(), find_table(), format_log_message_ap(), function_fieldnum_helper(), function_fieldqty_helper(), handle_showchan(), json_decode_read(), listfilter(), logger_add_verbose_magic(), pbx_find_extension(), realtime_curl(), realtime_directory(), realtime_multi_curl(), realtime_multi_mysql(), realtime_multi_odbc(), realtime_multi_pgsql(), realtime_mysql(), realtime_odbc(), realtime_pgsql(), realtimefield_read(), require_curl(), search_directory_sub(), security_event_stasis_cb(), shift_pop(), sqlite3_escape_column_op(), sqlite3_escape_string_helper(), store_curl(), store_mysql(), store_odbc(), store_pgsql(), strbetween(), strreplace(), substitute_escapes(), system_exec_helper(), unshift_push(), update2_curl(), update2_mysql(), update2_odbc(), update2_pgsql(), update2_prepare(), update_curl(), update_mysql(), update_odbc(), and update_pgsql().

◆ ast_str_to_lower()

static force_inline char * ast_str_to_lower ( char *  str)
static

Convert a string to all lower-case.

Parameters
strThe string to be converted to lower case
Return values
strthe char* passed in for convenience

Definition at line 1321 of file strings.h.

1322{
1323 char *str_orig = str;
1324 if (!str) {
1325 return str;
1326 }
1327
1328 for (; *str; ++str) {
1329 *str = tolower(*str);
1330 }
1331
1332 return str_orig;
1333}

References str.

Referenced by apps_handler(), ast_ari_endpoints_refer_to_endpoint(), ast_ari_endpoints_send_message_to_endpoint(), ast_uuid_to_str(), cel_track_app(), curl_header_callback(), get_user_agent(), and parse_simple_message_summary().

◆ ast_str_to_upper()

static force_inline char * ast_str_to_upper ( char *  str)
static

Convert a string to all upper-case.

Parameters
strThe string to be converted to upper case
Return values
strthe char* passed in for convenience

Definition at line 1342 of file strings.h.

1343{
1344 char *str_orig = str;
1345 if (!str) {
1346 return str;
1347 }
1348
1349 for (; *str; ++str) {
1350 *str = toupper(*str);
1351 }
1352
1353 return str_orig;
1354}

References str.

Referenced by ast_rtp_engine_load_format().

◆ ast_str_trim_blanks()

void ast_str_trim_blanks ( struct ast_str buf)
inline

Trims trailing whitespace characters from an ast_str string.

Parameters
bufA pointer to the ast_str string.

Definition at line 719 of file strings.h.

727{

References buf.

Referenced by acf_curl_helper(), process_text_line(), and xmldoc_string_cleanup().

◆ ast_str_truncate()

char * ast_str_truncate ( struct ast_str buf,
ssize_t  len 
)
inline

Truncates the enclosed string to the given length.

Parameters
bufA pointer to the ast_str structure.
lenMaximum length of the string. If len is larger than the current maximum length, things will explode. If it is negative at most -len characters will be trimmed off the end.
Returns
A pointer to the resulting string.

Definition at line 786 of file strings.h.

807{

Referenced by __test_cel_generate_peer_str(), _ast_xmldoc_build_arguments(), active_channels_to_str(), ast_regex_string_to_regex_pattern(), ast_str_substring(), build_cc_interfaces_chanvar(), cel_generate_peer_str(), contacts_to_str(), hashkeys_read2(), jack_str(), list_item_to_str(), opus_generate_sdp_fmtp(), pjsip_acf_dial_contacts_read(), send_eivr_event(), set_outbound_authentication_credentials(), set_var_to_str(), sorcery_function_read(), test_create_joint(), xmldoc_get_formatted(), and xmldoc_string_wrap().

◆ ast_str_update()

void ast_str_update ( struct ast_str buf)
inline

◆ ast_strings_equal()

int ast_strings_equal ( const char *  str1,
const char *  str2 
)

Compare strings for equality checking for NULL.

Since
16.3.0

This function considers NULL values as non-strings, thus a false condition. This means that it will return false if one, or both of the given values are NULL (i.e. two NULLs are not equal strings).

Parameters
str1The string to compare to str2
str2The string to compare to str1
Return values
trueif valid strings and equal.
falseotherwise.

Definition at line 238 of file strings.c.

239{
240 if (!str1 || !str2) {
241 return 0;
242 }
243
244 return str1 == str2 || !strcmp(str1, str2);
245}

Referenced by app_event_filter_matched(), ast_geoloc_gml_validate_varlist(), check_x5u_url(), config_object_cli_show(), geoloc_civicaddr_list_to_xml(), geoloc_gml_list_to_xml(), geoloc_profile_read(), geoloc_profile_write(), is_media_state_valid(), is_pidf_lo(), load_realtime_musiconhold(), resolve_refresh_media_states(), set_outbound_authentication_credentials(), and uom_validator().

◆ ast_strings_match()

int ast_strings_match ( const char *  left,
const char *  op,
const char *  right 
)

Compares 2 strings using realtime-style operators.

Since
13.9.0
Parameters
leftThe left side of the equation
opThe operator to apply
rightThe right side of the equation
Return values
1matches
0doesn't match

Operators: "=", "!=", "<", "<=", ">", ">=": If both left and right can be converted to float, then they will be compared as such. Otherwise the result will be derived from strcmp(left, right). "regex": The right value will be compiled as a regular expression and matched against the left value. "like": Any '' character in the right value will be converted to '.*' and the resulting string will be handled as a regex. NULL , "": If the right value starts and ends with a '/' then it will be processed as a regex. Otherwise, same as "=".

Definition at line 247 of file strings.c.

248{
249 char *internal_op = (char *)op;
250 char *internal_right = (char *)right;
251 double left_num;
252 double right_num;
253 int scan_numeric = 0;
254
255 if (!(left && right)) {
256 return 0;
257 }
258
259 if (ast_strlen_zero(op)) {
260 if (ast_strlen_zero(left) && ast_strlen_zero(right)) {
261 return 1;
262 }
263
264 if (strlen(right) >= 2 && right[0] == '/' && right[strlen(right) - 1] == '/') {
265 internal_op = "regex";
266 internal_right = ast_strdupa(right);
267 /* strip the leading and trailing '/' */
268 internal_right++;
269 internal_right[strlen(internal_right) - 1] = '\0';
270 goto regex;
271 } else {
272 internal_op = "=";
273 goto equals;
274 }
275 }
276
277 if (!strcasecmp(op, "like")) {
278 char *tok;
279 struct ast_str *buffer = ast_str_alloca(128);
280
281 if (!strchr(right, '%')) {
282 return !strcmp(left, right);
283 } else {
284 internal_op = "regex";
285 internal_right = ast_strdupa(right);
286 tok = strsep(&internal_right, "%");
287 ast_str_set(&buffer, 0, "^%s", tok);
288
289 while ((tok = strsep(&internal_right, "%"))) {
290 ast_str_append(&buffer, 0, ".*%s", tok);
291 }
292 ast_str_append(&buffer, 0, "%s", "$");
293
294 internal_right = ast_str_buffer(buffer);
295 /* fall through to regex */
296 }
297 }
298
299regex:
300 if (!strcasecmp(internal_op, "regex")) {
301 regex_t expression;
302 int rc;
303
304 if (regcomp(&expression, internal_right, REG_EXTENDED | REG_NOSUB)) {
305 return 0;
306 }
307
308 rc = regexec(&expression, left, 0, NULL, 0);
309 regfree(&expression);
310 return !rc;
311 }
312
313equals:
314 scan_numeric = (sscanf(left, "%lf", &left_num) > 0 && sscanf(internal_right, "%lf", &right_num) > 0);
315
316 if (internal_op[0] == '=') {
317 if (ast_strlen_zero(left) && ast_strlen_zero(internal_right)) {
318 return 1;
319 }
320
321 if (scan_numeric) {
322 return (left_num == right_num);
323 } else {
324 return (!strcmp(left, internal_right));
325 }
326 }
327
328 if (internal_op[0] == '!' && internal_op[1] == '=') {
329 if (scan_numeric) {
330 return (left_num != right_num);
331 } else {
332 return !!strcmp(left, internal_right);
333 }
334 }
335
336 if (internal_op[0] == '<') {
337 if (scan_numeric) {
338 if (internal_op[1] == '=') {
339 return (left_num <= right_num);
340 } else {
341 return (left_num < right_num);
342 }
343 } else {
344 if (internal_op[1] == '=') {
345 return strcmp(left, internal_right) <= 0;
346 } else {
347 return strcmp(left, internal_right) < 0;
348 }
349 }
350 }
351
352 if (internal_op[0] == '>') {
353 if (scan_numeric) {
354 if (internal_op[1] == '=') {
355 return (left_num >= right_num);
356 } else {
357 return (left_num > right_num);
358 }
359 } else {
360 if (internal_op[1] == '=') {
361 return strcmp(left, internal_right) >= 0;
362 } else {
363 return strcmp(left, internal_right) > 0;
364 }
365 }
366 }
367
368 return 0;
369}
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:298
static int regex(struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len)
char * strsep(char **str, const char *delims)
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
Definition: strings.h:1139
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition: strings.h:761
#define ast_str_alloca(init_len)
Definition: strings.h:848

References ast_str_alloca, ast_str_append(), ast_str_buffer(), ast_str_set(), ast_strdupa, ast_strlen_zero(), NULL, regex(), and strsep().

Referenced by AST_TEST_DEFINE(), and ast_variables_match().

◆ ast_strip()

char * ast_strip ( char *  s)
inline

Strip leading/trailing whitespace from a string.

Parameters
sThe string to be stripped (will be modified).
Returns
The stripped string.

This functions strips all leading and trailing whitespace characters from the input string, and returns a pointer to the resulting string. The string is modified in place.

Definition at line 223 of file strings.h.

254{

Referenced by acf_if(), add_menu_entry(), ami_sip_qualify(), apps_handler(), aqm_exec(), ari_channels_handle_originate_with_id(), ast_ari_channels_create(), ast_callerid_parse(), ast_el_add_history(), ast_format_cap_update_by_allow_disallow(), ast_geoloc_eprofile_create_from_uri(), ast_get_namedgroups(), ast_playtones_start(), ast_sip_auth_vector_init(), ast_sip_for_each_aor(), ast_sip_location_retrieve_contact_and_aor_from_list_filtered(), ast_strip_quoted(), ast_strsep(), ast_strsep_quoted(), ast_variable_list_from_quoted_string(), ast_vector_string_split(), ast_websocket_uri_cb(), bridge_create_common(), build_calendar(), build_profile(), chanavail_exec(), check_blacklist(), cli_qualify(), cli_reload_qualify_endpoint(), cli_show_qualify_endpoint(), config_text_file_load(), create_unsolicited_mwi_subscriptions(), dial_exec_full(), eivr_comm(), events_handler(), find_aor_for_resource(), find_aor_name(), func_read(), function_amiclient(), global_loaded(), h263_parse_sdp_fmtp(), h264_parse_sdp_fmtp(), header_identify_match_check(), ident_handler(), ip_identify_apply(), ip_identify_match_handler(), list_item_handler(), load_column_config(), load_config(), make_components(), mwi_on_aor(), mwi_validate_for_aor(), notify_endpoint(), page_exec(), parse_cookies(), pbx_builtin_background(), pbx_load_config(), permanent_uri_handler(), pjsip_acf_dial_contacts_read(), process_text_line(), read_header(), read_headers(), realtime_multi_mysql(), realtime_multi_odbc(), realtime_multi_pgsql(), realtime_odbc(), realtime_pgsql(), refer_blind_callback(), reload_single_member(), restrictedFile(), send_unsolicited_mwi_notify(), set(), sip_options_synchronize_endpoint(), store_tone_zone_ring_cadence(), and userevent_exec().

◆ ast_strip_quoted()

char * ast_strip_quoted ( char *  s,
const char *  beg_quotes,
const char *  end_quotes 
)

Strip leading/trailing whitespace and quotes from a string.

Parameters
sThe string to be stripped (will be modified).
beg_quotesThe list of possible beginning quote characters.
end_quotesThe list of matching ending quote characters.
Returns
The stripped string.

This functions strips all leading and trailing whitespace characters from the input string, and returns a pointer to the resulting string. The string is modified in place.

It can also remove beginning and ending quote (or quote-like) characters, in matching pairs. If the first character of the string matches any character in beg_quotes, and the last character of the string is the matching character in end_quotes, then they are removed from the string.

Examples:

ast_strip_quoted(buf, "\"", "\"");
ast_strip_quoted(buf, "'", "'");
ast_strip_quoted(buf, "[{(", "]})");
char * ast_strip_quoted(char *s, const char *beg_quotes, const char *end_quotes)
Strip leading/trailing whitespace and quotes from a string.
Definition: utils.c:1818

Definition at line 1818 of file utils.c.

1819{
1820 char *e;
1821 char *q;
1822
1823 s = ast_strip(s);
1824 if ((q = strchr(beg_quotes, *s)) && *q != '\0') {
1825 e = s + strlen(s) - 1;
1826 if (*e == *(end_quotes + (q - beg_quotes))) {
1827 s++;
1828 *e = '\0';
1829 }
1830 }
1831
1832 return s;
1833}
char * ast_strip(char *s)
Strip leading/trailing whitespace from a string.
Definition: strings.h:223

References ast_strip().

Referenced by applicationmap_handler(), ast_callerid_parse(), ast_sip_validate_uri_length(), ast_strsep(), ast_strsep_quoted(), dialog_info_generate_body_content(), hfp_parse_clip(), iftime(), load_values_config(), parse_cookies(), parse_dial_string(), pidf_allocate_body(), set_redirecting_reason(), and xpidf_allocate_body().

◆ ast_strlen_zero()

static force_inline int attribute_pure ast_strlen_zero ( const char *  s)
static
Examples
app_skel.c.

Definition at line 65 of file strings.h.

66{
67 return (!s || (*s == '\0'));
68}

Referenced by __analog_handle_event(), __analog_ss_thread(), __ast_bridge_technology_register(), __ast_bucket_scheme_register(), __ast_callerid_generate(), __ast_channel_alloc_ap(), __ast_channel_internal_alloc(), __ast_cli_generator(), __ast_cli_register(), __ast_datastore_alloc(), __ast_format_cache_get(), __ast_http_load(), __ast_pbx_run(), __ast_request_and_dial(), __ast_sorcery_apply_config(), __ast_sorcery_object_type_insert_wizard(), __ast_sorcery_wizard_register(), __astman_get_header(), __has_voicemail(), __init_manager(), __manager_event_sessions_va(), __queues_show(), __ssl_setup(), __state_find_or_add(), _iax2_show_peers_one(), acf_abs_exec(), acf_curl_exec(), acf_curl_write(), acf_if(), acf_isexten_exec(), acf_jabberreceive_read(), acf_jabberstatus_read(), acf_max_exec(), acf_meetme_info(), acf_min_exec(), acf_odbc_read(), acf_odbc_write(), acf_rand_exec(), acf_retrieve_docs(), acf_strptime(), acf_transaction_read(), acf_transaction_write(), acf_version_exec(), acf_vm_info(), acf_vmcount_exec(), acl_to_str(), aco_option_register_deprecated(), aco_process_var(), aco_set_defaults(), action_add_agi_cmd(), action_agent_logoff(), action_agents(), action_aoc_de_message(), action_aoc_s_submessage(), action_aocmessage(), action_atxfer(), action_blind_transfer(), action_bridge(), action_cancel_atxfer(), action_challenge(), action_command(), action_confbridgekick(), action_confbridgelist(), action_confbridgelistrooms(), action_confbridgesetsinglevideosrc(), action_confbridgestartrecord(), action_confbridgestoprecord(), action_coresettings(), action_coreshowchannelmap(), action_coreshowchannels(), action_corestatus(), action_dahdidialoffhook(), action_dahdidndoff(), action_dahdidndon(), action_dahdishowchannels(), action_dahdishowstatus(), action_devicestatelist(), action_events(), action_extensionstate(), action_extensionstatelist(), action_getconfig(), action_getconfigjson(), action_getvar(), action_listcategories(), action_lock_unlock_helper(), action_mailboxcount(), action_mailboxstatus(), action_meetmelist(), action_meetmelistrooms(), action_messagesend(), action_mute_unmute_helper(), action_originate(), action_ping(), action_presencestate(), action_presencestatelist(), action_redirect(), action_sendtext(), action_setvar(), action_status(), action_timeout(), action_transfer(), action_transferhangup(), action_updateconfig(), action_waitevent(), actual_load_config(), add_action_to_menu_entry(), add_calltoken_ignore(), add_cert_expiration_to_astdb(), add_diversion_header(), add_extension(), add_format_information_cb(), add_header(), add_header_from_channel_var(), add_hints(), add_history_info_header(), add_item(), add_menu_entry(), add_msid_to_stream(), add_security_headers(), add_vm_recipients_from_string(), admin_exec(), adsi_exec(), adsi_input_format(), adsi_message(), advanced_options(), aes_helper(), agent_alert(), agent_function_read(), agent_handle_logoff_cmd(), agent_handle_show_specific(), agent_login_channel_config(), agent_login_exec(), agent_pvt_destructor(), agent_request_exec(), agent_show_requested(), agi_exec_full(), agi_handle_command(), alarmreceiver_exec(), ami_register(), ami_show_endpoint(), ami_sip_qualify(), ami_unregister(), analog_call(), analog_ss_thread(), anonymous_identify(), answer_exec_enable(), aoc_create_ie_data(), aoc_create_ie_data_charging_rate(), aoc_parse_ie_charging_rate(), aoc_send_as_xml(), aoc_to_ami(), aocmessage_get_unit_entry(), aor_apply_handler(), app_event_filter_set(), app_exec(), app_is_subscribed_bridge_id(), app_is_subscribed_channel_id(), app_is_subscribed_endpoint_id(), app_subscribe(), append_mailbox(), append_mailbox_mapping(), append_source_stream(), append_transaction(), append_vmu_info_astman(), applicationmap_handler(), apply_general_options(), apply_option_timeout(), apply_options_full(), apply_outgoing(), apply_peer(), apps_handler(), aqm_exec(), ari_channels_handle_originate_with_id(), ari_channels_handle_snoop_channel(), ari_originate_dial(), as_check_common_config(), assign_and_insert(), ast_acl_output(), ast_add_extension2_lockopt(), ast_agi_register(), ast_aoc_s_add_rate_duration(), ast_aoc_s_add_rate_flat(), ast_aoc_s_add_rate_volume(), ast_aoc_set_association_number(), ast_aoc_set_currency_info(), ast_app_getdata_full(), ast_app_getdata_terminator(), ast_app_group_get_count(), ast_app_group_match_get_count(), ast_app_group_set_channel(), ast_app_group_split_group(), ast_app_run_sub(), ast_append_acl(), ast_apply_acl_internal(), ast_ari_applications_subscribe(), ast_ari_asterisk_get_global_var(), ast_ari_asterisk_set_global_var(), ast_ari_bridges_add_channel(), ast_ari_bridges_create_with_id(), ast_ari_channels_continue_in_dialplan(), ast_ari_channels_create(), ast_ari_channels_dial(), ast_ari_channels_external_media(), ast_ari_channels_get_channel_var(), ast_ari_channels_hangup(), ast_ari_channels_mute(), ast_ari_channels_redirect(), ast_ari_channels_send_dtmf(), ast_ari_channels_set_channel_var(), ast_ari_channels_unmute(), ast_ari_config_validate_user(), ast_ari_events_user_event(), ast_audiosocket_connect(), ast_audiosocket_init(), ast_base64decode_string(), ast_base64encode_string(), ast_base64url_decode_string(), ast_base64url_encode_string(), ast_bridge_add_channel(), ast_bridge_call_with_flags(), ast_bridge_channel_write_hold(), ast_bridge_features_enable(), ast_bridge_features_register(), ast_bridge_get_snapshot_by_uniqueid(), ast_bridge_read_after_goto(), ast_bridge_set_after_go_on(), ast_bridge_setup_after_goto(), ast_bridge_snapshot_to_json(), ast_bridge_timelimit(), ast_bridge_transfer_attended(), ast_bucket_alloc(), ast_bucket_file_alloc(), ast_bucket_file_retrieve(), ast_bucket_file_temporary_destroy(), ast_bucket_retrieve(), ast_build_timing(), ast_call_forward(), ast_cc_is_recall(), ast_cdr_format_var(), ast_cdr_getvar(), ast_cdr_serialize_variables(), ast_cel_backend_register(), ast_cel_fabricate_channel_from_event(), ast_channel_by_exten_cb(), ast_channel_by_name_cb(), ast_channel_by_uniqueid_cb(), ast_channel_connected_line_sub(), ast_channel_get_by_name_prefix(), ast_channel_hash_cb(), ast_channel_internal_setup_topics(), ast_channel_publish_dial_forward(), ast_channel_publish_dial_internal(), ast_channel_redirecting_sub(), ast_channel_snapshot_cep_equal(), ast_channel_snapshot_get_latest(), ast_channel_snapshot_get_latest_by_name(), ast_channel_snapshot_to_json(), ast_cli_complete(), ast_cli_perms_init(), ast_context_remove_extension_callerid2(), ast_control_tone(), ast_datastores_add(), ast_datastores_alloc_datastore(), ast_db_deltree(), ast_db_gettree(), ast_dns_resolve(), ast_dns_resolve_ipv6_and_ipv4(), ast_dns_resolve_recurring(), ast_dns_resolver_register(), ast_dns_resolver_set_result(), ast_dnsmgr_get_family(), ast_eivr_senddtmf(), ast_endpoint_add_channel(), ast_endpoint_create(), ast_endpoint_latest_snapshot(), ast_endpoint_set_max_channels(), ast_endpoint_set_state(), ast_endpoint_snapshot_create(), ast_escape(), ast_escape_c(), ast_explicit_goto(), ast_false(), ast_format_cache_set(), ast_format_cap_update_by_allow_disallow(), ast_frame_dump(), ast_geoloc_datastore_create(), ast_geoloc_datastore_create_from_profile_name(), ast_geoloc_eprofile_create_from_uri(), ast_geoloc_eprofile_refresh_location(), ast_geoloc_eprofile_to_pidf(), ast_geoloc_eprofile_to_uri(), ast_geoloc_eprofiles_to_pidf(), ast_geoloc_get_location(), ast_geoloc_get_profile(), ast_get_chan_applicationmap(), ast_get_encoded_char(), ast_get_enum(), ast_get_group(), ast_get_indication_zone(), ast_get_money_en_dollars_str(), ast_get_namedgroups(), ast_get_time_t(), ast_get_timeval(), ast_http_create_response(), ast_http_get_json(), ast_http_get_post_vars(), ast_http_header_parse(), ast_http_send(), ast_iax2_new(), ast_include_new(), ast_iostream_start_tls(), ast_is_valid_string(), ast_jb_read_conf(), ast_json_to_ast_variables(), ast_json_vpack(), ast_linear_stream(), ast_load_realtime_fields(), ast_logger_create_channel(), ast_makesocket(), ast_manager_build_bridge_state_string_prefix(), ast_manager_hangup_helper(), ast_manager_register2(), ast_media_cache_create_or_update(), ast_media_cache_delete(), ast_media_cache_exists(), ast_media_cache_retrieve(), ast_media_cache_retrieve_metadata(), ast_media_get_description(), ast_media_get_format_cap(), ast_media_index_update_for_file(), ast_module_check(), ast_moh_files_next(), ast_msg_send(), ast_multi_channel_blob_add_channel(), ast_multi_channel_blob_get_channel(), ast_multi_channel_blob_get_channels(), ast_multicast_rtp_create_options(), ast_multicast_rtp_options_get_format(), ast_mwi_mailbox_alloc(), ast_mwi_mailbox_delete(), ast_mwi_mailbox_get(), ast_parse_arg(), ast_parse_digest(), ast_pbx_exec_application(), ast_pbx_hangup_handler_push(), ast_pbx_outgoing_app_predial(), ast_phoneprov_add_extension(), ast_phoneprov_provider_register(), ast_pickup_call(), ast_playtones_start(), ast_privacy_set(), ast_publish_device_state_full(), ast_queue_hold(), ast_redirecting_reason_name(), ast_refer_send(), ast_register_application2(), ast_register_indication(), ast_remotecontrol(), ast_rtp_dtls_cfg_parse(), ast_rtp_dtls_cfg_validate(), ast_rtp_engine_register2(), ast_rtp_glue_register2(), ast_rtp_instance_new(), ast_rtp_publish_rtcp_message(), ast_sendtext(), ast_sendtext_data(), ast_set_cc_agent_dialstring(), ast_set_cc_callback_sub(), ast_set_hangupsource(), ast_set_indication_country(), ast_sip_auth_vector_init(), ast_sip_cli_traverse_objects(), ast_sip_create_ami_event(), ast_sip_create_dialog_uac(), ast_sip_create_rdata_with_contact(), ast_sip_create_subscription(), ast_sip_default_outbound_endpoint(), ast_sip_for_each_aor(), ast_sip_format_contact_ami(), ast_sip_get_host_ip(), ast_sip_get_transport_name(), ast_sip_location_create_contact(), ast_sip_location_retrieve_contact_and_aor_from_list_filtered(), ast_sip_message_apply_transport(), ast_sip_modify_id_header(), ast_sip_persistent_endpoint_add_to_regcontext(), ast_sip_persistent_endpoint_update_state(), ast_sip_publish_client_add_datastore(), ast_sip_publish_client_alloc_datastore(), ast_sip_register_endpoint_identifier_with_name(), ast_sip_register_event_publisher_handler(), ast_sip_register_publish_handler(), ast_sip_register_subscription_handler(), ast_sip_sched_is_task_running_by_name(), ast_sip_sched_task_cancel_by_name(), ast_sip_sched_task_get_next_run_by_name(), ast_sip_sched_task_get_times_by_name2(), ast_sip_schedule_task(), ast_sip_session_add_datastore(), ast_sip_session_add_reason_header(), ast_sip_session_alloc_datastore(), ast_sip_session_create_outgoing(), ast_sip_session_media_get_transport(), ast_sip_set_tpselector_from_transport_name(), ast_sip_str2rc(), ast_sip_transport_state_set_preferred_identity(), ast_sip_transport_state_set_service_routes(), ast_sip_transport_state_set_transport(), ast_sip_update_from(), ast_sorcery_alloc(), ast_sorcery_retrieve_by_id(), ast_speech_find_engine(), ast_speech_unregister2(), ast_statsd_log_string(), ast_stir_shaken_as_ctx_add_fingerprint(), ast_stir_shaken_as_ctx_create(), ast_stir_shaken_vs_ctx_create(), ast_stir_shaken_vs_verify(), ast_str_substitute_variables_full2(), ast_stream_and_wait(), ast_stream_topology_append_stream(), ast_stream_topology_set_stream(), ast_strings_match(), ast_strsep(), ast_strsep_quoted(), ast_taskprocessor_get(), ast_tcptls_client_create(), AST_TEST_DEFINE(), ast_true(), ast_tzset(), ast_unreal_new_channels(), ast_uri_is_secure(), ast_var_channels_table(), ast_variable_delete(), ast_variable_list_from_quoted_string(), ast_variable_update(), ast_vector_string_split(), ast_websocket_uri_cb(), ast_xmldoc_build_arguments(), ast_xmldoc_build_final_response(), ast_xmldoc_build_list_responses(), ast_xmldoc_build_seealso(), asterisk_publication_devicestate(), asterisk_publication_devicestate_refresh(), asterisk_publication_mailboxstate(), asterisk_publication_mwi_refresh(), asterisk_start_devicestate_publishing(), asterisk_start_mwi_publishing(), astman_send_list_complete_start_common(), astman_send_response_full(), async_delete_name_rec(), async_play_sound_helper(), asyncgoto_exec(), attempt_thread(), attended_transfer_exec(), audiosocket_exec(), audiosocket_request(), auth_apply(), auth_exec(), auth_http_callback(), authenticate(), authenticate_reply(), authenticate_verify(), autopause2int(), background_detect_exec(), base64_helper(), base_process_party_a(), begin_dial_prerun(), blind_transfer_exec(), bridge_agent_hold_push(), bridge_base_init(), bridge_builtin_set_limits(), bridge_exec(), bridge_features_duration_callback(), bridge_handle_trip(), bridge_parking_push(), bridge_personality_atxfer_push(), bridge_topics_init(), bridgeadd_exec(), bridgewait_exec(), broadcast_exec(), bucket_file_update_path(), bucket_http_wizard_retrieve_id(), build_calendar(), build_device(), build_mapping(), build_node_children(), build_peer(), build_profile(), build_user(), builtin_features_helper(), cache_get_callno_locked(), caldav_add_event(), caldav_load_calendar(), caldav_request(), caldav_write_event(), calendar_busy_exec(), calendar_event_read(), calendar_query_exec(), calendar_query_result_exec(), calendar_write_exec(), calendarstate(), caller_id_handler(), callerid_feed(), callerid_genmsg(), canonicalize_tn(), canonicalize_tn_alloc(), cc_unique_append(), cdr_format_var_internal(), cdr_object_create_public_records(), cdr_object_get_by_name(), cdr_prop_write_callback(), cdr_read(), cdr_read_callback(), cdr_retrieve_time(), cdr_write(), cdr_write_callback(), cel_channel_app_change(), cel_channel_linkedid_change(), cel_dial_cb(), cel_linkedid_ref(), celgenuserevent_exec(), chan_pjsip_new(), chanavail_exec(), channel_admin_exec(), channel_dial_cb(), channel_dialplan(), channel_do_masquerade(), channel_fill_empty_accountcode(), channel_fill_empty_peeraccount(), channel_hold_cb(), channel_newexten(), channel_read_pjsip(), channel_read_rtcp(), channel_read_rtp(), channel_req_accountcodes(), channel_spy(), chanspy_exec(), chararray_handler_fn(), check_access(), check_blacklist(), check_bridge_play_sound(), check_date_header(), check_day(), check_dow(), check_match(), check_month(), check_new_cdr_needed(), check_password(), check_regcontext(), check_retire_linkedid(), check_timerange(), check_x5u_url(), cleaned_basedn(), clear_stats(), cli_complete(), cli_complete_notify(), cli_console_dial(), cli_console_sendtext(), cli_contact_get_container(), cli_odbc_read(), cli_odbc_write(), cli_print_body(), cli_qualify(), cli_reload_qualify_endpoint(), cli_show_qualify_endpoint(), client_config_apply(), close_client(), cmp_strings(), commit_exec(), common_exec(), compare(), compile_script(), complete_agent(), complete_agent_logoff(), complete_ari_app(), complete_ari_user(), complete_bridge_live(), complete_number(), complete_parking_lot(), conf_ended(), conf_exec(), conf_find_bridge_profile(), conf_find_user_profile(), conf_run(), conf_set_menu_to_user(), confbridge_exec(), confbridge_handle_atxfer(), config_curl(), config_function_read(), config_ldap(), config_module(), config_object_cli_show(), config_text_file_load(), configuration_parse_unsigned_integer(), confkick_exec(), connection_dead(), console_new(), console_print(), contact_acl_to_str(), contact_apply_handler(), contactstatus_to_json(), control_list_create(), controlplayback_exec(), controlplayback_manager(), copy_message(), copy_rules(), copy_variables(), count_exec(), create_addr(), create_channel_name(), create_dialog_uas(), create_dynamic_lot_full(), create_local_sdp(), create_new_id_hdr(), create_out_of_dialog_request(), create_outgoing_sdp_stream(), create_queue_member(), create_rtp(), create_sound_blob(), create_transaction(), create_unsolicited_mwi_subscriptions(), create_vmaccount(), crement_function_read(), crypto_load_cert_from_file(), crypto_load_cert_from_memory(), crypto_load_cert_store(), crypto_load_privkey_from_file(), crypto_log_openssl(), crypto_register_x509_extension(), csv_log(), csv_quote(), curl_download_to_file(), curler(), custom_prepare(), custom_presence_callback(), dahdi_func_write(), dahdi_handle_event(), dahdi_new(), dahdi_read(), dahdiscan_exec(), database_increment(), declined_handler(), delete_existing_cb(), deltree_exec(), destroy_mysql(), destroy_pgsql(), destroy_trans(), detect_write(), determine_actual_value(), determine_starting_point(), device_state_alloc(), device_state_cb(), device_state_subscription_create(), devstate_write(), dial_append_common(), dial_exec_full(), dial_handle_playtones(), dialgroup_read(), dialgroup_refreshdb(), dialgroup_write(), dialog_info_generate_body_content(), dialout(), dialplan_has_destination_cb(), dictate_exec(), digest_check_auth(), directory_exec(), disa_exec(), dns_query_alloc(), do_broadcast(), do_forward(), do_message(), do_monitor(), do_notify(), does_category_match(), does_id_conflict(), does_method_match(), domain_alias_apply(), dtmf_store_framehook(), dtmfstore_exec(), dump_cause(), dump_consumer(), dump_hint(), dumpchan_exec(), dundi_exec(), dundi_flags2str(), dundi_helper(), dundi_hint2str(), dundi_lookup_local(), dundi_query_read(), dundi_query_thread(), dundi_result_read(), dundi_show_mappings(), dundi_show_peer(), dundifunc_read(), dynamic_dtmf_hook_add(), enable_jack_hook(), endpoint_acl_handler(), endpoint_internal_create(), enum_callback(), enum_query_read(), enum_result_read(), env_write(), eprofile_get_cfg(), eval_exten_read(), event_session_alloc(), events_handler(), ewscal_load_calendar(), exchangecal_load_calendar(), exchangecal_write_event(), exec_exec(), execif_exec(), execute_state_callback(), expand_gosub_args(), exten_state_publisher_cb(), extension_match_core(), extension_presence_state_helper(), extenspy_exec(), external_media_audiosocket_tcp(), extstate_read(), fast_originate(), feature_automixmonitor(), feature_blind_transfer(), festival_exec(), fetch_icalendar(), fileexists_core(), filename_parse(), filter_outgoing_message(), filter_session_outgoing_message(), find_account(), find_aor(), find_aor_for_resource(), find_aor_name(), find_app_by_name(), find_body_generator_accept(), find_channel_parking_lot_name(), find_cli(), find_conf_realtime(), find_endpoint(), find_header(), find_or_create(), find_queue_by_name_rt(), find_registrar_aor(), find_request_serializer(), find_table(), find_user(), findmeexec(), forkcdr_exec(), format_ami_endpoint_transport(), format_log_default(), format_log_plain(), forward_message(), forwards_create(), free_user_final(), freq_parser(), func_chan_exists_read(), func_channel_read(), func_channel_write_real(), func_channels_read(), func_confbridge_channels(), func_confbridge_helper(), func_confbridge_info(), func_get_parkingslot_channel(), func_mixmonitor_read(), func_read(), func_read_header(), func_read_param(), func_response_read_header(), func_response_read_headers(), func_write_header(), func_write_param(), function_amiclient(), function_db_delete(), function_db_exists(), function_db_read(), function_db_write(), function_enum(), function_eval(), function_eval2(), function_fieldnum_helper(), function_ltrim(), function_realtime_read(), function_realtime_readdestroy(), function_realtime_store(), function_realtime_write(), function_rtrim(), function_trim(), function_txtcidname(), generate_parked_user(), generic_fax_exec(), generic_recall(), geoloc_civicaddr_list_to_xml(), geoloc_eprofile_create_from_xslt_result(), geoloc_eprofile_to_intermediate(), geoloc_gml_list_to_xml(), geoloc_profile_apply_handler(), geoloc_profile_read(), geoloc_profile_write(), get_buddy_status(), get_container(), get_curl_instance(), get_destination(), get_interface_helper(), get_key(), get_or_create_subscription(), get_queue_member_status(), get_range(), get_resource_display_name(), get_subscription(), get_timerange(), get_transfer_context(), get_transfer_exten(), global_apply(), gosub_exec(), gosubif_exec(), goto_parser(), grab_transfer(), group_count_function_read(), group_function_read(), group_function_write(), group_list_function_read(), group_match_count_function_read(), group_show_channels(), h264_generate_sdp_fmtp(), h264_getjoint(), handle_aor(), handle_attended_transfer(), handle_blind_transfer(), handle_bridge_enter(), handle_chanlist(), handle_cli_check_permissions(), handle_cli_confbridge_show_bridge_profile(), handle_cli_confbridge_show_user_profile(), handle_cli_confbridge_start_record(), handle_cli_config_reload(), handle_cli_database_show(), handle_cli_database_showkey(), handle_cli_devstate_change(), handle_cli_dialplan_save(), handle_cli_dynamic_level_test(), handle_cli_file_convert(), handle_cli_iax2_show_cache(), handle_cli_iax2_show_peer(), handle_cli_iax2_show_users(), handle_cli_indication_add(), handle_cli_presencestate_change(), handle_cli_realtime_mysql_status(), handle_cli_realtime_pgsql_status(), handle_command_response(), handle_controlstreamfile(), handle_debug(), handle_debug_dialplan(), handle_dial_message(), handle_dial_page(), handle_endpoint(), handle_export_primitives(), handle_getvariable(), handle_hangup(), handle_incoming_request(), handle_incoming_sdp(), handle_logger_remove_channel(), handle_manager_bridge_tech_suspend(), handle_options(), handle_orig(), handle_outgoing_request(), handle_playtones(), handle_queue_add_member(), handle_queue_pause_member(), handle_queue_remove_member(), handle_queue_rule_show(), handle_registrations(), handle_saydatetime(), handle_show_dialplan(), handle_speechrecognize(), handle_trace(), handle_updates(), handle_verbose(), handle_voicemail_show_aliases(), handle_voicemail_show_users(), has_voicemail(), hashtab_compare_extens(), header_identify_match_check(), hep_queue_cb(), hepv3_config_pre_apply(), hint_hash(), hint_read(), hold_intercept_fn_write(), hook_off(), hook_on(), hook_re_enable(), http_body_discard_chunk_trailer_headers(), http_callback(), http_media_cache_config_pre_apply(), http_request_headers_get(), http_server_get_by_addr(), iax2_call(), iax2_datetime(), iax2_devicestate(), iax2_prov_app(), iax2_request(), iax_firmware_append(), iax_firmware_get_version(), iax_provflags2str(), ical_load_calendar(), icalendar_add_event(), iconv_read(), ident_handler(), iftime(), import_helper(), inboxcount2(), incoming_in_dialog_request(), init_acf_query(), init_jack_data(), initialize_cc_max_requests(), insert_penaltychange(), inspect_module(), internal_aco_type_find(), internal_dnsmgr_lookup(), internal_process_ast_config(), ip_identify_apply(), ip_identify_match_handler(), is_argument(), is_cert_cache_entry_expired(), is_media_state_valid(), is_new_rec_file(), is_prefix(), is_preload(), is_unsolicited_allowed(), is_valid_dialstatus(), is_valid_tone_zone(), is_video_dest(), isAnsweringMachine(), isexten_function_read(), jack_exec(), jb_choose_impl(), jb_framedata_init(), jb_helper(), jingle_action_hook(), jingle_alloc(), jingle_interpret_content(), jingle_interpret_description(), jingle_interpret_google_transport(), jingle_interpret_ice_udp_transport(), jingle_new(), jingle_outgoing_hook(), jingle_request(), jingle_send_error_response(), join_conference_bridge(), json_decode_read(), key_dial_page(), key_history(), key_main_page(), kill_if_unfound(), launch_asyncagi(), launch_monitor_thread(), launch_netscript(), ldap_reconnect(), ldap_table_config_add_attribute(), leave_voicemail(), line_identify(), list_item_handler(), load_aliases(), load_asterisk_conf(), load_column_config(), load_config(), load_endpoint(), load_indications(), load_modules(), load_moh_classes(), load_mysql_config(), load_odbc_config(), load_private_key_from_memory(), load_realtime_queues(), load_realtime_rules(), load_values_config(), local_ast_moh_start(), log_events(), log_exec(), logger_print_normal(), loopback_parse(), lua_get_variable(), lua_get_variable_value(), main(), make_components(), make_dir(), make_email_file(), make_filename(), make_fn(), make_logchannel(), man_do_variable_value(), manager_add_queue_member(), manager_bridge_destroy(), manager_bridge_info(), manager_bridge_kick(), manager_bridge_tech_list(), manager_bridges_list(), manager_change_priority_caller_on_queue(), manager_db_tree_get(), manager_dbdel(), manager_dbdeltree(), manager_dbget(), manager_dbput(), manager_dialplan_extension_add(), manager_dialplan_extension_remove(), manager_fax_session(), manager_fax_sessions(), manager_fax_stats(), manager_get_mailbox_summary(), manager_iax2_show_peer_list(), manager_iax2_show_peers(), manager_iax2_show_registry(), manager_jabber_send(), manager_list_voicemail_users(), manager_match_mailbox(), manager_mixmonitor(), manager_modulecheck(), manager_moduleload(), manager_mute_mixmonitor(), manager_mutestream(), manager_notify(), manager_notify_endpoint(), manager_notify_uri(), manager_optimize_away(), manager_park(), manager_parking_lot_list(), manager_parking_status(), manager_pause_queue_member(), manager_play_dtmf(), manager_play_mf(), manager_queue_log_custom(), manager_queue_member_penalty(), manager_queue_member_ringinuse(), manager_queue_rule_show(), manager_queues_status(), manager_queues_summary(), manager_remove_queue_member(), manager_request_withdraw_caller_from_queue(), manager_show_dialplan(), manager_show_dialplan_helper(), manager_status_voicemail_user(), manager_stop_mixmonitor(), manager_voicemail_forward(), manager_voicemail_move(), manager_voicemail_remove(), mark_unfound(), match_aor(), matchcid(), math(), mbl_load_adapter(), mbl_load_device(), mbl_sendsms_exec(), mbl_status_exec(), md5(), media_cache_item_populate_from_astdb(), meetmemute(), message_playback_callback_fn(), message_range_and_existence_check(), message_received_handler(), message_template_find(), message_template_parse_filebody(), messagecount(), messaging_app_unsubscribe_endpoint(), metermaidstate(), milliwatt_exec(), minivm_accmess_exec(), minivm_account_func_read(), minivm_counter_func_read(), minivm_counter_func_write(), minivm_delete_exec(), minivm_greet_exec(), minivm_mwi_exec(), minivm_notify_exec(), minivm_record_exec(), mixmonitor_exec(), mixmonitor_save_prep(), mixmonitor_thread(), mkintf(), module_load_helper_on_file(), moh_parse_options(), monitor_dial(), morsecode_exec(), mp3_exec(), msg_send(), msg_send_exec(), msg_set_var_full(), msg_to_endpoint(), mssql_connect(), multicast_rtp_request(), mute_mixmonitor_instance(), mwi_contact_changed(), mwi_contact_deleted(), mwi_create_state(), mwi_folder_map(), mwi_generate_body_content(), mwi_mailbox_delete(), mwi_mailbox_get(), mwi_mailbox_update(), mwi_new_subscribe(), mwi_on_aor(), mwi_state_create_message(), mwi_subscription_alloc(), mwi_subscription_established(), mwi_to_event(), mwi_validate_for_aor(), mysql_reconnect(), named_acl_find_realtime(), named_groups_handler(), new_outgoing(), new_realtime_sqlite3_db(), newpvt(), notify_endpoint(), notify_message(), notify_new_message(), notify_uri(), odbc_log(), onNewCallCreated(), onOutgoingCall(), ooh323_indicate(), ooh323_new(), ooh323_onReceivedSetup(), options_on_rx_request(), orig_app(), orig_exten(), originate_exec(), page_exec(), park_and_announce_app_exec(), park_announce_update_cb(), park_app_exec(), park_app_parse_data(), park_common_setup2(), parked_call_app_exec(), parking_blind_transfer_park(), parking_channel_set_roles(), parking_duration_callback(), parking_lot_cfg_create_extensions(), parking_lot_cfg_remove_extensions(), parse_bookmark(), parse_config(), parse_cookies(), parse_data(), parse_dial_string(), parse_line(), parse_playtone(), parse_simple_message_summary(), parse_tag(), parse_tone_uri(), participant_idle_mode_setup(), path_get_string(), path_outgoing_request(), payload_helper_app(), pbx_builtin_answer(), pbx_builtin_background(), pbx_builtin_execiftime(), pbx_builtin_gotoif(), pbx_builtin_gotoiftime(), pbx_builtin_hangup(), pbx_builtin_incomplete(), pbx_builtin_saycharacters_case(), pbx_builtin_saynumber(), pbx_builtin_sayordinal(), pbx_builtin_setvar(), pbx_builtin_setvar_helper(), pbx_builtin_setvar_multiple(), pbx_builtin_waitexten(), pbx_checkcondition(), pbx_extension_helper(), pbx_find_extension(), pbx_load_config(), pbx_load_users(), pbx_outgoing_attempt(), pbx_outgoing_exec(), pbx_parseable_goto(), pbx_set_overrideswitch(), pbx_substitute_variables_helper_full_location(), peek_read(), permanent_uri_handler(), pgsql_reconnect(), pickup_exec(), pickupchan_exec(), pidf_supplement_body(), pjsip_acf_channel_read(), pjsip_acf_dial_contacts_read(), pjsip_acf_parse_uri_read(), pjsip_aor_function_read(), pjsip_app_hangup(), pjsip_contact_function_read(), pjsip_endpoint_function_read(), pjsip_log_test_filter(), play_file(), play_mailbox_owner(), play_message(), play_message_by_id_helper(), play_message_callerid(), play_message_category(), play_message_datetime(), play_moh_exec(), play_record_review(), play_sound_helper(), playback_common(), playback_create(), playback_exec(), populate_cache(), post_cdr(), pp_each_extension_helper(), pp_each_user_helper(), pqm_exec(), prep_email_sub_vars(), presence_read(), presence_state_cached(), presence_write(), print_acl(), print_event_instance(), print_ext(), print_frame(), print_queue(), privacy_exec(), process_category(), process_dahdi(), process_description_file(), process_echocancel(), process_extmap_attributes(), process_histfile(), process_ice_attributes(), process_message(), process_message_callback(), process_my_load_module(), process_text_line(), process_token(), profile_get_cfg(), prometheus_callback_register(), prometheus_config_pre_apply(), prometheus_metric_full_to_string(), prometheus_show_status(), publish_acl_change(), publish_device_state_to_stasis(), publish_load_message_type(), publish_mwi_to_stasis(), publish_request_initial(), publisher_start(), pubsub_on_rx_mwi_notify_request(), ql_exec(), queue_exec(), queue_function_exists(), queue_function_mem_read(), queue_function_mem_write(), queue_function_memberpenalty_read(), queue_function_memberpenalty_write(), queue_function_qac_dep(), queue_function_queuegetchannel(), queue_function_queuememberlist(), queue_function_queuewaitingcount(), queue_function_var(), queue_mwi_event(), queue_reload_request(), quote(), qupd_exec(), raise_msg_handler(), rcv_mac_addr(), read_dirs_cb(), read_exec(), read_headers(), read_mf_exec(), read_sf_exec(), readexten_exec(), realtime_common(), realtime_curl(), realtime_directory(), realtime_exec(), realtime_ldap_entry_to_var(), realtime_ldap_result_to_vars(), realtime_ldap_status(), realtime_multi_curl(), realtime_multi_mysql(), realtime_multi_odbc(), realtime_multi_pgsql(), realtime_mysql(), realtime_odbc(), realtime_pgsql(), realtime_sqlite3_destroy(), realtime_sqlite3_helper(), realtime_sqlite3_load(), realtime_sqlite3_require(), realtime_sqlite3_store(), realtime_sqlite3_update(), realtime_sqlite3_update2(), realtime_update_peer(), realtimefield_read(), reason_code_to_str(), receive_ademco_event(), receivefax_exec(), record_exec(), record_serializer(), recording_publish(), recordthread(), recvtext_exec(), refer_blind_callback(), refer_incoming_blind_request(), refer_set_var_full(), regex_filter_handler(), register_peer_exten(), register_verify(), registrar_on_rx_request(), registration_client_send(), registry_rerequest(), reload_config(), reload_exec(), reload_followme(), reload_queue_members(), reload_queues(), reload_single_member(), remove_from_queue(), replace(), report_receive_fax_status(), report_send_fax_status(), request(), request_identify_match_check(), requirecalltoken_mark_auto(), res_sdp_crypto_parse_offer(), resetcdr_exec(), resource_event_handler(), resource_list_apply_handler(), retrydial_exec(), ring_entry(), rollback_exec(), rotate_file(), rqm_exec(), rt_handle_member_record(), rtcp_do_debug_ip(), rtcp_message_handler(), rtp_do_debug_ip(), run_externnotify(), save_dialstatus(), save_response_fields_to_transport(), saycountedadj_exec(), saycountednoun_exec(), sayfile_exec(), sayunixtime_exec(), scan_exec(), schedule_calendar_event(), sdp_fmtp_get(), sdp_requires_deferral(), search_directory(), search_directory_sub(), select_item_pause(), send_bridge_list_item_cb(), send_message(), send_refer(), send_refresh_cb(), send_unsolicited_mwi_notify(), send_unsolicited_mwi_notify_to_contact(), senddtmf_exec(), sendfax_exec(), sendmail(), sendmf_exec(), sendpage(), sendsf_exec(), sendtext(), sendtext_exec(), separate_mailbox(), session_outgoing_nat_hook(), set(), set_bridge_features_on_config(), set_config(), set_from_header(), set_id_from_hdr(), set_if(), set_loc_src(), set_local_info(), set_loop(), set_member_paused(), set_member_value(), set_outbound_authentication_credentials(), set_queue_member_pause(), set_rec_filename(), set_remote_mslabel_and_stream_group(), set_sound(), set_touch_variable(), set_transport(), set_ttl(), set_var_handler(), set_voicemail_extension(), setup_dahdi_int(), setup_mixmonitor(), setup_mixmonitor_ds(), setup_park_common_datastore(), setup_privacy_args(), setup_profile_caller(), setup_profile_paged(), setup_stunaddr(), sha1(), shared_read(), shared_write(), shell_helper(), shift_pop(), should_queue_connected_line_update(), show_main_page(), show_sound_info_cb(), signal_exec(), sip_dialog_create_contact(), sip_dialog_create_from(), sip_endpoint_apply_handler(), sip_is_token(), sip_msg_send(), sip_options_qualify_contact(), sip_options_synchronize_endpoint(), sip_outbound_publisher_init(), sip_outbound_publisher_set_uri(), sip_outbound_publisher_set_uris(), sip_outbound_registration_apply(), sip_outbound_registration_regc_alloc(), sip_publisher_service_queue(), sip_refer_send(), skel_exec(), sla_build_station(), sla_build_trunk(), sla_check_device(), sla_queue_event_conf(), sla_station_destructor(), sla_station_exec(), sla_trunk_destructor(), sla_trunk_exec(), smdi_md_q_cmp_fn(), smdi_msg_find(), smdi_msg_read(), smdi_msg_retrieve_read(), sms_exec(), socket_process_helper(), softhangup_exec(), sorcery_astdb_open(), sorcery_config_open(), sorcery_config_retrieve_regex(), sorcery_function_read(), sorcery_is_configuration_met(), sorcery_is_explicit_name_met(), sorcery_memory_cache_ami_expire(), sorcery_memory_cache_ami_expire_object(), sorcery_memory_cache_ami_populate(), sorcery_memory_cache_ami_stale(), sorcery_memory_cache_ami_stale_object(), sorcery_memory_cache_close(), sorcery_memory_cache_load(), sorcery_memory_cache_open(), sorcery_memory_retrieve_regex(), sorcery_realtime_open(), sorcery_realtime_retrieve_regex(), spawn_mp3(), speech_background(), split_ext(), srv_query_read(), srv_result_read(), stackpeek_read(), start_automixmonitor(), start_mixmonitor_callback(), stasis_app_control_moh_start(), stasis_app_control_play_uri(), stasis_app_control_record(), stasis_app_control_snoop(), stasis_app_device_state_delete(), stasis_app_device_state_update(), stasis_app_device_states_to_json(), stasis_app_recording_if_exists_parse(), stasis_app_recording_termination_parse(), static_callback(), stir_shaken_incoming_request(), stop_automixmonitor(), stop_mixmonitor_full(), strbetween(), stream_echo_exec(), stringfield_handler_fn(), strings_to_mask(), strreplace(), sub_bridge_update_handler(), subscription_persistence_remove(), substituted(), subsystem_alert_decrement(), subsystem_alert_increment(), sysinfo_helper(), system_exec_helper(), system_registry_to_ami(), t38_initialize_session(), talk_detect_fn_write(), test_msg_has_destination_cb(), testclient_exec(), testserver_exec(), transfer(), transfer_exec(), transfer_refer(), transport_apply(), transport_localnet_handler(), transport_tls_file_handler(), transport_tls_method_handler(), transport_tls_verify(), try_calling(), try_firmware(), tryexec_exec(), unbound_config_preapply(), unicast_rtp_request(), unistim_call(), unistim_new(), unistim_request(), unshift_push(), update_odbc(), update_realtime_member_field(), update_realtime_members(), update_registry(), upqm_exec(), uri_parse_and_default(), uridecode(), uriencode(), user_event_hook_cb(), userevent_exec(), ustmtext(), valid_exit(), validate_location_source(), validate_metric(), validate_metric_type_counter(), validate_metric_type_gauge(), validate_metric_type_set(), validate_metric_type_timer(), validate_name(), validate_publish_config(), validate_user_cb(), verbose_exec(), vm_authenticate(), vm_exec(), vm_execmain(), vm_mailbox_snapshot_create(), vm_msg_forward(), vm_msg_move(), vm_msg_play(), vm_msg_remove(), vm_newuser_setup(), vm_options(), vm_playmsgexec(), vm_sayname(), vmauthenticate(), vmsayname_exec(), vmu_tm(), volume_read(), volume_write(), vs_check_common_config(), wait_exec(), wait_for_answer(), wait_for_hangup(), wait_for_winner(), waitfor_exec(), waitforcond_exec(), waitsignal_exec(), waituntil_exec(), websocket_client_handshake(), wizard_apply_handler(), word_match(), write_metadata(), xml_translate(), xmldoc_build_field(), xmldoc_get_node(), xmldoc_get_syntax_fun(), xmldoc_load_documentation(), xmldoc_parse_specialtags(), xmldoc_update_config_type(), xmpp_client_authenticate_sasl(), xmpp_client_config_post_apply(), xmpp_client_reconnect(), xmpp_client_send_message(), xmpp_client_set_presence(), xmpp_config_prelink(), xmpp_join_exec(), xmpp_leave_exec(), xmpp_pak_message(), xmpp_pak_presence(), xmpp_pubsub_iq_create(), xmpp_send_cb(), xmpp_send_exec(), xmpp_sendgroup_exec(), and zapateller_exec().

◆ ast_strsep()

char * ast_strsep ( char **  s,
const char  sep,
uint32_t  flags 
)

Act like strsep but ignore separators inside quotes.

Parameters
sPointer to address of the string to be processed. Will be modified and can't be constant.
sepA single character delimiter.
flagsControls post-processing of the result. AST_STRSEP_TRIM trims all leading and trailing whitespace from the result. If the result containes only whitespace, it'll be passed through unchanged. AST_STRSEP_STRIP does a trim then strips the outermost quotes. You may want to trim again after the strip. Just OR both the TRIM and STRIP flags. AST_STRSEP_UNESCAPE unescapes '\' sequences. AST_STRSEP_ALL does all of the above processing.
Returns
The next token or NULL if done or if there are more than 8 levels of nested quotes. If provided an empty string, will return the empty string.

This function acts like strsep with three exceptions... The separator is a single character instead of a string. Separators inside quotes are treated literally instead of like separators. You can elect to have leading and trailing whitespace and quotes stripped from the result and have '\' sequences unescaped.

Like strsep, ast_strsep maintains no internal state and you can call it recursively using different separators on the same storage.

Also like strsep, for consistent results, consecutive separators are not collapsed so you may get an empty string as a valid result.

Examples:

char *mystr = ast_strdupa("abc=def,ghi='zzz=yyy,456',jkl");
char *token, *token2, *token3;
while((token = ast_strsep(&mystr, ',', AST_STRSEP_STRIP))) {
// 1st token will be aaa=def
// 2nd token will be ghi='zzz=yyy,456'
while((token2 = ast_strsep(&token, '=', AST_STRSEP_STRIP))) {
// 1st token2 will be ghi
// 2nd token2 will be zzz=yyy,456
while((token3 = ast_strsep(&token2, ',', AST_STRSEP_STRIP))) {
// 1st token3 will be zzz=yyy
// 2nd token3 will be 456
// and so on
}
}
// 3rd token will be jkl
}
char * ast_strsep(char **s, const char sep, uint32_t flags)
Act like strsep but ignore separators inside quotes.
Definition: utils.c:1835
Examples
app_skel.c.

Definition at line 1835 of file utils.c.

1836{
1837 char *st = *iss;
1838 char *is;
1839 int inquote = 0;
1840 int found = 0;
1841 char stack[8];
1842
1843 if (ast_strlen_zero(st)) {
1844 *iss = NULL;
1845 return st;
1846 }
1847
1848 memset(stack, 0, sizeof(stack));
1849
1850 for(is = st; *is; is++) {
1851 if (*is == '\\') {
1852 if (*++is != '\0') {
1853 is++;
1854 } else {
1855 break;
1856 }
1857 }
1858
1859 if (*is == '\'' || *is == '"') {
1860 if (*is == stack[inquote]) {
1861 stack[inquote--] = '\0';
1862 } else {
1863 if (++inquote >= sizeof(stack)) {
1864 return NULL;
1865 }
1866 stack[inquote] = *is;
1867 }
1868 }
1869
1870 if (*is == sep && !inquote) {
1871 *is = '\0';
1872 found = 1;
1873 *iss = is + 1;
1874 break;
1875 }
1876 }
1877 if (!found) {
1878 *iss = NULL;
1879 }
1880
1881 if (flags & AST_STRSEP_STRIP) {
1882 st = ast_strip_quoted(st, "'\"", "'\"");
1883 }
1884
1885 if (flags & AST_STRSEP_TRIM) {
1886 char *trimmed = ast_strip(st);
1887 if (!ast_strlen_zero(trimmed)) {
1888 st = trimmed;
1889 }
1890 }
1891
1892 if (flags & AST_STRSEP_UNESCAPE) {
1894 }
1895
1896 return st;
1897}
void ast_unescape_quoted(char *quote_str)
Unescape quotes in a string.
Definition: utils.c:842
char * ast_strip_quoted(char *s, const char *beg_quotes, const char *end_quotes)
Strip leading/trailing whitespace and quotes from a string.
Definition: utils.c:1818

References ast_strip(), ast_strip_quoted(), ast_strlen_zero(), AST_STRSEP_STRIP, AST_STRSEP_TRIM, AST_STRSEP_UNESCAPE, ast_unescape_quoted(), and NULL.

Referenced by action_playback(), action_playback_and_continue(), ast_app_getdata_terminator(), ast_sip_header_to_security_mechanism(), ast_sip_security_mechanism_vector_init(), ast_sip_str_to_security_mechanism(), AST_TEST_DEFINE(), does_category_match(), handle_incoming_request(), handle_updates(), originate_exec(), pbx_builtin_background(), play_files_helper(), playback_exec(), reload_exec(), rfc3329_incoming_response(), speech_background(), try_calling(), and wizard_apply_handler().

◆ ast_strsep_quoted()

char * ast_strsep_quoted ( char **  s,
const char  sep,
const char  quote,
uint32_t  flags 
)

Like ast_strsep() except you can specify a specific quote character.

Parameters
sPointer to address of the string to be processed. Will be modified and can't be constant.
sepA single character delimiter.
quoteThe quote character
flagsControls post-processing of the result. AST_STRSEP_TRIM trims all leading and trailing whitespace from the result. AST_STRSEP_STRIP does a trim then strips the outermost quotes. You may want to trim again after the strip. Just OR both the TRIM and STRIP flags. AST_STRSEP_UNESCAPE unescapes '\' sequences. AST_STRSEP_ALL does all of the above processing.
Returns
The next token or NULL if done or if there are more than 8 levels of nested quotes. If provided an empty string, will return the empty string.

Definition at line 1899 of file utils.c.

1900{
1901 char *st = *iss;
1902 char *is;
1903 int inquote = 0;
1904 int found = 0;
1905 char stack[8];
1906 const char qstr[] = { quote };
1907
1908 if (ast_strlen_zero(st)) {
1909 *iss = NULL;
1910 return st;
1911 }
1912
1913 memset(stack, 0, sizeof(stack));
1914
1915 for(is = st; *is; is++) {
1916 if (*is == '\\') {
1917 if (*++is != '\0') {
1918 is++;
1919 } else {
1920 break;
1921 }
1922 }
1923
1924 if (*is == quote) {
1925 if (*is == stack[inquote]) {
1926 stack[inquote--] = '\0';
1927 } else {
1928 if (++inquote >= sizeof(stack)) {
1929 return NULL;
1930 }
1931 stack[inquote] = *is;
1932 }
1933 }
1934
1935 if (*is == sep && !inquote) {
1936 *is = '\0';
1937 found = 1;
1938 *iss = is + 1;
1939 break;
1940 }
1941 }
1942 if (!found) {
1943 *iss = NULL;
1944 }
1945
1946 if (flags & AST_STRSEP_STRIP) {
1947 st = ast_strip_quoted(st, qstr, qstr);
1948 }
1949
1950 if (flags & AST_STRSEP_TRIM) {
1951 char *trimmed = ast_strip(st);
1952 if (!ast_strlen_zero(trimmed)) {
1953 st = trimmed;
1954 }
1955 }
1956
1957 if (flags & AST_STRSEP_UNESCAPE) {
1959 }
1960
1961 return st;
1962}
static int quote(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)

References ast_strip(), ast_strip_quoted(), ast_strlen_zero(), AST_STRSEP_STRIP, AST_STRSEP_TRIM, AST_STRSEP_UNESCAPE, ast_unescape_quoted(), NULL, and quote().

Referenced by AST_TEST_DEFINE(), and ast_variable_list_from_quoted_string().

◆ ast_tech_to_upper()

char * ast_tech_to_upper ( char *  dev_str)
inline

Convert the tech portion of a device string to upper case.

Return values
dev_strthe char* passed in for convenience

Definition at line 1236 of file strings.h.

1247{

Referenced by ast_endpoint_latest_snapshot(), create_new_generic_list(), find_generic_monitor_instance_list(), pvt_cause_cmp_fn(), and pvt_cause_hash_fn().

◆ ast_to_camel_case_delim()

char * ast_to_camel_case_delim ( const char *  s,
const char *  delim 
)

Attempts to convert the given string to camel case using the specified delimiter.

note - returned string needs to be freed

Parameters
sthe string to convert
delimdelimiter to parse out
Returns
The string converted to "CamelCase"
Since
12

Definition at line 2397 of file utils.c.

2398{
2399 char *res = ast_strdup(s);
2400 char *front, *back, *buf = res;
2401 int size;
2402
2403 front = strtok_r(buf, delim, &back);
2404
2405 while (front) {
2406 size = strlen(front);
2407 *front = toupper(*front);
2408 ast_copy_string(buf, front, size + 1);
2409 buf += size;
2410 front = strtok_r(NULL, delim, &back);
2411 }
2412
2413 return res;
2414}
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:241

References ast_copy_string(), ast_strdup, buf, and NULL.

◆ ast_trim_blanks()

char * ast_trim_blanks ( char *  str)
inline

◆ ast_true()

int attribute_pure ast_true ( const char *  val)

Make sure something is true. Determine if a string containing a boolean value is "true". This function checks to see whether a string passed to it is an indication of an "true" value. It checks to see if the string is "yes", "true", "y", "t", "on" or "1".

Return values
-1if "true".
0otherwise, like NULL pointer.
Examples
app_skel.c.

Definition at line 2199 of file utils.c.

2200{
2201 if (ast_strlen_zero(s))
2202 return 0;
2203
2204 /* Determine if this is a true value */
2205 if (!strcasecmp(s, "yes") ||
2206 !strcasecmp(s, "true") ||
2207 !strcasecmp(s, "y") ||
2208 !strcasecmp(s, "t") ||
2209 !strcasecmp(s, "1") ||
2210 !strcasecmp(s, "on"))
2211 return -1;
2212
2213 return 0;
2214}

References ast_strlen_zero().

Referenced by __ast_http_load(), __init_manager(), acf_curlopt_write(), acf_faxopt_write(), acf_transaction_write(), action_agent_logoff(), action_originate(), action_status(), action_updateconfig(), actual_load_config(), agent_login_channel_config(), analog_call(), announce_user_count_all_handler(), aoc_cli_debug_enable(), apply_general_options(), apply_option(), ast_ari_bridges_add_channel_cb(), ast_ari_bridges_record_cb(), ast_ari_channels_record_cb(), ast_ari_endpoints_refer_cb(), ast_ari_endpoints_refer_to_endpoint_cb(), ast_ari_events_event_websocket_ws_attempted_cb(), ast_ari_events_event_websocket_ws_established_cb(), ast_bridge_timelimit(), ast_jb_read_conf(), ast_rtp_dtls_cfg_parse(), AST_TEST_DEFINE(), ast_tls_read_conf(), autopause2int(), bool_handler_fn(), boolflag_handler_fn(), build_calendar(), build_device(), build_peer(), build_user(), cdr_prop_write_callback(), check_debug(), client_bitfield_handler(), custom_bitfield_handler(), customopt_handler(), dahdi_set_dnd(), dahdi_set_mwi(), do_reload(), encoding_format_handler(), festival_exec(), func_channel_write_real(), func_mute_write(), function_ooh323_write(), geoloc_profile_write(), get_encrypt_methods(), global_bitfield_handler(), handle_exec(), handle_incoming_request(), handle_logger_chanloggroup_filter(), handle_logger_set_level(), handle_queue_set_member_ringinuse(), hook_write(), init_logger_chain(), internal_feature_write(), is_variable_true(), load_asterisk_conf(), load_config(), load_config_meetme(), load_module(), load_moh_classes(), load_odbc_config(), load_users(), loader_config_init(), manager_add_queue_member(), manager_change_priority_caller_on_queue(), manager_dialplan_extension_add(), manager_moduleload(), manager_mute_mixmonitor(), manager_mutestream(), manager_pause_queue_member(), manager_play_dtmf(), manager_queue_member_ringinuse(), manager_send_flash(), mbl_load_adapter(), mbl_load_device(), message_template_build(), moh_parse_options(), new_realtime_sqlite3_db(), odbc_load_module(), parse_config(), parse_empty_options(), parse_line(), parse_playtone(), pbx_load_config(), pbx_load_users(), permit_dtmf_interrupt(), pjsip_acf_moh_passthrough_write(), pjsip_set_logger_verbose(), prack_handler(), process_dahdi(), process_echocancel(), process_my_load_module(), profile_set_param(), queue_rules_set_global_params(), queue_set_global_params(), queue_set_param(), realtime_directory(), reload(), reload_config(), reload_followme(), reload_module(), reload_single_member(), rt_handle_member_record(), rtp_reload(), run_agi(), run_startup_commands(), sayunixtime_exec(), search_directory(), search_directory_sub(), set_active(), set_config(), sla_load_config(), smdi_load(), sorcery_config_open(), sorcery_memory_cache_ami_stale_object(), sorcery_memory_cache_open(), speex_write(), stackpeek_read(), strings_to_mask(), tds_load_module(), timers_handler(), transport_tls_bool_handler(), xfer_set(), xmldoc_get_syntax_cmd(), xmldoc_get_syntax_config_object(), xmldoc_get_syntax_fun(), and xmldoc_get_syntax_manager().

◆ ast_unescape_c()

char * ast_unescape_c ( char *  s)

Convert some C escape sequences.

(\b\f\n\r\t) 

into the equivalent characters. The string to be converted (will be modified).

Returns
The converted string.

Definition at line 1983 of file utils.c.

1984{
1985 char c, *ret, *dst;
1986
1987 if (src == NULL)
1988 return NULL;
1989 for (ret = dst = src; (c = *src++); *dst++ = c ) {
1990 if (c != '\\')
1991 continue; /* copy char at the end of the loop */
1992 switch ((c = *src++)) {
1993 case '\0': /* special, trailing '\' */
1994 c = '\\';
1995 break;
1996 case 'b': /* backspace */
1997 c = '\b';
1998 break;
1999 case 'f': /* form feed */
2000 c = '\f';
2001 break;
2002 case 'n':
2003 c = '\n';
2004 break;
2005 case 'r':
2006 c = '\r';
2007 break;
2008 case 't':
2009 c = '\t';
2010 break;
2011 }
2012 /* default, use the char literally */
2013 }
2014 *dst = '\0';
2015 return ret;
2016}

References c, and NULL.

Referenced by ast_parse_digest().

◆ ast_unescape_semicolon()

char * ast_unescape_semicolon ( char *  s)

Strip backslash for "escaped" semicolons, the string to be stripped (will be modified).

Returns
The stripped string.

Definition at line 1964 of file utils.c.

1965{
1966 char *e;
1967 char *work = s;
1968
1969 while ((e = strchr(work, ';'))) {
1970 if ((e > work) && (*(e-1) == '\\')) {
1971 memmove(e - 1, e, strlen(e) + 1);
1972 work = e;
1973 } else {
1974 work = e + 1;
1975 }
1976 }
1977
1978 return s;
1979}