Asterisk - The Open Source Telephony Project GIT-master-f36a736
|
Utility functions. More...
#include "asterisk.h"
#include <ctype.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <unistd.h>
#include "asterisk/network.h"
#include "asterisk/ast_version.h"
#include "asterisk/lock.h"
#include "asterisk/io.h"
#include "asterisk/md5.h"
#include "asterisk/sha1.h"
#include "asterisk/cli.h"
#include "asterisk/linkedlists.h"
#include "asterisk/astobj2.h"
#include "asterisk/strings.h"
#include "asterisk/time.h"
#include "asterisk/utils.h"
#include "asterisk/threadstorage.h"
#include "asterisk/config.h"
#include "asterisk/alertpipe.h"
Go to the source code of this file.
Data Structures | |
struct | baseio |
Structure used for base64 encoding. More... | |
struct | thr_arg |
Macros | |
#define | AST_API_MODULE /* ensure that inlinable API functions will be built in lock.h if required */ |
#define | AST_API_MODULE /* ensure that inlinable API functions will be built in this module if required */ |
#define | AST_API_MODULE /* ensure that inlinable API functions will be built in this module if required */ |
#define | AST_API_MODULE /* ensure that inlinable API functions will be built in this module if required */ |
#define | AST_API_MODULE |
#define | AST_API_MODULE |
#define | AST_API_MODULE |
#define | BASELINELEN 72 |
#define | BASEMAXINLINE 256 |
#define | ONE_MILLION 1000000 |
Functions | |
void DO_CRASH_NORETURN | __ast_assert_failed (int condition, const char *condition_str, const char *file, int line, const char *function) |
int | __ast_fd_set_flags (int fd, int flags, enum ast_fd_flag_operation op, const char *file, int lineno, const char *function) |
static void | __init_inet_ntoa_buf (void) |
static void | __init_thread_user_interface_tl (void) |
A thread local indicating whether the current thread is a user interface. More... | |
int | ast_background_stacksize (void) |
int | ast_base64_encode_file (FILE *inputfile, FILE *outputfile, const char *endl) |
Performs a base 64 encode algorithm on the contents of a File. More... | |
int | ast_base64_encode_file_path (const char *filename, FILE *outputfile, const char *endl) |
Performs a base 64 encode algorithm on the contents of a File. More... | |
int | ast_base64decode (unsigned char *dst, const char *src, int max) |
decode BASE64 encoded text More... | |
char * | ast_base64decode_string (const char *src) |
Decode BASE64 encoded text and return the string. More... | |
int | ast_base64encode (char *dst, const unsigned char *src, int srclen, int max) |
Encode data in base64. More... | |
int | ast_base64encode_full (char *dst, const unsigned char *src, int srclen, int max, int linebreaks) |
encode text to BASE64 coding More... | |
char * | ast_base64encode_string (const char *src) |
Encode to BASE64 and return encoded string. More... | |
int | ast_base64url_decode (unsigned char *dst, const char *src, int max) |
Decode data from base64 URL. More... | |
char * | ast_base64url_decode_string (const char *src) |
Decode string from base64 URL. More... | |
int | ast_base64url_encode (char *dst, const unsigned char *src, int srclen, int max) |
Encode data in base64 URL. More... | |
int | ast_base64url_encode_full (char *dst, const unsigned char *src, int srclen, int max, int linebreaks) |
Same as ast_base64encode_full but for base64 URL. More... | |
char * | ast_base64url_encode_string (const char *src) |
Encode string in base64 URL. 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_carefulwrite (int fd, char *s, int len, int timeoutms) |
Try to write string, but wait no more than ms milliseconds before timing out. More... | |
int | ast_check_command_in_path (const char *cmd) |
Test for the presence of an executable command in $PATH. More... | |
int | ast_check_ipv6 (void) |
Test that an OS supports IPv6 Networking. More... | |
int | ast_compare_versions (const char *version1, const char *version2) |
Compare 2 major.minor.patch.extra version strings. More... | |
void DO_CRASH_NORETURN | ast_do_crash (void) |
Force a crash if DO_CRASH is defined. More... | |
int | ast_eid_cmp (const struct ast_eid *eid1, const struct ast_eid *eid2) |
Compare two EIDs. More... | |
int | ast_eid_is_empty (const struct ast_eid *eid) |
Check if EID is empty. More... | |
char * | ast_eid_to_str (char *s, int maxlen, struct ast_eid *eid) |
Convert an EID to a string. More... | |
void | ast_enable_packet_fragmentation (int sock) |
Disable PMTU discovery on a socket. 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... | |
char * | ast_escape_quoted (const char *string, char *outbuf, int buflen) |
Escape characters found in a quoted string. More... | |
char * | ast_escape_semicolons (const char *string, char *outbuf, int buflen) |
Escape semicolons found in a string. More... | |
int | ast_false (const char *s) |
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... | |
int | ast_file_is_readable (const char *filename) |
Test that a file exists and is readable by the effective user. More... | |
void | ast_format_duration_hh_mm_ss (int duration, char *buf, size_t length) |
Formats a duration into HH:MM:SS. More... | |
int | ast_get_tid (void) |
Get current thread ID. More... | |
int | ast_get_time_t (const char *src, time_t *dst, time_t _default, int *consumed) |
get values from config variables. More... | |
int | ast_get_timeval (const char *src, struct timeval *dst, struct timeval _default, int *consumed) |
get values from config variables. More... | |
struct hostent * | ast_gethostbyname (const char *host, struct ast_hostent *hp) |
Re-entrant (thread safe) version of gethostbyname that replaces the standard gethostbyname (which is not thread safe) More... | |
const char * | ast_inet_ntoa (struct in_addr ia) |
ast_inet_ntoa: Recursive thread safe replacement of inet_ntoa 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... | |
void | ast_md5_hash (char *output, const char *input) |
Produce 32 char MD5 hash of value. More... | |
int | ast_mkdir (const char *path, int mode) |
Recursively create directory path. More... | |
int | ast_parse_digest (const char *digest, struct ast_http_digest *d, int request, int pedantic) |
Parse digest authorization header. More... | |
char * | ast_process_quotes_and_slashes (char *start, char find, char replace_with) |
Process a string to find and replace characters. More... | |
int | ast_pthread_create_detached_stack (pthread_t *thread, pthread_attr_t *attr, void *(*start_routine)(void *), void *data, size_t stacksize, const char *file, const char *caller, int line, const char *start_fn) |
int | ast_pthread_create_stack (pthread_t *thread, pthread_attr_t *attr, void *(*start_routine)(void *), void *data, size_t stacksize, const char *file, const char *caller, int line, const char *start_fn) |
long int | ast_random (void) |
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... | |
int | ast_remaining_ms (struct timeval start, int max_ms) |
Calculate remaining milliseconds given a starting timestamp and upper bound. More... | |
void | ast_replace_subargument_delimiter (char *s) |
Replace '^' in a string with ','. More... | |
int | ast_safe_mkdir (const char *base_path, const char *path, int mode) |
Recursively create directory path, but only if it resolves within the given base_path. More... | |
void | ast_set_default_eid (struct ast_eid *eid) |
Fill in an ast_eid with the default eid of this machine. More... | |
void | ast_sha1_hash (char *output, const char *input) |
Produce 40 char SHA1 hash of value. More... | |
void | ast_sha1_hash_uint (uint8_t *digest, const char *input) |
Produce a 20 byte SHA1 hash of value. More... | |
int | ast_str_to_eid (struct ast_eid *eid, const char *s) |
Convert a string into an EID. 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... | |
char * | ast_strsep (char **iss, const char sep, uint32_t flags) |
Act like strsep but ignore separators inside quotes. More... | |
char * | ast_strsep_quoted (char **iss, const char sep, const char quote, uint32_t flags) |
Like ast_strsep() except you can specify a specific quote character. More... | |
int | ast_thread_is_user_interface (void) |
Indicates whether the current thread is a user interface. More... | |
int | ast_thread_user_interface_set (int is_user_interface) |
Set the current thread's user interface status. 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... | |
int | ast_true (const char *s) |
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... | |
struct timeval | ast_tvadd (struct timeval a, struct timeval b) |
Returns the sum of two timevals a + b. More... | |
struct timeval | ast_tvsub (struct timeval a, struct timeval b) |
Returns the difference of two timevals a - b. More... | |
char * | ast_unescape_c (char *src) |
Convert some C escape sequences. More... | |
void | ast_unescape_quoted (char *quote_str) |
Unescape quotes in a string. More... | |
char * | ast_unescape_semicolon (char *s) |
Strip backslash for "escaped" semicolons, the string to be stripped (will be modified). More... | |
void | ast_uri_decode (char *s, struct ast_flags spec) |
Decode URI, URN, URL (overwrite string) More... | |
char * | ast_uri_encode (const char *string, char *outbuf, int buflen, struct ast_flags spec) |
Turn text string to URI-encoded XX version. More... | |
int | ast_utils_init (void) |
char * | ast_utils_which (const char *binary, char *fullpath, size_t fullpath_size) |
Resolve a binary to a full pathname. More... | |
int | ast_wait_for_input (int fd, int ms) |
int | ast_wait_for_output (int fd, int ms) |
int | ast_xml_escape (const char *string, char *const outbuf, const size_t buflen) |
Escape reserved characters for use in XML. More... | |
static void | base64_init (void) |
static void * | dummy_start (void *data) |
static char * | escape_alloc (const char *s, size_t *size) |
static int | inbuf (struct baseio *bio, FILE *fi) |
utility used by inchar(), for base_encode() More... | |
static int | inchar (struct baseio *bio, FILE *fi) |
utility used by base_encode() More... | |
static int | ochar (struct baseio *bio, int c, FILE *so, const char *endl) |
utility used by base_encode() More... | |
static int | safe_mkdir (const char *base_path, char *path, int mode) |
static struct timeval | tvfix (struct timeval a) |
static void | utils_shutdown (void) |
static int | wait_for_output (int fd, int timeoutms) |
Variables | |
const struct ast_flags | ast_uri_http = {AST_URI_UNRESERVED} |
const struct ast_flags | ast_uri_http_legacy = {AST_URI_LEGACY_SPACE | AST_URI_UNRESERVED} |
const struct ast_flags | ast_uri_sip_user = {AST_URI_UNRESERVED | AST_URI_SIP_USER_UNRESERVED} |
static char | b2a [256] |
static char | b2a_url [256] |
static char | base64 [64] |
static char | base64url [64] |
static int | dev_urandom_fd = -1 |
char | escape_sequences [] |
static char | escape_sequences_map [] |
static struct ast_threadstorage | inet_ntoa_buf = { .once = PTHREAD_ONCE_INIT , .key_init = __init_inet_ntoa_buf , .custom_init = NULL , } |
static ast_mutex_t | randomlock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} } |
static struct ast_threadstorage | thread_user_interface_tl = { .once = PTHREAD_ONCE_INIT , .key_init = __init_thread_user_interface_tl , .custom_init = NULL , } |
Utility functions.
Definition in file utils.c.
#define BASELINELEN 72 |
#define BASEMAXINLINE 256 |
void DO_CRASH_NORETURN __ast_assert_failed | ( | int | condition, |
const char * | condition_str, | ||
const char * | file, | ||
int | line, | ||
const char * | function | ||
) |
Definition at line 2816 of file utils.c.
References __LOG_ERROR, ast_do_crash(), ast_log, ast_log_backtrace(), and make_ari_stubs::file.
Referenced by __ao2_container_clone(), __ao2_iterator_next(), __ao2_link(), __ao2_ref(), internal_ao2_traverse(), and log_bad_ao2().
int __ast_fd_set_flags | ( | int | fd, |
int | flags, | ||
enum ast_fd_flag_operation | op, | ||
const char * | file, | ||
int | lineno, | ||
const char * | function | ||
) |
Definition at line 3150 of file utils.c.
References __LOG_ERROR, ast_assert, AST_FD_FLAG_CLEAR, AST_FD_FLAG_SET, ast_log, errno, and make_ari_stubs::file.
|
static |
int ast_background_stacksize | ( | void | ) |
Definition at line 1616 of file utils.c.
References AST_STACKSIZE, and AST_STACKSIZE_LOW.
int ast_base64_encode_file | ( | FILE * | inputfile, |
FILE * | outputfile, | ||
const char * | endl | ||
) |
Performs a base 64 encode algorithm on the contents of a File.
inputfile | A FILE handle to the input file to be encoded. Must be readable. This handle is not automatically closed. |
outputfile | A FILE handle to the output file to receive the base 64 encoded contents of the input file, identified by filename. |
endl | The line ending to use (e.g. either "\n" or "\r\n") |
Definition at line 648 of file utils.c.
References BASEMAXINLINE, c, inchar(), baseio::iocp, and ochar().
Referenced by ast_base64_encode_file_path().
int ast_base64_encode_file_path | ( | const char * | filename, |
FILE * | outputfile, | ||
const char * | endl | ||
) |
Performs a base 64 encode algorithm on the contents of a File.
filename | The path to the file to be encoded. Must be readable, file is opened in read mode. |
outputfile | A FILE handle to the output file to receive the base 64 encoded contents of the input file, identified by filename. |
endl | The line ending to use (e.g. either "\n" or "\r\n") |
Definition at line 702 of file utils.c.
References ast_base64_encode_file(), ast_log, AST_LOG_WARNING, and errno.
Referenced by add_email_attachment(), and sendmail().
int ast_base64decode | ( | unsigned char * | dst, |
const char * | src, | ||
int | max | ||
) |
decode BASE64 encoded text
Decode data from base64.
Definition at line 296 of file utils.c.
Referenced by action_messagesend(), aes_helper(), ast_base64decode_string(), ast_check_signature(), ast_http_get_auth(), AST_TEST_DEFINE(), base64_helper(), crypto_init_keys(), custom_presence_callback(), presence_write(), and res_sdp_crypto_parse_offer().
char * ast_base64decode_string | ( | const char * | src | ) |
Decode BASE64 encoded text and return the string.
Same as ast_base64decode, but does the math for you and returns a decoded string.
Definition at line 323 of file utils.c.
References ast_base64decode(), ast_malloc, ast_strlen_zero(), and NULL.
int ast_base64encode | ( | char * | dst, |
const unsigned char * | src, | ||
int | srclen, | ||
int | max | ||
) |
Encode data in base64.
dst | the destination buffer |
src | the source data to be encoded |
srclen | the number of bytes present in the source buffer |
max | the maximum number of bytes to write into the destination buffer, including the terminating NULL character. |
Definition at line 406 of file utils.c.
References ast_base64encode_full(), and max.
Referenced by aes_helper(), ast_base64encode_string(), ast_sign(), AST_TEST_DEFINE(), base64_helper(), build_secret(), crypto_init_keys(), presence_read(), websocket_client_create_key(), websocket_combine_key(), and xmpp_client_authenticate_sasl().
int ast_base64encode_full | ( | char * | dst, |
const unsigned char * | src, | ||
int | srclen, | ||
int | max, | ||
int | linebreaks | ||
) |
encode text to BASE64 coding
Definition at line 355 of file utils.c.
Referenced by ast_base64encode().
char * ast_base64encode_string | ( | const char * | src | ) |
Encode to BASE64 and return encoded string.
Same as ast_base64encode, but does hte math for you and returns an encoded string.
Definition at line 412 of file utils.c.
References ast_base64encode(), ast_calloc, ast_strlen_zero(), and NULL.
int ast_base64url_decode | ( | unsigned char * | dst, |
const char * | src, | ||
int | max | ||
) |
Decode data from base64 URL.
dst | The destination buffer |
src | The source buffer |
max | The maximum number of bytes to write into the destination buffer. Note that this function will not ensure that the destination buffer is NULL terminated. So, in general, this parameter should be sizeof(dst) - 1 |
Definition at line 429 of file utils.c.
Referenced by ast_base64url_decode_string().
char * ast_base64url_decode_string | ( | const char * | src | ) |
Decode string from base64 URL.
src | The source buffer |
NULL | on failure |
Definition at line 450 of file utils.c.
References ast_base64url_decode(), ast_malloc, ast_strlen_zero(), and NULL.
int ast_base64url_encode | ( | char * | dst, |
const unsigned char * | src, | ||
int | srclen, | ||
int | max | ||
) |
Encode data in base64 URL.
dst | The destination buffer |
src | The source data to be encoded |
srclen | The number of bytes present in the source buffer |
max | The maximum number of bytes to write into the destination buffer, including the terminating NULL character |
Definition at line 518 of file utils.c.
References ast_base64url_encode_full(), and max.
Referenced by ast_base64url_encode_string().
int ast_base64url_encode_full | ( | char * | dst, |
const unsigned char * | src, | ||
int | srclen, | ||
int | max, | ||
int | linebreaks | ||
) |
Same as ast_base64encode_full but for base64 URL.
dst | The destination buffer |
src | The source buffer |
srclen | The number of bytes present in the source buffer |
max | The maximum number of bytes to write into the destination buffer, including the terminating NULL character. |
linebreaks | Set to 1 if there should be linebreaks inserted in the result |
Definition at line 471 of file utils.c.
References base64url, and max.
Referenced by ast_base64url_encode().
char * ast_base64url_encode_string | ( | const char * | src | ) |
Encode string in base64 URL.
src | The source data to be encoded |
NULL | on failure |
Definition at line 523 of file utils.c.
References ast_base64url_encode(), ast_malloc, ast_strlen_zero(), and NULL.
int ast_build_string | ( | char ** | buffer, |
size_t * | space, | ||
const char * | fmt, | ||
... | |||
) |
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.
buffer | current position in buffer to place string into (will be updated on return) |
space | remaining space in buffer (will be updated on return) |
fmt | printf-style format string |
0 | on success |
non-zero | on failure. |
Definition at line 2167 of file utils.c.
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().
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.
zero | on success. |
non-zero | on failure. |
buffer | current position in buffer to place string into (will be updated on return) |
space | remaining space in buffer (will be updated on return) |
fmt | printf-style format string |
ap | varargs list of arguments for format |
Definition at line 2148 of file utils.c.
References result.
Referenced by ast_build_string().
int ast_carefulwrite | ( | int | fd, |
char * | s, | ||
int | len, | ||
int | timeoutms | ||
) |
Try to write string, but wait no more than ms milliseconds before timing out.
Try to write string, but wait no more than ms milliseconds before timing out.
Definition at line 1771 of file utils.c.
References ast_debug, ast_log, ast_tvdiff_ms(), ast_tvnow(), errno, len(), LOG_ERROR, and wait_for_output().
Referenced by ast_agi_send(), ast_cli(), and cleanup_module().
int ast_check_command_in_path | ( | const char * | cmd | ) |
Test for the presence of an executable command in $PATH.
cmd | Name of command to locate. |
True | (non-zero) if command is in $PATH. |
False | (zero) command not found. |
Definition at line 3263 of file utils.c.
References ast_free, ast_log, ast_strdup, len(), LOG_WARNING, NULL, and PATH_MAX.
Referenced by AST_TEST_DEFINE().
int ast_check_ipv6 | ( | void | ) |
Test that an OS supports IPv6 Networking.
True | (non-zero) if the IPv6 supported. |
False | (zero) if the OS doesn't support IPv6. |
Definition at line 2792 of file utils.c.
Referenced by load_module().
int ast_compare_versions | ( | const char * | version1, |
const char * | version2 | ||
) |
Compare 2 major.minor.patch.extra version strings.
version1 | |
version2 |
negative | if version 1 < version 2. |
0 | if version 1 = version 2. |
positive | if version 1 > version 2. |
Definition at line 3124 of file utils.c.
Referenced by transport_apply().
void DO_CRASH_NORETURN ast_do_crash | ( | void | ) |
Force a crash if DO_CRASH is defined.
Definition at line 2804 of file utils.c.
Referenced by __ast_assert_failed().
Compare two EIDs.
0 | if the two are the same |
non-zero | otherwise |
Definition at line 3094 of file utils.c.
Referenced by AST_TEST_DEFINE(), asterisk_publisher_devstate_cb(), asterisk_publisher_mwistate_cb(), build_peer(), build_transactions(), cache_entry_by_eid(), cache_entry_create(), cache_remove(), cache_update(), clear_node_cache(), cpg_deliver_cb(), destroy_trans(), dundi_answer_entity(), dundi_answer_query(), dundi_ie_append_eid_appropriately(), dundi_lookup_internal(), dundi_prop_precache(), dundi_query_thread(), find_peer(), handle_command_response(), optimize_transactions(), publish_cluster_discovery_to_stasis(), publish_to_corosync(), register_request(), state_find_and_remove_eid(), state_find_or_add_eid(), xmpp_pubsub_devstate_cb(), xmpp_pubsub_handle_event(), and xmpp_pubsub_mwi_cb().
int ast_eid_is_empty | ( | const struct ast_eid * | eid | ) |
Check if EID is empty.
1 | if the EID is empty |
0 | otherwise |
Definition at line 3099 of file utils.c.
References ast_eid::eid, and empty_eid.
Referenced by load_module(), and set_config().
char * ast_eid_to_str | ( | char * | s, |
int | maxlen, | ||
struct ast_eid * | eid | ||
) |
Convert an EID to a string.
Definition at line 2839 of file utils.c.
References ast_eid::eid.
Referenced by app_send(), append_transaction(), ast_ari_asterisk_get_info(), ast_ari_asterisk_ping(), ast_set_default_eid(), ast_str_retrieve_variable(), AST_TEST_DEFINE(), asterisk_publication_send_refresh(), asterisk_publisher_devstate_cb(), asterisk_publisher_mwistate_cb(), bridges_scrape_cb(), build_peer(), build_transactions(), cache_lookup(), cache_lookup_internal(), channels_scrape_cb(), check_key(), complete_peer_helper(), cpg_deliver_cb(), destroy_trans(), do_autokill(), do_register(), do_register_expire(), dump_answer(), dump_eid(), dundi_answer_entity(), dundi_lookup_internal(), dundi_lookup_local(), dundi_lookup_thread(), dundi_precache_thread(), dundi_prop_precache(), dundi_query_thread(), dundi_send(), dundi_show_cache(), dundi_show_entityid(), dundi_show_hints(), dundi_show_peer(), dundi_show_peers(), dundi_show_requests(), endpoints_scrape_cb(), handle_command_response(), handle_show_settings(), populate_addr(), prometheus_config_post_apply(), publish_cluster_discovery_to_stasis_full(), publish_device_state_to_stasis(), publish_mwi_to_stasis(), publish_to_corosync(), register_request(), update_key(), xmpp_pubsub_publish_device_state(), and xmpp_pubsub_publish_mwi().
void ast_enable_packet_fragmentation | ( | int | sock | ) |
Disable PMTU discovery on a socket.
sock | The socket to manipulate |
On Linux, UDP sockets default to sending packets with the Dont Fragment (DF) bit set. This is supposedly done to allow the application to do PMTU discovery, but Asterisk does not do this.
Because of this, UDP packets sent by Asterisk that are larger than the MTU of any hop in the path will be lost. This function can be called on a socket to ensure that the DF bit will not be set.
Definition at line 2469 of file utils.c.
References ast_log, and LOG_WARNING.
Referenced by ast_netsock_bindaddr().
char * ast_escape | ( | char * | dest, |
const char * | s, | ||
size_t | size, | ||
const char * | to_escape | ||
) |
Escape the 'to_escape' characters in the given string.
dest | the escaped string |
s | the source string to escape |
size | The size of the destination buffer |
to_escape | an array of characters to escape |
Definition at line 2034 of file utils.c.
References ast_copy_string(), ast_strlen_zero(), c, escape_sequences, and escape_sequences_map.
Referenced by ast_escape_alloc().
char * ast_escape_alloc | ( | const char * | s, |
const char * | to_escape | ||
) |
Escape the 'to_escape' characters in the given string.
s | the source string to escape |
to_escape | an array of characters to escape |
Definition at line 2132 of file utils.c.
References ast_escape(), and escape_alloc().
char * ast_escape_c | ( | char * | dest, |
const char * | s, | ||
size_t | size | ||
) |
Escape standard 'C' sequences in the given string.
dest | the escaped string |
s | the source string to escape |
size | The size of the destination buffer |
Definition at line 2077 of file utils.c.
References ast_strlen_zero(), c, escape_sequences, and escape_sequences_map.
Referenced by ast_escape_c_alloc().
char * ast_escape_c_alloc | ( | const char * | s | ) |
Escape standard 'C' sequences in the given string.
s | the source string to escape |
Definition at line 2140 of file utils.c.
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().
char * ast_escape_quoted | ( | const char * | string, |
char * | outbuf, | ||
int | buflen | ||
) |
Escape characters found in a quoted string.
string | string to be escaped |
outbuf | resulting escaped string |
buflen | size of output buffer |
Definition at line 781 of file utils.c.
Referenced by ast_callerid_merge(), ast_sip_modify_id_header(), AST_TEST_DEFINE(), channel_read_pjsip(), create_new_id_hdr(), print_escaped_uri(), and refer_send().
char * ast_escape_semicolons | ( | const char * | string, |
char * | outbuf, | ||
int | buflen | ||
) |
Escape semicolons found in a string.
string | string to be escaped |
outbuf | resulting escaped string |
buflen | size of output buffer |
Definition at line 811 of file utils.c.
References ast_assert, NULL, out, and string.
Referenced by ast_config_text_file_save2(), handle_cli_dialplan_save(), and test_semi().
int 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".
-1 | if "true". |
0 | otherwise, like NUL pointer. |
Definition at line 2216 of file utils.c.
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().
int ast_file_is_readable | ( | const char * | filename | ) |
Test that a file exists and is readable by the effective user.
filename | File to test. |
True | (non-zero) if the file exists and is readable. |
False | (zero) if the file either doesn't exists or is not readable. |
Definition at line 3107 of file utils.c.
Referenced by add_email_attachment(), as_check_common_config(), ast_media_cache_retrieve(), ast_rtp_dtls_cfg_parse(), retrieve_cert_from_cache(), transport_tls_file_handler(), and vs_check_common_config().
void ast_format_duration_hh_mm_ss | ( | int | duration, |
char * | buf, | ||
size_t | length | ||
) |
Formats a duration into HH:MM:SS.
duration | The time (in seconds) to format |
buf | A buffer to hold the formatted string' |
length | The size of the buffer |
Definition at line 2297 of file utils.c.
References buf.
Referenced by cli_channel_print_body(), cli_channelstats_print_body(), handle_bridge_show_all(), handle_bridge_show_specific(), and stasis_show_topic().
int ast_get_tid | ( | void | ) |
Get current thread ID.
Definition at line 2752 of file utils.c.
Referenced by __ao2_ref(), ast_hangup(), ast_register_thread(), dummy_start(), format_log_message_ap(), and internal_ao2_alloc().
int ast_get_time_t | ( | const char * | src, |
time_t * | dst, | ||
time_t | _default, | ||
int * | consumed | ||
) |
get values from config variables.
Parse a time (integer) string.
Definition at line 2446 of file utils.c.
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().
int ast_get_timeval | ( | const char * | src, |
struct timeval * | dst, | ||
struct timeval | _default, | ||
int * | consumed | ||
) |
get values from config variables.
Parse a time (float) string.
Definition at line 2419 of file utils.c.
References ast_strlen_zero(), and NULL.
Referenced by acf_strftime(), expiration_str2struct(), persistence_expires_str2struct(), and timeval_str2struct().
struct hostent * ast_gethostbyname | ( | const char * | host, |
struct ast_hostent * | hp | ||
) |
Re-entrant (thread safe) version of gethostbyname that replaces the standard gethostbyname (which is not thread safe)
Thread-safe gethostbyname function to use in Asterisk.
Definition at line 199 of file utils.c.
References ast_hostent::buf, ast_hostent::hp, NULL, and result.
const char * ast_inet_ntoa | ( | struct in_addr | ia | ) |
ast_inet_ntoa: Recursive thread safe replacement of inet_ntoa
thread-safe replacement for inet_ntoa().
Definition at line 928 of file utils.c.
References ast_threadstorage_get(), buf, and inet_ntoa_buf.
Referenced by _stun_show_status(), ast_parse_arg(), create_client(), get_defaults(), get_to_address(), handle_cli_rtp_settings(), handle_error(), handle_stun_timeout(), iax_server(), parsing(), phoneprov_callback(), process_request(), reload_config(), rtp_reload(), score_address(), send_raw_client(), send_start_rtp(), send_trunk(), show_main_page(), start_rtp(), stun_monitor_request(), unistim_show_devices(), unistim_show_info(), and unistimsock_read().
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.
s | the resulting string buffer |
len | the length of the result buffer, s |
w | an array of strings to join. |
size | the number of elements to join |
delim | delimiter 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'.
Definition at line 2378 of file utils.c.
References len().
Referenced by ast_sip_auths_to_str().
void ast_md5_hash | ( | char * | output, |
const char * | input | ||
) |
Produce 32 char MD5 hash of value.
Produces MD5 hash based on input string.
Definition at line 250 of file utils.c.
References input(), md5(), MD5Final(), MD5Init(), and MD5Update().
Referenced by __init_manager(), ast_sip_location_create_contact(), AST_TEST_DEFINE(), auth_exec(), auth_http_callback(), build_nonce(), md5(), and permanent_uri_handler().
int ast_mkdir | ( | const char * | path, |
int | mode | ||
) |
Recursively create directory path.
path | The directory path to create |
mode | The permissions with which to try to create the directory |
0 | on success |
Creates a directory path, creating parent directories as needed.
Definition at line 2479 of file utils.c.
References ast_alloca, ast_strdupa, errno, len(), and tmp().
Referenced by ast_file_fdtemp(), ast_logger_rotate_channel(), conf_rec_name(), conf_run(), create_destination_directory(), create_dirpath(), dictate_exec(), filename_parse(), init_logger(), load_module(), reload_logger(), remove_from_queue(), setup_privacy_args(), sms_nextoutgoing(), sms_writefile(), test_vm_api_create_voicemail_folder(), testclient_exec(), testserver_exec(), and write_history().
int ast_parse_digest | ( | const char * | digest, |
struct ast_http_digest * | d, | ||
int | request, | ||
int | pedantic | ||
) |
Parse digest authorization header.
Definition at line 2638 of file utils.c.
References ast_free, ast_log, ast_skip_blanks(), ast_str_buffer(), ast_str_create, ast_str_set(), ast_string_field_ptr_set, ast_string_field_set, ast_strlen_zero(), ast_unescape_c(), c, d, LOG_WARNING, NULL, request(), str, and strsep().
Referenced by auth_http_callback().
char * ast_process_quotes_and_slashes | ( | char * | start, |
char | find, | ||
char | replace_with | ||
) |
Process a string to find and replace characters.
start | The string to analyze |
find | The character to find |
replace_with | The character that will replace the one we are looking for |
Definition at line 2352 of file utils.c.
int ast_pthread_create_detached_stack | ( | pthread_t * | thread, |
pthread_attr_t * | attr, | ||
void *(*)(void *) | start_routine, | ||
void * | data, | ||
size_t | stacksize, | ||
const char * | file, | ||
const char * | caller, | ||
int | line, | ||
const char * | start_fn | ||
) |
Definition at line 1673 of file utils.c.
References ast_alloca, ast_log, ast_pthread_create_stack(), thr_arg::data, errno, make_ari_stubs::file, LOG_WARNING, thr_arg::start_routine, and thread.
int ast_pthread_create_stack | ( | pthread_t * | thread, |
pthread_attr_t * | attr, | ||
void *(*)(void *) | start_routine, | ||
void * | data, | ||
size_t | stacksize, | ||
const char * | file, | ||
const char * | caller, | ||
int | line, | ||
const char * | start_fn | ||
) |
Definition at line 1625 of file utils.c.
References a, ast_alloca, ast_asprintf, ast_log, ast_malloc, AST_STACKSIZE, thr_arg::data, dummy_start(), errno, make_ari_stubs::file, LOG_WARNING, test_val::name, NULL, pthread_create, thr_arg::start_routine, and thread.
Referenced by ast_pthread_create_detached_stack().
long int ast_random | ( | void | ) |
Definition at line 2312 of file utils.c.
References ast_mutex_lock, ast_mutex_unlock, dev_urandom_fd, and randomlock.
Referenced by acf_rand_exec(), action_challenge(), agi_handle_command(), app_exec(), ast_generate_random_string(), ast_lock_path_lockfile(), ast_moh_files_next(), ast_rtp_change_source(), ast_rtp_new(), AST_TEST_DEFINE(), ast_udptl_new_with_bindaddr(), astobj2_test_1_helper(), auth_http_callback(), authenticate_request(), build_iv(), build_rand_pad(), calc_metric(), calc_rxstamp(), caldav_write_event(), create_channel_name(), create_local_sdp(), dns_srv_sort(), generate_parked_user(), generate_random_string(), generic_http_callback(), get_trans_id(), get_unused_callno(), handle_cli_sched_bench(), iax2_key_rotate(), jingle_add_ice_udp_candidates_to_transport(), jingle_alloc(), jingle_new(), load_module(), make_email_file(), mbl_new(), moh_files_alloc(), multicast_rtp_new(), ogg_vorbis_rewrite(), page_exec(), process_weights(), registry_authrequest(), reschedule_reinvite(), rtp_allocate_transport(), say_periodic_announcement(), sendmail(), sip_outbound_registration_perform(), socket_read(), sorcery_memory_cache_thrash_retrieve(), sorcery_memory_cache_thrash_update(), stun_req_id(), test_ao2_find_w_no_flags(), test_ao2_find_w_OBJ_KEY(), test_ao2_find_w_OBJ_PARTIAL_KEY(), test_ao2_find_w_OBJ_POINTER(), test_files_get_one(), try_firmware(), websocket_client_create_key(), and websocket_mask_payload().
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
0 | on success, non-zero on failure. |
1 | if we only stripped a leading / |
2 | if we only stripped a trailing / |
3 | if we did not strip any / characters |
regex_string | the string containing /regex/ |
regex_pattern | the destination ast_str which will contain "regex" after execution |
Definition at line 2179 of file utils.c.
References ast_str_set(), and ast_str_truncate().
Referenced by ast_manager_hangup_helper(), mwi_mailbox_delete(), and mwi_mailbox_get().
int ast_remaining_ms | ( | struct timeval | start, |
int | max_ms | ||
) |
Calculate remaining milliseconds given a starting timestamp and upper bound.
If the upper bound is negative, then this indicates that there is no upper bound on the amount of time to wait. This will result in a negative return.
start | When timing started being calculated |
max_ms | The maximum number of milliseconds to wait from start. May be negative. |
Definition at line 2281 of file utils.c.
References ast_tvdiff_ms(), and ast_tvnow().
Referenced by __analog_ss_thread(), __ast_answer(), __ast_request_and_dial(), analog_ss_thread(), ast_iostream_write(), ast_recvtext(), ast_stun_request(), ast_waitfordigit_full(), disable_t38(), generic_fax_exec(), iostream_read(), parking_set_duration(), read_mf_digits(), read_sf_digits(), receivefax_t38_init(), record_exec(), safe_sleep_conditional(), scan_exec(), sendfax_t38_init(), SLEEP_SPINNER(), wait_exec(), wait_for_answer(), wait_for_signal_or_hangup(), waitforcond_exec(), and waitforring_exec().
void ast_replace_subargument_delimiter | ( | char * | s | ) |
Replace '^' in a string with ','.
s | String within which to replace characters |
Definition at line 2343 of file utils.c.
Referenced by app_exec(), ast_bridge_set_after_go_on(), dial_exec_full(), originate_exec(), page_exec(), and queue_exec().
int ast_safe_mkdir | ( | const char * | base_path, |
const char * | path, | ||
int | mode | ||
) |
Recursively create directory path, but only if it resolves within the given base_path.
If base_path does not exist, it will not be created and this function returns EPERM
.
base_path | |
path | The directory path to create |
mode | The permissions with which to try to create the directory |
0 | on success |
Definition at line 2584 of file utils.c.
References ast_free, ast_std_free(), ast_strdup, errno, NULL, RAII_VAR, and safe_mkdir().
Referenced by AST_TEST_DEFINE(), stasis_app_control_record(), and stasis_app_stored_recording_copy().
void ast_set_default_eid | ( | struct ast_eid * | eid | ) |
Fill in an ast_eid with the default eid of this machine.
Definition at line 3001 of file utils.c.
References ast_debug, ast_eid_to_str(), ast_free, ast_log, ast_malloc, buf, if(), LOG_WARNING, and NULL.
Referenced by load_asterisk_conf().
void ast_sha1_hash | ( | char * | output, |
const char * | input | ||
) |
Produce 40 char SHA1 hash of value.
Produces SHA1 hash based on input string.
Definition at line 266 of file utils.c.
References input(), SHA1Input(), SHA1Reset(), and SHA1Result().
Referenced by ast_tcptls_server_start(), AST_TEST_DEFINE(), ctx_populate(), handle_call_token(), media_cache_item_sync_to_astdb(), sha1(), xmpp_client_authenticate_digest(), and xmpp_component_authenticate().
void ast_sha1_hash_uint | ( | uint8_t * | digest, |
const char * | input | ||
) |
Produce a 20 byte SHA1 hash of value.
Produces SHA1 hash based on input string, stored in uint8_t array.
Definition at line 284 of file utils.c.
References input(), SHA1Input(), SHA1Reset(), and SHA1Result().
Referenced by websocket_combine_key().
int ast_str_to_eid | ( | struct ast_eid * | eid, |
const char * | s | ||
) |
Convert a string into an EID.
This function expects an EID in the format: 00:11:22:33:44:55
0 | success |
non-zero | failure |
Definition at line 3077 of file utils.c.
References ast_eid::eid.
Referenced by asterisk_publication_devicestate_state_change(), asterisk_publication_mwi_state_change(), build_peer(), dundi_do_query(), load_asterisk_conf(), set_config(), and xmpp_pubsub_handle_event().
char * ast_strip_quoted | ( | char * | s, |
const char * | beg_quotes, | ||
const char * | end_quotes | ||
) |
Strip leading/trailing whitespace and quotes from a string.
s | The string to be stripped (will be modified). |
beg_quotes | The list of possible beginning quote characters. |
end_quotes | The list of matching ending quote characters. |
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:
Definition at line 1818 of file utils.c.
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().
char * ast_strsep | ( | char ** | s, |
const char | sep, | ||
uint32_t | flags | ||
) |
Act like strsep but ignore separators inside quotes.
s | Pointer to address of the string to be processed. Will be modified and can't be constant. |
sep | A single character delimiter. |
flags | Controls 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. |
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:
Definition at line 1835 of file utils.c.
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().
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.
s | Pointer to address of the string to be processed. Will be modified and can't be constant. |
sep | A single character delimiter. |
quote | The quote character |
flags | Controls 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. |
Definition at line 1899 of file utils.c.
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().
int ast_thread_is_user_interface | ( | void | ) |
Indicates whether the current thread is a user interface.
True | (non-zero) if thread is a user interface. |
False | (zero) if thread is not a user interface. |
Definition at line 3248 of file utils.c.
References ast_log, ast_threadstorage_get(), LOG_ERROR, NULL, and thread_user_interface_tl.
Referenced by ast_autoservice_start(), and ast_autoservice_stop().
int ast_thread_user_interface_set | ( | int | is_user_interface | ) |
Set the current thread's user interface status.
is_user_interface | Non-zero to mark the thread as a user interface. |
True | (non-zero) if marking current thread failed. |
False | (zero) if successfuly marked current thread. |
Definition at line 3233 of file utils.c.
References ast_log, ast_threadstorage_get(), LOG_ERROR, NULL, and thread_user_interface_tl.
Referenced by handle_tcptls_connection().
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
s | the string to convert |
delim | delimiter to parse out |
Definition at line 2397 of file utils.c.
References ast_copy_string(), ast_strdup, buf, and NULL.
int 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".
-1 | if "true". |
0 | otherwise, like NULL pointer. |
Definition at line 2199 of file utils.c.
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().
struct timeval ast_tvadd | ( | struct timeval | a, |
struct timeval | b | ||
) |
struct timeval ast_tvsub | ( | struct timeval | a, |
struct timeval | b | ||
) |
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).
Definition at line 1983 of file utils.c.
Referenced by ast_parse_digest().
void ast_unescape_quoted | ( | char * | quote_str | ) |
Unescape quotes in a string.
quote_str | The string with quotes to be unescaped |
Definition at line 842 of file utils.c.
Referenced by ast_callerid_parse(), ast_strsep(), ast_strsep_quoted(), and AST_TEST_DEFINE().
char * ast_unescape_semicolon | ( | char * | s | ) |
Strip backslash for "escaped" semicolons, the string to be stripped (will be modified).
Definition at line 1964 of file utils.c.
void ast_uri_decode | ( | char * | s, |
struct ast_flags | spec | ||
) |
Decode URI, URN, URL (overwrite string)
s | string to be decoded |
spec | flags describing how the decoding should be performed |
Definition at line 762 of file utils.c.
References ast_test_flag, AST_URI_LEGACY_SPACE, and tmp().
Referenced by acf_curl_helper(), ast_ari_invoke(), ast_http_get_post_vars(), AST_TEST_DEFINE(), config_curl(), handle_uri(), realtime_curl(), realtime_multi_curl(), and uridecode().
char * ast_uri_encode | ( | const char * | string, |
char * | outbuf, | ||
int | buflen, | ||
struct ast_flags | spec | ||
) |
Turn text string to URI-encoded XX version.
This function encodes characters according to the rules presented in RFC 2396 and/or RFC 3261 section 19.1.2 and section 25.1.
Outbuf needs to have more memory allocated than the instring to have room for the expansion. Every byte that is converted is replaced by three ASCII characters.
string | string to be converted |
outbuf | resulting encoded string |
buflen | size of output buffer |
spec | flags describing how the encoding should be performed |
Definition at line 723 of file utils.c.
References ast_test_flag, AST_URI_ALPHANUM, AST_URI_LEGACY_SPACE, AST_URI_MARK, AST_URI_SIP_USER_UNRESERVED, out, and string.
Referenced by ast_ari_bridges_record(), ast_ari_channels_record(), AST_TEST_DEFINE(), config_curl(), destroy_curl(), launch_asyncagi(), realtime_curl(), realtime_multi_curl(), require_curl(), store_curl(), update2_curl(), update_curl(), and uriencode().
int ast_utils_init | ( | void | ) |
Definition at line 2617 of file utils.c.
References ARRAY_LEN, ast_cli_register_multiple, ast_register_cleanup(), base64_init(), dev_urandom_fd, and utils_shutdown().
Referenced by asterisk_daemon().
char * ast_utils_which | ( | const char * | binary, |
char * | fullpath, | ||
size_t | fullpath_size | ||
) |
Resolve a binary to a full pathname.
binary | Name of the executable to resolve |
fullpath | Buffer to hold the complete pathname |
fullpath_size | Size of fullpath |
NULL | binary was not found or the environment variable PATH is not set |
Definition at line 2774 of file utils.c.
References ast_strdupa, NULL, and strsep().
int ast_wait_for_input | ( | int | fd, |
int | ms | ||
) |
Definition at line 1698 of file utils.c.
References ast_poll.
Referenced by action_waitevent(), ast_ari_websocket_session_read(), ast_iostream_wait_for_input(), ast_iostream_write(), ast_tcptls_server_root(), dahdi_test_timer(), get_input(), iostream_read(), moh_class_destructor(), and unbound_resolver_thread().
int ast_wait_for_output | ( | int | fd, |
int | ms | ||
) |
Definition at line 1708 of file utils.c.
References ast_poll.
Referenced by ast_iostream_write(), iostream_read(), and socket_connect().
int ast_xml_escape | ( | const char * | string, |
char * | outbuf, | ||
size_t | buflen | ||
) |
Escape reserved characters for use in XML.
ast_xml_escape
If outbuf is too short, the output string will be truncated. Regardless, the output will always be null terminated.
string | String to be converted |
outbuf | Resulting encoded string |
buflen | Size of output buffer |
0 | for success |
-1 | if buflen is too short. |
Definition at line 864 of file utils.c.
References ast_assert, end, len(), NULL, and string.
Referenced by ast_http_create_response(), and test_xml().
|
static |
|
static |
Definition at line 1573 of file utils.c.
References a, ast_free, ast_get_tid(), AST_LIST_INSERT_TAIL, AST_MUTEX_KIND, ast_register_thread(), ast_strdup, ast_threadstorage_get(), ast_unregister_thread(), thr_arg::data, lock_info, test_val::name, NULL, pthread_mutex_init, pthread_mutex_lock, and pthread_mutex_unlock.
Referenced by ast_pthread_create_stack().
|
static |
Definition at line 2118 of file utils.c.
References ast_malloc, and NULL.
Referenced by ast_escape_alloc(), and ast_escape_c_alloc().
|
static |
utility used by inchar(), for base_encode()
Definition at line 590 of file utils.c.
References baseio::ateof, BASEMAXINLINE, baseio::iobuf, baseio::iocp, and baseio::iolen.
Referenced by analys_(), ast_eivr_getvariable(), ast_eivr_setvariable(), find_sequence(), inchar(), lpfilt_(), netconsole(), preemp_(), term_color(), term_strip(), voicin_(), and vparms_().
|
static |
utility used by base_encode()
Definition at line 615 of file utils.c.
References inbuf(), baseio::iobuf, baseio::iocp, and baseio::iolen.
Referenced by ast_base64_encode_file().
|
static |
utility used by base_encode()
Definition at line 629 of file utils.c.
References BASELINELEN, c, and baseio::linelength.
Referenced by ast_base64_encode_file().
|
static |
Definition at line 2514 of file utils.c.
References ast_assert, ast_begins_with(), ast_std_free(), c, errno, NULL, and RAII_VAR.
Referenced by ast_safe_mkdir().
|
static |
Definition at line 2238 of file utils.c.
References a, ast_log, LOG_WARNING, and ONE_MILLION.
Referenced by ast_tvadd(), and ast_tvsub().
|
static |
Definition at line 2608 of file utils.c.
References ARRAY_LEN, ast_cli_unregister_multiple(), and dev_urandom_fd.
Referenced by ast_utils_init().
|
static |
Definition at line 1718 of file utils.c.
References ast_debug, ast_log, ast_poll, ast_tvdiff_ms(), ast_tvnow(), errno, and LOG_ERROR.
Referenced by ast_carefulwrite().
const struct ast_flags ast_uri_http = {AST_URI_UNRESERVED} |
Definition at line 719 of file utils.c.
Referenced by acf_curl_helper(), ast_ari_bridges_record(), ast_ari_channels_record(), AST_TEST_DEFINE(), config_curl(), destroy_curl(), launch_asyncagi(), realtime_curl(), realtime_multi_curl(), require_curl(), store_curl(), update2_curl(), update_curl(), uridecode(), and uriencode().
const struct ast_flags ast_uri_http_legacy = {AST_URI_LEGACY_SPACE | AST_URI_UNRESERVED} |
Definition at line 720 of file utils.c.
Referenced by acf_curl_helper(), ast_ari_invoke(), ast_http_get_post_vars(), AST_TEST_DEFINE(), and handle_uri().
const struct ast_flags ast_uri_sip_user = {AST_URI_UNRESERVED | AST_URI_SIP_USER_UNRESERVED} |
Definition at line 721 of file utils.c.
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 82 of file utils.c.
Referenced by ast_base64decode(), and base64_init().
|
static |
Definition at line 83 of file utils.c.
Referenced by ast_base64url_decode(), and base64_init().
|
static |
Definition at line 80 of file utils.c.
Referenced by ast_base64encode_full(), ast_http_get_auth(), ast_websocket_uri_cb(), base64_init(), websocket_client_handshake_get_response(), and xmpp_client_authenticate_sasl().
|
static |
Definition at line 81 of file utils.c.
Referenced by ast_base64url_encode_full(), and base64_init().
|
static |
Definition at line 938 of file utils.c.
Referenced by ast_random(), ast_utils_init(), ast_uuid_init(), and utils_shutdown().
char escape_sequences[] |
Definition at line 2022 of file utils.c.
Referenced by ast_escape(), and ast_escape_c().
|
static |
Definition at line 2030 of file utils.c.
Referenced by ast_escape(), and ast_escape_c().
|
static |
Definition at line 85 of file utils.c.
Referenced by ast_inet_ntoa().
|
static |
Definition at line 2309 of file utils.c.
Referenced by ast_random().
|
static |
Definition at line 3231 of file utils.c.
Referenced by ast_thread_is_user_interface(), and ast_thread_user_interface_set().