strings.h File Reference

String manipulation functions. More...

#include <ctype.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
 The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field to indicate the type of storage. Three special constants indicate malloc, ast_alloca() or static variables, all other values indicate a struct ast_threadstorage pointer. More...

Defines

#define __AST_STR_LEN   len
#define __AST_STR_STR   str
#define __AST_STR_TS   ts
#define __AST_STR_USED   used
#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, ' ')
#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.
#define ast_to_camel_case(s)   ast_to_camel_case_delim(s, "_")
#define AST_YESNO(x)   ((x) ? "Yes" : "No")
 return Yes or No depending on the argument.
#define DS_ALLOCA   ((struct ast_threadstorage *)2)
#define DS_MALLOC   ((struct ast_threadstorage *)1)
#define DS_STATIC   ((struct ast_threadstorage *)3)
#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>")
#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.

Enumerations

enum  { AST_DYNSTR_BUILD_FAILED = -1, AST_DYNSTR_BUILD_RETRY = -2 }
 Error codes from __ast_str_helper() The undelying 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)
 Core functionality of ast_str_(set|append)_va.
char * __ast_str_helper2 (struct ast_str **buf, ssize_t max_len, const char *src, size_t maxsrc, int append, int escapecommas)
static int force_inline
attribute_pure 
ast_begins_with (const char *str, const char *prefix)
int ast_build_string (char **buffer, size_t *space, const char *fmt,...)
 Build a string in a buffer, designed to be called repeatedly.
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.
int ast_check_digits (const char *arg)
 Check if a string is only digits.
void ast_copy_string (char *dst, const char *src, size_t size)
 Size-limited null-terminating string copy.
static int force_inline
attribute_pure 
ast_ends_with (const char *str, const char *suffix)
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".
char * ast_generate_random_string (char *buf, size_t size)
 Create a pseudo-random string of a fixed length.
int ast_get_time_t (const char *src, time_t *dst, time_t _default, int *consumed)
 get values from config variables.
int ast_get_timeval (const char *src, struct timeval *tv, struct timeval _default, int *consumed)
 get values from config variables.
void ast_join_delim (char *s, size_t len, const char *const w[], unsigned int size, char delim)
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".
char * ast_skip_blanks (const char *str)
 Gets a pointer to the first non-whitespace character in a string.
char * ast_skip_nonblanks (const char *str)
 Gets a pointer to first whitespace character in a string.
int ast_str_append (struct ast_str **buf, ssize_t max_len, const char *fmt,...)
 Append to a thread local dynamic string.
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.
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.
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.
char * ast_str_buffer (const struct ast_str *buf)
 Returns the string buffer within the ast_str buf.
static force_inline int
attribute_pure 
ast_str_case_hash (const char *str)
 Compute a hash value on a case-insensitive string.
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.
struct ao2_containerast_str_container_alloc_options (enum ao2_alloc_opts opts, int buckets)
 Allocates a hash container for bare strings.
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.
int ast_str_copy_string (struct ast_str **dst, struct ast_str *src)
struct ast_strast_str_create (size_t init_len)
 Create a malloc'ed dynamic length string.
static force_inline int
attribute_pure 
ast_str_hash (const char *str)
 Compute a hash value on a string.
static force_inline int ast_str_hash_add (const char *str, int hash)
 Compute a hash value on a string.
int ast_str_make_space (struct ast_str **buf, size_t new_len)
void ast_str_reset (struct ast_str *buf)
 Reset the content of a dynamic string. Useful before a series of ast_str_append.
int ast_str_set (struct ast_str **buf, ssize_t max_len, const char *fmt,...)
 Set a dynamic string using variable arguments.
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.
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.
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.
size_t ast_str_size (const struct ast_str *buf)
 Returns the current maximum length (without reallocation) of the current buffer.
size_t ast_str_strlen (const struct ast_str *buf)
 Returns the current length of the string stored within buf.
struct ast_strast_str_thread_get (struct ast_threadstorage *ts, size_t init_len)
 Retrieve a thread locally stored dynamic string.
static force_inline char
*attribute_pure 
ast_str_to_lower (char *str)
 Convert a string to all lower-case.
static force_inline char
*attribute_pure 
ast_str_to_upper (char *str)
 Convert a string to all upper-case.
void ast_str_trim_blanks (struct ast_str *buf)
 Trims trailing whitespace characters from an ast_str string.
char * ast_str_truncate (struct ast_str *buf, ssize_t len)
 Truncates the enclosed string to the given length.
void ast_str_update (struct ast_str *buf)
 Update the length of the buffer, after using ast_str merely as a buffer.
char * ast_strip (char *s)
 Strip leading/trailing whitespace from a string.
char * ast_strip_quoted (char *s, const char *beg_quotes, const char *end_quotes)
 Strip leading/trailing whitespace and quotes from a string.
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.
char * ast_tech_to_upper (char *dev_str)
 Convert the tech portion of a device string to upper case.
char * ast_to_camel_case_delim (const char *s, const char *delim)
char * ast_trim_blanks (char *str)
 Trims trailing whitespace characters from a string.
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".
char * ast_unescape_c (char *s)
 Convert some C escape sequences.
char * ast_unescape_semicolon (char *s)
 Strip backslash for "escaped" semicolons, the string to be stripped (will be modified).


Detailed Description

String manipulation functions.

Definition in file strings.h.


Define Documentation

#define __AST_STR_LEN   len

Definition at line 41 of file strings.h.

#define __AST_STR_STR   str

Definition at line 42 of file strings.h.

#define __AST_STR_TS   ts

Definition at line 43 of file strings.h.

#define __AST_STR_USED   used

Definition at line 40 of file strings.h.

#define _DB1 (  ) 

Definition at line 706 of file strings.h.

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

Definition at line 48 of file strings.h.

Referenced by aoc_to_ami(), mwi_update_cb(), mysql_log(), and rtcp_report_to_ami().

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

#define ast_str_alloca ( init_len   ) 

Definition at line 780 of file strings.h.

Referenced by __ast_manager_event_multichan(), __queues_show(), _iax2_show_peers_one(), _sip_show_peer(), _skinny_show_device(), _skinny_show_line(), action_agents(), action_createconfig(), action_listcommands(), action_login(), add_cc_call_info_to_response(), add_rpid(), add_sdp(), agent_handle_show_specific(), agent_show_requested(), alsa_request(), aocmessage_get_unit_entry(), app_exec(), ast_eivr_getvariable(), ast_json_ipaddr(), ast_request(), ast_sip_append_body(), ast_str_encode_mime(), ast_streamfile(), AST_TEST_DEFINE(), ast_var_channels_table(), ast_write(), build_nonce(), build_peer(), cc_extension_monitor_init(), cc_generic_agent_start_monitoring(), challenge(), chan_pjsip_write(), chanavail_exec(), check_nonce(), cli_alias_passthrough(), cli_match_char_tree(), codec_handler_fn(), console_request(), construct_pidf_body(), do_magic_pickup(), func_channel_read(), function_iaxpeer(), function_realtime_read(), function_realtime_readdestroy(), function_sippeer(), generate_fmtp_attr(), generate_status(), generate_uri(), handle_call_token(), handle_capabilities_res_message(), handle_cli_core_show_channeltype(), handle_cli_iax2_show_peer(), handle_cli_indication_show(), handle_cli_ooh323_show_config(), handle_cli_ooh323_show_peers(), handle_cli_ooh323_show_users(), handle_show_translation_path(), handle_showchan(), handle_showmanager(), handle_showmancmd(), hashkeys_read(), hashkeys_read2(), iax2_request(), initreqprep(), jingle_write(), log_jack_status(), manager_json_array_with_key(), manager_json_obj_with_key(), mbl_request(), mgcp_request(), mgcp_write(), native_rtp_bridge_compatible(), nbs_request(), onNewCallCreated(), ooh323_request(), ooh323_set_write_format(), ooh323_write(), oss_request(), peers_data_provider_get(), phone_request(), print_uptimestr(), process_sdp(), sendtext_exec(), serialize_showchan(), set_caps(), set_format(), show_channels_cb(), sip_new(), sip_request_call(), sip_send_mwi_to_peer(), sip_show_channel(), sip_show_sched(), sip_show_settings(), sip_write(), skinny_new(), skinny_request(), skinny_write(), socket_process_helper(), start_rtp(), stasis_app_device_states_to_json(), test_2way_function(), transmit_info_with_aoc(), transmit_notify_with_mwi(), transmit_state_notify(), unistim_new(), unistim_request(), unistim_rtp_read(), unistim_show_info(), unistim_write(), and wait_for_answer().

#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:
buckets The number of buckets to use for the hash container
Return values:
AO2 container for strings
NULL if allocation failed

Definition at line 1224 of file strings.h.

Referenced by ast_bridge_snapshot_create(), ast_cel_general_config_alloc(), ast_media_get_media(), ast_media_get_variants(), get_languages(), session_create(), stasis_app_get_all(), stasis_config_alloc(), and test_cel_peer_strings_match().

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

Definition at line 446 of file strings.h.

Referenced by ast_sip_sorcery_object_to_ami(), and sip_aor_to_ami().

#define AST_YESNO (  )     ((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:
x Boolean value
Returns:
"Yes" if x is true (non-zero)

"No" if x is false (zero)

Definition at line 138 of file strings.h.

Referenced by dtlsverify_to_str(), manager_bridge_tech_list(), require_client_cert_to_str(), statsd_init(), verify_client_to_str(), and verify_server_to_str().

#define DS_ALLOCA   ((struct ast_threadstorage *)2)

Definition at line 526 of file strings.h.

#define DS_MALLOC   ((struct ast_threadstorage *)1)

Definition at line 525 of file strings.h.

#define DS_STATIC   ((struct ast_threadstorage *)3)

Definition at line 527 of file strings.h.

#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>")

Examples:
/tmp/asterisk-trunk/trunk/main/app.c.

Definition at line 84 of file strings.h.

Referenced by __analog_handle_event(), __ast_goto_if_exists(), __ast_pbx_run(), _macro_exec(), _skinny_show_line(), acf_isexten_exec(), action_confbridgelist_item(), action_meetmelist(), add_rpid(), analog_call(), analog_ss_thread(), ast_app_dtget(), ast_bridge_setup_after_goto(), ast_channel_snapshot_create(), ast_pbx_h_exten_run(), background_detect_exec(), caller_id_to_str(), chan_pjsip_cng_tone_detected(), chan_pjsip_new(), cli_endpoint_print_body(), collect_digits(), confbridge_publish_manager_event(), console_call(), copy_message(), dahdi_handle_dtmf(), dahdi_handle_event(), dial_exec_full(), disa_exec(), do_forward(), fax_detect_framehook(), find_matching_endwhile(), findmeexec(), forward_message(), generate_status(), get_admin_header(), gosub_exec(), gosub_run(), handle_cli_confbridge_list_item(), handle_cli_misdn_show_channels(), handle_gosub(), handle_setpriority(), handle_showchan(), indicate_connected_line(), isAnsweringMachine(), isexten_function_read(), launch_monitor_thread(), leave_voicemail(), local_call(), manager_queues_status(), meetme_show_cmd(), mgcp_call(), mgcp_hangup(), mgcp_ss(), minivm_greet_exec(), minivm_notify_exec(), misdn_copy_redirecting_from_ast(), misdn_get_connected_line(), misdn_write(), my_handle_dtmf(), onModeChanged(), ooh323_rtp_read(), ospauth_exec(), osplookup_exec(), oss_call(), party_id_read(), pbx_builtin_background(), pbx_builtin_waitexten(), pbx_parseable_goto(), process_ast_dsp(), process_sdp(), push_callinfo(), queue_exec(), readexten_exec(), release_chan(), send_callinfo(), serialize_showchan(), setsubstate(), setup_env(), sip_read(), sip_subscription_to_ami(), sms_exec(), socket_process_helper(), start_automixmonitor(), start_automonitor(), state_notify_build_xml(), try_calling(), unistim_indicate(), update_connectedline(), valid_exit(), vm_authenticate(), waitstream_core(), and write_metadata().

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

Examples:
/tmp/asterisk-trunk/trunk/main/app.c.

Definition at line 78 of file strings.h.

Referenced by __ast_channel_alloc_ap(), __ast_cli_register(), __ast_codec_register(), __ast_format_cache_get_debug(), __ast_format_cap_alloc_debug(), __ast_format_cap_append_debug(), __ssl_setup(), _sip_show_peer(), _skinny_show_device(), _skinny_show_line(), acf_curl_helper(), acf_if(), acf_transaction_write(), acf_vm_info(), action_getvar(), action_messagesend(), action_reload(), action_setvar(), action_status(), add_transferer_role(), alloc_security_event_json_object(), analog_ss_thread(), app_handler(), append_event_str_single(), append_row_to_cfg(), ari_bridges_play_helper(), ari_channels_handle_originate_with_id(), ari_channels_handle_play(), array(), ast_ari_asterisk_get_global_var(), ast_ari_channels_continue_in_dialplan(), ast_ari_channels_get_channel_var(), ast_bridge_channel_run_app(), ast_bridge_timelimit(), ast_call_forward(), ast_cc_call_init(), ast_cdr_serialize_variables(), ast_cel_create_event(), ast_cel_fill_record(), ast_cel_get_type_name(), ast_channel_connected_line_macro(), ast_channel_connected_line_sub(), ast_channel_publish_dial_internal(), ast_channel_redirecting_macro(), ast_channel_redirecting_sub(), ast_channel_snapshot_create(), ast_cli_command_full(), ast_format_create_named(), ast_get_chan_applicationmap(), ast_manager_build_channel_state_string_prefix(), ast_msg_send(), ast_play_and_record_full(), ast_queue_log(), ast_sip_session_create_outgoing(), ast_sockaddr_parse(), ast_sockaddr_resolve(), ast_system_publish_registry(), authenticate(), bridge_parking_push(), build_callid_pvt(), build_callid_registry(), build_peer(), build_profile(), build_route(), calltoken_required(), cc_generic_agent_init(), cc_interfaces_datastore_init(), cdr_handler(), celgenuserevent_exec(), chan_pjsip_cng_tone_detected(), chan_pjsip_new(), channel_dial_cb(), channel_do_masquerade(), channel_enter_cb(), channel_read_rtcp(), channel_read_rtp(), check_auth(), cli_fax_show_sessions(), cli_odbc_write(), common_exec(), conf_get_sound(), config_curl(), config_handler(), config_parse_variables(), create_dynamic_lot_full(), create_queue_member(), dahdi_handle_dtmf(), dahdi_show_channel(), dial_exec_full(), dialplan_has_destination_cb(), do_forward(), dundi_exec(), enable_jack_hook(), endpoint_internal_create(), execif_exec(), extensionstate_update(), fast_originate(), fax_detect_framehook(), feature_automixmonitor(), feature_automonitor(), feature_blind_transfer(), file_write(), find_conf(), forward_message(), generate_status(), generic_recall(), get_also_info(), get_cid_name(), get_defaults(), get_destination(), get_rdnis(), get_refer_info(), get_single_field_as_var_list(), gosub_run(), goto_exten(), handle_bridge_show_all(), handle_bridge_show_specific(), handle_call_forward(), handle_call_token(), handle_chanlist(), handle_cli_agi_show(), handle_cli_cdr_mysql_status(), handle_cli_check_permissions(), handle_cli_config_list(), handle_cli_iax2_show_channels(), handle_cli_moh_show_classes(), handle_debug(), handle_gosub(), handle_manager_show_settings(), handle_request_invite(), handle_request_refer(), handle_request_subscribe(), handle_response_register(), handle_show_function(), handle_show_functions(), handle_show_settings(), handle_showchan(), handle_showmancmd(), handle_skinny_show_settings(), handle_streamfile(), handle_verbose(), hashtab_compare_exten_labels(), hashtab_hash_labels(), help1(), help_workhorse(), hints_data_provider_get(), hold_to_json(), hook_on(), iftime(), init_logger_chain(), init_pvt(), jingle_new(), leave_voicemail(), load_module(), local_alloc(), local_read(), make_email_file(), manager_dbput(), manager_fax_sessions_entry(), manager_mixmonitor(), manager_park(), manager_queue_log_custom(), manager_queue_reload(), manager_set_defaults(), manager_show_registry(), mbl_devicestate(), misdn_cfg_get(), misdn_copy_redirecting_from_ast(), misdn_get_connected_line(), mixmonitor_exec(), msg_create_from_file(), msg_q_cb(), msg_route(), msg_send_exec(), msg_to_endpoint(), mstime(), my_distinctive_ring(), my_handle_dtmf(), my_load_module(), npval(), on_dns_update_registry(), onModeChanged(), ooh323_rtp_read(), originate_exec(), oss_call(), park_app_exec(), pbx_builtin_execiftime(), pbx_builtin_waitexten(), pbx_exec(), pbx_extension_helper(), pbx_load_config(), pbx_outgoing_exec(), pgsql_reconnect(), phase_e_handler(), pjsip_acf_dial_contacts_read(), play_mailbox_owner(), play_moh_exec(), prep_email_sub_vars(), presence_state_alloc(), print_app_docs(), print_featuregroup(), process_ast_dsp(), process_sdp(), process_text_line(), publish_hangup_handler_message(), publish_reload_message(), publish_request_initial(), queue_exec(), realtime_common(), realtime_curl(), realtime_destroy_handler(), realtime_directory(), realtime_exec(), realtime_handler(), realtime_multi_curl(), realtime_multi_handler(), realtime_store_handler(), realtime_update2_handler(), realtime_update_handler(), refer_blind_callback(), register_exten(), register_peer_exten(), reload_config(), report_receive_fax_status(), report_send_fax_status(), return_exec(), ring_entry(), row_to_varlist(), rt_handle_member_record(), run_externnotify(), rx_data_to_ast_msg(), select_entry(), send_provisional_keepalive_full(), sendpage(), serialize_showchan(), set_channel_variables(), set_member_paused(), set_transfer_variables_all(), setup_env(), setup_park_common_datastore(), shared_write(), show_channels_cb(), sip_aor_to_ami(), sip_dialog_create_contact(), sip_msg_send(), sip_outbound_publish_client_alloc(), sip_outbound_registration_regc_alloc(), sip_parse_register_line(), sip_read(), sip_show_domains(), sip_show_settings(), sip_uri_cmp(), sla_show_stations(), sla_show_trunks(), sms_exec(), sms_log(), socket_process_helper(), start_automixmonitor(), start_automonitor(), start_moh_exec(), start_monitor_exec(), stasis_app_bridge_create(), stasis_app_control_continue(), state_notify_build_xml(), static_callback(), stop_mixmonitor_full(), testtime_write(), transmit_notify_with_mwi(), transmit_register(), transport_tls_cipher_handler(), unbound_resolver_callback(), unregister_exten(), users_apply_handler(), verify_mock_cdr_record(), wait_for_answer(), xmpp_client_reconnect(), xmpp_client_set_group_presence(), xmpp_pak_message(), and xmpp_pak_presence().


Enumeration Type Documentation

anonymous enum

Error codes from __ast_str_helper() The undelying 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 872 of file strings.h.

00872      {
00873    /*! An error has occurred and the contents of the dynamic string
00874     *  are undefined */
00875    AST_DYNSTR_BUILD_FAILED = -1,
00876    /*! The buffer size for the dynamic string had to be increased, and
00877     *  __ast_str_helper() needs to be called again after
00878     *  a va_end() and va_start().  This return value is legacy and will
00879     *  no longer be used.
00880     */
00881    AST_DYNSTR_BUILD_RETRY = -2
00882 };

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 241 of file strings.h.

00241                       {
00242    AST_STRSEP_STRIP =    0x01, /*!< Trim, then strip quotes.  You may want to trim again */
00243    AST_STRSEP_TRIM =     0x02, /*!< Trim leading and trailing whitespace */
00244    AST_STRSEP_UNESCAPE = 0x04, /*!< Unescape '\' */
00245    AST_STRSEP_ALL =      0x07, /*!< Trim, strip, unescape */
00246 };


Function Documentation

int __ast_str_helper ( struct ast_str **  buf,
ssize_t  max_len,
int  append,
const char *  fmt,
va_list  ap 
)

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 ''. 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 59 of file strings.c.

References AST_DYNSTR_BUILD_FAILED, ast_log_safe(), ast_str_make_space(), len(), and LOG_VERBOSE.

Referenced by ast_str_set_va().

00062 {
00063    int res, need;
00064    int offset = (append && (*buf)->__AST_STR_LEN) ? (*buf)->__AST_STR_USED : 0;
00065    va_list aq;
00066 
00067    do {
00068       if (max_len < 0) {
00069          max_len = (*buf)->__AST_STR_LEN; /* don't exceed the allocated space */
00070       }
00071       /*
00072        * Ask vsnprintf how much space we need. Remember that vsnprintf
00073        * does not count the final <code>'\\0'</code> so we must add 1.
00074        */
00075       va_copy(aq, ap);
00076       res = vsnprintf((*buf)->__AST_STR_STR + offset, (*buf)->__AST_STR_LEN - offset, fmt, aq);
00077 
00078       need = res + offset + 1;
00079       /*
00080        * If there is not enough space and we are below the max length,
00081        * reallocate the buffer and return a message telling to retry.
00082        */
00083       if (need > (*buf)->__AST_STR_LEN && (max_len == 0 || (*buf)->__AST_STR_LEN < max_len) ) {
00084          int len = (int)(*buf)->__AST_STR_LEN;
00085          if (max_len && max_len < need) { /* truncate as needed */
00086             need = max_len;
00087          } else if (max_len == 0) { /* if unbounded, give more room for next time */
00088             need += 16 + need / 4;
00089          }
00090          if (
00091 #if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
00092                _ast_str_make_space(buf, need, file, lineno, function)
00093 #else
00094                ast_str_make_space(buf, need)
00095 #endif
00096             ) {
00097             ast_log_safe(LOG_VERBOSE, "failed to extend from %d to %d\n", len, need);
00098             va_end(aq);
00099             return AST_DYNSTR_BUILD_FAILED;
00100          }
00101          (*buf)->__AST_STR_STR[offset] = '\0';  /* Truncate the partial write. */
00102 
00103          /* Restart va_copy before calling vsnprintf() again. */
00104          va_end(aq);
00105          continue;
00106       }
00107       va_end(aq);
00108       break;
00109    } while (1);
00110    /* update space used, keep in mind the truncation */
00111    (*buf)->__AST_STR_USED = (res + offset > (*buf)->__AST_STR_LEN) ? (*buf)->__AST_STR_LEN - 1: res + offset;
00112 
00113    return res;
00114 }

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 116 of file strings.c.

References ast_str::__AST_STR_LEN, and ast_str_make_space().

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

00117 {
00118    int dynamic = 0;
00119    char *ptr = append ? &((*buf)->__AST_STR_STR[(*buf)->__AST_STR_USED]) : (*buf)->__AST_STR_STR;
00120 
00121    if (maxlen < 1) {
00122       if (maxlen == 0) {
00123          dynamic = 1;
00124       }
00125       maxlen = (*buf)->__AST_STR_LEN;
00126    }
00127 
00128    while (*src && maxsrc && maxlen && (!escapecommas || (maxlen - 1))) {
00129       if (escapecommas && (*src == '\\' || *src == ',')) {
00130          *ptr++ = '\\';
00131          maxlen--;
00132          (*buf)->__AST_STR_USED++;
00133       }
00134       *ptr++ = *src++;
00135       maxsrc--;
00136       maxlen--;
00137       (*buf)->__AST_STR_USED++;
00138 
00139       if ((ptr >= (*buf)->__AST_STR_STR + (*buf)->__AST_STR_LEN - 3) ||
00140          (dynamic && (!maxlen || (escapecommas && !(maxlen - 1))))) {
00141          char *oldbase = (*buf)->__AST_STR_STR;
00142          size_t old = (*buf)->__AST_STR_LEN;
00143          if (ast_str_make_space(buf, (*buf)->__AST_STR_LEN * 2)) {
00144             /* If the buffer can't be extended, end it. */
00145             break;
00146          }
00147          /* What we extended the buffer by */
00148          maxlen = old;
00149 
00150          ptr += (*buf)->__AST_STR_STR - oldbase;
00151       }
00152    }
00153    if (__builtin_expect(!maxlen, 0)) {
00154       ptr--;
00155    }
00156    *ptr = '\0';
00157    return (*buf)->__AST_STR_STR;
00158 }

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

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:
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
Return values:
0 on success
non-zero on failure.

Definition at line 1640 of file main/utils.c.

References ast_build_string_va(), and result.

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

01641 {
01642    va_list ap;
01643    int result;
01644 
01645    va_start(ap, fmt);
01646    result = ast_build_string_va(buffer, space, fmt, ap);
01647    va_end(ap);
01648 
01649    return result;
01650 }

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.

Returns:
0 on success, non-zero on failure.
Parameters:
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 1621 of file main/utils.c.

References result.

Referenced by ast_build_string().

01622 {
01623    int result;
01624 
01625    if (!buffer || !*buffer || !space || !*space)
01626       return -1;
01627 
01628    result = vsnprintf(*buffer, *space, fmt, ap);
01629 
01630    if (result < 0)
01631       return -1;
01632    else if (result > *space)
01633       result = *space;
01634 
01635    *buffer += result;
01636    *space -= result;
01637    return 0;
01638 }

int ast_check_digits ( const char *  arg  )  [inline]

Check if a string is only digits.

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

Definition at line 1092 of file strings.h.

Referenced by create_addr().

01101 {

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

Size-limited null-terminating string copy.

Parameters:
dst The destination buffer.
src The source string
size The size of the destination buffer
Returns:
Nothing.
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.
Examples:
/tmp/asterisk-trunk/trunk/main/app.c.

Definition at line 338 of file strings.h.

Referenced by __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(), __set_address_from_contact(), __sip_alloc(), _ast_odbc_request_obj2(), _get_mohbyname(), _iax2_show_peers_one(), _macro_exec(), _sip_show_peers_one(), _skinny_message_set(), _transmit_displayprinotify(), _transmit_displayprinotifyvar(), acf_channel_read(), acf_curl_helper(), 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_mailbox_exists(), 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_cc_call_info_to_response(), add_diversion(), add_exten_to_pattern_tree(), add_line(), add_menu_entry(), add_realm_authentication(), add_sdp(), add_sip_domain(), add_vm_recipients_from_string(), adsi_load(), adsi_message(), adsi_process(), aes_helper(), agent_function_read(), alarmreceiver_exec(), alloc_profile(), 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_add_extension2_lockopt(), 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_bucket_file_temporary_create(), ast_call_forward(), ast_callerid_merge(), ast_callerid_parse(), ast_callerid_split(), ast_category_new(), ast_category_rename(), ast_cc_extension_monitor_add_dialstring(), ast_cc_get_param(), ast_cdr_format_var(), ast_cdr_register(), 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_channel_macrocontext_set(), ast_channel_macroexten_set(), ast_cli_completion_matches(), ast_context_find(), ast_context_find_or_create(), ast_context_remove_extension_callerid2(), ast_devstate_prov_add(), ast_eivr_getvariable(), ast_expr(), ast_frame_subclass2str(), ast_frame_type2str(), ast_func_read(), ast_get_enum(), ast_get_feature(), ast_get_hint(), ast_get_indication_zone(), ast_get_srv(), ast_get_txt(), ast_http_prefix(), ast_jb_conf_default(), ast_linear_stream(), ast_makesocket(), ast_moh_files_next(), ast_monitor_change_fname(), ast_monitor_start(), ast_monitor_stop(), ast_multi_channel_blob_add_channel(), ast_presence_state_prov_add(), ast_privacy_check(), ast_privacy_set(), ast_read_image(), ast_readconfig(), 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_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_vi(), ast_say_number_full_cs(), ast_say_number_full_da(), ast_say_number_full_de(), ast_say_number_full_en(), 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_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_macro(), ast_set_cc_callback_sub(), ast_setstate(), ast_sip_cli_traverse_objects(), ast_sip_create_rdata(), 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_assign(), ast_var_channels_table(), ast_var_indications(), ast_var_indications_table(), ast_websocket_read_string(), auth_http_callback(), authenticate(), authenticate_verify(), begin_dial_channel(), begin_dial_prerun(), blr_ebl(), bridge_agent_hold_push(), bridge_channel_internal_queue_attended_transfer(), bridge_channel_internal_queue_blind_transfer(), bridge_parking_push(), bridge_profile_alloc(), bucket_file_wizard_retrieve(), bucket_wizard_retrieve(), build_conf(), build_context(), build_device(), build_gateway(), build_mapping(), build_peer(), build_reply_digest(), build_user(), cache_lookup(), cache_lookup_internal(), calendar_event_read(), calendar_join_attendees(), calendar_query_result_exec(), callerid_feed(), callerid_feed_jp(), callerid_read(), callerpres_read(), cb_events(), cc_build_payload(), cc_generic_agent_init(), cdata(), cdr_object_create_public_records(), cdr_object_format_property(), cdr_object_format_var_internal(), cdr_read_callback(), chan_pjsip_add_hold(), chan_pjsip_incoming_response(), change_password_realtime(), channel_do_masquerade(), channel_read_pjsip(), channel_read_rtp(), chararray_handler_fn(), check_auth(), check_match(), check_password(), check_peer_ok(), check_sip_domain(), check_via(), cleanup_stale_contexts(), cli_tps_report(), common_exec(), compile_script(), complete_dpreply(), complete_fn(), complete_indications(), conf_exec(), conf_run(), config_device(), config_function_read(), config_line(), config_parse_variables(), config_pgsql(), config_text_file_load(), configure_local_rtp(), connectedline_read(), console_dial(), construct_pidf_body(), copy_error(), copy_menu_entry(), copy_message(), copy_via_headers(), create_addr(), create_addr_from_peer(), create_epa_entry(), create_followme_number(), create_outgoing_sdp_stream(), create_queue_member(), create_vmaccount(), crement_function_read(), csv_quote(), 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(), devstate_read(), dial_exec_full(), dialandactivatesub(), dialgroup_read(), dialgroup_write(), dialout(), dictate_exec(), disa_exec(), dispatch_thread_handler(), do_forward(), dtls_handler(), 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_lookup_internal(), dundi_lookup_local(), dundi_precache_internal(), dundi_prop_precache(), dundi_query_eid_internal(), dundi_query_thread(), ebl_callback(), 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(), extract_uri(), exts_compare(), extstate_read(), featuremap_get(), filename_parse(), find_account(), find_agent_callbacks(), find_cache(), find_conf(), find_conf_realtime(), find_context(), find_context_locked(), find_engine(), find_line_by_name(), find_or_create(), find_queue_by_name_rt(), find_realtime_gw(), find_subchannel_and_lock(), find_subchannel_by_name(), find_user_realtime(), findmeexec(), forward_message(), func_channel_read(), func_check_sipdomain(), func_header_read(), func_mixmonitor_read(), function_enum(), function_iaxpeer(), function_ooh323_read(), function_realtime_read(), function_realtime_readdestroy(), function_sippeer(), gen_header(), general_get(), generate_uri(), get_also_info(), get_date(), get_destination(), get_domain(), get_esc_entry(), get_name_and_number(), get_pai(), get_rdnis(), get_rpid(), getdisplaybyname(), getflagbyname(), getkeybyname(), getstatebyname(), getsubbyname(), gettag(), global_read(), 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_misdn_send_display(), handle_cli_misdn_send_facility(), handle_cli_presencestate_list(), handle_cli_ulimit(), handle_command_response(), handle_common_options(), handle_dial_page(), handle_incoming(), handle_request_invite(), handle_response(), handle_response_publish(), handle_select_codec(), handle_select_language(), handle_setcallerid(), 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(), ices_exec(), ifmodule_read(), iftime(), import_ch(), inboxcount2(), init_acf_query(), init_logger_chain(), init_profile(), init_state(), initreqprep(), 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(), listfilter(), load_config(), load_module(), load_moh_classes(), load_mysql_config(), load_odbc_config(), load_password(), load_pktccops_config(), load_realtime_rules(), load_values_config(), local_alloc(), local_read(), lock_read(), log_events(), lookup_iface(), main(), make_email_file(), make_fn(), make_logchannel(), manager_modulecheck(), 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(), mgcp_call(), mgcp_request(), mgcp_ss(), minivm_accmess_exec(), minivm_account_func_read(), minivm_delete_exec(), minivm_greet_exec(), minivm_mwi_exec(), minivm_notify_exec(), misdn_answer(), misdn_call(), misdn_cfg_get(), misdn_cfg_get_desc(), misdn_cfg_get_name(), misdn_check_l2l1(), misdn_copy_redirecting_from_ast(), misdn_digit_end(), misdn_facility_ie_handler(), misdn_get_connected_line(), misdn_hangup(), misdn_is_msn_valid(), misdn_request(), misdn_send_text(), misdn_set_opt_exec(), mkif(), mkintf(), moh_files_alloc(), moh_parse_options(), moh_scan_files(), msg_data_func_read(), msg_func_read(), my_distinctive_ring(), my_get_callerid(), mysql_log(), named_acl_alloc(), named_acl_find(), nbs_alloc(), 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(), osp_check_destination(), osp_convert_inout(), osp_convert_outin(), osp_create_provider(), osp_create_transaction(), osp_lookup(), osp_report_qos(), ospfinished_exec(), osplookup_exec(), page_exec(), parking_park_call(), parse_bookmark(), parse_config(), parse_moved_contact(), parse_naptr(), parse_ok_contact(), parse_options(), parse_register_contact(), parse_sip_options(), parse_tag(), parse_tone_zone(), party_id_read(), party_name_read(), party_number_read(), party_subaddress_read(), pbx_builtin_saynumber(), pbx_extension_helper(), pbx_load_config(), pbx_load_users(), pbx_outgoing_attempt(), pbx_retrieve_variable(), pbx_substitute_variables_helper_full(), peek_read(), peer_status(), pgsql_reconnect(), phone_call(), pickup_get(), pjsip_acf_dial_contacts_read(), pktccops_show_cmtses(), pktccops_show_gates(), play_message_by_id(), play_record_review(), populate_defaults(), presence_read(), presence_state_cb(), private_enum_init(), process_dahdi(), process_precache(), process_request(), profile_set_param(), proxy_from_config(), queue_function_queuegetchannel(), queue_set_param(), quote(), rcv_mac_addr(), read_config(), read_config_maps(), read_header(), read_password_from_file(), realtime_common(), realtime_peer(), realtime_peer_by_addr(), realtime_switch_common(), realtime_update_peer(), realtimefield_read(), receive_ademco_event(), receive_message(), record_exec(), redirecting_read(), register_exten(), register_peer_exten(), register_verify(), registry_rerequest(), reload_config(), reload_followme(), reload_queue_rules(), reload_single_member(), remove_from_queue(), reply_digest(), reqprep(), reset_user_pw(), respprep(), ring_entry(), rt_extend_conf(), rt_handle_member_record(), run_externnotify(), sendmail(), sendpage(), sendtext_data_create(), set(), set_callforwards(), set_config(), set_destination(), set_fn(), set_insecure_flags(), set_message_vars_from_req(), set_next_mime_type(), setsubstate(), setup_bridge_role(), setup_mixmonitor(), setup_privacy_args(), shared_read(), show_entry_history(), show_phone_number(), sip_acf_channel_read(), sip_call(), sip_cc_agent_init(), sip_cli_notify(), sip_find_peer_full(), sip_get_cc_information(), sip_parse_register_line(), sip_poke_peer(), sip_prepare_socket(), sip_prune_realtime(), sip_queryoption(), sip_report_chal_sent(), sip_report_failed_challenge_response(), sip_request_call(), sip_route_add(), sip_show_inuse(), sip_sipredirect(), sip_subscribe_mwi(), skinny_call(), skinny_device_alloc(), skinny_register(), skinny_request(), 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(), stasis_app_control_dial(), stasis_app_control_snoop(), stat_read(), store_config(), store_odbc(), store_tone_zone_ring_cadence(), subscription_established(), subscription_get_generator_from_rdata(), subscription_persistence_update(), substring(), temp_peer(), term_color(), term_prompt(), timeout_read(), timezone_add(), transmit_callinfo(), transmit_callinfo_variable(), transmit_cfwdstate(), transmit_connect(), transmit_connect_with_sdp(), transmit_dialednumber(), transmit_displaynotify(), transmit_displaypromptstatus(), transmit_displaypromptstatusvar(), transmit_modify_request(), transmit_modify_with_sdp(), transmit_notify_request(), transmit_notify_request_with_callerid(), transmit_refer(), transmit_speeddialstatres(), transmit_state_notify(), transmit_versionres(), try_calling(), try_load_key(), trylock_read(), txt_callback(), unistim_request(), unistim_sp(), unistim_ss(), unlock_read(), unregister_exten(), update_call_counter(), 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(), write_history(), write_metadata(), xfer_get(), xmpp_client_alloc(), xmpp_client_create_buddy(), xmpp_pak_message(), and xmpp_pak_presence().

00480 :
 *

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

Definition at line 111 of file strings.h.

References ast_assert, and NULL.

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

00112 {
00113    size_t str_len;
00114    size_t suffix_len;
00115 
00116    ast_assert(str != NULL);
00117    ast_assert(suffix != NULL);
00118    str_len = strlen(str);
00119    suffix_len = strlen(suffix);
00120 
00121    if (suffix_len > str_len) {
00122       return 0;
00123    }
00124 
00125    return strcmp(str + str_len - suffix_len, suffix) == 0;
00126 }

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:
0 if val is a NULL pointer.
-1 if "true".
0 otherwise.

Definition at line 1689 of file main/utils.c.

References ast_strlen_zero.

Referenced by acf_faxopt_write(), acf_transaction_write(), 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(), find_realtime(), func_channel_write_real(), function_ooh323_write(), handle_common_options(), handle_queue_set_member_ringinuse(), hook_write(), init_acf_query(), load_config(), load_odbc_config(), manager_mute_mixmonitor(), manager_queue_member_ringinuse(), parking_feature_flag_cfg(), parse_empty_options(), parse_playtone(), prack_handler(), process_dahdi(), reload_config(), reload_single_member(), rt_handle_member_record(), rtp_reload(), run_agi(), set_config(), set_insecure_flags(), sip_parse_nat_option(), sla_build_trunk(), strings_to_mask(), and timers_handler().

01690 {
01691    if (ast_strlen_zero(s))
01692       return 0;
01693 
01694    /* Determine if this is a false value */
01695    if (!strcasecmp(s, "no") ||
01696        !strcasecmp(s, "false") ||
01697        !strcasecmp(s, "n") ||
01698        !strcasecmp(s, "f") ||
01699        !strcasecmp(s, "0") ||
01700        !strcasecmp(s, "off"))
01701       return -1;
01702 
01703    return 0;
01704 }

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:
buf Buffer to write random string into.
size The size of the buffer.
Returns:
A pointer to buf

Definition at line 197 of file strings.c.

References ast_random().

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

00198 {
00199    int i;
00200 
00201    for (i = 0; i < size - 1; ++i) {
00202       buf[i] = 'a' + (ast_random() % 26);
00203    }
00204    buf[i] = '\0';
00205 
00206    return buf;
00207 }

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

get values from config variables.

Definition at line 2299 of file main/utils.c.

References ast_strlen_zero, and NULL.

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

02300 {
02301    long t;
02302    int scanned;
02303 
02304    if (dst == NULL)
02305       return -1;
02306 
02307    *dst = _default;
02308 
02309    if (ast_strlen_zero(src))
02310       return -1;
02311 
02312    /* only integer at the moment, but one day we could accept more formats */
02313    if (sscanf(src, "%30ld%n", &t, &scanned) == 1) {
02314       *dst = t;
02315       if (consumed)
02316          *consumed = scanned;
02317       return 0;
02318    } else
02319       return -1;
02320 }

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

get values from config variables.

Definition at line 2272 of file main/utils.c.

References ast_strlen_zero, and NULL.

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

02273 {
02274    long double dtv = 0.0;
02275    int scanned;
02276 
02277    if (dst == NULL)
02278       return -1;
02279 
02280    *dst = _default;
02281 
02282    if (ast_strlen_zero(src))
02283       return -1;
02284 
02285    /* only integer at the moment, but one day we could accept more formats */
02286    if (sscanf(src, "%30Lf%n", &dtv, &scanned) > 0) {
02287       dst->tv_sec = dtv;
02288       dst->tv_usec = (dtv - dst->tv_sec) * 1000000.0;
02289       if (consumed)
02290          *consumed = scanned;
02291       return 0;
02292    } else
02293       return -1;
02294 }

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

Definition at line 1851 of file main/utils.c.

Referenced by ast_sip_auths_to_str().

01852 {
01853    int x, ofs = 0;
01854    const char *src;
01855 
01856    /* Join words into a string */
01857    if (!s)
01858       return;
01859    for (x = 0; ofs < len && x < size && w[x] ; x++) {
01860       if (x > 0)
01861          s[ofs++] = delim;
01862       for (src = w[x]; *src && ofs < len; src++)
01863          s[ofs++] = *src;
01864    }
01865    if (ofs == len)
01866       ofs--;
01867    s[ofs] = '\0';
01868 }

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

Returns:
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

Parameters:
regex_string the string containing /regex/
regex_pattern the destination ast_str which will contain "regex" after execution

Definition at line 1652 of file main/utils.c.

References ast_str_set(), and ast_str_truncate().

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

01653 {
01654    int regex_len = strlen(regex_string);
01655    int ret = 3;
01656 
01657    /* Chop off the leading / if there is one */
01658    if ((regex_len >= 1) && (regex_string[0] == '/')) {
01659       ast_str_set(regex_pattern, 0, "%s", regex_string + 1);
01660       ret -= 2;
01661    }
01662 
01663    /* Chop off the ending / if there is one */
01664    if ((regex_len > 1) && (regex_string[regex_len - 1] == '/')) {
01665       ast_str_truncate(*regex_pattern, -1);
01666       ret -= 1;
01667    }
01668 
01669    return ret;
01670 }

char * ast_skip_blanks ( const char *  str  )  [inline]

char * ast_skip_nonblanks ( const char *  str  )  [inline]

Gets a pointer to first whitespace character in a string.

Parameters:
str the input string
Returns:
a pointer to the first whitespace character

Definition at line 191 of file strings.h.

References ast_skip_blanks(), and ast_trim_blanks().

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

00204 {

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 1073 of file strings.h.

Referenced by __ast_manager_event_multichan(), __ast_verbose_ap(), __queues_show(), __test_cel_generate_peer_str(), acf_curl_helper(), acf_odbc_read(), action_agents(), action_createconfig(), action_userevent(), active_channels_to_str_cb(), add_allow_header(), add_blank(), add_codec_to_sdp(), add_content(), add_dtls_to_sdp(), add_header(), add_ice_to_sdp(), add_ice_to_stream(), add_noncodec_to_sdp(), add_required_respheader(), add_rpid(), add_sdp(), add_tcodec_to_sdp(), add_vcodec_to_sdp(), 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_get_docs(), ast_ari_response_created(), ast_category_get_templates(), ast_cdr_serialize_variables(), ast_eivr_getvariable(), ast_format_cap_get_names(), ast_ha_join(), ast_ha_join_cidr(), ast_json_ipaddr(), ast_manager_build_channel_state_string_prefix(), 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_sorcery_object_to_ami(), ast_statsd_log_full(), ast_str_append_event_header(), ast_str_encode_mime(), ast_str_quote(), ast_str_substitute_variables_full(), ast_term_color_code(), AST_TEST_DEFINE(), ast_translate_path_to_str(), attended_transfer_to_ami(), auth_http_callback(), authority_to_str(), build_nonce(), build_notify(), build_path_data(), build_peer(), caldav_get_events_between(), caldav_write_event(), calendar_join_attendees(), CB_ADD(), CB_ADD_LEN(), cc_unique_append(), cdata(), cdr_handler(), cel_generate_peer_str(), celt_generate_sdp_fmtp(), chanavail_exec(), channel_fax_cb(), channel_hangup_request_cb(), check_message_integrity(), cipher_to_str(), cli_alias_passthrough(), cli_aor_print_body(), cli_aor_print_header(), cli_channel_print_body(), cli_channel_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(), codec_append_name(), collect_names_cb(), commit_exec(), construct_pidf_body(), cut_internal(), data_result_print_cli_node(), data_search_generate(), dbl_list_expect_forward(), dbl_list_expect_reverse(), destroy_curl(), destroy_mysql(), 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(), finalize_content(), find_aor(), format_ami_aor_handler(), format_ami_auth_handler(), format_ami_endpoint_identify(), format_ami_endpoint_transport(), format_ami_endpoints(), format_contact_status(), format_str_append_auth(), function_db_keys(), function_realtime_read(), function_realtime_readdestroy(), generate_status(), generate_uri(), generic_http_callback(), get_content(), h263_generate_sdp_fmtp(), h264_generate_sdp_fmtp(), handle_characters(), handle_cli_indication_show(), handle_missing_table(), handle_options(), handle_request_refer(), handle_show_translation_path(), handle_show_translation_table(), handle_showchan(), hashkeys_read2(), httpstatus_callback(), initreqprep(), jack_str(), list_expect(), list_item_to_str(), listfilter(), load_column_config(), load_config(), local_message_to_ami(), log_jack_status(), manager_json_value_str_append(), manager_sipnotify(), media_index_update(), meetme_cmd_helper(), modify_mysql(), multi_object_blob_to_ami(), mwi_generate_body_content(), mwi_subscription_mailboxes_str(), mwi_to_ami(), mysql_log(), odbc_log(), opus_generate_sdp_fmtp(), pbx_builtin_serialize_variables(), peer_mailboxes_to_str(), peerstatus_to_ami(), pgsql_log(), pgsql_reconnect(), phoneprov_callback(), pjsip_acf_dial_contacts_read(), pjsip_aor_function_read(), pp_each_extension_helper(), pp_each_user_helper(), print_uptimestr(), process_cors_request(), process_description_file(), process_output(), process_text_line(), realtime_curl(), realtime_directory(), realtime_ldap_base_ap(), realtime_multi_curl(), realtime_multi_mysql(), realtime_multi_pgsql(), realtime_mysql(), realtime_pgsql(), realtime_sqlite3_destroy(), realtime_sqlite3_helper(), realtime_sqlite3_store(), realtime_sqlite3_update(), realtime_sqlite3_update2(), realtime_update2_handler(), realtimefield_read(), registrar_on_rx_request(), require_curl(), rollback_exec(), rtcp_report_to_ami(), run_station(), scan(), scan_dir(), send_eivr_event(), set_rec_filename(), set_var_to_str(), silk_generate_sdp_fmtp(), sip_aor_to_ami(), sip_cli_notify(), sip_cli_print_global(), sip_cli_print_system(), sip_endpoint_to_ami(), sip_endpoints_aors_ami(), sip_route_list(), sip_rtp_read(), sip_sorcery_object_ami_set_type_name(), sip_subscription_to_ami(), sip_tcptls_read(), sorcery_function_read(), spandsp_manager_fax_session(), stasis_app_control_snoop(), state_notify_build_xml(), store_curl(), store_mysql(), store_pgsql(), strreplace(), substitute_escapes(), test_core_format_generate_sdp_fmtp(), to_ami(), transmit_info_with_aoc(), transmit_notify_with_mwi(), update2_curl(), update2_ldap(), update2_mysql(), update2_pgsql(), update2_prepare(), update_curl(), update_ldap(), update_mysql(), update_pgsql(), user_authority_to_str(), websocket_client_parse_uri(), write_cdr(), write_cel(), xml_copy_escape(), xml_encode_str(), and xml_translate().

01083 {

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 1010 of file strings.h.

References ast_str_set_va().

Referenced by acf_odbc_read(), and function_db_keys().

01037 {

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 996 of file strings.h.

References __ast_str_helper2().

Referenced by __ast_verbose_ap(), ast_str_substitute_variables_full(), file_read(), listfilter(), write_to_ast_str(), and WriteMemoryCallback().

01000 {

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 982 of file strings.h.

References __ast_str_helper2().

Referenced by __ast_manager_event_multichan(), and ast_str_set().

00986 {

char * ast_str_buffer ( const struct ast_str buf  )  [inline]

Returns the string buffer within the ast_str buf.

Parameters:
buf A pointer to the ast_str structure.
Return values:
A pointer to the enclosed string.
Examples:
/tmp/asterisk-trunk/trunk/main/app.c.

Definition at line 669 of file strings.h.

References ast_str::__AST_STR_STR, ast_str::__AST_STR_USED, and typeof().

Referenced by __ast_manager_event_multichan(), __ast_verbose_ap(), __queues_show(), __sip_pretend_ack(), __sip_reliable_xmit(), __sip_semi_ack(), __sip_xmit(), _iax2_show_peers_one(), _macro_exec(), _sip_show_peer(), _sip_tcp_helper_thread(), acf_curl_helper(), acf_cut_exec(), acf_odbc_read(), acf_odbc_write(), action_agents(), action_coreshowchannels(), action_createconfig(), action_getconfig(), action_getconfigjson(), action_hangup(), action_userevent(), add_cc_call_info_to_response(), add_crypto_to_stream(), add_hintdevice(), add_ice_to_stream(), add_required_respheader(), add_route(), add_rpid(), add_sdp(), 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_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_channel_get_manager_vars(), ast_cli(), ast_eivr_getvariable(), ast_format_cap_get_names(), ast_func_read(), ast_func_read2(), ast_http_create_response(), ast_http_send(), ast_json_ipaddr(), ast_json_load_str(), ast_log_full(), ast_odbc_ast_str_SQLGetData(), ast_parse_digest(), ast_print_namedgroups(), ast_realtime_encode_chunk(), ast_rtp_lookup_mime_multiple2(), ast_set_cc_interfaces_chanvar(), ast_sip_append_body(), ast_sockaddr_stringify_fmt(), ast_sounds_reindex(), ast_statsd_log_full(), ast_str_encode_mime(), ast_str_get_encoded_str(), ast_str_quote(), ast_str_retrieve_variable(), ast_str_substitute_variables_full(), ast_str_substring(), AST_TEST_DEFINE(), ast_translate_path_to_str(), ast_var_channels_table(), astman_append(), 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_peer(), build_user_routes(), caldav_request(), calendar_join_attendees(), call_pickup_to_ami(), cc_extension_monitor_init(), cc_unique_append(), cdata(), cdr_handler(), cel_bridge_enter_cb(), cel_bridge_leave_cb(), challenge(), chanavail_exec(), change_hold_state(), 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_hangup_handler_cb(), channel_hangup_request_cb(), channel_hold_cb(), channel_leave_cb(), channel_moh_start_cb(), channel_snapshot_update(), channel_unhold_cb(), check_auth(), check_message_integrity(), check_nonce(), cipher_to_str(), cli_alias_passthrough(), cli_match_char_tree(), cli_odbc_read(), cli_odbc_write(), cli_prompt(), cli_show_settings(), commit_exec(), conf_start_record(), confbridge_publish_manager_event(), config_curl(), config_mysql(), config_pgsql(), config_text_file_load(), construct_pidf_body(), contacts_to_str(), create_channel_name(), custom_log(), cut_internal(), dahdi_cc_callback(), dahdi_new(), dahdichannel_to_ami(), data_provider_print_cli(), data_result_manager_output(), data_result_print_cli_node(), data_search_generate(), dbl_list_expect_forward(), dbl_list_expect_reverse(), destroy_curl(), destroy_mysql(), destroy_pgsql(), detect_disconnect(), determine_firstline_parts(), dialog_info_to_string(), do_magic_pickup(), 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(), fetch_icalendar(), file2display(), finalize_content(), find_aor(), find_realtime(), find_table(), format_ami_aor_handler(), format_ami_auth_handler(), format_ami_endpoint(), format_ami_endpoint_identify(), format_ami_endpoint_transport(), format_ami_endpoints(), format_ami_resource_lists(), format_contact_status(), function_fieldnum_helper(), function_fieldqty_helper(), function_iaxpeer(), function_realtime_read(), function_realtime_readdestroy(), function_sippeer(), generate_fmtp_attr(), generate_notify_body(), generate_status(), generate_uri(), get_content(), get_languages(), handle_aor(), handle_call_token(), handle_cli_cdr_mysql_status(), handle_cli_iax2_show_peer(), handle_cli_indication_show(), handle_dbget(), handle_end_element(), handle_getvariablefull(), handle_missing_table(), handle_options(), handle_registrations(), handle_request_do(), handle_request_refer(), handle_show_translation_path(), handle_show_translation_table(), handle_showchan(), hangupcause_keys_read(), hashkeys_read(), hashkeys_read2(), http_post_callback(), iax2_getformatname_multiple(), iax_parse_ies(), initreqprep(), is_new_rec_file(), is_valid_uuid(), jack_str(), leave_voicemail(), list_expect(), list_item_to_str(), listfilter(), load_column_config(), local_message_to_ami(), localnet_to_str(), log_attended_transfer(), log_jack_status(), lws2sws(), make_email_file(), manager_bridge_info(), manager_bridge_tech_list(), manager_bridges_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(), media_index_update(), meetme_cmd_helper(), meetme_show_cmd(), meetme_stasis_cb(), modify_mysql(), multi_object_blob_to_ami(), multi_user_event_to_ami(), mwi_app_event_cb(), mwi_mailbox_delete(), mwi_mailbox_get(), mwi_to_string(), my_load_module(), mysql_log(), 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(), parse_register_contact(), parse_request(), pbx_find_extension(), pbx_retrieve_variable(), peers_data_provider_get(), peerstatus_to_ami(), pgsql_log(), pgsql_reconnect(), phoneprov_callback(), pidf_to_string(), pjsip_acf_dial_contacts_read(), pp_each_extension_helper(), pp_each_user_helper(), print_uptimestr(), process_description_file(), process_media_file(), process_text_line(), 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(), read_raw_content_length(), realtime_curl(), realtime_directory(), realtime_ldap_base_ap(), 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(), realtime_update2_handler(), realtimefield_read(), registrar_on_rx_request(), replace(), require_curl(), require_mysql(), require_pgsql(), retrans_pkt(), rollback_exec(), rtcp_report_to_ami(), run_app_helper(), run_station(), rx_task(), say_periodic_announcement(), scan(), scan_dir(), 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_request(), send_response(), send_unsolicited_mwi_notify(), sendmail(), sendpage(), sendtext_exec(), session_timeout_to_ami(), set2(), set_format(), shift_pop(), show_channels_cb(), sip_hangup(), sip_report_security_event(), sip_rtp_read(), sip_send_mwi_to_peer(), sip_show_channel(), sip_show_sched(), sip_tcptls_read(), snoop_stasis_thread(), spandsp_manager_fax_session(), sqlite3_escape_column_op(), sqlite3_escape_string_helper(), startelm(), stasis_app_device_states_to_json(), statsmaker(), store_curl(), store_mysql(), store_pgsql(), string_tolower2(), string_toupper2(), strreplace(), substitute_escapes(), syslog_log(), 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(), threadpool_alloc(), transmit_fake_auth_response(), transmit_info_dtmf(), transmit_info_with_aoc(), transmit_invite(), transmit_notify_with_mwi(), transmit_state_notify(), 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_ldap(), update_mysql(), update_peer(), update_pgsql(), user_authority_to_str(), users_data_provider_get(), varset_to_ami(), websocket_client_handshake(), write_cdr(), write_cel(), and xpidf_to_string().

00680 {

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.

Definition at line 1162 of file strings.h.

References abs.

Referenced by ast_channel_hash_cb(), ast_tone_zone_hash(), bridge_hash_cb(), cache_hash(), calendar_hash_fn(), cdr_object_channel_hash_fn(), channel_role_hash_cb(), channel_snapshot_hash_cb(), conference_bridge_hash_cb(), config_opt_hash(), data_provider_hash(), dialog_hash_cb(), featuregroup_hash(), format_hash_cb(), hint_hash(), hintdevice_hash_cb(), media_info_hash(), media_variant_hash(), menu_hash_cb(), moh_class_hash(), msg_data_hash_fn(), notify_option_hash(), peer_hash_cb(), protocol_hash_fn(), pvt_hash_cb(), queue_hash_cb(), skel_level_hash(), sla_station_hash(), sla_trunk_hash(), test_item_hash(), topic_pool_entry_hash(), tps_hash_cb(), user_hash_cb(), and xmpp_config_hash().

01163 {
01164    int hash = 5381;
01165 
01166    while (*str) {
01167       hash = hash * 33 ^ tolower(*str++);
01168    }
01169 
01170    return abs(hash);
01171 }

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_container The container to which to add a string
add The string to add to the container
Return values:
zero on success
non-zero if the operation failed

Definition at line 176 of file strings.c.

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(), custom_nameserver_handler(), declined_handler(), get_languages(), load_module(), session_register_app(), and test_cel_peer_strings_match().

00177 {
00178    char *ao2_add;
00179 
00180    /* The ao2_add object is immutable so it doesn't need a lock of its own. */
00181    ao2_add = ao2_alloc_options(strlen(add) + 1, NULL, AO2_ALLOC_OPT_LOCK_NOLOCK);
00182    if (!ao2_add) {
00183       return -1;
00184    }
00185    strcpy(ao2_add, add);/* Safe */
00186 
00187    ao2_link(str_container, ao2_add);
00188    ao2_ref(ao2_add, -1);
00189    return 0;
00190 }

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

Allocates a hash container for bare strings.

Since:
12
Parameters:
opts Options to be provided to the container
buckets The number of buckets to use for the hash container
Return values:
AO2 container for strings
NULL if allocation failed

Definition at line 171 of file strings.c.

References ao2_container_alloc_options, str_cmp(), and str_hash().

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

00172 {
00173    return ao2_container_alloc_options(opts, buckets, str_hash, str_cmp);
00174 }

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_container The container from which to remove a string
remove The string to remove from the container

Definition at line 192 of file strings.c.

References ao2_find, OBJ_NODATA, OBJ_SEARCH_KEY, and OBJ_UNLINK.

Referenced by endpoint_cache_clear(), and test_cel_peer_strings_match().

00193 {
00194    ao2_find(str_container, remove, OBJ_SEARCH_KEY | OBJ_NODATA | OBJ_UNLINK);
00195 }

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

Definition at line 778 of file strings.h.

Referenced by copy_request().

00781 {                 \

struct ast_str * ast_str_create ( size_t  init_len  )  [read]

Create a malloc'ed dynamic length string.

Parameters:
init_len This 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 592 of file strings.h.

References ast_str::__AST_STR_LEN, ast_str::__AST_STR_STR, and ast_str::__AST_STR_USED.

Referenced by __ast_http_post_load(), __sip_reliable_xmit(), __test_cel_generate_peer_str(), _macro_exec(), _sip_tcp_helper_thread(), acf_curl_helper(), acf_cut_exec(), action_hangup(), add_crypto_to_stream(), add_ice_to_stream(), add_required_respheader(), add_sdp(), add_user_extension(), allocate_subscription(), analog_publish_dnd_state(), aoc_display_decoded_debug(), ari_channels_handle_originate_with_id(), ast_ari_asterisk_get_global_var(), ast_ari_callback(), ast_ari_channels_get_channel_var(), ast_ari_get_docs(), ast_category_get_templates(), ast_cc_agent_set_interfaces_chanvar(), ast_channel_dialed_causes_channels(), ast_channel_get_manager_vars(), ast_func_read(), ast_http_auth(), ast_http_create_response(), ast_http_error(), ast_http_send(), ast_manager_build_bridge_state_string_prefix(), ast_manager_build_channel_state_string_prefix(), ast_manager_str_from_json_object(), ast_parse_digest(), ast_set_cc_interfaces_chanvar(), ast_sip_cli_traverse_objects(), ast_sip_create_ami_event(), ast_sounds_reindex(), ast_statsd_log_full(), ast_str_append_event_header(), ast_str_substitute_variables_full(), ast_tcptls_client_create(), ast_tcptls_server_root(), AST_TEST_DEFINE(), attended_transfer_to_ami(), auth_http_callback(), build_notify(), build_path_data(), build_user_routes(), caldav_get_events_between(), caldav_request(), caldav_write_event(), calendar_join_attendees(), cdr_handler(), cel_generate_peer_str(), channel_fax_cb(), channel_hangup_request_cb(), channel_hold_cb(), cipher_to_str(), cli_print_body(), cli_prompt(), cli_show_settings(), config_text_file_load(), contacts_to_str(), copy_request(), create_channel_name(), cut_internal(), data_provider_print_cli(), data_result_manager_output(), data_result_print_cli_node(), data_search_generate(), device_state_cb(), do_notify(), dump_queue_members(), ewscal_write_event(), exchangecal_get_events_between(), exchangecal_request(), exchangecal_write_event(), exec_exec(), fetch_icalendar(), find_aor(), find_realtime(), function_sippeer(), generate_status(), generic_http_callback(), get_ewscal_ids_for(), get_languages(), handle_aor(), handle_dbget(), handle_getvariablefull(), handle_missing_table(), handle_options(), handle_registrations(), handle_request_refer(), handle_show_translation_table(), handle_showchan(), handle_updates(), handle_uri(), httpstatus_callback(), iax_parse_ies(), init_appendbuf(), init_queue(), init_req(), init_resp(), is_new_rec_file(), jack_str(), join_conference_bridge(), leave_voicemail(), list_item_to_str(), load_column_config(), load_config(), local_message_to_ami(), localnet_to_str(), log_attended_transfer(), make_email_file(), manager_bridge_info(), manager_bridge_tech_list(), manager_bridges_list(), manager_build_parked_call_string(), manager_json_to_ast_str(), match_to_str(), media_index_update(), meetme_cmd_helper(), meetme_show_cmd(), meetme_stasis_cb(), misdn_cfg_get_config_string(), multi_object_blob_to_ami(), mwi_allocate_body(), mwi_mailbox_delete(), mwi_mailbox_get(), my_load_config_string(), named_callgroups_to_str(), named_pickupgroups_to_str(), odbc_log(), parking_lot_cfg_create_extensions(), parse_ewscal_id(), pbx_retrieve_variable(), peerstatus_to_ami(), pgsql_log(), pgsql_reconnect(), phoneprov_callback(), pjsip_acf_dial_contacts_read(), pp_each_extension_helper(), pp_each_user_helper(), presence_state_cb(), print_named_groups(), process_description_file(), process_media_file(), publish_channel_alarm(), publish_channel_alarm_clear(), publish_dnd_state(), queue_set_param(), read_config(), read_raw_content_length(), realtime_ldap_base_ap(), realtime_sqlite3_destroy(), realtime_sqlite3_helper(), realtime_sqlite3_store(), realtime_sqlite3_update(), realtime_sqlite3_update2(), registrar_on_rx_request(), replace(), require_pgsql(), response_alloc(), rtcp_report_to_ami(), run_app_helper(), run_station(), scan(), scan_dir(), security_event_to_ami_blob(), send_eivr_event(), send_unsolicited_mwi_notify(), sendmail(), sendpage(), set_var_to_str(), sip_notify_alloc(), sip_route_list(), sip_rtp_read(), sip_tcptls_write(), sip_websocket_callback(), sipsock_read(), spandsp_manager_fax_session(), startelm(), stasis_app_control_snoop(), static_callback(), statsmaker(), system_registry_to_ami(), test_2way_function(), test_chan_function(), test_chan_integer(), test_chan_integer_accessor(), test_chan_string(), test_chan_variable(), test_expected_result(), threadpool_alloc(), transmit_info_dtmf(), tryexec_exec(), update2_ldap(), update_caldav(), update_ldap(), users_data_provider_get(), varset_to_ami(), websocket_bad_request(), websocket_client_parse_uri(), write_cdr(), and write_cel().

00600 {

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 1122 of file strings.h.

References abs.

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(), bucket_file_metadata_hash(), bucket_scheme_hash(), cel_backend_hash(), channel_hash(), cli_channel_hash(), codec_hash(), contact_expiration_hash(), control_hash(), data_filter_hash(), data_result_hash(), data_search_hash(), datastore_hash(), db_hash_fn(), device_state_subscriptions_hash(), dialstatus_hash(), endpoint_hash(), entry_hash_fn(), esc_hash_fn(), event_hash_fn(), format_interface_hash(), formatter_hash(), generic_monitor_hash_fn(), group_hash_fn(), hook_hash(), jingle_add_ice_udp_candidates_to_transport(), jingle_endpoint_hash(), jingle_session_hash(), keepalive_transport_hash_fn(), lang_hash_fn(), lid_hash(), message_subscription_hash_cb(), mwi_sub_hash(), named_acl_hash_fn(), object_type_field_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(), registry_hash_cb(), sched_qualifies_hash_fn(), sdp_handler_list_hash(), serializer_hash(), session_media_hash(), sorcery_config_hash(), sorcery_instance_hash(), sorcery_memory_hash(), sorcery_type_hash(), sorcery_wizard_hash(), stasis_sub_hash(), str_hash(), str_hash_fn(), test_vm_api_create_mock_snapshot(), uid_hold_hash_fn(), user_hash_cb(), variable_count_hash_fn(), wait_bridge_hash_fn(), and xmpp_buddy_hash().

01123 {
01124    int hash = 5381;
01125 
01126    while (*str)
01127       hash = hash * 33 ^ *str++;
01128 
01129    return abs(hash);
01130 }

static force_inline int ast_str_hash_add ( const char *  str,
int  hash 
) [static]

Compute a hash value on a string.

Parameters:
[in] str The string to add to the hash
[in] hash The hash value to add to
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 1147 of file strings.h.

References abs.

01148 {
01149    while (*str)
01150       hash = hash * 33 ^ *str++;
01151 
01152    return abs(hash);
01153 }

int ast_str_make_space ( struct ast_str **  buf,
size_t  new_len 
) [inline]

void ast_str_reset ( struct ast_str buf  )  [inline]

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:
buf This 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_len This 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.
fmt This 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()
Examples:
/tmp/asterisk-trunk/trunk/main/app.c.

Definition at line 1047 of file strings.h.

References ast_str_append_va().

Referenced by __ast_http_post_load(), __ast_manager_event_multichan(), __queues_show(), __sip_reliable_xmit(), acf_curl_helper(), acf_curlopt_helper(), action_agents(), action_createconfig(), add_cc_call_info_to_response(), add_crypto_to_stream(), add_hintdevice(), add_ice_to_stream(), add_rpid(), 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_format_cap_get_names(), 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_reindex(), ast_str_encode_mime(), ast_str_expr(), ast_str_get_encoded_str(), ast_str_get_hint(), ast_str_quote(), ast_str_retrieve_variable(), AST_TEST_DEFINE(), bs_to_exchange_bs(), build_notify(), build_path_data(), build_peer(), caldav_write_event(), cc_extension_monitor_init(), cc_generic_agent_start_monitoring(), cdata(), cdr_handler(), channel_hold_cb(), check_auth(), cli_match_char_tree(), cli_odbc_read(), cli_prompt(), config_curl(), config_mysql(), config_pgsql(), create_channel_name(), data_provider_print_cli(), data_result_manager_output(), destroy_curl(), destroy_mysql(), destroy_pgsql(), device_state_cb(), do_magic_pickup(), do_notify(), encmethods_to_str(), ewscal_write_event(), exchangecal_write_event(), extension_presence_state_helper(), file_count_line(), file_format(), find_aor(), find_realtime(), find_table(), function_fieldnum_helper(), function_fieldqty_helper(), generate_exchange_uuid(), generate_uri(), get_ewscal_ids_for(), get_languages(), handle_call_token(), handle_cli_indication_show(), handle_missing_table(), handle_show_translation_path(), handle_show_translation_table(), handle_uri(), hashkeys_read(), hashkeys_read2(), iax_parse_ies(), init_queue(), init_req(), init_resp(), initreqprep(), 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(), media_index_update(), meetme_cmd_helper(), meetme_show_cmd(), meetme_stasis_cb(), modify_mysql(), mwi_to_string(), my_load_config_string(), my_load_module(), mysql_log(), 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_cb(), process_description_file(), process_media_file(), process_text_line(), publish_channel_alarm(), publish_channel_alarm_clear(), publish_dnd_state(), queue_set_param(), read_raw_content_length(), realtime_curl(), realtime_directory(), realtime_multi_curl(), realtime_multi_mysql(), realtime_multi_pgsql(), realtime_mysql(), realtime_odbc(), realtime_pgsql(), realtime_sqlite3_destroy(), realtime_sqlite3_helper(), realtime_sqlite3_store(), realtime_sqlite3_update(), realtime_sqlite3_update2(), realtime_update2_handler(), registrar_on_rx_request(), replace(), require_curl(), require_mysql(), require_pgsql(), run_station(), search_directory_sub(), security_event_stasis_cb(), sendmail(), sendpage(), set_rec_filename(), shift_pop(), sip_report_security_event(), sip_tcptls_write(), sip_websocket_callback(), sipsock_read(), sorcery_function_read(), stackpeek_read(), startelm(), stasis_app_control_snoop(), stasis_app_device_states_to_json(), static_callback(), statsmaker(), store_curl(), store_mysql(), store_pgsql(), system_registry_to_ami(), test_2way_function(), test_chan_variable(), threadpool_alloc(), transmit_fake_auth_response(), transmit_info_dtmf(), unshift_push(), update2_curl(), update2_mysql(), update2_pgsql(), update2_prepare(), update_curl(), update_mysql(), update_pgsql(), users_data_provider_get(), varset_to_ami(), websocket_bad_request(), and websocket_client_parse_uri().

01063 {

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 1003 of file strings.h.

References __ast_str_helper2().

Referenced by acf_curl_helper(), and realtimefield_read().

01007 {

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 989 of file strings.h.

References __ast_str_helper2().

Referenced by ast_str_substitute_variables_full(), and set_rec_filename().

00993 {

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:
buf This 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_len This is the maximum length to allow the string buffer to grow to. If this is set to 0, then there is no maximum length.
fmt This is the format string (printf style)
ap This 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);
      ...
 }

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 964 of file strings.h.

References __ast_str_helper().

Referenced by __ast_verbose_ap(), ast_agi_send(), ast_cli(), ast_log_full(), ast_str_append_escapecommas(), astman_append(), and astman_send_error_va().

00979 {

size_t ast_str_size ( const struct ast_str buf  )  [inline]

size_t ast_str_strlen ( const struct ast_str buf  )  [inline]

Returns the current length of the string stored within buf.

Parameters:
buf A pointer to the ast_str structure.

Definition at line 643 of file strings.h.

References ast_str::__AST_STR_LEN.

Referenced by __sip_reliable_xmit(), __sip_xmit(), _sip_tcp_helper_thread(), acf_curl_helper(), acf_odbc_read(), action_getconfig(), action_getconfigjson(), add_header(), add_required_respheader(), add_route(), ALLOC_COMMENT(), ast_agi_send(), ast_cli(), ast_http_send(), ast_statsd_log_full(), ast_str_encode_mime(), ast_str_expr(), ast_str_substitute_variables_full(), ast_str_substring(), AST_TEST_DEFINE(), ast_var_channels_table(), authority_to_str(), base64_helper(), blacklist_read2(), build_cc_interfaces_chanvar(), build_notify(), build_peer(), caldav_get_events_between(), caldav_request(), cc_extension_monitor_init(), cdata(), chanavail_exec(), check_message_integrity(), collect_names_cb(), commit_exec(), config_mysql(), config_text_file_load(), copy_request(), cut_internal(), destroy_mysql(), detect_disconnect(), dump_queue_members(), encmethods_to_str(), endelm(), exchangecal_request(), fetch_icalendar(), finalize_content(), find_table(), function_fieldnum_helper(), function_fieldqty_helper(), generate_fmtp_attr(), handle_cli_cdr_mysql_status(), handle_dbget(), handle_end_element(), handle_request_cancel(), handle_request_do(), handle_showchan(), hangupcause_keys_read(), hashkeys_read(), hashkeys_read2(), listfilter(), load_column_config(), load_config(), lws2sws(), manager_log(), manager_sipnotify(), modify_mysql(), my_load_module(), mysql_log(), odbc_log(), parse_request(), pgsql_log(), pjsip_acf_dial_contacts_read(), print_uptimestr(), realtime_multi_mysql(), realtime_multi_odbc(), realtime_mysql(), realtime_odbc(), replace(), require_mysql(), rollback_exec(), say_periodic_announcement(), send_ews_request_and_parse(), set_rec_filename(), shift_pop(), sip_cli_notify(), sip_hangup(), sip_send_mwi_to_peer(), sip_tcptls_read(), store_mysql(), system_exec_helper(), transmit_invite(), unshift_push(), update2_mysql(), update_caldav(), update_exchangecal(), update_mysql(), user_authority_to_str(), write_cdr(), write_cel(), write_to_ast_str(), and WriteMemoryCallback().

00651 {

struct ast_str * ast_str_thread_get ( struct ast_threadstorage ts,
size_t  init_len 
) [read]

Retrieve a thread locally stored dynamic string.

Parameters:
ts This 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_len This 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 841 of file strings.h.

References ast_str::__AST_STR_LEN, ast_str::__AST_STR_TS, ast_str::__AST_STR_USED, and NULL.

Referenced by __ast_manager_event_multichan(), __ast_verbose_ap(), acf_curl_helper(), acf_odbc_read(), acf_odbc_write(), action_userevent(), add_hintdevice(), ast_agi_send(), ast_cli(), ast_extension_state2(), ast_log_full(), ast_sockaddr_stringify_fmt(), astman_append(), astman_send_error_va(), check_auth(), cli_odbc_read(), cli_odbc_write(), commit_exec(), config_curl(), config_mysql(), config_pgsql(), custom_log(), destroy_curl(), destroy_mysql(), destroy_pgsql(), dumpchan_exec(), extension_presence_state_helper(), find_table(), function_fieldnum_helper(), function_fieldqty_helper(), get_content(), handle_showchan(), listfilter(), modify_mysql(), mysql_log(), 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(), realtime_update2_handler(), realtimefield_read(), require_curl(), require_mysql(), rollback_exec(), search_directory_sub(), security_event_stasis_cb(), shift_pop(), sip_report_security_event(), sqlite3_escape_column_op(), sqlite3_escape_string_helper(), store_curl(), store_mysql(), store_pgsql(), strreplace(), substitute_escapes(), syslog_log(), system_exec_helper(), transmit_fake_auth_response(), unshift_push(), update2_curl(), update2_mysql(), update2_odbc(), update2_pgsql(), update2_prepare(), update_curl(), update_mysql(), and update_pgsql().

00846 {

static force_inline char* attribute_pure ast_str_to_lower ( char *  str  )  [static]

Convert a string to all lower-case.

Parameters:
str The string to be converted to lower case
Return values:
str for convenience

Definition at line 1180 of file strings.h.

Referenced by apps_handler(), ast_ari_endpoints_send_message_to_endpoint(), cel_track_app(), and get_user_agent().

01181 {
01182    char *str_orig = str;
01183    if (!str) {
01184       return str;
01185    }
01186 
01187    for (; *str; ++str) {
01188       *str = tolower(*str);
01189    }
01190 
01191    return str_orig;
01192 }

static force_inline char* attribute_pure ast_str_to_upper ( char *  str  )  [static]

Convert a string to all upper-case.

Parameters:
str The string to be converted to upper case
Return values:
str for convenience

Definition at line 1201 of file strings.h.

Referenced by ast_rtp_engine_load_format().

01202 {
01203    char *str_orig = str;
01204    if (!str) {
01205       return str;
01206    }
01207 
01208    for (; *str; ++str) {
01209       *str = toupper(*str);
01210    }
01211 
01212    return str_orig;
01213 }

void ast_str_trim_blanks ( struct ast_str buf  )  [inline]

Trims trailing whitespace characters from an ast_str string.

Parameters:
buf A pointer to the ast_str string.

Definition at line 633 of file strings.h.

References ast_str::__AST_STR_USED.

Referenced by acf_curl_helper(), and process_text_line().

00640 {

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

Truncates the enclosed string to the given length.

Parameters:
buf A pointer to the ast_str structure.
len Maximum 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.
Return values:
A pointer to the resulting string.

Definition at line 693 of file strings.h.

Referenced by __test_cel_generate_peer_str(), active_channels_to_str(), ast_regex_string_to_regex_pattern(), build_cc_interfaces_chanvar(), cel_generate_peer_str(), check_message_integrity(), contacts_to_str(), jack_str(), list_item_to_str(), pjsip_acf_dial_contacts_read(), set_var_to_str(), and sorcery_function_read().

00715 {

void ast_str_update ( struct ast_str buf  )  [inline]

char * ast_strip ( char *  s  )  [inline]

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

Strip leading/trailing whitespace and quotes from a string.

Parameters:
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.
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, "[{(", "]})");

Definition at line 1490 of file main/utils.c.

References ast_strip().

Referenced by applicationmap_handler(), ast_callerid_parse(), ast_register_file_version(), ast_strsep(), dialog_info_generate_body_content(), get_rdnis(), iftime(), load_values_config(), parse_allowed_methods(), parse_cookies(), parse_dial_string(), pidf_allocate_body(), sip_parse_register_line(), and xpidf_allocate_body().

01491 {
01492    char *e;
01493    char *q;
01494 
01495    s = ast_strip(s);
01496    if ((q = strchr(beg_quotes, *s)) && *q != '\0') {
01497       e = s + strlen(s) - 1;
01498       if (*e == *(end_quotes + (q - beg_quotes))) {
01499          s++;
01500          *e = '\0';
01501       }
01502    }
01503 
01504    return s;
01505 }

static force_inline int attribute_pure ast_strlen_zero ( const char *  s  )  [static]

Definition at line 64 of file strings.h.

00065 {
00066    return (!s || (*s == '\0'));
00067 }

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

Act like strsep but ignore separators inside quotes.

Parameters:
s Pointer to address of the 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. 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.
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_SEP_STRIP))) {
      // 1st token will be aaa=def
      // 2nd token will be ghi='zzz=yyy,456'
      while((token2 = ast_strsep(&token, '=', AST_SEP_STRIP))) {
         // 1st token2 will be ghi
         // 2nd token2 will be zzz=yyy,456
         while((token3 = ast_strsep(&token2, ',', AST_SEP_STRIP))) {
            // 1st token3 will be zzz=yyy
            // 2nd token3 will be 456
            // and so on
         }
      }
      // 3rd token will be jkl
   }

Definition at line 1507 of file main/utils.c.

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

Referenced by AST_TEST_DEFINE(), does_category_match(), handle_updates(), and wizard_apply_handler().

01508 {
01509    char *st = *iss;
01510    char *is;
01511    int inquote = 0;
01512    int found = 0;
01513    char stack[8];
01514 
01515    if (iss == NULL || *iss == '\0') {
01516       return NULL;
01517    }
01518 
01519    memset(stack, 0, sizeof(stack));
01520 
01521    for(is = st; *is; is++) {
01522       if (*is == '\\') {
01523          if (*++is != '\0') {
01524             is++;
01525          } else {
01526             break;
01527          }
01528       }
01529 
01530       if (*is == '\'' || *is == '"') {
01531          if (*is == stack[inquote]) {
01532             stack[inquote--] = '\0';
01533          } else {
01534             if (++inquote >= sizeof(stack)) {
01535                return NULL;
01536             }
01537             stack[inquote] = *is;
01538          }
01539       }
01540 
01541       if (*is == sep && !inquote) {
01542          *is = '\0';
01543          found = 1;
01544          *iss = is + 1;
01545          break;
01546       }
01547    }
01548    if (!found) {
01549       *iss = NULL;
01550    }
01551 
01552    if (flags & AST_STRSEP_STRIP) {
01553       st = ast_strip_quoted(st, "'\"", "'\"");
01554    }
01555 
01556    if (flags & AST_STRSEP_TRIM) {
01557       st = ast_strip(st);
01558    }
01559 
01560    if (flags & AST_STRSEP_UNESCAPE) {
01561       ast_unescape_quoted(st);
01562    }
01563 
01564    return st;
01565 }

char * ast_tech_to_upper ( char *  dev_str  )  [inline]

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

Return values:
dev_str Returns the char* passed in for convenience

Definition at line 1112 of file strings.h.

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

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

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

Definition at line 1870 of file main/utils.c.

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

01871 {
01872    char *res = ast_strdup(s);
01873    char *front, *back, *buf = res;
01874    int size;
01875 
01876    front = strtok_r(buf, delim, &back);
01877 
01878    while (front) {
01879       size = strlen(front);
01880       *front = toupper(*front);
01881       ast_copy_string(buf, front, size + 1);
01882       buf += size;
01883       front = strtok_r(NULL, delim, &back);
01884    }
01885 
01886    return res;
01887 }

char * ast_trim_blanks ( char *  str  )  [inline]

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:
0 if val is a NULL pointer.
-1 if "true".
0 otherwise.

Definition at line 1672 of file main/utils.c.

References ast_strlen_zero.

Referenced by __ast_http_load(), __init_manager(), _parse(), 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(), announce_user_count_all_handler(), aoc_cli_debug_enable(), apply_general_options(), apply_option(), apply_outgoing(), ast_ari_bridges_record_cb(), ast_ari_channels_record_cb(), ast_bridge_timelimit(), ast_jb_read_conf(), ast_plc_reload(), ast_readconfig(), ast_rtp_dtls_cfg_parse(), AST_TEST_DEFINE(), ast_tls_read_conf(), autopause2int(), bool_handler_fn(), boolflag_handler_fn(), build_device(), build_gateway(), build_peer(), build_user(), cdr_prop_write_callback(), check_debug(), client_bitfield_handler(), config_parse_variables(), custom_bitfield_handler(), customopt_handler(), dahdi_set_dnd(), data_search_cmp_bool(), do_reload(), encoding_format_handler(), festival_exec(), func_channel_write_real(), func_mute_write(), function_ooh323_write(), get_encrypt_methods(), global_bitfield_handler(), handle_common_options(), handle_logger_set_level(), handle_queue_set_member_ringinuse(), handle_t38_options(), hook_write(), init_logger_chain(), internal_feature_write(), is_variable_true(), load_config(), load_config_meetme(), load_module(), load_modules(), load_moh_classes(), load_odbc_config(), load_users(), manager_add_queue_member(), manager_dialplan_extension_add(), manager_mutestream(), manager_pause_queue_member(), manager_queue_member_ringinuse(), mbl_load_adapter(), mbl_load_device(), message_template_build(), misdn_answer(), moh_parse_options(), my_load_module(), new_realtime_sqlite3_db(), odbc_load_module(), osp_load(), osplookup_exec(), parse_config(), parse_empty_options(), parse_playtone(), pbx_builtin_saycharacters(), pbx_builtin_saycharacters_case(), pbx_builtin_saydigits(), pbx_builtin_saynumber(), pbx_builtin_sayphonetic(), pbx_load_config(), pbx_load_users(), prack_handler(), process_dahdi(), process_echocancel(), process_my_load_module(), queue_rules_set_global_params(), queue_set_global_params(), queue_set_param(), realtime_directory(), reload_config(), 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(), speex_write(), stackpeek_read(), start_monitor_action(), strings_to_mask(), tds_load_module(), timers_handler(), transport_tls_bool_handler(), and xfer_set().

01673 {
01674    if (ast_strlen_zero(s))
01675       return 0;
01676 
01677    /* Determine if this is a true value */
01678    if (!strcasecmp(s, "yes") ||
01679        !strcasecmp(s, "true") ||
01680        !strcasecmp(s, "y") ||
01681        !strcasecmp(s, "t") ||
01682        !strcasecmp(s, "1") ||
01683        !strcasecmp(s, "on"))
01684       return -1;
01685 
01686    return 0;
01687 }

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 1586 of file main/utils.c.

References c, and NULL.

Referenced by ast_parse_digest().

01587 {
01588    char c, *ret, *dst;
01589 
01590    if (src == NULL)
01591       return NULL;
01592    for (ret = dst = src; (c = *src++); *dst++ = c ) {
01593       if (c != '\\')
01594          continue;   /* copy char at the end of the loop */
01595       switch ((c = *src++)) {
01596       case '\0':  /* special, trailing '\' */
01597          c = '\\';
01598          break;
01599       case 'b':   /* backspace */
01600          c = '\b';
01601          break;
01602       case 'f':   /* form feed */
01603          c = '\f';
01604          break;
01605       case 'n':
01606          c = '\n';
01607          break;
01608       case 'r':
01609          c = '\r';
01610          break;
01611       case 't':
01612          c = '\t';
01613          break;
01614       }
01615       /* default, use the char literally */
01616    }
01617    *dst = '\0';
01618    return ret;
01619 }

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 1567 of file main/utils.c.

Referenced by sip_cli_notify().

01568 {
01569    char *e;
01570    char *work = s;
01571 
01572    while ((e = strchr(work, ';'))) {
01573       if ((e > work) && (*(e-1) == '\\')) {
01574          memmove(e - 1, e, strlen(e) + 1);
01575          work = e;
01576       } else {
01577          work = e + 1;
01578       }
01579    }
01580 
01581    return s;
01582 }


Generated on Thu Apr 16 06:34:06 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6