#include "asterisk/compat.h"
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <limits.h>
#include <time.h>
#include "asterisk/lock.h"
#include "asterisk/strings.h"
#include "asterisk/logger.h"
#include "asterisk/compiler.h"
#include "asterisk/localtime.h"
Go to the source code of this file.
Data Structures | |
struct | ast_flags |
struct | ast_hostent |
Defines | |
#define | ARRAY_LEN(a) (sizeof(a) / sizeof(a[0])) |
#define | ast_asprintf(ret, fmt,...) _ast_asprintf((ret), __FILE__, __LINE__, __PRETTY_FUNCTION__, fmt, __VA_ARGS__) |
#define | AST_BACKGROUND_STACKSIZE 240 * 1024 |
#define | ast_calloc(num, len) _ast_calloc((num), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__) |
#define | ast_calloc_cache(num, len) _ast_calloc((num), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__) |
#define | ast_clear_flag(p, flag) |
#define | ast_clear_flag_nonstd(p, flag) |
#define | ast_copy_flags(dest, src, flagz) |
#define | ast_copy_flags_nonstd(dest, src, flagz) |
#define | AST_FLAGS_ALL UINT_MAX |
#define | ast_free free |
free() wrapper | |
#define | ast_malloc(len) _ast_malloc((len), __FILE__, __LINE__, __PRETTY_FUNCTION__) |
A wrapper for malloc(). | |
#define | ast_pthread_create(a, b, c, d) |
#define | ast_pthread_create_background(a, b, c, d) |
#define | ast_realloc(p, len) _ast_realloc((p), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__) |
#define | ast_set2_flag(p, value, flag) |
#define | ast_set2_flag_nonstd(p, value, flag) |
#define | ast_set_flag(p, flag) |
#define | ast_set_flag_nonstd(p, flag) |
#define | ast_set_flags_to(p, flag, value) |
#define | AST_STACKSIZE 240 * 1024 |
#define | ast_strdup(str) _ast_strdup((str), __FILE__, __LINE__, __PRETTY_FUNCTION__) |
#define | ast_strdupa(s) |
#define | ast_strndup(str, len) _ast_strndup((str), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__) |
#define | ast_test_flag(p, flag) |
#define | ast_test_flag_nonstd(p, flag) ((p)->flags & (flag)) |
#define | ast_vasprintf(ret, fmt, ap) _ast_vasprintf((ret), __FILE__, __LINE__, __PRETTY_FUNCTION__, (fmt), (ap)) |
#define | inet_ntoa __dont__use__inet_ntoa__use__ast_inet_ntoa__instead__ |
#define | localtime_r __dont_use_localtime_r_use_ast_localtime_instead__ |
#define | MALLOC_FAILURE_MSG ast_log(LOG_ERROR, "Memory Allocation Failure in function %s at line %d of %s\n", func, lineno, file); |
Functions | |
int | ast_base64decode (unsigned char *dst, const char *src, int max) |
decode BASE64 encoded text | |
int | ast_base64encode (char *dst, const unsigned char *src, int srclen, int max) |
int | ast_base64encode_full (char *dst, const unsigned char *src, int srclen, int max, int linebreaks) |
encode text to BASE64 coding | |
int | ast_carefulwrite (int fd, char *s, int len, int timeoutms) |
Try to write string, but wait no more than ms milliseconds before timing out. | |
struct hostent * | ast_gethostbyname (const char *host, struct ast_hostent *hp) |
Re-entrant (thread safe) version of gethostbyname that replaces the standard gethostbyname (which is not thread safe). | |
const char * | ast_inet_ntoa (struct in_addr ia) |
thread-safe replacement for inet_ntoa(). | |
AST_INLINE_API (void *attribute_malloc _ast_malloc(size_t len, const char *file, int lineno, const char *func),{void *p;if(!(p=malloc(len))) MALLOC_FAILURE_MSG;return p;}) AST_INLINE_API(void *attribute_malloc _ast_calloc(size_t num | |
A wrapper for calloc(). | |
void | ast_md5_hash (char *output, char *input) |
Produce 32 char MD5 hash of value. | |
char * | ast_process_quotes_and_slashes (char *start, char find, char replace_with) |
Process a string to find and replace characters. | |
int | ast_pthread_create_stack (pthread_t *thread, pthread_attr_t *attr, void *(*start_routine)(void *), void *data, size_t stacksize, const char *file, const char *caller, int line, const char *start_fn) |
long int | ast_random (void) |
void | ast_register_thread (char *name) |
void | ast_sha1_hash (char *output, char *input) |
Produce 40 char SHA1 hash of value. | |
static force_inline void | ast_slinear_saturated_add (short *input, short *value) |
static force_inline void | ast_slinear_saturated_divide (short *input, short *value) |
static force_inline void | ast_slinear_saturated_multiply (short *input, short *value) |
void | ast_unregister_thread (void *id) |
void | ast_uri_decode (char *s) |
Decode URI, URN, URL (overwrite string). | |
char * | ast_uri_encode (const char *string, char *outbuf, int buflen, int doreserved) |
Turn text string to URI-encoded XX version At this point, we're converting from ISO-8859-x (8-bit), not UTF8 as in the SIP protocol spec If doreserved == 1 we will convert reserved characters also. RFC 2396, section 2.4 outbuf needs to have more memory allocated than the instring to have room for the expansion. Every char that is converted is replaced by three ASCII characters. | |
int | ast_utils_init (void) |
int | ast_wait_for_input (int fd, int ms) |
static force_inline int | inaddrcmp (const struct sockaddr_in *sin1, const struct sockaddr_in *sin2) |
int | test_for_thread_safety (void) |
Variables | |
unsigned int | __unsigned_int_flags_dummy |
size_t const char * | file |
size_t const char int const char * | func |
size_t | len |
size_t const char int | lineno |
Definition in file utils.h.
#define ARRAY_LEN | ( | a | ) | (sizeof(a) / sizeof(a[0])) |
#define ast_asprintf | ( | ret, | |||
fmt, | |||||
... | ) | _ast_asprintf((ret), __FILE__, __LINE__, __PRETTY_FUNCTION__, fmt, __VA_ARGS__) |
#define ast_calloc | ( | num, | |||
len | ) | _ast_calloc((num), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__) |
Referenced by __ast_context_create(), __ast_device_state_changed_literal(), __ast_format_register(), __ast_module_user_add(), __ast_pbx_run(), __sip_reliable_xmit(), accept_thread(), action_command(), action_originate(), add_agent(), add_realm_authentication(), add_sip_domain(), add_string_pool(), add_to_interfaces(), add_to_load_order(), aji_handle_message(), ALLOC_COMMENT(), alloc_jb_frame(), alloc_profile(), alloc_queue(), answer_exec_enable(), append_history_va(), append_mapping(), append_permission(), ast_add_extension2(), ast_add_hint(), ast_add_profile(), ast_autoservice_start(), ast_backtrace(), ast_category_new(), ast_cdr_alloc(), ast_cdr_detach(), ast_cdr_register(), ast_channel_alloc(), ast_channel_datastore_alloc(), ast_channel_register(), ast_channel_spy_add(), ast_channel_start_silence_generator(), ast_channel_whisper_start(), ast_config_new(), ast_context_add_ignorepat2(), ast_context_add_include2(), ast_context_add_switch2(), ast_devstate_add(), ast_devstate_prov_add(), ast_dial_append(), ast_dial_create(), ast_dnsmgr_get(), ast_dsp_new(), ast_extension_state_add(), ast_frame_header_new(), AST_INLINE_API(), ast_linear_stream(), ast_merge_contexts_and_delete(), ast_module_register(), ast_monitor_start(), ast_netsock_bindaddr(), ast_netsock_list_alloc(), ast_odbc_request_obj(), ast_park_call(), ast_pbx_outgoing_app(), ast_pbx_outgoing_exten(), ast_register_application(), ast_register_atexit(), ast_register_file_version(), ast_register_thread(), ast_rtcp_new(), ast_rtp_new_with_bindaddr(), ast_speech_new(), ast_udptl_new_with_bindaddr(), ast_var_assign(), ast_variable_new(), astman_append(), build_conf(), build_context(), build_device(), build_mapping(), build_peer(), build_user(), builtin_atxfer(), callerid_feed(), callerid_feed_jp(), callerid_new(), compile_script(), conf_run(), create_followme_number(), create_queue_member(), create_transaction(), create_trunk_ref(), defer_full_frame(), do_monitor(), do_proxy_auth(), dundi_answer_entity(), dundi_answer_query(), dundi_prop_precache(), dundi_send(), enum_newtoplev(), find_cache(), find_idle_thread(), find_or_create(), find_tpeer(), find_user_realtime(), findmeexec(), fixed_jb_new(), gen_alloc(), generic_http_callback(), get_filestream(), gtalk_add_candidate(), gtalk_alloc(), gtalk_create_candidates(), handle_add_indication(), http_root(), iax2_register(), iax_frame_new(), iax_park(), ind_load_module(), init_acf_query(), init_logger_chain(), init_manager(), io_context_create(), leave_voicemail(), load_config(), load_odbc_config(), local_alloc(), local_call(), make_entry(), make_logchannel(), milliwatt_alloc(), mkintf(), moh_add_file(), moh_class_malloc(), moh_files_alloc(), mohalloc(), new_iax(), newpvt(), osp_create_provider(), playtones_alloc(), queue_ringing_trunk(), realtime_multi_pgsql(), realtime_pgsql(), receive_ademco_contact_id(), register_translator(), reload(), req_alloc(), reschedule_precache(), sched_alloc(), sched_context_create(), sip_alloc(), sip_park(), sip_refer_allocate(), sip_register(), sip_request_call(), skinny_new(), skinny_req_parse(), sla_build_station(), sla_build_trunk(), sla_create_ringing_station(), sla_create_station_ref(), sla_queue_event_full(), sla_ring_station(), smdi_load(), smdi_read(), spawn_dp_lookup(), speech_background(), start_network_thread(), statechange_queue(), store_config(), temp_peer(), tonepair_alloc(), try_calling(), try_firmware(), try_load_key(), and vm_execmain().
#define ast_calloc_cache | ( | num, | |||
len | ) | _ast_calloc((num), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__) |
#define ast_clear_flag | ( | p, | |||
flag | ) |
Definition at line 83 of file utils.h.
Referenced by __ast_read(), aji_filter_roster(), aji_pruneregister(), ast_app_parse_options(), ast_bridge_call(), ast_cdr_reset(), ast_channel_bridge(), ast_channel_spy_add(), ast_channel_spy_read_frame(), ast_channel_undefer_dtmf(), ast_channel_whisper_stop(), ast_deactivate_generator(), ast_do_masquerade(), ast_jb_destroy(), ast_jb_put(), ast_rtp_stop(), ast_sendtext(), ast_speech_start(), ast_waitfor_nandfds(), ast_write(), authenticate_verify(), bridge_p2p_loop(), build_peer(), build_user(), builtin_atxfer(), change_hold_state(), channel_spy(), chanspy_exec(), check_goto_on_transfer(), check_pendings(), common_exec(), create_addr(), dictate_exec(), do_parking_thread(), dundi_lookup_local(), extenspy_exec(), find_conf(), find_conf_realtime(), forward_message(), handle_command_response(), handle_common_options(), handle_request_invite(), handle_request_refer(), iax2_destroy_helper(), init_acf_query(), linear_alloc(), local_ast_moh_stop(), local_attended_transfer(), local_hangup(), local_queue_frame(), main(), phone_read(), playtones_alloc(), process_sdp(), queue_frame_to_spies(), register_verify(), reload_config(), reset_transaction(), set_config(), set_config_flags(), sip_dtmfmode(), sip_hangup(), sip_no_debug(), sip_no_debug_deprecated(), socket_process(), speech_background(), update_call_counter(), wait_for_answer(), and zt_read().
#define ast_clear_flag_nonstd | ( | p, | |||
flag | ) |
Value:
do { \ ((p)->flags &= ~(flag)); \ } while(0)
Definition at line 128 of file utils.h.
Referenced by build_transactions(), cache_lookup_internal(), dundi_lookup_local(), dundi_prop_precache(), and handle_command_response().
#define ast_copy_flags | ( | dest, | |||
src, | |||||
flagz | ) |
Definition at line 90 of file utils.h.
Referenced by agent_read(), aji_create_client(), aji_filter_roster(), ast_cdr_reset(), ast_do_masquerade(), ast_feature_interpret(), build_peer(), build_user(), cache_lookup_internal(), check_access(), check_user_full(), create_addr(), create_addr_from_peer(), dundi_lookup_local(), find_callno(), iax2_request(), populate_defaults(), realtime_peer(), register_verify(), reload_config(), set_peer_defaults(), sip_alloc(), sip_poke_peer(), transmit_response_using_temp(), vm_exec(), and wait_for_answer().
#define ast_copy_flags_nonstd | ( | dest, | |||
src, | |||||
flagz | ) |
#define AST_FLAGS_ALL UINT_MAX |
Definition at line 144 of file utils.h.
Referenced by aji_create_client(), ast_app_parse_options(), ast_cdr_reset(), ast_feature_interpret(), builtin_atxfer(), cache_lookup_internal(), chanspy_exec(), check_goto_on_transfer(), dundi_lookup_local(), extenspy_exec(), populate_defaults(), reload_config(), and set_config_flags().
#define ast_free free |
free() wrapper
ast_free should be used when a function pointer for free() needs to be passed as the argument to a function. Otherwise, astmm will cause seg faults.
Definition at line 318 of file utils.h.
Referenced by action_command(), add_extensions(), ast_park_call(), ast_readfile(), ast_writefile(), do_parking_thread(), handle_deferred_full_frames(), pbx_load_config(), pbx_load_users(), register_peer_exten(), sla_build_station(), and sla_build_trunk().
#define ast_malloc | ( | len | ) | _ast_malloc((len), __FILE__, __LINE__, __PRETTY_FUNCTION__) |
A wrapper for malloc().
ast_malloc() is a wrapper for malloc() that will generate an Asterisk log message in the case that the allocation fails.
The argument and return value are the same as malloc()
Definition at line 333 of file utils.h.
Referenced by aji_act_hook(), append_event(), ast_append_ha(), ast_cli_completion_matches(), ast_db_gettree(), ast_duplicate_ha(), ast_frisolate(), ast_io_add(), ast_loader_register(), ast_manager_register2(), ast_pthread_create_stack(), ast_read_textfile(), ast_register_indication(), ast_register_verbose(), ast_safe_string_alloc(), ast_smoother_new(), build_route(), CB_INIT(), chandup(), cli_complete(), complete_queue_add_member(), convert(), destroy_trans(), find_user(), handle_commandmatchesarray(), html_translate(), iax2_setoption(), ind_load_module(), init_batch(), io_context_create(), jb_new(), load_config(), myrealloc(), pgsql_reconnect(), queue_put(), send_cwcidspill(), socket_receive_file_to_buff(), xml_translate(), zt_call(), zt_callwait(), and zt_sendtext().
#define ast_pthread_create | ( | a, | |||
b, | |||||
c, | |||||
d | ) |
Value:
ast_pthread_create_stack(a, b, c, d, \ 0, \ __FILE__, __FUNCTION__, \ __LINE__, #c)
Definition at line 281 of file utils.h.
Referenced by accept_thread(), action_originate(), ast_bridge_call_thread_launch(), ast_dial_run(), ast_pbx_outgoing_app(), ast_pbx_outgoing_exten(), ast_pbx_start(), dundi_answer_entity(), dundi_answer_query(), dundi_prop_precache(), find_idle_thread(), function_autopatchup(), handle_enbloc_call_message(), handle_hd_hf(), handle_init_event(), handle_offhook_message(), handle_soft_key_event_message(), handle_stimulus_message(), launch_service(), load_module(), local_dtmf_helper(), main(), rpt_master(), rpt_telemetry(), show_console(), sla_load_config(), spawn_dp_lookup(), start_network_thread(), test_for_thread_safety(), and zt_handle_event().
#define ast_pthread_create_background | ( | a, | |||
b, | |||||
c, | |||||
d | ) |
Value:
ast_pthread_create_stack(a, b, c, d, \ AST_BACKGROUND_STACKSIZE, \ __FILE__, __FUNCTION__, \ __LINE__, #c)
Definition at line 286 of file utils.h.
Referenced by accept_thread(), aji_reload(), ast_autoservice_start(), ast_cdr_submit_batch(), ast_device_state_engine_init(), ast_makesocket(), conf_run(), do_reload(), http_root(), http_server_start(), iax_park(), init_manager(), launch_monitor_thread(), listener(), load_module(), moh_register(), reload_config(), restart_monitor(), sip_park(), sla_handle_dial_state_event(), sla_station_exec(), smdi_load(), start_network_thread(), statechange_queue(), and store_config().
#define ast_realloc | ( | p, | |||
len | ) | _ast_realloc((p), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__) |
Referenced by ast_add_profile(), ast_cli_completion_matches(), ast_dynamic_str_thread_build_va(), ast_el_strtoarr(), ast_playtones_start(), CB_ADD(), CB_ADD_LEN(), cli_complete(), enum_callback(), handle_commandmatchesarray(), iax2_trunk_queue(), ind_load_module(), io_grow(), LLB_ADD(), moh_add_file(), myrealloc(), and socket_receive_file_to_buff().
#define ast_set2_flag | ( | p, | |||
value, | |||||
flag | ) |
Definition at line 100 of file utils.h.
Referenced by __ast_pbx_run(), _macro_exec(), aji_create_client(), aji_load_config(), apply_option(), apply_outgoing(), ast_jb_read_conf(), ast_readconfig(), ast_rtp_setdtmf(), ast_rtp_setdtmfcompensate(), ast_rtp_setstun(), build_peer(), build_user(), check_access(), do_reload(), find_user(), forkcdr_exec(), handle_common_options(), load_config(), load_module(), load_moh_classes(), pbx_load_config(), reload_config(), set_config(), and sip_alloc().
#define ast_set_flag | ( | p, | |||
flag | ) |
Definition at line 76 of file utils.h.
Referenced by __ast_pbx_run(), __ast_read(), __expire_registry(), __sip_reliable_xmit(), _macro_exec(), app_exec(), apply_peer(), ast_app_parse_options(), ast_call(), ast_cdr_detach(), ast_cdr_fork(), ast_cdr_merge(), ast_cdr_reset(), ast_channel_bridge(), ast_channel_defer_dtmf(), ast_channel_spy_add(), ast_channel_whisper_start(), ast_do_masquerade(), ast_hangup(), ast_jb_do_usecheck(), ast_jb_put(), ast_rtp_bridge(), ast_rtp_new_init(), ast_rtp_new_with_bindaddr(), ast_rtp_raw_write(), ast_rtp_read(), ast_speech_change_state(), ast_waitfor_nandfds(), authenticate_reply(), authenticate_request(), bridge_p2p_rtp_write(), build_peer(), build_user(), builtin_atxfer(), change_hold_state(), channel_spy(), chanspy_exec(), check_access(), check_availability(), check_bridge(), check_user_full(), check_via(), common_exec(), conf_exec(), create_addr_from_peer(), create_transaction(), decrypt_frame(), delete_users(), destroy_trans(), dial_trunk(), dictate_exec(), do_parking_thread(), do_register(), dundi_encrypt(), dundi_lookup_local(), dundi_send(), extenspy_exec(), find_call(), find_user_realtime(), handle_command_response(), handle_common_options(), handle_invite_replaces(), handle_request(), handle_request_refer(), handle_request_subscribe(), handle_response(), handle_response_invite(), handle_response_peerpoke(), handle_response_refer(), handle_response_register(), iax2_destroy(), iax2_predestroy(), iax2_provision(), iax2_prune_realtime(), init_acf_query(), init_outgoing(), launch_monitor_thread(), leave_voicemail(), linear_alloc(), load_config(), local_alloc(), local_ast_moh_start(), local_attended_transfer(), local_call(), local_hangup(), local_queue_frame(), main(), moh_register(), nocdr_exec(), park_exec(), playtones_alloc(), post_cdr(), process_rfc3389(), process_sdp(), qualify_peer(), queue_frame_to_spies(), realtime_peer(), realtime_user(), register_verify(), reload_config(), retrans_pkt(), run_station(), set_config(), set_config_flags(), set_insecure_flags(), sip_alreadygone(), sip_call(), sip_do_debug(), sip_do_debug_deprecated(), sip_do_debug_ip(), sip_do_debug_peer(), sip_dtmfmode(), sip_handle_t38_reinvite(), sip_hangup(), sip_indicate(), sip_poke_peer(), sip_read(), sip_reg_timeout(), sip_request_call(), sip_send_mwi_to_peer(), sip_set_rtp_peer(), sip_set_udptl_peer(), sip_write(), sipsock_read(), sla_station_exec(), sla_trunk_exec(), socket_process(), temp_peer(), tonepair_alloc(), transmit_register(), transmit_reinvite_with_sdp(), transmit_reinvite_with_t38_sdp(), transmit_response_using_temp(), try_calling(), update_call_counter(), vm_exec(), vm_execmain(), and zt_read().
#define ast_set_flag_nonstd | ( | p, | |||
flag | ) |
Value:
do { \ ((p)->flags |= (flag)); \ } while(0)
Definition at line 124 of file utils.h.
Referenced by dundi_lookup_internal(), dundi_query_eid_internal(), and handle_command_response().
#define ast_set_flags_to | ( | p, | |||
flag, | |||||
value | ) |
#define AST_STACKSIZE 240 * 1024 |
#define ast_strdup | ( | str | ) | _ast_strdup((str), __FILE__, __LINE__, __PRETTY_FUNCTION__) |
Referenced by __ast_cli_register(), __oh323_new(), _macro_exec(), add_to_load_order(), aji_handle_message(), aji_handle_presence(), answer_exec_enable(), ast_add_profile(), ast_channel_alloc(), ast_channel_datastore_alloc(), ast_cli_complete(), ast_complete_channels(), ast_ext_ctx(), ast_frisolate(), ast_iax2_new(), ast_register_indication(), ast_set_callerid(), autoanswer_complete(), begin_dial(), callerid_write(), complete_agent_logoff_cmd(), complete_iax2_show_peer(), complete_meetmecmd(), complete_peer_helper(), complete_queue(), complete_queue_add_member(), complete_queue_remove_member(), complete_show_dialplan_context(), complete_show_mancmd(), complete_show_version_files(), complete_show_version_files_deprecated(), complete_sip_peer(), complete_sip_user(), complete_sipch(), complete_sipnotify(), complete_skinny_reset(), complete_voicemail_show_users(), dial_trunk(), features_call(), gtalk_new(), init_manager(), load_config(), local_call(), mgcp_new(), misdn_new(), moh_add_file(), oss_new(), parse_args(), pbx_load_config(), phone_new(), process_my_load_module(), register_peer_exten(), ring_entry(), sip_new(), skinny_new(), sla_build_station(), sla_build_trunk(), sla_ring_station(), spawn_dp_lookup(), split_ec(), start_monitor_action(), store_config(), store_mixer(), wait_for_answer(), zt_handle_event(), and zt_new().
#define ast_strdupa | ( | s | ) |
Referenced by __ast_play_and_record(), __login_exec(), _macro_exec(), _while_exec(), acf_channel_read(), acf_odbc_write(), action_agents(), action_getvar(), add_agent(), admin_exec(), advanced_options(), agent_logoff_maintenance(), aji_send_exec(), aji_status_exec(), answer_exec_enable(), app_exec(), append_mailbox(), apply_options(), aqm_exec(), array(), ast_bridge_call(), ast_callerid_split(), ast_device_state(), ast_device_state_changed_literal(), ast_feature_interpret(), ast_filehelper(), ast_get_group(), ast_monitor_start(), ast_netsock_bind(), ast_parse_allow_disallow(), ast_parseable_goto(), ast_playtones_start(), ast_register_file_version(), ast_writefile(), astman_get_variables(), asyncgoto_exec(), auth_exec(), authenticate_verify(), background_detect_exec(), build_channels(), build_mapping(), build_peer(), build_user(), builtin_automonitor(), cache_get_callno_locked(), chanavail_exec(), changethread(), channel_spy(), chanspy_exec(), check_access(), check_day(), check_dow(), check_goto_on_transfer(), check_month(), check_switch_expr(), check_timerange(), check_user_full(), cli_audio_convert(), cli_audio_convert_deprecated(), common_exec(), complete_meetmecmd(), conf_exec(), conf_run(), controlplayback_exec(), count_exec(), create_addr(), create_addr_from_peer(), cut_internal(), decrypt_frame(), del_exec(), deltree_exec(), dial_trunk(), dictate_exec(), directory_exec(), disa_exec(), do_message(), do_parking_thread(), do_say(), exec_exec(), execif_exec(), extenspy_exec(), features_alloc(), festival_exec(), find_conf(), find_conf_realtime(), find_gtalk(), find_sdp(), findmeexec(), forward_message(), function_agent(), function_autopatchup(), function_iaxpeer(), get_refer_info(), get_wait_interval(), gosubif_exec(), gtalk_alloc(), gtalk_new(), gtalk_request(), handle_request_invite(), handle_request_subscribe(), handle_show_dialplan(), hasvoicemail_exec(), iax2_call(), iax2_devicestate(), iax2_prov_app(), iax2_request(), ind_load_module(), isAnsweringMachine(), ivr_dispatch(), launch_monitor_thread(), launch_netscript(), load_config(), local_devicestate(), log_exec(), macroif_exec(), meetmemute(), metermaidstate(), mgcp_devicestate(), mixmonitor_exec(), notify_new_message(), orig_app(), orig_exten(), ospauth_exec(), ospfinished_exec(), osplookup_exec(), ospnext_exec(), page_exec(), parkandannounce_exec(), parse_moved_contact(), parse_sip_options(), pbx_builtin_background(), pbx_builtin_execiftime(), pbx_builtin_gotoif(), pbx_builtin_gotoiftime(), pbx_builtin_importvar(), pbx_builtin_pushvar_helper(), pbx_builtin_resetcdr(), pbx_builtin_setvar(), pbx_builtin_setvar_helper(), pbx_builtin_waitexten(), pbx_retrieve_variable(), peer_set_srcaddr(), pickup_exec(), play_message(), playback_exec(), pqm_exec(), prep_email_sub_vars(), privacy_exec(), process_sdp(), ql_exec(), queue_exec(), queue_set_param(), random_exec(), read_exec(), readfile_exec(), realtime_common(), realtime_exec(), realtime_multi_odbc(), realtime_multi_pgsql(), realtime_update_exec(), record_exec(), register_verify(), reload_config(), reload_followme(), resource_name_match(), retrydial_exec(), rpt_do_stats(), rpt_tele_thread(), rqm_exec(), sayunixtime_exec(), send_tone_telemetry(), senddtmf_exec(), sendimage_exec(), sendtext_exec(), sendurl_exec(), set_address_from_contact(), set_config_flags(), setcallerid_exec(), settransfercapability_exec(), sip_devicestate(), sip_sipredirect(), sla_add_trunk_to_station(), sla_check_device(), sla_queue_event_conf(), sla_ring_station(), sla_state(), sla_station_exec(), socket_process(), softhangup_exec(), sort_internal(), speech_background(), speech_load(), start_monitor_exec(), telem_lookup(), transfer_exec(), transmit_invite(), transmit_refer(), try_calling(), tryexec_exec(), upqm_exec(), userevent_exec(), verbose_exec(), vm_box_exists(), vm_exec(), vm_execmain(), vmauthenticate(), wait_for_winner(), zapras_exec(), and zt_request().
#define ast_strndup | ( | str, | |||
len | ) | _ast_strndup((str), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__) |
Referenced by ast_recvtext().
#define ast_test_flag | ( | p, | |||
flag | ) |
Definition at line 69 of file utils.h.
Referenced by __ast_pbx_run(), __ast_read(), __do_deliver(), __expire_registry(), __get_from_jb(), __iax2_show_peers(), __sip_ack(), __sip_destroy(), __sip_pretend_ack(), __sip_reliable_xmit(), __sip_semi_ack(), __sip_show_channels(), _macro_exec(), _sip_show_peer(), _sip_show_peers(), acf_odbc_read(), add_codec_to_sdp(), add_sdp(), agent_new(), aji_pruneregister(), app_exec(), ast_answer(), ast_autoservice_stop(), ast_bridge_call(), ast_call(), ast_cdr_appenduserfield(), ast_cdr_busy(), ast_cdr_failed(), ast_cdr_fork(), ast_cdr_free(), ast_cdr_init(), ast_cdr_merge(), ast_cdr_noanswer(), ast_cdr_reset(), ast_cdr_setaccount(), ast_cdr_setamaflags(), ast_cdr_setapp(), ast_cdr_setcid(), ast_cdr_setdestchan(), ast_cdr_setuserfield(), ast_cdr_start(), ast_cdr_update(), ast_channel_bridge(), ast_channel_defer_dtmf(), ast_channel_spy_add(), ast_channel_spy_free(), ast_channel_spy_read_frame(), ast_cli_netstats(), ast_do_masquerade(), ast_explicit_goto(), ast_feature_interpret(), ast_hangup(), ast_indicate_data(), ast_jb_destroy(), ast_jb_do_usecheck(), ast_jb_get_and_deliver(), ast_jb_get_when_to_wakeup(), ast_jb_put(), ast_moh_files_next(), ast_queue_frame(), ast_readstring_full(), ast_rtp_bridge(), ast_rtp_early_bridge(), ast_rtp_getnat(), ast_rtp_make_compatible(), ast_rtp_raw_write(), ast_sendtext(), ast_softhangup_nolock(), ast_speech_results_get(), ast_transfer(), ast_waitfordigit_full(), ast_write(), auth_exec(), authenticate_reply(), authenticate_request(), authenticate_verify(), bridge_native_loop(), bridge_p2p_rtp_write(), build_peer(), build_radius_record(), build_user(), build_via(), cdr_read(), cdr_write(), channel_spy(), chanspy_exec(), check_access(), check_bridge(), check_pendings(), check_post(), check_user_full(), common_exec(), complete_sip_peer(), complete_sip_user(), conf_exec(), copy_via_headers(), create_addr(), create_addr_from_peer(), create_jb(), decrypt_frame(), destroy_association(), destroy_trans(), dictate_exec(), do_monitor(), do_register_auth(), does_peer_need_mwi(), dundi_encrypt(), dundi_exec(), dundi_helper(), dundi_lookup_local(), dundi_lookup_thread(), dundi_precache_thread(), dundi_query_thread(), dundi_rexmit(), dundi_send(), dundifunc_read(), expire_register(), extenspy_exec(), feature_exec_app(), find_cache(), find_conf(), find_conf_realtime(), find_or_create(), find_user(), find_user_realtime(), forward_message(), free_user(), function_iaxpeer(), function_sippeer(), get_destination(), get_sip_pvt_byid_locked(), handle_command_response(), handle_frame(), handle_request(), handle_request_bye(), handle_request_cancel(), handle_request_info(), handle_request_invite(), handle_request_message(), handle_request_refer(), handle_request_register(), handle_request_subscribe(), handle_response(), handle_response_invite(), handle_showchan(), handle_showchan_deprecated(), iax2_bridge(), iax2_call(), iax2_destroy_helper(), iax2_devicestate(), iax2_getpeername(), iax2_getpeertrunk(), iax2_hangup(), iax2_predestroy(), iax2_prune_realtime(), iax2_request(), iax2_send(), iax2_show_channels(), iax2_show_peer(), iax2_show_users(), iax2_trunk_queue(), iax2_write(), initialize_initreq(), initreqprep(), leave_voicemail(), load_resource(), local_hangup(), local_queue_frame(), local_write(), make_email_file(), mixmonitor_exec(), mixmonitor_thread(), moh_classes_show(), moh_files_alloc(), moh_on_off(), notify_new_message(), p2p_callback_disable(), page_exec(), parse_moved_contact(), parse_register_contact(), pbx_builtin_background(), pbx_builtin_waitexten(), play_message(), play_record_review(), post_cdr(), precache_transactions(), process_rfc2833(), process_rfc3389(), process_sdp(), prune_peers(), prune_users(), queue_frame_to_spies(), read_exec(), realtime_peer(), realtime_update_peer(), realtime_user(), reg_source_db(), register_verify(), registry_authrequest(), remove_from_queue(), reqprep(), respprep(), retrans_pkt(), retrydial_exec(), schedule_delivery(), send_dtmf(), send_request(), send_response(), send_trunk(), sendmail(), serialize_showchan(), set_address_from_contact(), set_config(), set_config_flags(), sip_addrcmp(), sip_alloc(), sip_destroy_peer(), sip_destroy_user(), sip_dtmfmode(), sip_fixup(), sip_get_rtp_peer(), sip_get_udptl_peer(), sip_get_vrtp_peer(), sip_handle_t38_reinvite(), sip_hangup(), sip_indicate(), sip_nat_mode(), sip_new(), sip_prune_realtime(), sip_read(), sip_real_dst(), sip_reregister(), sip_rtp_read(), sip_scheddestroy(), sip_senddigit_begin(), sip_senddigit_end(), sip_set_rtp_peer(), sip_set_udptl_peer(), sip_show_channel(), sip_show_settings(), sip_show_users(), sip_write(), sipsock_read(), socket_process(), spawn_mp3(), speech_background(), speech_read(), spy_detach(), start_spying(), startmon(), transmit_notify_with_mwi(), transmit_refer(), transmit_register(), transmit_reinvite_with_sdp(), transmit_reinvite_with_t38_sdp(), transmit_response_using_temp(), transmit_response_with_sdp(), try_calling(), update_call_counter(), update_peer(), update_registry(), valid_priv_reply(), vm_exec(), vm_execmain(), vm_intro(), vm_newuser(), and wait_for_answer().
#define ast_test_flag_nonstd | ( | p, | |||
flag | ) | ((p)->flags & (flag)) |
Definition at line 121 of file utils.h.
Referenced by cache_save_hint(), dundi_lookup_thread(), dundi_precache_thread(), and handle_command_response().
#define ast_vasprintf | ( | ret, | |||
fmt, | |||||
ap | ) | _ast_vasprintf((ret), __FILE__, __LINE__, __PRETTY_FUNCTION__, (fmt), (ap)) |
#define inet_ntoa __dont__use__inet_ntoa__use__ast_inet_ntoa__instead__ |
#define localtime_r __dont_use_localtime_r_use_ast_localtime_instead__ |
int ast_base64decode | ( | unsigned char * | dst, | |
const char * | src, | |||
int | max | |||
) |
decode BASE64 encoded text
Definition at line 328 of file utils.c.
00329 { 00330 int cnt = 0; 00331 unsigned int byte = 0; 00332 unsigned int bits = 0; 00333 int incnt = 0; 00334 while(*src && (cnt < max)) { 00335 /* Shift in 6 bits of input */ 00336 byte <<= 6; 00337 byte |= (b2a[(int)(*src)]) & 0x3f; 00338 bits += 6; 00339 src++; 00340 incnt++; 00341 /* If we have at least 8 bits left over, take that character 00342 off the top */ 00343 if (bits >= 8) { 00344 bits -= 8; 00345 *dst = (byte >> bits) & 0xff; 00346 dst++; 00347 cnt++; 00348 } 00349 } 00350 /* Dont worry about left over bits, they're extra anyway */ 00351 return cnt; 00352 }
int ast_base64encode | ( | char * | dst, | |
const unsigned char * | src, | |||
int | srclen, | |||
int | max | |||
) |
Definition at line 406 of file utils.c.
References ast_base64encode_full().
00407 { 00408 return ast_base64encode_full(dst, src, srclen, max, 0); 00409 }
int ast_base64encode_full | ( | char * | dst, | |
const unsigned char * | src, | |||
int | srclen, | |||
int | max, | |||
int | linebreaks | |||
) |
encode text to BASE64 coding
Definition at line 355 of file utils.c.
00356 { 00357 int cnt = 0; 00358 int col = 0; 00359 unsigned int byte = 0; 00360 int bits = 0; 00361 int cntin = 0; 00362 /* Reserve space for null byte at end of string */ 00363 max--; 00364 while ((cntin < srclen) && (cnt < max)) { 00365 byte <<= 8; 00366 byte |= *(src++); 00367 bits += 8; 00368 cntin++; 00369 if ((bits == 24) && (cnt + 4 <= max)) { 00370 *dst++ = base64[(byte >> 18) & 0x3f]; 00371 *dst++ = base64[(byte >> 12) & 0x3f]; 00372 *dst++ = base64[(byte >> 6) & 0x3f]; 00373 *dst++ = base64[byte & 0x3f]; 00374 cnt += 4; 00375 col += 4; 00376 bits = 0; 00377 byte = 0; 00378 } 00379 if (linebreaks && (cnt < max) && (col == 64)) { 00380 *dst++ = '\n'; 00381 cnt++; 00382 col = 0; 00383 } 00384 } 00385 if (bits && (cnt + 4 <= max)) { 00386 /* Add one last character for the remaining bits, 00387 padding the rest with 0 */ 00388 byte <<= 24 - bits; 00389 *dst++ = base64[(byte >> 18) & 0x3f]; 00390 *dst++ = base64[(byte >> 12) & 0x3f]; 00391 if (bits == 16) 00392 *dst++ = base64[(byte >> 6) & 0x3f]; 00393 else 00394 *dst++ = '='; 00395 *dst++ = '='; 00396 cnt += 4; 00397 } 00398 if (linebreaks && (cnt < max)) { 00399 *dst++ = '\n'; 00400 cnt++; 00401 } 00402 *dst = '\0'; 00403 return cnt; 00404 }
int ast_carefulwrite | ( | int | fd, | |
char * | s, | |||
int | len, | |||
int | timeoutms | |||
) |
Try to write string, but wait no more than ms milliseconds before timing out.
ast_carefulwrite
Definition at line 838 of file utils.c.
References pollfd::events, pollfd::fd, poll(), and POLLOUT.
00839 { 00840 /* Try to write string, but wait no more than ms milliseconds 00841 before timing out */ 00842 int res = 0; 00843 struct pollfd fds[1]; 00844 while (len) { 00845 res = write(fd, s, len); 00846 if ((res < 0) && (errno != EAGAIN)) { 00847 return -1; 00848 } 00849 if (res < 0) 00850 res = 0; 00851 len -= res; 00852 s += res; 00853 res = 0; 00854 if (len) { 00855 fds[0].fd = fd; 00856 fds[0].events = POLLOUT; 00857 /* Wait until writable again */ 00858 res = poll(fds, 1, timeoutms); 00859 if (res < 1) 00860 return -1; 00861 } 00862 } 00863 return res; 00864 }
struct hostent* ast_gethostbyname | ( | const char * | host, | |
struct ast_hostent * | hp | |||
) | [read] |
Re-entrant (thread safe) version of gethostbyname that replaces the standard gethostbyname (which is not thread safe).
Definition at line 184 of file utils.c.
References ast_hostent::buf, gethostbyname_r(), ast_hostent::hp, and s.
00185 { 00186 int res; 00187 int herrno; 00188 int dots=0; 00189 const char *s; 00190 struct hostent *result = NULL; 00191 /* Although it is perfectly legitimate to lookup a pure integer, for 00192 the sake of the sanity of people who like to name their peers as 00193 integers, we break with tradition and refuse to look up a 00194 pure integer */ 00195 s = host; 00196 res = 0; 00197 while(s && *s) { 00198 if (*s == '.') 00199 dots++; 00200 else if (!isdigit(*s)) 00201 break; 00202 s++; 00203 } 00204 if (!s || !*s) { 00205 /* Forge a reply for IP's to avoid octal IP's being interpreted as octal */ 00206 if (dots != 3) 00207 return NULL; 00208 memset(hp, 0, sizeof(struct ast_hostent)); 00209 hp->hp.h_addrtype = AF_INET; 00210 hp->hp.h_addr_list = (void *) hp->buf; 00211 hp->hp.h_addr = hp->buf + sizeof(void *); 00212 if (inet_pton(AF_INET, host, hp->hp.h_addr) > 0) 00213 return &hp->hp; 00214 return NULL; 00215 00216 } 00217 #ifdef HAVE_GETHOSTBYNAME_R_5 00218 result = gethostbyname_r(host, &hp->hp, hp->buf, sizeof(hp->buf), &herrno); 00219 00220 if (!result || !hp->hp.h_addr_list || !hp->hp.h_addr_list[0]) 00221 return NULL; 00222 #else 00223 res = gethostbyname_r(host, &hp->hp, hp->buf, sizeof(hp->buf), &result, &herrno); 00224 00225 if (res || !result || !hp->hp.h_addr_list || !hp->hp.h_addr_list[0]) 00226 return NULL; 00227 #endif 00228 return &hp->hp; 00229 }
const char* ast_inet_ntoa | ( | struct in_addr | ia | ) |
thread-safe replacement for inet_ntoa().
Definition at line 495 of file utils.c.
00496 { 00497 char *buf; 00498 00499 if (!(buf = ast_threadstorage_get(&inet_ntoa_buf, INET_ADDRSTRLEN))) 00500 return ""; 00501 00502 return inet_ntop(AF_INET, &ia, buf, INET_ADDRSTRLEN); 00503 }
AST_INLINE_API | ( | void *attribute_malloc | _ast_malloc(size_t len, const char *file, int lineno, const char *func) | ) |
A wrapper for calloc().
ast_calloc() is a wrapper for calloc() that will generate an Asterisk log message in the case that the allocation fails.
The arguments and return value are the same as calloc()
void ast_md5_hash | ( | char * | output, | |
char * | input | |||
) |
Produce 32 char MD5 hash of value.
Definition at line 294 of file utils.c.
References MD5Final(), MD5Init(), and MD5Update().
00295 { 00296 struct MD5Context md5; 00297 unsigned char digest[16]; 00298 char *ptr; 00299 int x; 00300 00301 MD5Init(&md5); 00302 MD5Update(&md5, (unsigned char *)input, strlen(input)); 00303 MD5Final(digest, &md5); 00304 ptr = output; 00305 for (x = 0; x < 16; x++) 00306 ptr += sprintf(ptr, "%2.2x", digest[x]); 00307 }
char* ast_process_quotes_and_slashes | ( | char * | start, | |
char | find, | |||
char | replace_with | |||
) |
Process a string to find and replace characters.
start | The string to analyze | |
find | The character to find | |
replace_with | The character that will replace the one we are looking for |
Definition at line 1013 of file utils.c.
01014 { 01015 char *dataPut = start; 01016 int inEscape = 0; 01017 int inQuotes = 0; 01018 01019 for (; *start; start++) { 01020 if (inEscape) { 01021 *dataPut++ = *start; /* Always goes verbatim */ 01022 inEscape = 0; 01023 } else { 01024 if (*start == '\\') { 01025 inEscape = 1; /* Do not copy \ into the data */ 01026 } else if (*start == '\'') { 01027 inQuotes = 1 - inQuotes; /* Do not copy ' into the data */ 01028 } else { 01029 /* Replace , with |, unless in quotes */ 01030 *dataPut++ = inQuotes ? *start : ((*start == find) ? replace_with : *start); 01031 } 01032 } 01033 } 01034 if (start != dataPut) 01035 *dataPut = 0; 01036 return dataPut; 01037 }
int ast_pthread_create_stack | ( | pthread_t * | thread, | |
pthread_attr_t * | attr, | |||
void *(*)(void *) | start_routine, | |||
void * | data, | |||
size_t | stacksize, | |||
const char * | file, | |||
const char * | caller, | |||
int | line, | |||
const char * | start_fn | |||
) |
Definition at line 784 of file utils.c.
References asprintf, ast_log(), ast_malloc, AST_STACKSIZE, thr_arg::data, dummy_start(), LOG_WARNING, thr_arg::name, pthread_create, and thr_arg::start_routine.
00787 { 00788 #if !defined(LOW_MEMORY) 00789 struct thr_arg *a; 00790 #endif 00791 00792 if (!attr) { 00793 attr = alloca(sizeof(*attr)); 00794 pthread_attr_init(attr); 00795 } 00796 00797 #ifdef __linux__ 00798 /* On Linux, pthread_attr_init() defaults to PTHREAD_EXPLICIT_SCHED, 00799 which is kind of useless. Change this here to 00800 PTHREAD_INHERIT_SCHED; that way the -p option to set realtime 00801 priority will propagate down to new threads by default. 00802 This does mean that callers cannot set a different priority using 00803 PTHREAD_EXPLICIT_SCHED in the attr argument; instead they must set 00804 the priority afterwards with pthread_setschedparam(). */ 00805 if ((errno = pthread_attr_setinheritsched(attr, PTHREAD_INHERIT_SCHED))) 00806 ast_log(LOG_WARNING, "pthread_attr_setinheritsched: %s\n", strerror(errno)); 00807 #endif 00808 00809 if (!stacksize) 00810 stacksize = AST_STACKSIZE; 00811 00812 if ((errno = pthread_attr_setstacksize(attr, stacksize ? stacksize : AST_STACKSIZE))) 00813 ast_log(LOG_WARNING, "pthread_attr_setstacksize: %s\n", strerror(errno)); 00814 00815 #if !defined(LOW_MEMORY) 00816 if ((a = ast_malloc(sizeof(*a)))) { 00817 a->start_routine = start_routine; 00818 a->data = data; 00819 start_routine = dummy_start; 00820 asprintf(&a->name, "%-20s started at [%5d] %s %s()", 00821 start_fn, line, file, caller); 00822 data = a; 00823 } 00824 #endif /* !LOW_MEMORY */ 00825 00826 return pthread_create(thread, attr, start_routine, data); /* We're in ast_pthread_create, so it's okay */ 00827 }
long int ast_random | ( | void | ) |
Definition at line 1003 of file utils.c.
References ast_mutex_lock(), and ast_mutex_unlock().
01004 { 01005 long int res; 01006 ast_mutex_lock(&randomlock); 01007 res = random(); 01008 ast_mutex_unlock(&randomlock); 01009 return res; 01010 }
void ast_register_thread | ( | char * | name | ) |
Definition at line 304 of file asterisk.c.
References ast_calloc, AST_LIST_INSERT_HEAD, AST_LIST_LOCK, and AST_LIST_UNLOCK.
00305 { 00306 struct thread_list_t *new = ast_calloc(1, sizeof(*new)); 00307 00308 if (!new) 00309 return; 00310 new->id = pthread_self(); 00311 new->name = name; /* steal the allocated memory for the thread name */ 00312 AST_LIST_LOCK(&thread_list); 00313 AST_LIST_INSERT_HEAD(&thread_list, new, list); 00314 AST_LIST_UNLOCK(&thread_list); 00315 }
void ast_sha1_hash | ( | char * | output, | |
char * | input | |||
) |
Produce 40 char SHA1 hash of value.
Definition at line 310 of file utils.c.
References SHA1Input(), SHA1Reset(), and SHA1Result().
00311 { 00312 struct SHA1Context sha; 00313 char *ptr; 00314 int x; 00315 uint8_t Message_Digest[20]; 00316 00317 SHA1Reset(&sha); 00318 00319 SHA1Input(&sha, (const unsigned char *) input, strlen(input)); 00320 00321 SHA1Result(&sha, Message_Digest); 00322 ptr = output; 00323 for (x = 0; x < 20; x++) 00324 ptr += sprintf(ptr, "%2.2x", Message_Digest[x]); 00325 }
static force_inline void ast_slinear_saturated_add | ( | short * | input, | |
short * | value | |||
) | [static] |
static force_inline void ast_slinear_saturated_divide | ( | short * | input, | |
short * | value | |||
) | [static] |
Definition at line 216 of file utils.h.
Referenced by ast_frame_adjust_volume().
00217 { 00218 *input /= *value; 00219 }
static force_inline void ast_slinear_saturated_multiply | ( | short * | input, | |
short * | value | |||
) | [static] |
void ast_unregister_thread | ( | void * | id | ) |
Definition at line 317 of file asterisk.c.
References AST_LIST_LOCK, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, AST_LIST_UNLOCK, and free.
00318 { 00319 struct thread_list_t *x; 00320 00321 AST_LIST_LOCK(&thread_list); 00322 AST_LIST_TRAVERSE_SAFE_BEGIN(&thread_list, x, list) { 00323 if ((void *) x->id == id) { 00324 AST_LIST_REMOVE_CURRENT(&thread_list, list); 00325 break; 00326 } 00327 } 00328 AST_LIST_TRAVERSE_SAFE_END; 00329 AST_LIST_UNLOCK(&thread_list); 00330 if (x) { 00331 free(x->name); 00332 free(x); 00333 } 00334 }
void ast_uri_decode | ( | char * | s | ) |
Decode URI, URN, URL (overwrite string).
s | String to be decoded |
Definition at line 478 of file utils.c.
00479 { 00480 char *o; 00481 unsigned int tmp; 00482 00483 for (o = s; *s; s++, o++) { 00484 if (*s == '%' && strlen(s) > 2 && sscanf(s + 1, "%2x", &tmp) == 1) { 00485 /* have '%', two chars and correct parsing */ 00486 *o = tmp; 00487 s += 2; /* Will be incremented once more when we break out */ 00488 } else /* all other cases, just copy */ 00489 *o = *s; 00490 } 00491 *o = '\0'; 00492 }
char* ast_uri_encode | ( | const char * | string, | |
char * | outbuf, | |||
int | buflen, | |||
int | doreserved | |||
) |
Turn text string to URI-encoded XX version At this point, we're converting from ISO-8859-x (8-bit), not UTF8 as in the SIP protocol spec If doreserved == 1 we will convert reserved characters also. RFC 2396, section 2.4 outbuf needs to have more memory allocated than the instring to have room for the expansion. Every char that is converted is replaced by three ASCII characters.
ast_uri_encode
string | String to be converted | |
outbuf | Resulting encoded string | |
buflen | Size of output buffer | |
doreserved | Convert reserved characters |
Definition at line 447 of file utils.c.
00448 { 00449 char *reserved = ";/?:@&=+$, "; /* Reserved chars */ 00450 00451 const char *ptr = string; /* Start with the string */ 00452 char *out = NULL; 00453 char *buf = NULL; 00454 00455 ast_copy_string(outbuf, string, buflen); 00456 00457 /* If there's no characters to convert, just go through and don't do anything */ 00458 while (*ptr) { 00459 if (((unsigned char) *ptr) > 127 || (doreserved && strchr(reserved, *ptr)) ) { 00460 /* Oops, we need to start working here */ 00461 if (!buf) { 00462 buf = outbuf; 00463 out = buf + (ptr - string) ; /* Set output ptr */ 00464 } 00465 out += sprintf(out, "%%%02x", (unsigned char) *ptr); 00466 } else if (buf) { 00467 *out = *ptr; /* Continue copying the string */ 00468 out++; 00469 } 00470 ptr++; 00471 } 00472 if (buf) 00473 *out = '\0'; 00474 return outbuf; 00475 }
int ast_utils_init | ( | void | ) |
Definition at line 1246 of file utils.c.
References ast_cli_register_multiple(), and base64_init().
01247 { 01248 base64_init(); 01249 #ifdef DEBUG_THREADS 01250 ast_cli_register_multiple(utils_cli, sizeof(utils_cli) / sizeof(utils_cli[0])); 01251 #endif 01252 return 0; 01253 }
int ast_wait_for_input | ( | int | fd, | |
int | ms | |||
) |
static force_inline int inaddrcmp | ( | const struct sockaddr_in * | sin1, | |
const struct sockaddr_in * | sin2 | |||
) | [static] |
Compares the source address and port of two sockaddr_in
Definition at line 260 of file utils.h.
Referenced by ast_netsock_find(), ast_udptl_bridge(), bridge_native_loop(), find_tpeer(), find_transaction(), handle_command_response(), iax2_ack_registry(), oh323_addrcmp(), parse_register_contact(), register_verify(), registry_rerequest(), sip_addrcmp(), socket_process(), socket_read(), and update_registry().
00261 { 00262 return ((sin1->sin_addr.s_addr != sin2->sin_addr.s_addr) 00263 || (sin1->sin_port != sin2->sin_port)); 00264 }
int test_for_thread_safety | ( | void | ) |
Definition at line 265 of file utils.c.
References ast_mutex_lock(), ast_mutex_unlock(), ast_pthread_create, and test_thread_body().
00266 { 00267 ast_mutex_lock(&test_lock2); 00268 ast_mutex_lock(&test_lock); 00269 lock_count += 1; 00270 ast_mutex_lock(&test_lock); 00271 lock_count += 1; 00272 ast_pthread_create(&test_thread, NULL, test_thread_body, NULL); 00273 usleep(100); 00274 if (lock_count != 2) 00275 test_errors++; 00276 ast_mutex_unlock(&test_lock); 00277 lock_count -= 1; 00278 usleep(100); 00279 if (lock_count != 1) 00280 test_errors++; 00281 ast_mutex_unlock(&test_lock); 00282 lock_count -= 1; 00283 if (lock_count != 0) 00284 test_errors++; 00285 ast_mutex_unlock(&test_lock2); 00286 usleep(100); 00287 if (lock_count != 0) 00288 test_errors++; 00289 pthread_join(test_thread, NULL); 00290 return(test_errors); /* return 0 on success. */ 00291 }
unsigned int __unsigned_int_flags_dummy |
Note: It is very important to use only unsigned variables to hold bit flags, as otherwise you can fall prey to the compiler's sign-extension antics if you try to use the top two bits in your variable. The flag macros below use a set of compiler tricks to verify that the caller is using an "unsigned int" variable to hold the flags, and nothing else. If the caller uses any other type of variable, a warning message similar to this: warning: comparison of distinct pointer types lacks cast will be generated. The "dummy" variable below is used to make these comparisons. Also note that at -O2 or above, this type-safety checking does _not_ produce any additional object code at all.
size_t const char* file |
Definition at line 360 of file utils.h.
Referenced by ast_smdi_mwi_set(), ast_smdi_mwi_unset(), handle_save_dialplan(), loadModule(), and readfile_exec().
size_t const char int const char* func |
Definition at line 360 of file utils.h.
Referenced by __ast_read(), __schedule_action(), ast_manager_register2(), ast_register_atexit(), ast_settimeout(), ast_unregister_atexit(), dundi_set_error(), dundi_set_output(), iax_set_error(), iax_set_output(), ss_thread(), and zt_indicate().
size_t len |
Definition at line 360 of file utils.h.
Referenced by __ast_cli_register(), __get_header(), _parse(), add_sdp(), add_t38_sdp(), aji_act_hook(), alsa_write(), append_interface(), ast_app_group_set_channel(), ast_cdr_appenduserfield(), ast_cli_complete(), ast_codec_get_len(), ast_dsp_digitdetect(), ast_dsp_process(), ast_dsp_silence(), ast_feature_request_and_dial(), ast_frdup(), ast_getformatname_multiple(), ast_read_image(), ast_rtcp_read(), ast_rtcp_write_rr(), ast_rtcp_write_sr(), ast_rtp_lookup_mime_multiple(), ast_rtp_read(), ast_safe_string_alloc(), ast_say_number_full_ge(), ast_smoother_read(), ast_translate(), ast_udptl_read(), ast_udptl_write(), authenticate(), build_facility(), build_route(), builtin_automonitor(), callerid_generate(), cli_complete(), complete_agent_logoff_cmd(), complete_context_add_extension(), complete_context_add_extension_deprecated(), complete_context_add_ignorepat(), complete_context_add_ignorepat_deprecated(), complete_context_add_include(), complete_context_add_include_deprecated(), complete_context_dont_include_deprecated(), complete_context_remove_extension(), complete_context_remove_extension_deprecated(), complete_context_remove_ignorepat(), complete_context_remove_ignorepat_deprecated(), complete_context_remove_include(), complete_meetmecmd(), complete_peer_helper(), conf_play(), config_jitterbuffer(), copy(), dictate_exec(), dundi_encrypt(), dundi_parse_ies(), dundi_send(), expr2_token_subst(), generic_http_callback(), get_body(), get_sdp(), get_sdp_iterate(), gsm_write(), gsmtolin_framein(), h263_read(), h263_write(), h264_read(), h264_write(), handle_commandmatchesarray(), handle_message(), handle_request(), handle_response(), handle_uri(), help1(), html_translate(), iax_parse_ies(), iax_str2flags(), launch_monitor_thread(), listener(), local_call(), lpc10tolin_framein(), method_match(), mgcp_ss(), mgcpsock_read(), misdn_join_conf(), misdn_read(), monmp3thread(), newpvt(), ogg_vorbis_read(), parse_ie(), pbx_load_users(), pbx_substitute_variables_helper_full(), process_sdp(), readfile_exec(), realtime_exec(), reschedule_precache(), schedule_delivery(), set(), sip_show_channel(), sip_show_history(), sipsock_read(), skinny_ss(), socket_process(), socket_read(), ss_thread(), static_callback(), strndup(), strnlen(), term_filter_escapes(), transfer_exec(), try_firmware(), udptl_build_packet(), vmwi_generate(), wav_write(), xml_translate(), and zt_setoption().
size_t const char int lineno |
Definition at line 360 of file utils.h.
Referenced by action_getconfig(), apply_outgoing(), compile_script(), and config_text_file_load().