Asterisk - The Open Source Telephony Project  GIT-master-8beac82
Data Structures | Macros | Typedefs | Enumerations | Functions
include/asterisk/app.h File Reference

Application convenience functions, designed to give consistent look and feel to Asterisk apps. More...

#include "asterisk/stringfields.h"
#include "asterisk/strings.h"
#include "asterisk/threadstorage.h"
#include "asterisk/file.h"
#include "asterisk/linkedlists.h"
#include "asterisk/utils.h"
#include "asterisk/stasis.h"

Go to the source code of this file.

Data Structures

struct  ast_app_option
 A structure to hold the description of an application 'option'. More...
 
struct  ast_app_stack_funcs
 Stack applications callback functions. More...
 
struct  ast_ivr_menu
 
struct  ast_ivr_option
 
struct  ast_vm_functions
 Voicemail function table definition. More...
 
struct  ast_vm_greeter_functions
 Voicemail greeter function table definition. More...
 
struct  ast_vm_mailbox_snapshot
 
struct  ast_vm_msg_snapshot
 
struct  ast_vm_recording_data
 Structure used for ast_copy_recording_to_vm in order to cleanly supply data needed for making the recording from the recorded file. More...
 

Macros

#define AST_APP_ARG(name)   char *name
 Define an application argument. More...
 
#define AST_APP_OPTION(option, flagno)   [option] = { .flag = flagno }
 Declares an application option that does not accept an argument. More...
 
#define AST_APP_OPTION_ARG(option, flagno, argno)   [option] = { .flag = flagno, .arg_index = argno + 1 }
 Declares an application option that accepts an argument. More...
 
#define AST_APP_OPTIONS(holder, options...)   static const struct ast_app_option holder[128] = options
 Declares an array of options for an application. More...
 
#define ast_app_separate_args(a, b, c, d)   __ast_app_separate_args(a,b,1,c,d)
 
#define AST_DECLARE_APP_ARGS(name, arglist)   AST_DEFINE_APP_ARGS_TYPE(argtype_##name, arglist) name = { 0, }
 Declare a structure to hold an application's arguments. More...
 
#define AST_DEFINE_APP_ARGS_TYPE(type, arglist)
 Define a structure type to hold an application's arguments. More...
 
#define AST_IVR_DECLARE_MENU(holder, title, flags, foo...)
 
#define AST_IVR_FLAG_AUTORESTART   (1 << 0)
 
#define AST_NONSTANDARD_APP_ARGS(args, parse, sep)   args.argc = __ast_app_separate_args(parse, sep, 1, args.argv, ((sizeof(args) - offsetof(typeof(args), argv)) / sizeof(args.argv[0])))
 Performs the 'nonstandard' argument separation process for an application. More...
 
#define AST_NONSTANDARD_RAW_ARGS(args, parse, sep)   args.argc = __ast_app_separate_args(parse, sep, 0, args.argv, ((sizeof(args) - offsetof(typeof(args), argv)) / sizeof(args.argv[0])))
 
#define AST_STANDARD_APP_ARGS(args, parse)   args.argc = __ast_app_separate_args(parse, ',', 1, args.argv, ((sizeof(args) - offsetof(typeof(args), argv)) / sizeof(args.argv[0])))
 Performs the 'standard' argument separation process for an application. More...
 
#define AST_STANDARD_RAW_ARGS(args, parse)   args.argc = __ast_app_separate_args(parse, ',', 0, args.argv, ((sizeof(args) - offsetof(typeof(args), argv)) / sizeof(args.argv[0])))
 
#define ast_vm_greeter_register(vm_table)   __ast_vm_greeter_register(vm_table, AST_MODULE_SELF)
 See __ast_vm_greeter_register() More...
 
#define ast_vm_register(vm_table)   __ast_vm_register(vm_table, AST_MODULE_SELF)
 See __ast_vm_register() More...
 
#define BEGIN_OPTIONS   {
 
#define END_OPTIONS   }
 
#define VM_GREETER_MODULE_VERSION   1
 
#define VM_MODULE_VERSION   2
 

Typedefs

typedef int() ast_copy_recording_to_vm_fn(struct ast_vm_recording_data *vm_rec_data)
 Creates a voicemail based on a specified file to a mailbox. More...
 
typedef int() ast_has_voicemail_fn(const char *mailboxes, const char *folder)
 Determines if the given folder has messages. More...
 
typedef int() ast_inboxcount2_fn(const char *mailboxes, int *urgentmsgs, int *newmsgs, int *oldmsgs)
 Gets the number of messages that exist for the mailbox list. More...
 
typedef int() ast_inboxcount_fn(const char *mailboxes, int *newmsgs, int *oldmsgs)
 Gets the number of messages that exist for the mailbox list. More...
 
typedef int() ast_ivr_callback(struct ast_channel *chan, char *option, void *cbdata)
 Callback function for IVR. More...
 
typedef int() ast_messagecount_fn(const char *mailbox_id, const char *folder)
 Gets the number of messages that exist in a mailbox folder. More...
 
typedef int() ast_sayname_fn(struct ast_channel *chan, const char *mailbox_id)
 Play a recorded user name for the mailbox to the specified channel. More...
 
typedef const char *() ast_vm_index_to_foldername_fn(int id)
 Convert the mailbox folder id to a folder name. More...
 
typedef struct ast_vm_mailbox_snapshot *() ast_vm_mailbox_snapshot_create_fn(const char *user, const char *context, const char *folder, int descending, enum ast_vm_snapshot_sort_val sort_val, int combine_INBOX_and_OLD)
 Create a snapshot of a mailbox which contains information about every msg. More...
 
typedef struct ast_vm_mailbox_snapshot *() ast_vm_mailbox_snapshot_destroy_fn(struct ast_vm_mailbox_snapshot *mailbox_snapshot)
 destroy a snapshot More...
 
typedef int() ast_vm_msg_forward_fn(const char *from_mailbox, const char *from_context, const char *from_folder, const char *to_mailbox, const char *to_context, const char *to_folder, size_t num_msgs, const char *msg_ids[], int delete_old)
 forward a message from one mailbox to another. More...
 
typedef int() ast_vm_msg_move_fn(const char *mailbox, const char *context, size_t num_msgs, const char *oldfolder, const char *old_msg_ids[], const char *newfolder)
 Move messages from one folder to another. More...
 
typedef void() ast_vm_msg_play_cb(struct ast_channel *chan, const char *playfile, int duration)
 Voicemail playback callback function definition. More...
 
typedef int() ast_vm_msg_play_fn(struct ast_channel *chan, const char *mailbox, const char *context, const char *folder, const char *msg_num, ast_vm_msg_play_cb *cb)
 Play a voicemail msg back on a channel. More...
 
typedef int() ast_vm_msg_remove_fn(const char *mailbox, const char *context, size_t num_msgs, const char *folder, const char *msgs[])
 Remove/delete messages from a mailbox folder. More...
 

Enumerations

enum  ast_getdata_result {
  AST_GETDATA_FAILED = -1, AST_GETDATA_COMPLETE = 0, AST_GETDATA_TIMEOUT = 1, AST_GETDATA_INTERRUPTED = 2,
  AST_GETDATA_EMPTY_END_TERMINATED = 3
}
 
enum  ast_ivr_action {
  AST_ACTION_UPONE, AST_ACTION_EXIT, AST_ACTION_CALLBACK, AST_ACTION_PLAYBACK,
  AST_ACTION_BACKGROUND, AST_ACTION_PLAYLIST, AST_ACTION_MENU, AST_ACTION_REPEAT,
  AST_ACTION_RESTART, AST_ACTION_TRANSFER, AST_ACTION_WAITOPTION, AST_ACTION_NOOP,
  AST_ACTION_BACKLIST
}
 
enum  AST_LOCK_RESULT { AST_LOCK_SUCCESS = 0, AST_LOCK_TIMEOUT = -1, AST_LOCK_PATH_NOT_FOUND = -2, AST_LOCK_FAILURE = -3 }
 
enum  AST_LOCK_TYPE { AST_LOCK_TYPE_LOCKFILE = 0, AST_LOCK_TYPE_FLOCK = 1 }
 Type of locking to use in ast_lock_path / ast_unlock_path. More...
 
enum  ast_record_if_exists { AST_RECORD_IF_EXISTS_ERROR = -1, AST_RECORD_IF_EXISTS_FAIL, AST_RECORD_IF_EXISTS_OVERWRITE, AST_RECORD_IF_EXISTS_APPEND }
 
enum  ast_timelen { TIMELEN_HOURS, TIMELEN_MINUTES, TIMELEN_SECONDS, TIMELEN_MILLISECONDS }
 
enum  ast_vm_snapshot_sort_val { AST_VM_SNAPSHOT_SORT_BY_ID = 0, AST_VM_SNAPSHOT_SORT_BY_TIME }
 

Functions

unsigned int __ast_app_separate_args (char *buf, char delim, int remove_chars, char **array, int arraylen)
 Separate a string into arguments in an array. More...
 
int __ast_vm_greeter_register (const struct ast_vm_greeter_functions *vm_table, struct ast_module *module)
 Set voicemail greeter function callbacks. More...
 
int __ast_vm_register (const struct ast_vm_functions *vm_table, struct ast_module *module)
 Set voicemail function callbacks. More...
 
int app_init (void)
 Initialize the application core. More...
 
int ast_app_copy_recording_to_vm (struct ast_vm_recording_data *vm_rec_data)
 param[in] vm_rec_data Contains data needed to make the recording. retval 0 voicemail successfully created from recording. retval -1 Failure More...
 
int ast_app_dtget (struct ast_channel *chan, const char *context, char *collect, size_t size, int maxlen, int timeout)
 Present a dialtone and collect a certain length extension. More...
 
int ast_app_exec_macro (struct ast_channel *autoservice_chan, struct ast_channel *macro_chan, const char *macro_args)
 Run a macro on a channel, placing an optional second channel into autoservice. More...
 
int ast_app_exec_sub (struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const char *sub_args, int ignore_hangup)
 Run a subroutine on a channel, placing an optional second channel into autoservice. More...
 
const char * ast_app_expand_sub_args (struct ast_channel *chan, const char *args)
 Add missing context/exten to subroutine argument string. More...
 
int ast_app_getdata (struct ast_channel *c, const char *prompt, char *s, int maxlen, int timeout)
 Plays a stream and gets DTMF data from a channel. More...
 
int ast_app_getdata_full (struct ast_channel *c, const char *prompt, char *s, int maxlen, int timeout, int audiofd, int ctrlfd)
 Full version with audiofd and controlfd. NOTE: returns '2' on ctrlfd available, not '1' like other full functions. More...
 
int ast_app_getdata_terminator (struct ast_channel *c, const char *prompt, char *s, int maxlen, int timeout, char *terminator)
 Plays a stream and gets DTMF data from a channel. More...
 
int ast_app_group_discard (struct ast_channel *chan)
 Discard all group counting for a channel. More...
 
int ast_app_group_get_count (const char *group, const char *category)
 Get the current channel count of the specified group and category. More...
 
struct ast_group_infoast_app_group_list_head (void)
 Get the head of the group count list. More...
 
int ast_app_group_list_rdlock (void)
 Read Lock the group count list. More...
 
int ast_app_group_list_unlock (void)
 Unlock the group count list. More...
 
int ast_app_group_list_wrlock (void)
 Write Lock the group count list. More...
 
int ast_app_group_match_get_count (const char *groupmatch, const char *category)
 Get the current channel count of all groups that match the specified pattern and category. More...
 
int ast_app_group_set_channel (struct ast_channel *chan, const char *data)
 Set the group for a channel, splitting the provided data into group and category, if specified. More...
 
int ast_app_group_split_group (const char *data, char *group, int group_max, char *category, int category_max)
 Split a group string into group and category, returning a default category if none is provided. More...
 
int ast_app_group_update (struct ast_channel *oldchan, struct ast_channel *newchan)
 Update all group counting for a channel to a new one. More...
 
int ast_app_has_voicemail (const char *mailboxes, const char *folder)
 Determine if a given mailbox has any voicemail If folder is NULL, defaults to "INBOX". If folder is "INBOX", includes the number of messages in the "Urgent" folder. More...
 
int ast_app_inboxcount (const char *mailboxes, int *newmsgs, int *oldmsgs)
 Determine number of new/old messages in a mailbox. More...
 
int ast_app_inboxcount2 (const char *mailboxes, int *urgentmsgs, int *newmsgs, int *oldmsgs)
 Determine number of urgent/new/old messages in a mailbox. More...
 
int ast_app_messagecount (const char *mailbox_id, const char *folder)
 Get the number of messages in a given mailbox folder. More...
 
void ast_app_options2str64 (const struct ast_app_option *options, struct ast_flags64 *flags, char *buf, size_t len)
 Given a list of options array, return an option string based on passed flags. More...
 
int ast_app_parse_options (const struct ast_app_option *options, struct ast_flags *flags, char **args, char *optstr)
 Parses a string containing application options and sets flags/arguments. More...
 
int ast_app_parse_options64 (const struct ast_app_option *options, struct ast_flags64 *flags, char **args, char *optstr)
 Parses a string containing application options and sets flags/arguments. More...
 
int ast_app_parse_timelen (const char *timestr, int *result, enum ast_timelen defunit)
 Common routine to parse time lengths, with optional time unit specifier. More...
 
int ast_app_run_macro (struct ast_channel *autoservice_chan, struct ast_channel *macro_chan, const char *macro_name, const char *macro_args)
 Run a macro on a channel, placing an optional second channel into autoservice. More...
 
int ast_app_run_sub (struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const char *sub_location, const char *sub_args, int ignore_hangup)
 Run a subroutine on a channel, placing an optional second channel into autoservice. More...
 
int ast_app_sayname (struct ast_channel *chan, const char *mailbox_id)
 Play a recorded user name for the mailbox to the specified channel. More...
 
void ast_close_fds_above_n (int n)
 Common routine for child processes, to close all fds prior to exec(2) More...
 
int ast_control_streamfile (struct ast_channel *chan, const char *file, const char *fwd, const char *rev, const char *stop, const char *pause, const char *restart, int skipms, long *offsetms)
 Stream a file with fast forward, pause, reverse, restart. More...
 
int ast_control_streamfile_lang (struct ast_channel *chan, const char *file, const char *fwd, const char *rev, const char *stop, const char *suspend, const char *restart, int skipms, const char *lang, long *offsetms)
 Version of ast_control_streamfile() which allows the language of the media file to be specified. More...
 
int ast_control_streamfile_w_cb (struct ast_channel *chan, const char *file, const char *fwd, const char *rev, const char *stop, const char *pause, const char *restart, int skipms, long *offsetms, ast_waitstream_fr_cb cb)
 Stream a file with fast forward, pause, reverse, restart. More...
 
int ast_control_tone (struct ast_channel *chan, const char *tone)
 Controls playback of a tone. More...
 
int ast_dtmf_stream (struct ast_channel *chan, struct ast_channel *peer, const char *digits, int between, unsigned int duration)
 Send a string of DTMF digits to a channel. More...
 
void ast_dtmf_stream_external (struct ast_channel *chan, const char *digits, int between, unsigned int duration)
 Send a string of DTMF digits to a channel from an external thread. More...
 
int ast_get_encoded_char (const char *stream, char *result, size_t *consumed)
 Decode an encoded control or extended ASCII character. More...
 
char * ast_get_encoded_str (const char *stream, char *result, size_t result_len)
 Decode a stream of encoded control or extended ASCII characters. More...
 
void ast_install_stack_functions (const struct ast_app_stack_funcs *funcs)
 Set stack application function callbacks. More...
 
int ast_ivr_menu_run (struct ast_channel *c, struct ast_ivr_menu *menu, void *cbdata)
 Runs an IVR menu. More...
 
int ast_linear_stream (struct ast_channel *chan, const char *filename, int fd, int allowoverride)
 Stream a filename (or file descriptor) as a generator. More...
 
enum AST_LOCK_RESULT ast_lock_path (const char *path)
 Lock a filesystem path. More...
 
int ast_play_and_prepend (struct ast_channel *chan, char *playfile, char *recordfile, int maxtime_sec, char *fmt, int *duration, int *sound_duration, int beep, int silencethreshold, int maxsilence_ms)
 Record a file based on input frm a channel. Recording is performed in 'prepend' mode which works a little differently from normal recordings This function will not play a success message due to post-recording control in the application this was added for. More...
 
int ast_play_and_record (struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime_sec, const char *fmt, int *duration, int *sound_duration, int silencethreshold, int maxsilence_ms, const char *path)
 Record a file based on input from a channel. Use default accept and cancel DTMF. This function will play "auth-thankyou" upon successful recording. More...
 
int ast_play_and_record_full (struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime_sec, const char *fmt, int *duration, int *sound_duration, int beep, int silencethreshold, int maxsilence_ms, const char *path, const char *acceptdtmf, const char *canceldtmf, int skip_confirmation_sound, enum ast_record_if_exists if_exists)
 Record a file based on input from a channel This function will play "auth-thankyou" upon successful recording if skip_confirmation_sound is false. More...
 
int ast_play_and_wait (struct ast_channel *chan, const char *fn)
 Play a stream and wait for a digit, returning the digit that was pressed. More...
 
struct stasis_topicast_queue_topic (const char *queuename)
 Get the Stasis Message Bus API topic for queue messages for a particular queue name. More...
 
struct stasis_topicast_queue_topic_all (void)
 Get the Stasis Message Bus API topic for queue messages. More...
 
char * ast_read_textfile (const char *file)
 Read a file into asterisk. More...
 
int ast_record_review (struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime, const char *fmt, int *duration, const char *path)
 Allow to record message and have a review option. More...
 
void ast_replace_sigchld (void)
 Replace the SIGCHLD handler. More...
 
int ast_safe_execvp (int dualfork, const char *file, char *const argv[])
 Safely spawn an external program while closing file descriptors. More...
 
int ast_safe_fork (int stop_reaper)
 Common routine to safely fork without a chance of a signal handler firing badly in the child. More...
 
void ast_safe_fork_cleanup (void)
 Common routine to cleanup after fork'ed process is complete (if reaping was stopped) More...
 
int ast_safe_system (const char *s)
 Safely spawn an OS shell command while closing file descriptors. More...
 
void ast_set_lock_type (enum AST_LOCK_TYPE type)
 Set the type of locks used by ast_lock_path() More...
 
int ast_str_get_encoded_str (struct ast_str **str, int maxlen, const char *stream)
 Decode a stream of encoded control or extended ASCII characters. More...
 
 AST_THREADSTORAGE_EXTERNAL (ast_str_thread_global_buf)
 
int ast_unlock_path (const char *path)
 Unlock a path. More...
 
void ast_unreplace_sigchld (void)
 Restore the SIGCHLD handler. More...
 
int ast_vm_greeter_is_registered (void)
 Determine if a voicemail greeter provider is registered. More...
 
void ast_vm_greeter_unregister (const char *module_name)
 Unregister the specified voicemail greeter provider. More...
 
const char * ast_vm_index_to_foldername (int id)
 Return name of folder, given an id. More...
 
int ast_vm_is_registered (void)
 Determine if a voicemail provider is registered. More...
 
struct ast_vm_mailbox_snapshotast_vm_mailbox_snapshot_create (const char *mailbox, const char *context, const char *folder, int descending, enum ast_vm_snapshot_sort_val sort_val, int combine_INBOX_and_OLD)
 Create a snapshot of a mailbox which contains information about every msg. More...
 
struct ast_vm_mailbox_snapshotast_vm_mailbox_snapshot_destroy (struct ast_vm_mailbox_snapshot *mailbox_snapshot)
 destroy a snapshot More...
 
int ast_vm_msg_forward (const char *from_mailbox, const char *from_context, const char *from_folder, const char *to_mailbox, const char *to_context, const char *to_folder, size_t num_msgs, const char *msg_ids[], int delete_old)
 forward a message from one mailbox to another. More...
 
int ast_vm_msg_move (const char *mailbox, const char *context, size_t num_msgs, const char *oldfolder, const char *old_msg_ids[], const char *newfolder)
 Move messages from one folder to another. More...
 
int ast_vm_msg_play (struct ast_channel *chan, const char *mailbox, const char *context, const char *folder, const char *msg_num, ast_vm_msg_play_cb *cb)
 Play a voicemail msg back on a channel. More...
 
int ast_vm_msg_remove (const char *mailbox, const char *context, size_t num_msgs, const char *folder, const char *msgs[])
 Remove/delete messages from a mailbox folder. More...
 
void ast_vm_unregister (const char *module_name)
 Unregister the specified voicemail provider. More...
 

Detailed Description

Application convenience functions, designed to give consistent look and feel to Asterisk apps.

Definition in file include/asterisk/app.h.

Macro Definition Documentation

◆ AST_APP_ARG

#define AST_APP_ARG (   name)    char *name

Define an application argument.

Parameters
nameThe name of the argument

Definition at line 1218 of file include/asterisk/app.h.

Referenced by acf_abs_exec(), acf_curl_exec(), acf_curl_write(), acf_if(), acf_isexten_exec(), acf_jabberreceive_read(), acf_jabberstatus_read(), acf_max_exec(), acf_meetme_info(), acf_min_exec(), acf_odbc_read(), acf_odbc_write(), acf_rand_exec(), acf_sprintf(), acf_strftime(), acf_strptime(), acf_transaction_read(), acf_transaction_write(), acf_version_exec(), acf_vm_info(), acf_vmcount_exec(), action_status(), add_action_to_menu_entry(), admin_exec(), aelsub_exec(), aes_helper(), agent_function_read(), agent_login_exec(), agent_request_exec(), agi_exec_full(), app_exec(), applicationmap_handler(), aqm_exec(), array(), ast_eivr_senddtmf(), ast_queue_log(), asyncgoto_exec(), attended_transfer_exec(), audiosocket_exec(), audiosocket_request(), auth_exec(), background_detect_exec(), blind_transfer_exec(), bridge_exec(), bridgewait_exec(), build_profile(), calendar_query_exec(), calendar_query_result_exec(), calendar_write_exec(), callerid_read(), cdr_prop_write_callback(), cdr_read_callback(), cdr_write(), cdr_write_callback(), celgenuserevent_exec(), chanavail_exec(), channel_admin_exec(), channelvars_handler(), chanspy_exec(), cli_odbc_read(), cli_odbc_write(), conf_exec(), confbridge_exec(), config_function_read(), confkick_exec(), controlplayback_exec(), count_exec(), create_addr(), cut_internal(), dahdi_call(), destroy_all_channels(), detect_write(), determine_starting_point(), dial_exec_full(), dialgroup_write(), dictate_exec(), directory_exec(), disa_exec(), dtmfstore_exec(), dundi_query_read(), dundi_result_read(), dundifunc_read(), enable_jack_hook(), enum_query_read(), enum_result_read(), execif_exec(), extenspy_exec(), festival_exec(), file_count_line(), file_read(), file_write(), filter(), find_conf(), find_realtime_gw(), forkcdr_exec(), func_confbridge_helper(), func_confbridge_info(), func_get_parkingslot_channel(), func_header_read(), func_headers_read2(), func_mixmonitor_read(), func_read_header(), func_read_headers(), func_write_header(), function_amiclient(), function_db_delete(), function_db_exists(), function_db_read(), function_db_write(), function_enum(), function_fieldnum_helper(), function_fieldqty_helper(), function_realtime_read(), function_realtime_readdestroy(), function_realtime_store(), function_realtime_write(), function_txtcidname(), gosub_exec(), gosubif_exec(), hangupcause_read(), hash_read(), hash_write(), hint_read(), hook_on(), iconv_read(), import_helper(), init_acf_query(), isAnsweringMachine(), isexten_function_read(), jb_helper(), jingle_request(), listfilter(), load_channelvars(), load_values_config(), log_exec(), man_do_variable_value(), math(), mbl_sendsms_exec(), mbl_status_exec(), mixmonitor_exec(), msg_send_exec(), multicast_rtp_request(), my_on_hook(), originate_exec(), ospauth_exec(), ospfinished_exec(), osplookup_exec(), ospnext_exec(), page_exec(), park_and_announce_app_exec(), park_app_parse_data(), parked_call_app_exec(), pbx_builtin_answer(), pbx_builtin_background(), pbx_builtin_saycharacters_case(), pbx_builtin_setvar_multiple(), pbx_builtin_waitdigit(), pbx_builtin_waitexten(), peek_read(), pickupchan_exec(), pjsip_acf_channel_read(), pjsip_acf_dial_contacts_read(), pjsip_acf_parse_uri_read(), pjsip_aor_function_read(), pjsip_contact_function_read(), pjsip_endpoint_function_read(), play_moh_exec(), playback_exec(), pp_each_extension_helper(), pqm_exec(), presence_read(), privacy_exec(), ql_exec(), queue_exec(), queue_function_mem_read(), queue_function_mem_write(), queue_function_memberpenalty_read(), queue_function_memberpenalty_write(), queue_function_queuegetchannel(), qupd_exec(), read_exec(), readexten_exec(), realtimefield_read(), receivefax_exec(), record_exec(), reg_source_db(), regex(), reload_single_member(), replace(), request(), retrydial_exec(), rqm_exec(), saycountedadj_exec(), saycountednoun_exec(), sayfile_exec(), sayunixtime_exec(), scramble_write(), senddtmf_exec(), sendfax_exec(), sendmf_exec(), shared_read(), shared_write(), shift_pop(), sip_acf_channel_read(), sip_parse_register_line(), sip_request_call(), sla_trunk_exec(), smdi_msg_read(), smdi_msg_retrieve_read(), sms_exec(), softhangup_exec(), sorcery_function_read(), speech_background(), speech_load(), srv_result_read(), stackpeek_read(), start_moh_exec(), start_monitor_exec(), statsd_exec(), stir_shaken_read(), stop_mixmonitor_full(), strbetween(), stream_echo_exec(), strreplace(), talk_detect_fn_write(), transfer_exec(), unicast_rtp_request(), unshift_push(), upqm_exec(), userevent_exec(), verbose_exec(), vm_check_password_shell(), vm_exec(), vm_execmain(), vm_playmsgexec(), volume_read(), volume_write(), wait_exec(), waitfor_exec(), waitforcond_exec(), xmpp_join_exec(), xmpp_leave_exec(), xmpp_send_exec(), xmpp_sendgroup_exec(), and zapateller_exec().

◆ AST_APP_OPTION

#define AST_APP_OPTION (   option,
  flagno 
)    [option] = { .flag = flagno }

Declares an application option that does not accept an argument.

Parameters
optionThe single character representing the option
flagnoThe flag index to be set if this option is present
See also
AST_APP_OPTIONS, ast_app_parse_options

Definition at line 1388 of file include/asterisk/app.h.

◆ AST_APP_OPTION_ARG

#define AST_APP_OPTION_ARG (   option,
  flagno,
  argno 
)    [option] = { .flag = flagno, .arg_index = argno + 1 }

Declares an application option that accepts an argument.

Parameters
optionThe single character representing the option
flagnoThe flag index to be set if this option is present
argnoThe index into the argument array where the argument should be placed
See also
AST_APP_OPTIONS, ast_app_parse_options

Definition at line 1399 of file include/asterisk/app.h.

Referenced by AST_TEST_DEFINE().

◆ AST_APP_OPTIONS

#define AST_APP_OPTIONS (   holder,
  options... 
)    static const struct ast_app_option holder[128] = options

Declares an array of options for an application.

Parameters
holderThe name of the array to be created
optionsThe actual options to be placed into the array
See also
ast_app_parse_options

This macro declares a 'static const' array of struct ast_option elements to hold the list of available options for an application. Each option must be declared using either the AST_APP_OPTION() or AST_APP_OPTION_ARG() macros.

Example usage:

enum my_app_option_flags {
OPT_JUMP = (1 << 0),
OPT_BLAH = (1 << 1),
OPT_BLORT = (1 << 2),
};
enum my_app_option_args {
OPT_ARG_BLAH = 0,
OPT_ARG_BLORT,
!! this entry tells how many possible arguments there are,
and must be the last entry in the list
};
AST_APP_OPTIONS(my_app_options, {
AST_APP_OPTION_ARG('b', OPT_BLAH, OPT_ARG_BLAH),
AST_APP_OPTION_BLORT('B', OPT_BLORT, OPT_ARG_BLORT),
});
static int my_app_exec(struct ast_channel *chan, void *data)
{
char *options;
struct ast_flags opts = { 0, };
char *opt_args[OPT_ARG_ARRAY_SIZE];
... do any argument parsing here ...
if (ast_app_parse_options(my_app_options, &opts, opt_args, options)) {
return -1;
}
}

Definition at line 1379 of file include/asterisk/app.h.

Referenced by AST_TEST_DEFINE().

◆ ast_app_separate_args

#define ast_app_separate_args (   a,
  b,
  c,
  d 
)    __ast_app_separate_args(a,b,1,c,d)

◆ AST_DECLARE_APP_ARGS

#define AST_DECLARE_APP_ARGS (   name,
  arglist 
)    AST_DEFINE_APP_ARGS_TYPE(argtype_##name, arglist) name = { 0, }

Declare a structure to hold an application's arguments.

Parameters
nameThe name of the structure
arglistThe list of arguments, defined using AST_APP_ARG

This macro declares a structure intended to be used in a call to ast_app_separate_args(). The structure includes all the arguments specified, plus an argv array that overlays them and an argc argument counter. The arguments must be declared using AST_APP_ARG, and they will all be character pointers (strings).

Note
The structure is not initialized, as the call to ast_app_separate_args() will perform that function before parsing the arguments.

Definition at line 1235 of file include/asterisk/app.h.

Referenced by acf_abs_exec(), acf_curl_exec(), acf_curl_write(), acf_if(), acf_isexten_exec(), acf_jabberreceive_read(), acf_jabberstatus_read(), acf_max_exec(), acf_meetme_info(), acf_min_exec(), acf_odbc_read(), acf_odbc_write(), acf_rand_exec(), acf_sprintf(), acf_strftime(), acf_strptime(), acf_transaction_read(), acf_transaction_write(), acf_version_exec(), acf_vm_info(), acf_vmcount_exec(), action_status(), add_action_to_menu_entry(), admin_exec(), aelsub_exec(), aes_helper(), agent_function_read(), agent_login_exec(), agent_request_exec(), agi_exec_full(), app_exec(), applicationmap_handler(), aqm_exec(), array(), ast_eivr_senddtmf(), ast_queue_log(), asyncgoto_exec(), attended_transfer_exec(), audiosocket_exec(), audiosocket_request(), auth_exec(), background_detect_exec(), blind_transfer_exec(), bridge_exec(), bridgewait_exec(), build_profile(), calendar_query_exec(), calendar_query_result_exec(), calendar_write_exec(), callerid_read(), cdr_prop_write_callback(), cdr_read_callback(), cdr_write(), cdr_write_callback(), celgenuserevent_exec(), chanavail_exec(), channel_admin_exec(), channelvars_handler(), chanspy_exec(), cli_odbc_read(), cli_odbc_write(), conf_exec(), confbridge_exec(), config_function_read(), confkick_exec(), controlplayback_exec(), count_exec(), create_addr(), cut_internal(), dahdi_call(), destroy_all_channels(), detect_write(), determine_starting_point(), dial_exec_full(), dialgroup_write(), dictate_exec(), directory_exec(), disa_exec(), dtmfstore_exec(), dundi_query_read(), dundi_result_read(), dundifunc_read(), enable_jack_hook(), enum_query_read(), enum_result_read(), execif_exec(), extenspy_exec(), festival_exec(), file_count_line(), file_read(), file_write(), filter(), find_conf(), find_realtime_gw(), forkcdr_exec(), func_confbridge_helper(), func_confbridge_info(), func_get_parkingslot_channel(), func_header_read(), func_headers_read2(), func_mixmonitor_read(), func_read_header(), func_read_headers(), func_write_header(), function_amiclient(), function_db_delete(), function_db_exists(), function_db_read(), function_db_write(), function_enum(), function_fieldnum_helper(), function_fieldqty_helper(), function_realtime_read(), function_realtime_readdestroy(), function_realtime_store(), function_realtime_write(), function_txtcidname(), gosub_exec(), gosubif_exec(), hangupcause_read(), hash_read(), hash_write(), hint_read(), hook_on(), iconv_read(), import_helper(), init_acf_query(), isAnsweringMachine(), isexten_function_read(), jb_helper(), jingle_request(), listfilter(), load_channelvars(), load_values_config(), log_exec(), man_do_variable_value(), math(), mbl_sendsms_exec(), mbl_status_exec(), mixmonitor_exec(), msg_send_exec(), multicast_rtp_request(), my_on_hook(), originate_exec(), ospauth_exec(), ospfinished_exec(), osplookup_exec(), ospnext_exec(), page_exec(), park_and_announce_app_exec(), park_app_parse_data(), parked_call_app_exec(), pbx_builtin_answer(), pbx_builtin_background(), pbx_builtin_saycharacters_case(), pbx_builtin_setvar_multiple(), pbx_builtin_waitdigit(), pbx_builtin_waitexten(), peek_read(), pickupchan_exec(), pjsip_acf_channel_read(), pjsip_acf_dial_contacts_read(), pjsip_acf_parse_uri_read(), pjsip_aor_function_read(), pjsip_contact_function_read(), pjsip_endpoint_function_read(), play_moh_exec(), playback_exec(), pp_each_extension_helper(), pqm_exec(), presence_read(), privacy_exec(), ql_exec(), queue_exec(), queue_function_mem_read(), queue_function_mem_write(), queue_function_memberpenalty_read(), queue_function_memberpenalty_write(), queue_function_queuegetchannel(), qupd_exec(), read_exec(), readexten_exec(), realtimefield_read(), receivefax_exec(), record_exec(), reg_source_db(), regex(), reload_single_member(), replace(), request(), retrydial_exec(), rqm_exec(), saycountedadj_exec(), saycountednoun_exec(), sayfile_exec(), sayunixtime_exec(), scramble_write(), senddtmf_exec(), sendfax_exec(), sendmf_exec(), shared_read(), shared_write(), shift_pop(), sip_acf_channel_read(), sip_parse_register_line(), sip_request_call(), sla_trunk_exec(), smdi_msg_read(), smdi_msg_retrieve_read(), sms_exec(), softhangup_exec(), sorcery_function_read(), speech_background(), speech_load(), srv_result_read(), stackpeek_read(), start_moh_exec(), start_monitor_exec(), statsd_exec(), stir_shaken_read(), stop_mixmonitor_full(), strbetween(), stream_echo_exec(), strreplace(), talk_detect_fn_write(), transfer_exec(), unicast_rtp_request(), unshift_push(), upqm_exec(), userevent_exec(), verbose_exec(), vm_check_password_shell(), vm_exec(), vm_execmain(), vm_playmsgexec(), volume_read(), volume_write(), wait_exec(), waitfor_exec(), waitforcond_exec(), xmpp_join_exec(), xmpp_leave_exec(), xmpp_send_exec(), xmpp_sendgroup_exec(), and zapateller_exec().

◆ AST_DEFINE_APP_ARGS_TYPE

#define AST_DEFINE_APP_ARGS_TYPE (   type,
  arglist 
)

Define a structure type to hold an application's arguments.

Parameters
typeThe name of the structure type
arglistThe list of arguments, defined using AST_APP_ARG

This macro defines a structure type intended to be used in a call to ast_app_separate_args(). The structure includes all the arguments specified, plus an argv array that overlays them and an argc argument counter. The arguments must be declared using AST_APP_ARG, and they will all be character pointers (strings).

Note
This defines a structure type, but does not declare an instance of the structure. That must be done separately.

Definition at line 1252 of file include/asterisk/app.h.

◆ AST_IVR_DECLARE_MENU

#define AST_IVR_DECLARE_MENU (   holder,
  title,
  flags,
  foo... 
)
Value:
static struct ast_ivr_option __options_##holder[] = foo;\
static struct ast_ivr_menu holder = { title, flags, __options_##holder }
unsigned int flags

Definition at line 109 of file include/asterisk/app.h.

Referenced by ivr_demo_func().

◆ AST_IVR_FLAG_AUTORESTART

#define AST_IVR_FLAG_AUTORESTART   (1 << 0)

Definition at line 107 of file include/asterisk/app.h.

◆ AST_NONSTANDARD_APP_ARGS

#define AST_NONSTANDARD_APP_ARGS (   args,
  parse,
  sep 
)    args.argc = __ast_app_separate_args(parse, sep, 1, args.argv, ((sizeof(args) - offsetof(typeof(args), argv)) / sizeof(args.argv[0])))

Performs the 'nonstandard' argument separation process for an application.

Parameters
argsAn argument structure defined using AST_DECLARE_APP_ARGS
parseA modifiable buffer containing the input to be parsed
sepA nonstandard separator character

This function will separate the input string using the nonstandard argument separator character and fill in the provided structure, including the argc argument counter field.

Definition at line 1286 of file include/asterisk/app.h.

Referenced by acf_if(), acf_jabberreceive_read(), acf_jabberstatus_read(), agent_function_read(), ast_queue_log(), audiosocket_request(), build_profile(), callerid_read(), callerid_write(), connectedline_read(), connectedline_write(), dahdi_call(), determine_starting_point(), dialgroup_write(), function_db_delete(), function_db_exists(), function_db_read(), function_db_write(), jingle_request(), multicast_rtp_request(), my_on_hook(), pbx_builtin_setvar_multiple(), redirecting_read(), redirecting_write(), regex(), request(), sip_request_call(), unicast_rtp_request(), and vm_check_password_shell().

◆ AST_NONSTANDARD_RAW_ARGS

#define AST_NONSTANDARD_RAW_ARGS (   args,
  parse,
  sep 
)    args.argc = __ast_app_separate_args(parse, sep, 0, args.argv, ((sizeof(args) - offsetof(typeof(args), argv)) / sizeof(args.argv[0])))

◆ AST_STANDARD_APP_ARGS

#define AST_STANDARD_APP_ARGS (   args,
  parse 
)    args.argc = __ast_app_separate_args(parse, ',', 1, args.argv, ((sizeof(args) - offsetof(typeof(args), argv)) / sizeof(args.argv[0])))

Performs the 'standard' argument separation process for an application.

Parameters
argsAn argument structure defined using AST_DECLARE_APP_ARGS
parseA modifiable buffer containing the input to be parsed

This function will separate the input string using the standard argument separator character ',' and fill in the provided structure, including the argc argument counter field.

Definition at line 1271 of file include/asterisk/app.h.

Referenced by acf_abs_exec(), acf_curl_exec(), acf_curl_write(), acf_isexten_exec(), acf_jabberreceive_read(), acf_jabberstatus_read(), acf_max_exec(), acf_meetme_info(), acf_min_exec(), acf_odbc_read(), acf_odbc_write(), acf_rand_exec(), acf_sprintf(), acf_strftime(), acf_strptime(), acf_transaction_read(), acf_transaction_write(), acf_version_exec(), acf_vm_info(), acf_vmcount_exec(), action_status(), add_action_to_menu_entry(), admin_exec(), aes_helper(), agent_login_exec(), agent_request_exec(), agi_exec_full(), app_exec(), applicationmap_handler(), aqm_exec(), array(), ast_eivr_senddtmf(), asyncgoto_exec(), attended_transfer_exec(), audiosocket_exec(), auth_exec(), background_detect_exec(), blind_transfer_exec(), bridge_exec(), bridgewait_exec(), build_profile(), calendar_query_exec(), calendar_query_result_exec(), calendar_write_exec(), callerid_read(), callerid_write(), cdr_prop_write_callback(), cdr_read_callback(), cdr_write(), cdr_write_callback(), celgenuserevent_exec(), chanavail_exec(), channel_admin_exec(), channelvars_handler(), chanspy_exec(), cli_odbc_read(), cli_odbc_write(), conf_exec(), confbridge_exec(), config_function_read(), confkick_exec(), connectedline_write(), controlplayback_exec(), count_exec(), cut_internal(), destroy_all_channels(), detect_write(), dial_exec_full(), dialgroup_write(), dictate_exec(), directory_exec(), disa_exec(), dtmfstore_exec(), dundi_query_read(), dundi_result_read(), dundifunc_read(), enable_jack_hook(), enum_query_read(), enum_result_read(), execif_exec(), extenspy_exec(), festival_exec(), file_count_line(), file_read(), file_write(), find_conf(), find_realtime_gw(), forkcdr_exec(), func_confbridge_helper(), func_confbridge_info(), func_get_parkingslot_channel(), func_header_read(), func_headers_read2(), func_mixmonitor_read(), func_read_header(), func_read_headers(), func_write_header(), function_amiclient(), function_enum(), function_fieldnum_helper(), function_fieldqty_helper(), function_realtime_read(), function_realtime_readdestroy(), function_realtime_store(), function_realtime_write(), function_txtcidname(), hangupcause_read(), hash_read(), hash_write(), hint_read(), hook_on(), iconv_read(), import_helper(), init_acf_query(), isAnsweringMachine(), isexten_function_read(), jb_helper(), listfilter(), load_channelvars(), log_exec(), man_do_variable_value(), math(), mbl_sendsms_exec(), mbl_status_exec(), mixmonitor_exec(), msg_send_exec(), originate_exec(), ospauth_exec(), ospfinished_exec(), osplookup_exec(), ospnext_exec(), page_exec(), park_and_announce_app_exec(), park_app_parse_data(), parked_call_app_exec(), pbx_builtin_answer(), pbx_builtin_background(), pbx_builtin_saycharacters_case(), pbx_builtin_setvar_multiple(), pbx_builtin_waitdigit(), pbx_builtin_waitexten(), pickupchan_exec(), pjsip_acf_channel_read(), pjsip_acf_dial_contacts_read(), pjsip_acf_parse_uri_read(), pjsip_aor_function_read(), pjsip_contact_function_read(), pjsip_endpoint_function_read(), play_moh_exec(), playback_exec(), pp_each_extension_helper(), pqm_exec(), presence_read(), privacy_exec(), ql_exec(), queue_exec(), queue_function_mem_read(), queue_function_mem_write(), queue_function_memberpenalty_read(), queue_function_memberpenalty_write(), queue_function_queuegetchannel(), qupd_exec(), read_exec(), readexten_exec(), realtimefield_read(), receivefax_exec(), record_exec(), redirecting_write(), reload_single_member(), replace(), retrydial_exec(), rqm_exec(), saycountedadj_exec(), saycountednoun_exec(), sayfile_exec(), sayunixtime_exec(), scramble_write(), senddtmf_exec(), sendfax_exec(), sendmf_exec(), shared_read(), shared_write(), shift_pop(), sip_acf_channel_read(), sla_trunk_exec(), smdi_msg_read(), smdi_msg_retrieve_read(), sms_exec(), softhangup_exec(), sorcery_function_read(), speech_background(), speech_load(), srv_result_read(), stackpeek_read(), start_moh_exec(), start_monitor_exec(), statsd_exec(), stir_shaken_read(), stop_mixmonitor_full(), strbetween(), stream_echo_exec(), strreplace(), talk_detect_fn_write(), transfer_exec(), unshift_push(), upqm_exec(), userevent_exec(), verbose_exec(), vm_exec(), vm_execmain(), vm_playmsgexec(), volume_read(), volume_write(), wait_exec(), waitfor_exec(), waitforcond_exec(), xmpp_join_exec(), xmpp_leave_exec(), xmpp_send_exec(), xmpp_sendgroup_exec(), and zapateller_exec().

◆ AST_STANDARD_RAW_ARGS

#define AST_STANDARD_RAW_ARGS (   args,
  parse 
)    args.argc = __ast_app_separate_args(parse, ',', 0, args.argv, ((sizeof(args) - offsetof(typeof(args), argv)) / sizeof(args.argv[0])))

◆ ast_vm_greeter_register

#define ast_vm_greeter_register (   vm_table)    __ast_vm_greeter_register(vm_table, AST_MODULE_SELF)

See __ast_vm_greeter_register()

Definition at line 674 of file include/asterisk/app.h.

Referenced by load_module().

◆ ast_vm_register

#define ast_vm_register (   vm_table)    __ast_vm_register(vm_table, AST_MODULE_SELF)

See __ast_vm_register()

Definition at line 605 of file include/asterisk/app.h.

Referenced by load_module().

◆ BEGIN_OPTIONS

#define BEGIN_OPTIONS   {

Definition at line 1329 of file include/asterisk/app.h.

◆ END_OPTIONS

#define END_OPTIONS   }

Definition at line 1330 of file include/asterisk/app.h.

◆ VM_GREETER_MODULE_VERSION

#define VM_GREETER_MODULE_VERSION   1
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 632 of file include/asterisk/app.h.

Referenced by __ast_vm_greeter_register().

◆ VM_MODULE_VERSION

#define VM_MODULE_VERSION   2
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 553 of file include/asterisk/app.h.

Referenced by __ast_vm_register().

Typedef Documentation

◆ ast_copy_recording_to_vm_fn

typedef int() ast_copy_recording_to_vm_fn(struct ast_vm_recording_data *vm_rec_data)

Creates a voicemail based on a specified file to a mailbox.

Parameters
vm_rec_dataA record containing filename and voicemail txt info.
Return values
0on success
-1on failure

Definition at line 431 of file include/asterisk/app.h.

◆ ast_has_voicemail_fn

typedef int() ast_has_voicemail_fn(const char *mailboxes, const char *folder)

Determines if the given folder has messages.

Parameters
mailboxesComma or & delimited list of mailboxes (user). If no context is found, uses 'default' for the context.
folderThe folder to look in. Default is INBOX if not provided.
Return values
1if the folder has one or more messages.
0otherwise.

Definition at line 361 of file include/asterisk/app.h.

◆ ast_inboxcount2_fn

typedef int() ast_inboxcount2_fn(const char *mailboxes, int *urgentmsgs, int *newmsgs, int *oldmsgs)

Gets the number of messages that exist for the mailbox list.

Parameters
mailboxesComma or space delimited list of mailboxes (user). If no context is found, uses 'default' for the context.
urgentmsgsWhere to put the count of urgent messages. (Can be NULL)
newmsgsWhere to put the count of new messages. (Can be NULL)
oldmsgsWhere to put the count of old messages. (Can be NULL)

Simultaneously determines the count of new, old, and urgent messages. The total messages would then be the sum of these three.

Return values
0on success
-1on failure

Definition at line 397 of file include/asterisk/app.h.

◆ ast_inboxcount_fn

typedef int() ast_inboxcount_fn(const char *mailboxes, int *newmsgs, int *oldmsgs)

Gets the number of messages that exist for the mailbox list.

Parameters
mailboxesComma or space delimited list of mailboxes (user). If no context is found, uses 'default' for the context.
newmsgsWhere to put the count of new messages. (Can be NULL)
oldmsgsWhere to put the count of old messages. (Can be NULL)

Simultaneously determines the count of new + urgent and old messages. The total messages would then be the sum of these.

Return values
0on success
-1on failure

Definition at line 378 of file include/asterisk/app.h.

◆ ast_ivr_callback

typedef int() ast_ivr_callback(struct ast_channel *chan, char *option, void *cbdata)

Callback function for IVR.

Returns
returns 0 on completion, -1 on hangup or digit if interrupted

Definition at line 47 of file include/asterisk/app.h.

◆ ast_messagecount_fn

typedef int() ast_messagecount_fn(const char *mailbox_id, const char *folder)

Gets the number of messages that exist in a mailbox folder.

Parameters
mailbox_idThe mailbox name.
folderThe folder to look in. Default is INBOX if not provided.
Note
If requesting INBOX then the returned count is INBOX + Urgent.
Returns
The number of messages in the mailbox folder (zero or more).

Definition at line 409 of file include/asterisk/app.h.

◆ ast_sayname_fn

typedef int() ast_sayname_fn(struct ast_channel *chan, const char *mailbox_id)

Play a recorded user name for the mailbox to the specified channel.

Parameters
chanWhere to play the recorded name file.
mailbox_idThe mailbox name.
Return values
0Name played without interruption
dtmfASCII value of the DTMF which interrupted playback.
-1Unable to locate mailbox or hangup occurred.

Definition at line 421 of file include/asterisk/app.h.

◆ ast_vm_index_to_foldername_fn

typedef const char*() ast_vm_index_to_foldername_fn(int id)

Convert the mailbox folder id to a folder name.

Parameters
idMailbox folder id to convert.
Deprecated:
Nothing calls it and nothing ever should.
Returns
The folder name associated with the id.

Definition at line 442 of file include/asterisk/app.h.

◆ ast_vm_mailbox_snapshot_create_fn

typedef struct ast_vm_mailbox_snapshot*() ast_vm_mailbox_snapshot_create_fn(const char *user, const char *context, const char *folder, int descending, enum ast_vm_snapshot_sort_val sort_val, int combine_INBOX_and_OLD)

Create a snapshot of a mailbox which contains information about every msg.

Parameters
userThe user part of user.
contextThe context part of user. Must be explicit.
folderWhen not NULL only msgs from the specified folder will be included.
descendinglist the msgs in descending order rather than ascending order.
sort_valWhat to sort in the snapshot.
combine_INBOX_and_OLDWhen this argument is set, The OLD folder will be represented in the INBOX folder of the snapshot. This allows the snapshot to represent the OLD and INBOX messages in sorted order merged together.
Note
Only used by voicemail unit tests.
Return values
snapshoton success
NULLon failure

Definition at line 461 of file include/asterisk/app.h.

◆ ast_vm_mailbox_snapshot_destroy_fn

typedef struct ast_vm_mailbox_snapshot*() ast_vm_mailbox_snapshot_destroy_fn(struct ast_vm_mailbox_snapshot *mailbox_snapshot)

destroy a snapshot

Parameters
mailbox_snapshotThe snapshot to destroy.
Note
Only used by voicemail unit tests.
Return values
NULL

Definition at line 474 of file include/asterisk/app.h.

◆ ast_vm_msg_forward_fn

typedef int() ast_vm_msg_forward_fn(const char *from_mailbox, const char *from_context, const char *from_folder, const char *to_mailbox, const char *to_context, const char *to_folder, size_t num_msgs, const char *msg_ids[], int delete_old)

forward a message from one mailbox to another.

from_mailbox The original mailbox the message is being forwarded from from_context The voicemail context of the from_mailbox from_folder The folder from which the message is being forwarded to_mailbox The mailbox to forward the message to to_context The voicemail context of the to_mailbox to_folder The folder to which the message is being forwarded num_msgs The number of messages being forwarded msg_ids The message IDs of the messages in from_mailbox to forward delete_old If non-zero, the forwarded messages are also deleted from from_mailbox. Otherwise, the messages will remain in the from_mailbox.

Note
Only used by voicemail unit tests.
Return values
-1Failure
0Success

Definition at line 531 of file include/asterisk/app.h.

◆ ast_vm_msg_move_fn

typedef int() ast_vm_msg_move_fn(const char *mailbox, const char *context, size_t num_msgs, const char *oldfolder, const char *old_msg_ids[], const char *newfolder)

Move messages from one folder to another.

Parameters
mailboxThe mailbox to which the folders belong
contextThe voicemail context for the mailbox
num_msgsThe number of messages to move
oldfolderThe folder from where messages should be moved
old_msg_idsThe message IDs of the messages to move
newfolderThe folder to which messages should be moved new folder. This array must be num_msgs sized.
Note
Only used by voicemail unit tests.
Return values
-1Failure
0Success

Definition at line 492 of file include/asterisk/app.h.

◆ ast_vm_msg_play_cb

typedef void() ast_vm_msg_play_cb(struct ast_channel *chan, const char *playfile, int duration)

Voicemail playback callback function definition.

Parameters
chanChannel to play the file back on.
playfileLocation of file on disk
durationof file in seconds. This will be zero if msg is very short or has an unknown duration.
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 349 of file include/asterisk/app.h.

◆ ast_vm_msg_play_fn

typedef int() ast_vm_msg_play_fn(struct ast_channel *chan, const char *mailbox, const char *context, const char *folder, const char *msg_num, ast_vm_msg_play_cb *cb)

Play a voicemail msg back on a channel.

Parameters
chan
mailboxmsg is in.
contextof mailbox.
foldervoicemail folder to look in.
msg_nummessage number in the voicemailbox to playback to the channel.
cb
Note
Only used by voicemail unit tests.
Return values
0success
-1failure

Definition at line 550 of file include/asterisk/app.h.

◆ ast_vm_msg_remove_fn

typedef int() ast_vm_msg_remove_fn(const char *mailbox, const char *context, size_t num_msgs, const char *folder, const char *msgs[])

Remove/delete messages from a mailbox folder.

Parameters
mailboxThe mailbox from which to delete messages
contextThe voicemail context for the mailbox
num_msgsThe number of messages to delete
folderThe folder from which to remove messages
msgsThe message IDs of the messages to delete
Note
Only used by voicemail unit tests.
Return values
-1Failure
0Success

Definition at line 509 of file include/asterisk/app.h.

Enumeration Type Documentation

◆ ast_getdata_result

Enumerator
AST_GETDATA_FAILED 
AST_GETDATA_COMPLETE 
AST_GETDATA_TIMEOUT 
AST_GETDATA_INTERRUPTED 
AST_GETDATA_EMPTY_END_TERMINATED 

indicates a user terminated empty string rather than an empty string resulting from a timeout or other factors

Definition at line 1140 of file include/asterisk/app.h.

1140  {
1141  AST_GETDATA_FAILED = -1,
1143  AST_GETDATA_TIMEOUT = 1,
1145  /*! indicates a user terminated empty string rather than an empty string resulting
1146  * from a timeout or other factors */
1148 };

◆ ast_ivr_action

Enumerator
AST_ACTION_UPONE 

adata is unused

AST_ACTION_EXIT 

adata is the return value for ast_ivr_menu_run if channel was not hungup

AST_ACTION_CALLBACK 

adata is an ast_ivr_callback

AST_ACTION_PLAYBACK 

adata is file to play

AST_ACTION_BACKGROUND 

adata is file to play

AST_ACTION_PLAYLIST 

adata is list of files, separated by ; to play

AST_ACTION_MENU 

adata is a pointer to an ast_ivr_menu

AST_ACTION_REPEAT 

adata is max # of repeats, cast to a pointer

AST_ACTION_RESTART 

adata is like repeat, but resets repeats to 0

AST_ACTION_TRANSFER 

adata is a string with exten

[@context]
AST_ACTION_WAITOPTION 

adata is a timeout, or 0 for defaults

AST_ACTION_NOOP 

adata is unused

AST_ACTION_BACKLIST 

adata is list of files separated by ; allows interruption

Definition at line 49 of file include/asterisk/app.h.

49  {
50  AST_ACTION_UPONE, /*!< adata is unused */
51  AST_ACTION_EXIT, /*!< adata is the return value for ast_ivr_menu_run if channel was not hungup */
52  AST_ACTION_CALLBACK, /*!< adata is an ast_ivr_callback */
53  AST_ACTION_PLAYBACK, /*!< adata is file to play */
54  AST_ACTION_BACKGROUND, /*!< adata is file to play */
55  AST_ACTION_PLAYLIST, /*!< adata is list of files, separated by ; to play */
56  AST_ACTION_MENU, /*!< adata is a pointer to an ast_ivr_menu */
57  AST_ACTION_REPEAT, /*!< adata is max # of repeats, cast to a pointer */
58  AST_ACTION_RESTART, /*!< adata is like repeat, but resets repeats to 0 */
59  AST_ACTION_TRANSFER, /*!< adata is a string with exten\verbatim[@context]\endverbatim */
60  AST_ACTION_WAITOPTION, /*!< adata is a timeout, or 0 for defaults */
61  AST_ACTION_NOOP, /*!< adata is unused */
62  AST_ACTION_BACKLIST, /*!< adata is list of files separated by ; allows interruption */
ast_ivr_action

◆ AST_LOCK_RESULT

Enumerator
AST_LOCK_SUCCESS 
AST_LOCK_TIMEOUT 
AST_LOCK_PATH_NOT_FOUND 
AST_LOCK_FAILURE 

Definition at line 1150 of file include/asterisk/app.h.

◆ AST_LOCK_TYPE

Type of locking to use in ast_lock_path / ast_unlock_path.

Enumerator
AST_LOCK_TYPE_LOCKFILE 
AST_LOCK_TYPE_FLOCK 

Definition at line 1158 of file include/asterisk/app.h.

◆ ast_record_if_exists

Possible actions to take if a recording already exists

Since
12
Enumerator
AST_RECORD_IF_EXISTS_ERROR 

Return an Error State for IF_Exists

AST_RECORD_IF_EXISTS_FAIL 

Fail the recording.

AST_RECORD_IF_EXISTS_OVERWRITE 

Overwrite the existing recording.

AST_RECORD_IF_EXISTS_APPEND 

Append to the existing recording.

Definition at line 1058 of file include/asterisk/app.h.

1058  {
1059  /*! Return an Error State for IF_Exists */
1061  /*! Fail the recording. */
1063  /*! Overwrite the existing recording. */
1065  /*! Append to the existing recording. */
1067 };

◆ ast_timelen

Enumerator
TIMELEN_HOURS 
TIMELEN_MINUTES 
TIMELEN_SECONDS 
TIMELEN_MILLISECONDS 

Definition at line 113 of file include/asterisk/app.h.

◆ ast_vm_snapshot_sort_val

Enumerator
AST_VM_SNAPSHOT_SORT_BY_ID 
AST_VM_SNAPSHOT_SORT_BY_TIME 

Definition at line 312 of file include/asterisk/app.h.

Function Documentation

◆ __ast_app_separate_args()

unsigned int __ast_app_separate_args ( char *  buf,
char  delim,
int  remove_chars,
char **  array,
int  arraylen 
)

Separate a string into arguments in an array.

Parameters
bufThe string to be parsed (this must be a writable copy, as it will be modified)
delimThe character to be used to delimit arguments
remove_charsRemove backslashes and quote characters, while parsing
arrayAn array of 'char *' to be filled in with pointers to the found arguments
arraylenThe number of elements in the array (i.e. the number of arguments you will accept)

Note: if there are more arguments in the string than the array will hold, the last element of the array will contain the remaining arguments, not separated.

The array will be completely zeroed by this function before it populates any entries.

Returns
The number of arguments found, or zero if the function arguments are not valid.
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 2139 of file main/app.c.

References buf, NULL, paren, and quote().

2140 {
2141  int argc;
2142  char *scan, *wasdelim = NULL;
2143  int paren = 0, quote = 0, bracket = 0;
2144 
2145  if (!array || !arraylen) {
2146  return 0;
2147  }
2148 
2149  memset(array, 0, arraylen * sizeof(*array));
2150 
2151  if (!buf) {
2152  return 0;
2153  }
2154 
2155  scan = buf;
2156 
2157  for (argc = 0; *scan && (argc < arraylen - 1); argc++) {
2158  array[argc] = scan;
2159  for (; *scan; scan++) {
2160  if (*scan == '(') {
2161  paren++;
2162  } else if (*scan == ')') {
2163  if (paren) {
2164  paren--;
2165  }
2166  } else if (*scan == '[') {
2167  bracket++;
2168  } else if (*scan == ']') {
2169  if (bracket) {
2170  bracket--;
2171  }
2172  } else if (*scan == '"' && delim != '"') {
2173  quote = quote ? 0 : 1;
2174  if (remove_chars) {
2175  /* Remove quote character from argument */
2176  memmove(scan, scan + 1, strlen(scan));
2177  scan--;
2178  }
2179  } else if (*scan == '\\') {
2180  if (remove_chars) {
2181  /* Literal character, don't parse */
2182  memmove(scan, scan + 1, strlen(scan));
2183  } else {
2184  scan++;
2185  }
2186  } else if ((*scan == delim) && !paren && !quote && !bracket) {
2187  wasdelim = scan;
2188  *scan++ = '\0';
2189  break;
2190  }
2191  }
2192  }
2193 
2194  /* If the last character in the original string was the delimiter, then
2195  * there is one additional argument. */
2196  if (*scan || (scan > buf && (scan - 1) == wasdelim)) {
2197  array[argc++] = scan;
2198  }
2199 
2200  return argc;
2201 }
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
#define NULL
Definition: resample.c:96
static int quote(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
static int array(struct ast_channel *chan, const char *cmd, char *var, const char *value)
#define paren
Definition: ael_lex.c:973

◆ __ast_vm_greeter_register()

int __ast_vm_greeter_register ( const struct ast_vm_greeter_functions vm_table,
struct ast_module module 
)

Set voicemail greeter function callbacks.

Since
13.0.0
Parameters
vm_tableVoicemail greeter function table to install.
modulePointer to the module implementing the interface
Return values
0on success.
-1on error.
AST_MODULE_LOAD_DECLINEif there's already another greeter registered.
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 569 of file main/app.c.

References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_alloc_options, ao2_cleanup, ao2_global_obj_ref, ao2_global_obj_replace_unref, ast_log, AST_MODULE_LOAD_DECLINE, LOG_ERROR, LOG_WARNING, ast_vm_greeter_functions::module, ast_vm_greeter_functions::module_name, ast_vm_greeter_functions::module_version, NULL, RAII_VAR, table, VM_GREETER_MODULE_VERSION, and vm_table.

570 {
572 
573  if (!vm_table->module_name) {
574  ast_log(LOG_ERROR, "Voicemail greeter provider missing required information.\n");
575  return -1;
576  }
577  if (vm_table->module_version != VM_GREETER_MODULE_VERSION) {
578  ast_log(LOG_ERROR, "Voicemail greeter provider '%s' has incorrect version\n",
579  vm_table->module_name);
580  return -1;
581  }
582 
583  table = ao2_global_obj_ref(vm_greeter_provider);
584  if (table) {
585  ast_log(LOG_WARNING, "Voicemail greeter provider already registered by %s.\n",
586  table->module_name);
588  }
589 
591  if (!table) {
592  return -1;
593  }
594  *table = *vm_table;
595  table->module = module;
596 
597  ao2_global_obj_replace_unref(vm_greeter_provider, table);
598  return 0;
599 }
unsigned int module_version
The version of this function table.
static const struct ast_vm_functions vm_table
#define LOG_WARNING
Definition: logger.h:274
Voicemail greeter function table definition.
#define ao2_global_obj_ref(holder)
Definition: astobj2.h:925
#define VM_GREETER_MODULE_VERSION
#define ao2_alloc_options(data_size, destructor_fn, options)
Definition: astobj2.h:406
#define NULL
Definition: resample.c:96
static char * table
Definition: cdr_odbc.c:58
#define ast_log
Definition: astobj2.c:42
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:911
#define LOG_ERROR
Definition: logger.h:285
const char * module_name
The name of the module that provides the voicemail greeter functionality.
Module has failed to load, may be in an inconsistent state.
Definition: module.h:78
#define ao2_global_obj_replace_unref(holder, obj)
Definition: astobj2.h:908
#define ao2_cleanup(obj)
Definition: astobj2.h:1958

◆ __ast_vm_register()

int __ast_vm_register ( const struct ast_vm_functions vm_table,
struct ast_module module 
)

Set voicemail function callbacks.

Parameters
vm_tableVoicemail function table to install.
modulePointer to the module implementing the interface
Return values
0on success.
-1on error.
AST_MODULE_LOAD_DECLINEif there's already another provider registered.
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 458 of file main/app.c.

References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_alloc_options, ao2_cleanup, ao2_global_obj_ref, ao2_global_obj_replace_unref, ast_log, AST_MODULE_LOAD_DECLINE, LOG_ERROR, LOG_WARNING, ast_vm_functions::module, ast_vm_functions::module_name, ast_vm_functions::module_version, NULL, RAII_VAR, table, VM_MODULE_VERSION, and vm_table.

459 {
461 
462  if (!vm_table->module_name) {
463  ast_log(LOG_ERROR, "Voicemail provider missing required information.\n");
464  return -1;
465  }
466  if (vm_table->module_version != VM_MODULE_VERSION) {
467  ast_log(LOG_ERROR, "Voicemail provider '%s' has incorrect version\n",
468  vm_table->module_name);
469  return -1;
470  }
471 
472  table = ao2_global_obj_ref(vm_provider);
473  if (table) {
474  ast_log(LOG_WARNING, "Voicemail provider already registered by %s.\n",
475  table->module_name);
477  }
478 
480  if (!table) {
481  return -1;
482  }
483  *table = *vm_table;
484  table->module = module;
485 
486  ao2_global_obj_replace_unref(vm_provider, table);
487  return 0;
488 }
static const struct ast_vm_functions vm_table
#define LOG_WARNING
Definition: logger.h:274
#define ao2_global_obj_ref(holder)
Definition: astobj2.h:925
#define ao2_alloc_options(data_size, destructor_fn, options)
Definition: astobj2.h:406
#define NULL
Definition: resample.c:96
static char * table
Definition: cdr_odbc.c:58
#define ast_log
Definition: astobj2.c:42
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:911
#define VM_MODULE_VERSION
#define LOG_ERROR
Definition: logger.h:285
Module has failed to load, may be in an inconsistent state.
Definition: module.h:78
const char * module_name
The name of the module that provides the voicemail functionality.
#define ao2_global_obj_replace_unref(holder, obj)
Definition: astobj2.h:908
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
unsigned int module_version
The version of this function table.
Voicemail function table definition.

◆ app_init()

int app_init ( void  )

Initialize the application core.

Return values
0Success
-1Failure
Since
12
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 3145 of file main/app.c.

References app_cleanup(), ast_register_cleanup(), stasis_topic_create(), and stasis_topic_pool_create().

Referenced by asterisk_daemon().

3146 {
3148 #ifdef HAVE_CAP
3149  child_cap = cap_from_text("cap_net_admin-eip");
3150 #endif
3151  queue_topic_all = stasis_topic_create("queue:all");
3152  if (!queue_topic_all) {
3153  return -1;
3154  }
3156  if (!queue_topic_pool) {
3157  return -1;
3158  }
3159  return 0;
3160 }
static struct stasis_topic * queue_topic_all
Definition: main/app.c:90
static void app_cleanup(void)
Definition: main/app.c:3134
struct stasis_topic_pool * stasis_topic_pool_create(struct stasis_topic *pooled_topic)
Create a topic pool that routes messages from dynamically generated topics to the given topic...
Definition: stasis.c:1833
static struct stasis_topic_pool * queue_topic_pool
Definition: main/app.c:91
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
struct stasis_topic * stasis_topic_create(const char *name)
Create a new topic.
Definition: stasis.c:618

◆ ast_app_copy_recording_to_vm()

int ast_app_copy_recording_to_vm ( struct ast_vm_recording_data vm_rec_data)

param[in] vm_rec_data Contains data needed to make the recording. retval 0 voicemail successfully created from recording. retval -1 Failure

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

Definition at line 686 of file main/app.c.

References VM_API_CALL.

Referenced by copy_to_voicemail().

687 {
688  int res = -1;
689 
690  VM_API_CALL(res, copy_recording_to_vm, (vm_rec_data));
691  return res;
692 }
#define VM_API_CALL(res, api_call, api_parms)
Definition: main/app.c:637

◆ ast_app_dtget()

int ast_app_dtget ( struct ast_channel chan,
const char *  context,
char *  collect,
size_t  size,
int  maxlen,
int  timeout 
)

Present a dialtone and collect a certain length extension.

Returns
Returns 1 on valid extension entered, -1 on hangup, or 0 on invalid extension.
Note
Note that if 'collect' holds digits already, new digits will be appended, so be sure it's initialized properly

Present a dialtone and collect a certain length extension.

Parameters
chanstruct.
context
collect
size
maxlen
timeouttimeout in milliseconds
Returns
0 if extension does not exist, 1 if extension exists
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 139 of file main/app.c.

References ast_channel_caller(), ast_channel_pbx(), ast_channel_zone(), ast_exists_extension(), ast_get_indication_tone(), ast_ignore_pattern(), ast_log, ast_matchmore_extension(), ast_playtones_start(), ast_playtones_stop(), ast_tone_zone_sound_unref(), ast_waitfordigit(), ast_tone_zone_sound::data, ast_pbx::dtimeoutms, LOG_NOTICE, NULL, and S_COR.

Referenced by grab_transfer().

140 {
141  struct ast_tone_zone_sound *ts;
142  int res = 0, x = 0;
143 
144  if (maxlen > size) {
145  maxlen = size;
146  }
147 
148  if (!timeout) {
149  if (ast_channel_pbx(chan) && ast_channel_pbx(chan)->dtimeoutms) {
150  timeout = ast_channel_pbx(chan)->dtimeoutms;
151  } else {
152  timeout = 5000;
153  }
154  }
155 
156  if ((ts = ast_get_indication_tone(ast_channel_zone(chan), "dial"))) {
157  res = ast_playtones_start(chan, 0, ts->data, 0);
158  ts = ast_tone_zone_sound_unref(ts);
159  } else {
160  ast_log(LOG_NOTICE, "Huh....? no dial for indications?\n");
161  }
162 
163  for (x = strlen(collect); x < maxlen; ) {
164  res = ast_waitfordigit(chan, timeout);
165  if (!ast_ignore_pattern(context, collect)) {
166  ast_playtones_stop(chan);
167  }
168  if (res < 1) {
169  break;
170  }
171  if (res == '#') {
172  break;
173  }
174  collect[x++] = res;
175  if (!ast_matchmore_extension(chan, context, collect, 1,
176  S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL))) {
177  break;
178  }
179  }
180 
181  if (res >= 0) {
182  res = ast_exists_extension(chan, context, collect, 1,
183  S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL)) ? 1 : 0;
184  }
185 
186  return res;
187 }
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
int ast_matchmore_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Looks to see if adding anything to this extension might match something. (exists ^ canmatch) ...
Definition: pbx.c:4199
struct ast_tone_zone * ast_channel_zone(const struct ast_channel *chan)
int ast_ignore_pattern(const char *context, const char *pattern)
Checks to see if a number should be ignored.
Definition: pbx.c:6921
void ast_playtones_stop(struct ast_channel *chan)
Stop playing tones on a channel.
Definition: indications.c:393
#define NULL
Definition: resample.c:96
Number structure.
Definition: app_followme.c:154
#define ast_log
Definition: astobj2.c:42
struct ast_pbx * ast_channel_pbx(const struct ast_channel *chan)
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
Definition: strings.h:85
static struct ast_tone_zone_sound * ast_tone_zone_sound_unref(struct ast_tone_zone_sound *ts)
Release a reference to an ast_tone_zone_sound.
Definition: indications.h:227
int ast_exists_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Determine whether an extension exists.
Definition: pbx.c:4179
Description of a tone.
Definition: indications.h:35
struct ast_tone_zone_sound * ast_get_indication_tone(const struct ast_tone_zone *zone, const char *indication)
Locate a tone zone sound.
Definition: indications.c:455
#define LOG_NOTICE
Definition: logger.h:263
int ast_waitfordigit(struct ast_channel *c, int ms)
Waits for a digit.
Definition: channel.c:3180
int dtimeoutms
Definition: pbx.h:212
int ast_playtones_start(struct ast_channel *chan, int vol, const char *tonelist, int interruptible)
Start playing a list of tones on a channel.
Definition: indications.c:302
const char * data
Description of a tone.
Definition: indications.h:52
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:120

◆ ast_app_exec_macro()

int ast_app_exec_macro ( struct ast_channel autoservice_chan,
struct ast_channel macro_chan,
const char *  macro_args 
)

Run a macro on a channel, placing an optional second channel into autoservice.

Since
11.0

This is a shorthand method that makes it very easy to run a macro on any given channel. It is perfectly reasonable to supply a NULL autoservice_chan here in case there is no channel to place into autoservice.

Note
Absolutely NO channel locks should be held before calling this function.
Parameters
autoservice_chanA channel to place into autoservice while the macro is run
macro_chanChannel to execute macro on.
macro_argsMacro application argument string.
Return values
0success
-1on error
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 290 of file main/app.c.

References ast_autoservice_start(), ast_autoservice_stop(), ast_channel_context(), ast_channel_exten(), ast_channel_name(), ast_channel_priority(), ast_check_hangup_locked(), ast_debug, ast_log, ast_queue_hangup(), LOG_WARNING, pbx_exec(), and pbx_findapp().

Referenced by ast_app_run_macro(), dial_exec_full(), generic_recall(), run_app_helper(), and try_calling().

291 {
292  struct ast_app *macro_app;
293  int res;
294 
295  macro_app = pbx_findapp("Macro");
296  if (!macro_app) {
298  "Cannot run 'Macro(%s)'. The application is not available.\n", macro_args);
299  return -1;
300  }
301  if (autoservice_chan) {
302  ast_autoservice_start(autoservice_chan);
303  }
304 
305  ast_debug(4, "%s Original location: %s,%s,%d\n", ast_channel_name(macro_chan),
306  ast_channel_context(macro_chan), ast_channel_exten(macro_chan),
307  ast_channel_priority(macro_chan));
308 
309  res = pbx_exec(macro_chan, macro_app, macro_args);
310  ast_debug(4, "Macro exited with status %d\n", res);
311 
312  /*
313  * Assume anything negative from Macro is an error.
314  * Anything else is success.
315  */
316  if (res < 0) {
317  res = -1;
318  } else {
319  res = 0;
320  }
321 
322  ast_debug(4, "%s Ending location: %s,%s,%d\n", ast_channel_name(macro_chan),
323  ast_channel_context(macro_chan), ast_channel_exten(macro_chan),
324  ast_channel_priority(macro_chan));
325 
326  if (autoservice_chan) {
327  ast_autoservice_stop(autoservice_chan);
328  }
329 
330  if (ast_check_hangup_locked(macro_chan)) {
331  ast_queue_hangup(macro_chan);
332  }
333 
334  return res;
335 }
int ast_queue_hangup(struct ast_channel *chan)
Queue a hangup frame.
Definition: channel.c:1146
int ast_autoservice_start(struct ast_channel *chan)
Automatically service a channel for us...
Definition: autoservice.c:200
int pbx_exec(struct ast_channel *c, struct ast_app *app, const char *data)
Execute an application.
Definition: pbx_app.c:471
int ast_check_hangup_locked(struct ast_channel *chan)
Definition: channel.c:455
#define LOG_WARNING
Definition: logger.h:274
int ast_channel_priority(const struct ast_channel *chan)
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define ast_log
Definition: astobj2.c:42
const char * ast_channel_exten(const struct ast_channel *chan)
int ast_autoservice_stop(struct ast_channel *chan)
Stop servicing a channel for us...
Definition: autoservice.c:266
ast_app: A registered application
Definition: pbx_app.c:45
const char * ast_channel_name(const struct ast_channel *chan)
const char * ast_channel_context(const struct ast_channel *chan)
struct ast_app * pbx_findapp(const char *app)
Look up an application.
Definition: ael_main.c:165

◆ ast_app_exec_sub()

int ast_app_exec_sub ( struct ast_channel autoservice_chan,
struct ast_channel sub_chan,
const char *  sub_args,
int  ignore_hangup 
)

Run a subroutine on a channel, placing an optional second channel into autoservice.

Since
11

This is a shorthand method that makes it very easy to run a subroutine on any given channel. It is perfectly reasonable to supply a NULL autoservice_chan here in case there is no channel to place into autoservice.

Note
Absolutely NO channel locks should be held before calling this function.
Parameters
autoservice_chanA channel to place into autoservice while the subroutine is run
sub_chanChannel to execute subroutine on.
sub_argsGosub application argument string.
ignore_hangupTRUE if a hangup does not stop execution of the routine.
Return values
0success
-1on error
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 387 of file main/app.c.

References app_stack_callbacks, ast_autoservice_start(), ast_autoservice_stop(), ast_check_hangup_locked(), ast_log, ast_module_running_ref, ast_module_unref, ast_queue_hangup(), LOG_WARNING, ast_app_stack_funcs::module, and ast_app_stack_funcs::run_sub.

Referenced by app_exec(), ast_app_run_sub(), ast_pbx_hangup_handler_run(), ast_pre_call(), dial_exec_full(), generic_recall(), originate_exec(), page_exec(), queue_exec(), run_app_helper(), and try_calling().

388 {
389  const struct ast_app_stack_funcs *funcs;
390  int res;
391 
392  funcs = app_stack_callbacks;
393  if (!funcs || !funcs->run_sub || !ast_module_running_ref(funcs->module)) {
395  "Cannot run 'Gosub(%s)'. The app_stack module is not available.\n",
396  sub_args);
397  return -1;
398  }
399 
400  if (autoservice_chan) {
401  ast_autoservice_start(autoservice_chan);
402  }
403 
404  res = funcs->run_sub(sub_chan, sub_args, ignore_hangup);
405  ast_module_unref(funcs->module);
406 
407  if (autoservice_chan) {
408  ast_autoservice_stop(autoservice_chan);
409  }
410 
411  if (!ignore_hangup && ast_check_hangup_locked(sub_chan)) {
412  ast_queue_hangup(sub_chan);
413  }
414 
415  return res;
416 }
int ast_queue_hangup(struct ast_channel *chan)
Queue a hangup frame.
Definition: channel.c:1146
int ast_autoservice_start(struct ast_channel *chan)
Automatically service a channel for us...
Definition: autoservice.c:200
int ast_check_hangup_locked(struct ast_channel *chan)
Definition: channel.c:455
#define LOG_WARNING
Definition: logger.h:274
#define ast_module_unref(mod)
Release a reference to the module.
Definition: module.h:469
#define ast_log
Definition: astobj2.c:42
int ast_autoservice_stop(struct ast_channel *chan)
Stop servicing a channel for us...
Definition: autoservice.c:266
Stack applications callback functions.
static const struct ast_app_stack_funcs * app_stack_callbacks
Definition: main/app.c:361
int(* run_sub)(struct ast_channel *chan, const char *args, int ignore_hangup)
Callback for the routine to run a subroutine on a channel.
#define ast_module_running_ref(mod)
Hold a reference to the module if it is running.
Definition: module.h:455

◆ ast_app_expand_sub_args()

const char* ast_app_expand_sub_args ( struct ast_channel chan,
const char *  args 
)

Add missing context/exten to subroutine argument string.

Parameters
chanChannel to obtain context/exten.
argsGosub application argument string.

Fills in the optional context and exten from the given channel.

Return values
New-argsGosub argument string on success. Must be freed.
NULLon error.
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 368 of file main/app.c.

References app_stack_callbacks, ast_log, ast_module_running_ref, ast_module_unref, ast_app_stack_funcs::expand_sub_args, LOG_WARNING, ast_app_stack_funcs::module, and NULL.

Referenced by app_exec(), ast_pbx_hangup_handler_push(), dial_exec_full(), and page_exec().

369 {
370  const struct ast_app_stack_funcs *funcs;
371  const char *new_args;
372 
373  funcs = app_stack_callbacks;
374  if (!funcs || !funcs->expand_sub_args || !ast_module_running_ref(funcs->module)) {
376  "Cannot expand 'Gosub(%s)' arguments. The app_stack module is not available.\n",
377  args);
378  return NULL;
379  }
380 
381  new_args = funcs->expand_sub_args(chan, args);
382  ast_module_unref(funcs->module);
383 
384  return new_args;
385 }
#define LOG_WARNING
Definition: logger.h:274
const char * args
#define NULL
Definition: resample.c:96
#define ast_module_unref(mod)
Release a reference to the module.
Definition: module.h:469
#define ast_log
Definition: astobj2.c:42
Stack applications callback functions.
static const struct ast_app_stack_funcs * app_stack_callbacks
Definition: main/app.c:361
#define ast_module_running_ref(mod)
Hold a reference to the module if it is running.
Definition: module.h:455
const char *(* expand_sub_args)(struct ast_channel *chan, const char *args)
Add missing context/exten to Gosub application argument string.

◆ ast_app_getdata()

int ast_app_getdata ( struct ast_channel c,
const char *  prompt,
char *  s,
int  maxlen,
int  timeout 
)

Plays a stream and gets DTMF data from a channel.

Parameters
cWhich channel one is interacting with
promptFile to pass to ast_streamfile (the one that you wish to play). It is also valid for this to be multiple files concatenated by "&". For example, "file1&file2&file3".
sThe location where the DTMF data will be stored
maxlenMax Length of the data
timeoutTimeout length waiting for data(in milliseconds). Set to 0 for standard timeout(six seconds), or -1 for no time out.

This function was designed for application programmers for situations where they need to play a message and then get some DTMF data in response to the message. If a digit is pressed during playback, it will immediately break out of the message and continue execution of your code.

Plays a stream and gets DTMF data from a channel.

Parameters
cThe channel to read from
promptThe file to stream to the channel
sThe string to read in to. Must be at least the size of your length
maxlenHow many digits to read (maximum)
timeoutset timeout to 0 for "standard" timeouts. Set timeout to -1 for "ludicrous time" (essentially never times out)
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 198 of file main/app.c.

References ast_app_getdata_terminator(), and NULL.

Referenced by auth_exec(), conf_exec(), conf_get_pin(), dictate_exec(), find_conf(), testclient_exec(), testserver_exec(), and vm_exec().

199 {
200  return ast_app_getdata_terminator(c, prompt, s, maxlen, timeout, NULL);
201 }
enum ast_getdata_result ast_app_getdata_terminator(struct ast_channel *c, const char *prompt, char *s, int maxlen, int timeout, char *terminator)
ast_app_getdata
Definition: main/app.c:213
#define NULL
Definition: resample.c:96
static struct ast_str * prompt
Definition: asterisk.c:2725

◆ ast_app_getdata_full()

int ast_app_getdata_full ( struct ast_channel c,
const char *  prompt,
char *  s,
int  maxlen,
int  timeout,
int  audiofd,
int  ctrlfd 
)

Full version with audiofd and controlfd. NOTE: returns '2' on ctrlfd available, not '1' like other full functions.

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

Definition at line 267 of file main/app.c.

References ast_channel_language(), ast_readstring_full(), ast_streamfile(), and ast_strlen_zero().

Referenced by handle_getdata().

268 {
269  int res, to = 2000, fto = 6000;
270 
271  if (!ast_strlen_zero(prompt)) {
273  if (res < 0) {
274  return res;
275  }
276  }
277 
278  if (timeout > 0) {
279  fto = to = timeout;
280  }
281  if (timeout < 0) {
282  fto = to = 1000000000;
283  }
284 
285  res = ast_readstring_full(c, s, maxlen, to, fto, "#", audiofd, ctrlfd);
286 
287  return res;
288 }
int ast_streamfile(struct ast_channel *c, const char *filename, const char *preflang)
Streams a file.
Definition: file.c:1250
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
int ast_readstring_full(struct ast_channel *c, char *s, int len, int timeout, int rtimeout, char *enders, int audiofd, int ctrlfd)
Definition: channel.c:6577
const char * ast_channel_language(const struct ast_channel *chan)
static struct ast_str * prompt
Definition: asterisk.c:2725

◆ ast_app_getdata_terminator()

int ast_app_getdata_terminator ( struct ast_channel c,
const char *  prompt,
char *  s,
int  maxlen,
int  timeout,
char *  terminator 
)

Plays a stream and gets DTMF data from a channel.

Parameters
cWhich channel one is interacting with
promptFile to pass to ast_streamfile (the one that you wish to play). It is also valid for this to be multiple files concatenated by "&". For example, "file1&file2&file3".
sThe location where the DTMF data will be stored
maxlenMax Length of the data
timeoutTimeout length waiting for data(in milliseconds). Set to 0 for standard timeout(six seconds), or -1 for no time out.
terminatorA string of characters that may be used as terminators to end input. If NULL, "#" will be used.

This function was designed for application programmers for situations where they need to play a message and then get some DTMF data in response to the message. If a digit is pressed during playback, it will immediately break out of the message and continue execution of your code.

Plays a stream and gets DTMF data from a channel.

Parameters
cThe channel to read from
promptThe file to stream to the channel
sThe string to read in to. Must be at least the size of your length
maxlenHow many digits to read (maximum)
timeoutset timeout to 0 for "standard" timeouts. Set timeout to -1 for "ludicrous time" (essentially never times out)
terminatorA string of characters that may be used as terminators to end input. Default if NULL is "#"
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 213 of file main/app.c.

References ast_channel_language(), ast_channel_pbx(), AST_GETDATA_EMPTY_END_TERMINATED, ast_readstring(), ast_strdupa, ast_streamfile(), ast_strlen_zero(), ast_pbx::dtimeoutms, ast_pbx::rtimeoutms, S_OR, and strsep().

Referenced by ast_app_getdata(), and read_exec().

215 {
216  int res = 0, to, fto;
217  char *front, *filename;
218 
219  /* XXX Merge with full version? XXX */
220 
221  if (maxlen)
222  s[0] = '\0';
223 
224  if (!prompt)
225  prompt = "";
226 
227  filename = ast_strdupa(prompt);
228  while ((front = strsep(&filename, "&"))) {
229  if (!ast_strlen_zero(front)) {
230  res = ast_streamfile(c, front, ast_channel_language(c));
231  if (res)
232  continue;
233  }
234  if (ast_strlen_zero(filename)) {
235  /* set timeouts for the last prompt */
236  fto = ast_channel_pbx(c) ? ast_channel_pbx(c)->rtimeoutms : 6000;
237  to = ast_channel_pbx(c) ? ast_channel_pbx(c)->dtimeoutms : 2000;
238 
239  if (timeout > 0) {
240  fto = to = timeout;
241  }
242  if (timeout < 0) {
243  fto = to = 1000000000;
244  }
245  } else {
246  /* there is more than one prompt, so
247  * get rid of the long timeout between
248  * prompts, and make it 50ms */
249  fto = 50;
250  to = ast_channel_pbx(c) ? ast_channel_pbx(c)->dtimeoutms : 2000;
251  }
252  res = ast_readstring(c, s, maxlen, to, fto, S_OR(terminator, "#"));
254  return res;
255  }
256  if (!ast_strlen_zero(s)) {
257  return res;
258  }
259  }
260 
261  return res;
262 }
int ast_streamfile(struct ast_channel *c, const char *filename, const char *preflang)
Streams a file.
Definition: file.c:1250
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
struct ast_pbx * ast_channel_pbx(const struct ast_channel *chan)
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
char * strsep(char **str, const char *delims)
int dtimeoutms
Definition: pbx.h:212
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
Definition: strings.h:79
const char * ast_channel_language(const struct ast_channel *chan)
static struct ast_str * prompt
Definition: asterisk.c:2725
int ast_readstring(struct ast_channel *c, char *s, int len, int timeout, int rtimeout, char *enders)
Reads multiple digits.
Definition: channel.c:6572
int rtimeoutms
Definition: pbx.h:213

◆ ast_app_group_discard()

int ast_app_group_discard ( struct ast_channel chan)

Discard all group counting for a channel.

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

Definition at line 2102 of file main/app.c.

References ast_free, AST_RWLIST_REMOVE_CURRENT, AST_RWLIST_TRAVERSE_SAFE_BEGIN, AST_RWLIST_TRAVERSE_SAFE_END, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_group_info::chan, ast_group_info::group_list, and NULL.

Referenced by ast_channel_destructor().

2103 {
2104  struct ast_group_info *gi = NULL;
2105 
2108  if (gi->chan == chan) {
2110  ast_free(gi);
2111  }
2112  }
2115 
2116  return 0;
2117 }
channel group info
Definition: channel.h:2906
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition: linkedlists.h:51
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
#define NULL
Definition: resample.c:96
#define AST_RWLIST_REMOVE_CURRENT
Definition: linkedlists.h:569
#define AST_RWLIST_TRAVERSE_SAFE_BEGIN
Definition: linkedlists.h:544
struct ast_channel * chan
Definition: channel.h:2907
#define ast_free(a)
Definition: astmm.h:182
struct ast_group_info::@235 group_list
#define AST_RWLIST_TRAVERSE_SAFE_END
Definition: linkedlists.h:616

◆ ast_app_group_get_count()

int ast_app_group_get_count ( const char *  group,
const char *  category 
)

Get the current channel count of the specified group and category.

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

Definition at line 2023 of file main/app.c.

References AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, ast_strlen_zero(), ast_group_info::category, ast_group_info::group, ast_group_info::group_list, and NULL.

Referenced by group_count_function_read().

2024 {
2025  struct ast_group_info *gi = NULL;
2026  int count = 0;
2027 
2028  if (ast_strlen_zero(group)) {
2029  return 0;
2030  }
2031 
2034  if (!strcasecmp(gi->group, group) && (ast_strlen_zero(category) || (!ast_strlen_zero(gi->category) && !strcasecmp(gi->category, category)))) {
2035  count++;
2036  }
2037  }
2039 
2040  return count;
2041 }
channel group info
Definition: channel.h:2906
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
#define NULL
Definition: resample.c:96
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
Definition: linkedlists.h:77
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
#define AST_RWLIST_TRAVERSE
Definition: linkedlists.h:493
char * group
Definition: channel.h:2909
char * category
Definition: channel.h:2908
struct ast_group_info::@235 group_list

◆ ast_app_group_list_head()

struct ast_group_info* ast_app_group_list_head ( void  )

Get the head of the group count list.

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

Definition at line 2129 of file main/app.c.

References AST_RWLIST_FIRST.

Referenced by group_count_function_read(), group_function_read(), group_list_function_read(), and group_show_channels().

2130 {
2131  return AST_RWLIST_FIRST(&groups);
2132 }
#define AST_RWLIST_FIRST
Definition: linkedlists.h:422

◆ ast_app_group_list_rdlock()

int ast_app_group_list_rdlock ( void  )

Read Lock the group count list.

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

Definition at line 2124 of file main/app.c.

References AST_RWLIST_RDLOCK.

Referenced by group_count_function_read(), group_function_read(), group_list_function_read(), and group_show_channels().

2125 {
2126  return AST_RWLIST_RDLOCK(&groups);
2127 }
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
Definition: linkedlists.h:77

◆ ast_app_group_list_unlock()

int ast_app_group_list_unlock ( void  )

Unlock the group count list.

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

Definition at line 2134 of file main/app.c.

References AST_RWLIST_UNLOCK.

Referenced by group_count_function_read(), group_function_read(), group_list_function_read(), and group_show_channels().

2135 {
2136  return AST_RWLIST_UNLOCK(&groups);
2137 }
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150

◆ ast_app_group_list_wrlock()

int ast_app_group_list_wrlock ( void  )

Write Lock the group count list.

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

Definition at line 2119 of file main/app.c.

References AST_RWLIST_WRLOCK.

2120 {
2121  return AST_RWLIST_WRLOCK(&groups);
2122 }
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition: linkedlists.h:51

◆ ast_app_group_match_get_count()

int ast_app_group_match_get_count ( const char *  groupmatch,
const char *  category 
)

Get the current channel count of all groups that match the specified pattern and category.

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

Definition at line 2043 of file main/app.c.

References ast_log, AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, ast_strlen_zero(), ast_group_info::category, ast_group_info::group, ast_group_info::group_list, LOG_ERROR, LOG_NOTICE, and NULL.

Referenced by AST_TEST_DEFINE(), and group_match_count_function_read().

2044 {
2045  struct ast_group_info *gi = NULL;
2046  regex_t regexbuf_group;
2047  regex_t regexbuf_category;
2048  int count = 0;
2049 
2050  if (ast_strlen_zero(groupmatch)) {
2051  ast_log(LOG_NOTICE, "groupmatch empty\n");
2052  return 0;
2053  }
2054 
2055  /* if regex compilation fails, return zero matches */
2056  if (regcomp(&regexbuf_group, groupmatch, REG_EXTENDED | REG_NOSUB)) {
2057  ast_log(LOG_ERROR, "Regex compile failed on: %s\n", groupmatch);
2058  return 0;
2059  }
2060 
2061  if (!ast_strlen_zero(category) && regcomp(&regexbuf_category, category, REG_EXTENDED | REG_NOSUB)) {
2062  ast_log(LOG_ERROR, "Regex compile failed on: %s\n", category);
2063  regfree(&regexbuf_group);
2064  return 0;
2065  }
2066 
2069  if (!regexec(&regexbuf_group, gi->group, 0, NULL, 0) && (ast_strlen_zero(category) || (!ast_strlen_zero(gi->category) && !regexec(&regexbuf_category, gi->category, 0, NULL, 0)))) {
2070  count++;
2071  }
2072  }
2074 
2075  regfree(&regexbuf_group);
2076  if (!ast_strlen_zero(category)) {
2077  regfree(&regexbuf_category);
2078  }
2079 
2080  return count;
2081 }
channel group info
Definition: channel.h:2906
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
#define NULL
Definition: resample.c:96
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
Definition: linkedlists.h:77
#define ast_log
Definition: astobj2.c:42
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
#define AST_RWLIST_TRAVERSE
Definition: linkedlists.h:493
char * group
Definition: channel.h:2909
#define LOG_ERROR
Definition: logger.h:285
#define LOG_NOTICE
Definition: logger.h:263
char * category
Definition: channel.h:2908
struct ast_group_info::@235 group_list

◆ ast_app_group_set_channel()

int ast_app_group_set_channel ( struct ast_channel chan,
const char *  data 
)

Set the group for a channel, splitting the provided data into group and category, if specified.

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

Definition at line 1976 of file main/app.c.

References ast_app_group_split_group(), ast_calloc, ast_free, AST_RWLIST_INSERT_TAIL, AST_RWLIST_REMOVE_CURRENT, AST_RWLIST_TRAVERSE_SAFE_BEGIN, AST_RWLIST_TRAVERSE_SAFE_END, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_strlen_zero(), ast_group_info::category, ast_group_info::chan, ast_group_info::group, ast_group_info::group_list, len(), and NULL.

Referenced by AST_TEST_DEFINE(), dial_exec_full(), and group_function_write().

1977 {
1978  int res = 0;
1979  char group[80] = "", category[80] = "";
1980  struct ast_group_info *gi = NULL;
1981  size_t len = 0;
1982 
1983  if (ast_app_group_split_group(data, group, sizeof(group), category, sizeof(category))) {
1984  return -1;
1985  }
1986 
1987  /* Calculate memory we will need if this is new */
1988  len = sizeof(*gi) + strlen(group) + 1;
1989  if (!ast_strlen_zero(category)) {
1990  len += strlen(category) + 1;
1991  }
1992 
1995  if ((gi->chan == chan) && ((ast_strlen_zero(category) && ast_strlen_zero(gi->category)) || (!ast_strlen_zero(gi->category) && !strcasecmp(gi->category, category)))) {
1997  ast_free(gi);
1998  break;
1999  }
2000  }
2002 
2003  if (ast_strlen_zero(group)) {
2004  /* Enable unsetting the group */
2005  } else if ((gi = ast_calloc(1, len))) {
2006  gi->chan = chan;
2007  gi->group = (char *) gi + sizeof(*gi);
2008  strcpy(gi->group, group);
2009  if (!ast_strlen_zero(category)) {
2010  gi->category = (char *) gi + sizeof(*gi) + strlen(group) + 1;
2011  strcpy(gi->category, category);
2012  }
2014  } else {
2015  res = -1;
2016  }
2017 
2019 
2020  return res;
2021 }
channel group info
Definition: channel.h:2906
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition: linkedlists.h:51
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
#define NULL
Definition: resample.c:96
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
#define AST_RWLIST_REMOVE_CURRENT
Definition: linkedlists.h:569
char * group
Definition: channel.h:2909
#define AST_RWLIST_TRAVERSE_SAFE_BEGIN
Definition: linkedlists.h:544
struct ast_channel * chan
Definition: channel.h:2907
int ast_app_group_split_group(const char *data, char *group, int group_max, char *category, int category_max)
Split a group string into group and category, returning a default category if none is provided...
Definition: main/app.c:1949
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
#define ast_free(a)
Definition: astmm.h:182
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:204
char * category
Definition: channel.h:2908
#define AST_RWLIST_INSERT_TAIL
Definition: linkedlists.h:740
struct ast_group_info::@235 group_list
#define AST_RWLIST_TRAVERSE_SAFE_END
Definition: linkedlists.h:616

◆ ast_app_group_split_group()

int ast_app_group_split_group ( const char *  data,
char *  group,
int  group_max,
char *  category,
int  category_max 
)

Split a group string into group and category, returning a default category if none is provided.

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

Definition at line 1949 of file main/app.c.

References ast_copy_string(), ast_strlen_zero(), NULL, and tmp().

Referenced by ast_app_group_set_channel(), group_count_function_read(), and group_match_count_function_read().

1950 {
1951  int res = 0;
1952  char tmp[256];
1953  char *grp = NULL, *cat = NULL;
1954 
1955  if (!ast_strlen_zero(data)) {
1956  ast_copy_string(tmp, data, sizeof(tmp));
1957  grp = tmp;
1958  if ((cat = strchr(tmp, '@'))) {
1959  *cat++ = '\0';
1960  }
1961  }
1962 
1963  if (!ast_strlen_zero(grp)) {
1964  ast_copy_string(group, grp, group_max);
1965  } else {
1966  *group = '\0';
1967  }
1968 
1969  if (!ast_strlen_zero(cat)) {
1970  ast_copy_string(category, cat, category_max);
1971  }
1972 
1973  return res;
1974 }
static int tmp()
Definition: bt_open.c:389
#define NULL
Definition: resample.c:96
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
char * category
Definition: channel.h:2908
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401

◆ ast_app_group_update()

int ast_app_group_update ( struct ast_channel oldchan,
struct ast_channel newchan 
)

Update all group counting for a channel to a new one.

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

Definition at line 2083 of file main/app.c.

References ast_free, AST_RWLIST_REMOVE_CURRENT, AST_RWLIST_TRAVERSE_SAFE_BEGIN, AST_RWLIST_TRAVERSE_SAFE_END, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_group_info::chan, ast_group_info::group_list, and NULL.

Referenced by channel_do_masquerade().

2084 {
2085  struct ast_group_info *gi = NULL;
2086 
2089  if (gi->chan == old) {
2090  gi->chan = new;
2091  } else if (gi->chan == new) {
2093  ast_free(gi);
2094  }
2095  }
2098 
2099  return 0;
2100 }
channel group info
Definition: channel.h:2906
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition: linkedlists.h:51
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
#define NULL
Definition: resample.c:96
#define AST_RWLIST_REMOVE_CURRENT
Definition: linkedlists.h:569
#define AST_RWLIST_TRAVERSE_SAFE_BEGIN
Definition: linkedlists.h:544
struct ast_channel * chan
Definition: channel.h:2907
#define ast_free(a)
Definition: astmm.h:182
struct ast_group_info::@235 group_list
#define AST_RWLIST_TRAVERSE_SAFE_END
Definition: linkedlists.h:616

◆ ast_app_has_voicemail()

int ast_app_has_voicemail ( const char *  mailboxes,
const char *  folder 
)

Determine if a given mailbox has any voicemail If folder is NULL, defaults to "INBOX". If folder is "INBOX", includes the number of messages in the "Urgent" folder.

Return values
1Mailbox has voicemail
0No new voicemail in specified mailbox
-1Failure
Since
1.0
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 672 of file main/app.c.

References has_voicemail(), and VM_API_CALL.

Referenced by action_mailboxstatus(), has_voicemail(), mwi_update_cb(), notify_new_message(), play_dialtone(), poll_mailbox(), run_externnotify(), skinny_register(), unistim_send_mwi_to_peer(), and vmsayname_exec().

673 {
674  int res = 0;
675 
676  VM_API_CALL(res, has_voicemail, (mailboxes, folder));
677  return res;
678 }
static struct stasis_rest_handlers mailboxes
REST handler for /api-docs/mailboxes.json.
#define VM_API_CALL(res, api_call, api_parms)
Definition: main/app.c:637
static int has_voicemail(const char *mailbox, const char *folder)
Determines if the given folder has messages.

◆ ast_app_inboxcount()

int ast_app_inboxcount ( const char *  mailboxes,
int *  newmsgs,
int *  oldmsgs 
)

Determine number of new/old messages in a mailbox.

Since
1.0
Parameters
[in]mailboxesMailbox specification in the format /code mbox[@context][&mbox2[@context2]][...] /code
[out]newmsgsNumber of messages in the "INBOX" folder. Includes number of messages in the "Urgent" folder, if any.
[out]oldmsgsNumber of messages in the "Old" folder.
Return values
0Success
-1Failure
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 694 of file main/app.c.

References inboxcount(), and VM_API_CALL.

Referenced by sip_send_mwi_to_peer(), update_registry(), and vmsayname_exec().

695 {
696  int res = 0;
697 
698  if (newmsgs) {
699  *newmsgs = 0;
700  }
701  if (oldmsgs) {
702  *oldmsgs = 0;
703  }
704 
705  VM_API_CALL(res, inboxcount, (mailboxes, newmsgs, oldmsgs));
706  return res;
707 }
static struct stasis_rest_handlers mailboxes
REST handler for /api-docs/mailboxes.json.
#define VM_API_CALL(res, api_call, api_parms)
Definition: main/app.c:637
static int inboxcount(const char *mailbox, int *newmsgs, int *oldmsgs)

◆ ast_app_inboxcount2()

int ast_app_inboxcount2 ( const char *  mailboxes,
int *  urgentmsgs,
int *  newmsgs,
int *  oldmsgs 
)

Determine number of urgent/new/old messages in a mailbox.

Parameters
[in]mailboxesthe mailbox context to use
[out]urgentmsgsthe urgent message count
[out]newmsgsthe new message count
[out]oldmsgsthe old message count
Returns
Returns 0 for success, negative upon error
Since
1.6.1
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 709 of file main/app.c.

References inboxcount2(), and VM_API_CALL.

Referenced by action_mailboxcount(), mwi_retrieve_then_create_state(), notify_new_message(), notify_new_state(), vm_execmain(), and vmsayname_exec().

710 {
711  int res = 0;
712 
713  if (newmsgs) {
714  *newmsgs = 0;
715  }
716  if (oldmsgs) {
717  *oldmsgs = 0;
718  }
719  if (urgentmsgs) {
720  *urgentmsgs = 0;
721  }
722 
723  VM_API_CALL(res, inboxcount2, (mailboxes, urgentmsgs, newmsgs, oldmsgs));
724  return res;
725 }
static struct stasis_rest_handlers mailboxes
REST handler for /api-docs/mailboxes.json.
static int inboxcount2(const char *mailbox, int *urgentmsgs, int *newmsgs, int *oldmsgs)
Check the given mailbox&#39;s message count.
#define VM_API_CALL(res, api_call, api_parms)
Definition: main/app.c:637

◆ ast_app_messagecount()

int ast_app_messagecount ( const char *  mailbox_id,
const char *  folder 
)

Get the number of messages in a given mailbox folder.

Parameters
[in]mailbox_idMailbox name
[in]folderThe folder to look in. Default is INBOX if not provided.
Note
If requesting INBOX then the returned count is INBOX + Urgent.
Returns
The number of messages in the mailbox folder (zero or more).
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 735 of file main/app.c.

References messagecount(), and VM_API_CALL.

Referenced by acf_vmcount_exec(), and vmsayname_exec().

736 {
737  int res = 0;
738 
739  VM_API_CALL(res, messagecount, (mailbox_id, folder));
740  return res;
741 }
static int messagecount(const char *mailbox_id, const char *folder)
#define VM_API_CALL(res, api_call, api_parms)
Definition: main/app.c:637

◆ ast_app_options2str64()

void ast_app_options2str64 ( const struct ast_app_option options,
struct ast_flags64 flags,
char *  buf,
size_t  len 
)

Given a list of options array, return an option string based on passed flags.

Parameters
optionsThe array of possible options declared with AST_APP_OPTIONS
flagsThe flags of the options that you wish to populate the buffer with
bufThe buffer to fill with the string of options
lenThe maximum length of buf
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 2856 of file main/app.c.

References ast_test_flag64, and len().

2857 {
2858  unsigned int i, found = 0;
2859  for (i = 32; i < 128 && found < len; i++) {
2860  if (ast_test_flag64(flags, options[i].flag)) {
2861  buf[found++] = i;
2862  }
2863  }
2864  buf[found] = '\0';
2865 }
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
long int flag
Definition: f2c.h:83
#define ast_test_flag64(p, flag)
Definition: utils.h:120

◆ ast_app_parse_options()

int ast_app_parse_options ( const struct ast_app_option options,
struct ast_flags flags,
char **  args,
char *  optstr 
)

Parses a string containing application options and sets flags/arguments.

Parameters
optionsThe array of possible options declared with AST_APP_OPTIONS
flagsThe flag structure to have option flags set
argsThe array of argument pointers to hold arguments found
optstrThe string containing the options to be parsed
Returns
zero for success, non-zero if an error occurs
See also
AST_APP_OPTIONS
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 2846 of file main/app.c.

References parse_options().

Referenced by agent_login_exec(), app_exec(), ast_multicast_rtp_create_options(), AST_TEST_DEFINE(), audiosocket_request(), auth_exec(), bridge_exec(), bridgewait_exec(), cdr_read_callback(), cdr_write_callback(), chanspy_exec(), connectedline_write(), controlplayback_exec(), detect_write(), directory_exec(), disa_exec(), dundi_query_read(), dundifunc_read(), extenspy_exec(), forkcdr_exec(), handle_options(), hint_read(), manager_mixmonitor(), minivm_accmess_exec(), minivm_greet_exec(), minivm_record_exec(), mixmonitor_exec(), page_exec(), park_app_parse_data(), pbx_builtin_background(), pbx_builtin_waitexten(), pickupchan_exec(), queue_exec(), read_exec(), readexten_exec(), realtime_common(), receivefax_exec(), record_exec(), redirecting_write(), resetcdr_exec(), sendfax_exec(), sla_trunk_exec(), smdi_msg_retrieve_read(), sms_exec(), softhangup_exec(), speech_background(), start_monitor_exec(), unicast_rtp_request(), vm_exec(), vm_execmain(), volume_write(), and wait_exec().

2847 {
2848  return parse_options(options, flags, args, optstr, 32);
2849 }
const char * args
static int parse_options(const struct ast_app_option *options, void *_flags, char **args, char *optstr, int flaglen)
Definition: main/app.c:2766

◆ ast_app_parse_options64()

int ast_app_parse_options64 ( const struct ast_app_option options,
struct ast_flags64 flags,
char **  args,
char *  optstr 
)

Parses a string containing application options and sets flags/arguments.

Parameters
optionsThe array of possible options declared with AST_APP_OPTIONS
flagsThe 64-bit flag structure to have option flags set
argsThe array of argument pointers to hold arguments found
optstrThe string containing the options to be parsed
Returns
zero for success, non-zero if an error occurs
See also
AST_APP_OPTIONS
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 2851 of file main/app.c.

References parse_options().

Referenced by AST_TEST_DEFINE(), conf_exec(), dial_exec_full(), find_conf_realtime(), originate_exec(), and sayunixtime_exec().

2852 {
2853  return parse_options(options, flags, args, optstr, 64);
2854 }
const char * args
static int parse_options(const struct ast_app_option *options, void *_flags, char **args, char *optstr, int flaglen)
Definition: main/app.c:2766

◆ ast_app_parse_timelen()

int ast_app_parse_timelen ( const char *  timestr,
int *  result,
enum ast_timelen  defunit 
)

Common routine to parse time lengths, with optional time unit specifier.

Parameters
[in]timestrString to parse
[in]defunitDefault unit type
[out]resultResulting value, specified in milliseconds
Return values
0Success
-1Failure
Since
1.8
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 3053 of file main/app.c.

References FMT, TIMELEN_HOURS, TIMELEN_MILLISECONDS, TIMELEN_MINUTES, and TIMELEN_SECONDS.

Referenced by ast_eivr_senddtmf(), ast_parse_arg(), new_realtime_sqlite3_db(), pbx_builtin_wait(), pbx_builtin_waitdigit(), pbx_builtin_waitexten(), senddtmf_exec(), and sendmf_exec().

3054 {
3055  int res;
3056  char u[10];
3057 #ifdef HAVE_LONG_DOUBLE_WIDER
3058  long double amount;
3059  #define FMT "%30Lf%9s"
3060 #else
3061  double amount;
3062  #define FMT "%30lf%9s"
3063 #endif
3064  if (!timestr) {
3065  return -1;
3066  }
3067 
3068  res = sscanf(timestr, FMT, &amount, u);
3069 
3070  if (res == 0 || res == EOF) {
3071 #undef FMT
3072  return -1;
3073  } else if (res == 2) {
3074  switch (u[0]) {
3075  case 'h':
3076  case 'H':
3077  unit = TIMELEN_HOURS;
3078  if (u[1] != '\0') {
3079  return -1;
3080  }
3081  break;
3082  case 's':
3083  case 'S':
3084  unit = TIMELEN_SECONDS;
3085  if (u[1] != '\0') {
3086  return -1;
3087  }
3088  break;
3089  case 'm':
3090  case 'M':
3091  if (toupper(u[1]) == 'S') {
3092  unit = TIMELEN_MILLISECONDS;
3093  if (u[2] != '\0') {
3094  return -1;
3095  }
3096  } else if (u[1] == '\0') {
3097  unit = TIMELEN_MINUTES;
3098  } else {
3099  return -1;
3100  }
3101  break;
3102  default:
3103  return -1;
3104  }
3105  }
3106 
3107  switch (unit) {
3108  case TIMELEN_HOURS:
3109  amount *= 60;
3110  /* fall-through */
3111  case TIMELEN_MINUTES:
3112  amount *= 60;
3113  /* fall-through */
3114  case TIMELEN_SECONDS:
3115  amount *= 1000;
3116  /* fall-through */
3117  case TIMELEN_MILLISECONDS:
3118  ;
3119  }
3120  *result = amount > INT_MAX ? INT_MAX : (int) amount;
3121  return 0;
3122 }
#define FMT
static PGresult * result
Definition: cel_pgsql.c:88

◆ ast_app_run_macro()

int ast_app_run_macro ( struct ast_channel autoservice_chan,
struct ast_channel macro_chan,
const char *  macro_name,
const char *  macro_args 
)

Run a macro on a channel, placing an optional second channel into autoservice.

Since
1.8

This is a shorthand method that makes it very easy to run a macro on any given channel. It is perfectly reasonable to supply a NULL autoservice_chan here in case there is no channel to place into autoservice.

Note
Absolutely NO channel locks should be held before calling this function.
Parameters
autoservice_chanA channel to place into autoservice while the macro is run
macro_chanChannel to execute macro on.
macro_nameThe name of the macro to run.
macro_argsThe arguments to pass to the macro.
Return values
0success
-1on error
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 337 of file main/app.c.

References ast_app_exec_macro(), ast_free, ast_malloc, and ast_strlen_zero().

Referenced by ast_channel_connected_line_macro(), and ast_channel_redirecting_macro().

338 {
339  int res;
340  char *args_str;
341  size_t args_len;
342 
343  if (ast_strlen_zero(macro_args)) {
344  return ast_app_exec_macro(autoservice_chan, macro_chan, macro_name);
345  }
346 
347  /* Create the Macro application argument string. */
348  args_len = strlen(macro_name) + strlen(macro_args) + 2;
349  args_str = ast_malloc(args_len);
350  if (!args_str) {
351  return -1;
352  }
353  snprintf(args_str, args_len, "%s,%s", macro_name, macro_args);
354 
355  res = ast_app_exec_macro(autoservice_chan, macro_chan, args_str);
356  ast_free(args_str);
357  return res;
358 }
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
int ast_app_exec_macro(struct ast_channel *autoservice_chan, struct ast_channel *macro_chan, const char *macro_args)
Run a macro on a channel, placing an optional second channel into autoservice.
Definition: main/app.c:290
#define ast_malloc(len)
A wrapper for malloc()
Definition: astmm.h:193
#define ast_free(a)
Definition: astmm.h:182

◆ ast_app_run_sub()

int ast_app_run_sub ( struct ast_channel autoservice_chan,
struct ast_channel sub_chan,
const char *  sub_location,
const char *  sub_args,
int  ignore_hangup 
)

Run a subroutine on a channel, placing an optional second channel into autoservice.

Since
11

This is a shorthand method that makes it very easy to run a subroutine on any given channel. It is perfectly reasonable to supply a NULL autoservice_chan here in case there is no channel to place into autoservice.

Note
Absolutely NO channel locks should be held before calling this function.
Parameters
autoservice_chanA channel to place into autoservice while the subroutine is run
sub_chanChannel to execute subroutine on.
sub_locationThe location of the subroutine to run.
sub_argsThe arguments to pass to the subroutine.
ignore_hangupTRUE if a hangup does not stop execution of the routine.
Return values
0success
-1on error
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 418 of file main/app.c.

References AO2_GLOBAL_OBJ_STATIC(), ast_app_exec_sub(), ast_free, ast_malloc, and ast_strlen_zero().

Referenced by ast_channel_connected_line_sub(), and ast_channel_redirecting_sub().

419 {
420  int res;
421  char *args_str;
422  size_t args_len;
423 
424  if (ast_strlen_zero(sub_args)) {
425  return ast_app_exec_sub(autoservice_chan, sub_chan, sub_location, ignore_hangup);
426  }
427 
428  /* Create the Gosub application argument string. */
429  args_len = strlen(sub_location) + strlen(sub_args) + 3;
430  args_str = ast_malloc(args_len);
431  if (!args_str) {
432  return -1;
433  }
434  snprintf(args_str, args_len, "%s(%s)", sub_location, sub_args);
435 
436  res = ast_app_exec_sub(autoservice_chan, sub_chan, args_str, ignore_hangup);
437  ast_free(args_str);
438  return res;
439 }
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
#define ast_malloc(len)
A wrapper for malloc()
Definition: astmm.h:193
#define ast_free(a)
Definition: astmm.h:182
int ast_app_exec_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const char *sub_args, int ignore_hangup)
Run a subroutine on a channel, placing an optional second channel into autoservice.
Definition: main/app.c:387

◆ ast_app_sayname()

int ast_app_sayname ( struct ast_channel chan,
const char *  mailbox_id 
)

Play a recorded user name for the mailbox to the specified channel.

Parameters
chanWhere to play the recorded name file.
mailbox_idThe mailbox name.
Return values
0Name played without interruption
dtmfASCII value of the DTMF which interrupted playback.
-1Unable to locate mailbox or hangup occurred.
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 727 of file main/app.c.

References sayname(), and VM_GREETER_API_CALL.

Referenced by play_mailbox_owner(), and spy_sayname().

728 {
729  int res = -1;
730 
731  VM_GREETER_API_CALL(res, sayname, (chan, mailbox_id));
732  return res;
733 }
static int sayname(struct ast_channel *chan, const char *mailbox, const char *context)
#define VM_GREETER_API_CALL(res, api_call, api_parms)
Definition: main/app.c:658

◆ ast_close_fds_above_n()

void ast_close_fds_above_n ( int  n)

Common routine for child processes, to close all fds prior to exec(2)

Parameters
[in]nstarting file descriptor number for closing all higher file descriptors
Since
1.6.1
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 2982 of file main/app.c.

References closefrom().

Referenced by app_exec(), asterisk_daemon(), launch_script(), mp3play(), safe_exec_prep(), send_waveform_to_fd(), spawn_mp3(), and vm_check_password_shell().

2983 {
2984  closefrom(n + 1);
2985 }
void closefrom(int lowfd)
Definition: strcompat.c:429

◆ ast_control_streamfile()

int ast_control_streamfile ( struct ast_channel chan,
const char *  file,
const char *  fwd,
const char *  rev,
const char *  stop,
const char *  pause,
const char *  restart,
int  skipms,
long *  offsetms 
)

Stream a file with fast forward, pause, reverse, restart.

Parameters
chanChannel
fileFile to play.
fwd,rev,stop,pause,restartDTMF keys for media control
skipmsNumber of milliseconds to skip for fwd/rev.
offsetmsNumber of milliseconds to skip when starting the media.

Before calling this function, set this to be the number of ms to start from the beginning of the file. When the function returns, it will be the number of ms from the beginning where the playback stopped. Pass NULL if you don't care.

Return values
0on success
Non-zeroon failure
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 1259 of file main/app.c.

References control_streamfile(), and NULL.

Referenced by controlplayback_exec(), handle_controlstreamfile(), and wait_file().

1263 {
1264  return control_streamfile(chan, file, fwd, rev, stop, suspend, restart, skipms, offsetms, NULL, NULL);
1265 }
unsigned int stop
Definition: app_meetme.c:1098
#define NULL
Definition: resample.c:96
static int skipms
static void suspend(struct cc_core_instance *core_instance)
Definition: ccss.c:3193
static int control_streamfile(struct ast_channel *chan, const char *file, const char *fwd, const char *rev, const char *stop, const char *suspend, const char *restart, int skipms, long *offsetms, const char *lang, ast_waitstream_fr_cb cb)
Definition: main/app.c:1071

◆ ast_control_streamfile_lang()

int ast_control_streamfile_lang ( struct ast_channel chan,
const char *  file,
const char *  fwd,
const char *  rev,
const char *  stop,
const char *  suspend,
const char *  restart,
int  skipms,
const char *  lang,
long *  offsetms 
)

Version of ast_control_streamfile() which allows the language of the media file to be specified.

Return values
0on success
Non-zeroon failure
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 1267 of file main/app.c.

References control_streamfile(), and NULL.

Referenced by play_on_channel().

1270 {
1271  return control_streamfile(chan, file, fwd, rev, stop, suspend, restart, skipms, offsetms, lang, NULL);
1272 }
unsigned int stop
Definition: app_meetme.c:1098
#define NULL
Definition: resample.c:96
static int skipms
static void suspend(struct cc_core_instance *core_instance)
Definition: ccss.c:3193
static int control_streamfile(struct ast_channel *chan, const char *file, const char *fwd, const char *rev, const char *stop, const char *suspend, const char *restart, int skipms, long *offsetms, const char *lang, ast_waitstream_fr_cb cb)
Definition: main/app.c:1071

◆ ast_control_streamfile_w_cb()

int ast_control_streamfile_w_cb ( struct ast_channel chan,
const char *  file,
const char *  fwd,
const char *  rev,
const char *  stop,
const char *  pause,
const char *  restart,
int  skipms,
long *  offsetms,
ast_waitstream_fr_cb  cb 
)

Stream a file with fast forward, pause, reverse, restart.

Parameters
chan
filefilename
fwd,rev,stop,pause,restart,skipms,offsetms
cbwaitstream callback to invoke when fastforward or rewind occurrs.

Before calling this function, set this to be the number of ms to start from the beginning of the file. When the function returns, it will be the number of ms from the beginning where the playback stopped. Pass NULL if you don't care.

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

Definition at line 1245 of file main/app.c.

References control_streamfile(), and NULL.

1255 {
1256  return control_streamfile(chan, file, fwd, rev, stop, suspend, restart, skipms, offsetms, NULL, cb);
1257 }
unsigned int stop
Definition: app_meetme.c:1098
#define NULL
Definition: resample.c:96
static int skipms
static void suspend(struct cc_core_instance *core_instance)
Definition: ccss.c:3193
static int control_streamfile(struct ast_channel *chan, const char *file, const char *fwd, const char *rev, const char *stop, const char *suspend, const char *restart, int skipms, long *offsetms, const char *lang, ast_waitstream_fr_cb cb)
Definition: main/app.c:1071

◆ ast_control_tone()

int ast_control_tone ( struct ast_channel chan,
const char *  tone 
)

Controls playback of a tone.

Return values
0on success
Non-zeroon failure
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 1339 of file main/app.c.

References ast_channel_zone(), AST_FRAME_CONTROL, ast_get_indication_tone(), ast_get_indication_zone(), ast_playtones_start(), ast_read_noaudio(), ast_strdupa, ast_strlen_zero(), ast_tone_zone_sound_unref(), ast_tone_zone_unref(), ast_waitfor(), control_tone_frame_response(), CONTROL_TONE_RESPONSE_FAILED, CONTROL_TONE_RESPONSE_FINISHED, ast_tone_zone_sound::data, ast_frame::frametype, NULL, and parse_tone_uri().

Referenced by play_on_channel().

1340 {
1341  struct ast_tone_zone *zone = NULL;
1342  struct ast_tone_zone_sound *ts;
1343  int paused = 0;
1344  int res = 0;
1345 
1346  const char *tone_indication = NULL;
1347  const char *tone_zone = NULL;
1348  char *tone_uri_parser;
1349 
1350  if (ast_strlen_zero(tone)) {
1351  return -1;
1352  }
1353 
1354  tone_uri_parser = ast_strdupa(tone);
1355 
1356  if (parse_tone_uri(tone_uri_parser, &tone_indication, &tone_zone)) {
1357  return -1;
1358  }
1359 
1360  if (tone_zone) {
1361  zone = ast_get_indication_zone(tone_zone);
1362  }
1363 
1364  ts = ast_get_indication_tone(zone ? zone : ast_channel_zone(chan), tone_indication);
1365 
1366  if (ast_playtones_start(chan, 0, ts ? ts->data : tone_indication, 0)) {
1367  res = -1;
1368  }
1369 
1370  while (!res) {
1371  struct ast_frame *fr;
1372 
1373  if (ast_waitfor(chan, -1) < 0) {
1374  res = -1;
1375  break;
1376  }
1377 
1378  fr = ast_read_noaudio(chan);
1379 
1380  if (!fr) {
1381  res = -1;
1382  break;
1383  }
1384 
1385  if (fr->frametype != AST_FRAME_CONTROL) {
1386  continue;
1387  }
1388 
1389  res = control_tone_frame_response(chan, fr, ts, tone_indication, &paused);
1390  if (res == CONTROL_TONE_RESPONSE_FINISHED) {
1391  res = 0;
1392  break;
1393  } else if (res == CONTROL_TONE_RESPONSE_FAILED) {
1394  res = -1;
1395  break;
1396  }
1397  }
1398 
1399  if (ts) {
1401  }
1402 
1403  if (zone) {
1404  ast_tone_zone_unref(zone);
1405  }
1406 
1407  return res;
1408 }
static struct ast_tone_zone * ast_tone_zone_unref(struct ast_tone_zone *tz)
Release a reference to an ast_tone_zone.
Definition: indications.h:205
static int parse_tone_uri(char *tone_parser, const char **tone_indication, const char **tone_zone)
Definition: main/app.c:1318
struct ast_tone_zone * ast_channel_zone(const struct ast_channel *chan)
#define NULL
Definition: resample.c:96
A set of tones for a given locale.
Definition: indications.h:74
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
static struct ast_tone_zone_sound * ast_tone_zone_sound_unref(struct ast_tone_zone_sound *ts)
Release a reference to an ast_tone_zone_sound.
Definition: indications.h:227
struct ast_tone_zone * ast_get_indication_zone(const char *country)
locate ast_tone_zone
Definition: indications.c:433
Description of a tone.
Definition: indications.h:35
struct ast_tone_zone_sound * ast_get_indication_tone(const struct ast_tone_zone *zone, const char *indication)
Locate a tone zone sound.
Definition: indications.c:455
static enum control_tone_frame_response_result control_tone_frame_response(struct ast_channel *chan, struct ast_frame *fr, struct ast_tone_zone_sound *ts, const char *tone, int *paused)
Definition: main/app.c:1280
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
Definition: channel.c:3167
Data structure associated with a single frame of data.
int ast_playtones_start(struct ast_channel *chan, int vol, const char *tonelist, int interruptible)
Start playing a list of tones on a channel.
Definition: indications.c:302
const char * data
Description of a tone.
Definition: indications.h:52
enum ast_frame_type frametype
struct ast_frame * ast_read_noaudio(struct ast_channel *chan)
Reads a frame, returning AST_FRAME_NULL frame if audio.
Definition: channel.c:4299

◆ ast_dtmf_stream()

int ast_dtmf_stream ( struct ast_channel chan,
struct ast_channel peer,
const char *  digits,
int  between,
unsigned int  duration 
)

Send a string of DTMF digits to a channel.

Parameters
chanThe channel that will receive the DTMF frames
peer(optional) Peer channel that will be autoserviced while the primary channel is receiving DTMF
digitsThis is a string of characters representing the DTMF digits to be sent to the channel. Valid characters are "0123456789*#abcdABCD". Note: You can pass arguments 'f' or 'F', if you want to Flash the channel (if supported by the channel), or 'w' to add a 500 millisecond pause to the DTMF sequence.
betweenThis is the number of milliseconds to wait in between each DTMF digit. If zero milliseconds is specified, then the default value of 100 will be used.
durationThis is the duration that each DTMF digit should have.
Precondition
This must only be called by the channel's media handler thread.
Return values
0on success.
-1on failure or a channel hung up.
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 921 of file main/app.c.

References ast_autoservice_start(), ast_autoservice_stop(), and dtmf_stream().

Referenced by ast_eivr_senddtmf(), bridge_channel_dtmf_stream(), dial_exec_full(), dtmf_no_bridge(), senddtmf_exec(), testclient_exec(), testserver_exec(), and wait_for_answer().

922 {
923  int res;
924 
925  if (peer && ast_autoservice_start(peer)) {
926  return -1;
927  }
928  res = dtmf_stream(chan, digits, between, duration, 0);
929  if (peer && ast_autoservice_stop(peer)) {
930  res = -1;
931  }
932 
933  return res;
934 }
int ast_autoservice_start(struct ast_channel *chan)
Automatically service a channel for us...
Definition: autoservice.c:200
static int dtmf_stream(struct ast_channel *chan, const char *digits, int between, unsigned int duration, int is_external)
Definition: main/app.c:853
int ast_autoservice_stop(struct ast_channel *chan)
Stop servicing a channel for us...
Definition: autoservice.c:266

◆ ast_dtmf_stream_external()

void ast_dtmf_stream_external ( struct ast_channel chan,
const char *  digits,
int  between,
unsigned int  duration 
)

Send a string of DTMF digits to a channel from an external thread.

Parameters
chanThe channel that will receive the DTMF frames
digitsThis is a string of characters representing the DTMF digits to be sent to the channel. Valid characters are "0123456789*#abcdABCD". Note: You can pass arguments 'f' or 'F', if you want to Flash the channel (if supported by the channel), or 'w' to add a 500 millisecond pause to the DTMF sequence.
betweenThis is the number of milliseconds to wait in between each DTMF digit. If zero milliseconds is specified, then the default value of 100 will be used.
durationThis is the duration that each DTMF digit should have.
Precondition
This must only be called by threads that are not the channel's media handler thread.
Returns
Nothing
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 936 of file main/app.c.

References dtmf_stream().

Referenced by dtmf_in_bridge().

937 {
938  dtmf_stream(chan, digits, between, duration, 1);
939 }
static int dtmf_stream(struct ast_channel *chan, const char *digits, int between, unsigned int duration, int is_external)
Definition: main/app.c:853

◆ ast_get_encoded_char()

int ast_get_encoded_char ( const char *  stream,
char *  result,
size_t *  consumed 
)

Decode an encoded control or extended ASCII character.

Parameters
[in]streamString to decode
[out]resultDecoded character
[out]consumedNumber of characters used in stream to encode the character
Return values
-1Stream is of zero length
0Success
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 2867 of file main/app.c.

References ast_debug, ast_log, ast_strlen_zero(), and LOG_ERROR.

Referenced by ast_get_encoded_str(), ast_str_get_encoded_str(), cut_internal(), filter(), function_fieldnum_helper(), function_fieldqty_helper(), replace(), shift_pop(), and unshift_push().

2868 {
2869  int i;
2870  *consumed = 1;
2871  *result = 0;
2872  if (ast_strlen_zero(stream)) {
2873  *consumed = 0;
2874  return -1;
2875  }
2876 
2877  if (*stream == '\\') {
2878  *consumed = 2;
2879  switch (*(stream + 1)) {
2880  case 'n':
2881  *result = '\n';
2882  break;
2883  case 'r':
2884  *result = '\r';
2885  break;
2886  case 't':
2887  *result = '\t';
2888  break;
2889  case 'x':
2890  /* Hexadecimal */
2891  if (strchr("0123456789ABCDEFabcdef", *(stream + 2)) && *(stream + 2) != '\0') {
2892  *consumed = 3;
2893  if (*(stream + 2) <= '9') {
2894  *result = *(stream + 2) - '0';
2895  } else if (*(stream + 2) <= 'F') {
2896  *result = *(stream + 2) - 'A' + 10;
2897  } else {
2898  *result = *(stream + 2) - 'a' + 10;
2899  }
2900  } else {
2901  ast_log(LOG_ERROR, "Illegal character '%c' in hexadecimal string\n", *(stream + 2));
2902  return -1;
2903  }
2904 
2905  if (strchr("0123456789ABCDEFabcdef", *(stream + 3)) && *(stream + 3) != '\0') {
2906  *consumed = 4;
2907  *result <<= 4;
2908  if (*(stream + 3) <= '9') {
2909  *result += *(stream + 3) - '0';
2910  } else if (*(stream + 3) <= 'F') {
2911  *result += *(stream + 3) - 'A' + 10;
2912  } else {
2913  *result += *(stream + 3) - 'a' + 10;
2914  }
2915  }
2916  break;
2917  case '0':
2918  /* Octal */
2919  *consumed = 2;
2920  for (i = 2; ; i++) {
2921  if (strchr("01234567", *(stream + i)) && *(stream + i) != '\0') {
2922  (*consumed)++;
2923  ast_debug(5, "result was %d, ", *result);
2924  *result <<= 3;
2925  *result += *(stream + i) - '0';
2926  ast_debug(5, "is now %d\n", *result);
2927  } else {
2928  break;
2929  }
2930  }
2931  break;
2932  default:
2933  *result = *(stream + 1);
2934  }
2935  } else {
2936  *result = *stream;
2937  *consumed = 1;
2938  }
2939  return 0;
2940 }
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define ast_log
Definition: astobj2.c:42
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
#define LOG_ERROR
Definition: logger.h:285
static PGresult * result
Definition: cel_pgsql.c:88

◆ ast_get_encoded_str()

char* ast_get_encoded_str ( const char *  stream,
char *  result,
size_t  result_len 
)

Decode a stream of encoded control or extended ASCII characters.

Parameters
[in]streamEncoded string
[out]resultDecoded string
[in]result_lenMaximum size of the result buffer
Returns
A pointer to the result string
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 2942 of file main/app.c.

References ast_get_encoded_char(), and result.

Referenced by chan_pjsip_new(), listfilter(), mgcp_new(), replace(), sip_addheader(), and sip_new().

2943 {
2944  char *cur = result;
2945  size_t consumed;
2946 
2947  while (cur < result + result_size - 1 && !ast_get_encoded_char(stream, cur, &consumed)) {
2948  cur++;
2949  stream += consumed;
2950  }
2951  *cur = '\0';
2952  return result;
2953 }
static PGresult * result
Definition: cel_pgsql.c:88
int ast_get_encoded_char(const char *stream, char *result, size_t *consumed)
Decode an encoded control or extended ASCII character.
Definition: main/app.c:2867

◆ ast_install_stack_functions()

void ast_install_stack_functions ( const struct ast_app_stack_funcs funcs)

Set stack application function callbacks.

Since
11
Parameters
funcsStack applications callback functions.
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 363 of file main/app.c.

Referenced by load_module(), and unload_module().

364 {
365  app_stack_callbacks = funcs;
366 }
static const struct ast_app_stack_funcs * app_stack_callbacks
Definition: main/app.c:361

◆ ast_ivr_menu_run()

int ast_ivr_menu_run ( struct ast_channel c,
struct ast_ivr_menu menu,
void *  cbdata 
)

Runs an IVR menu.

Returns
returns 0 on successful completion, -1 on hangup, or -2 on user error in menu
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 2725 of file main/app.c.

References ast_ivr_menu_run_internal().

Referenced by skel_exec().

2726 {
2727  int res = ast_ivr_menu_run_internal(chan, menu, cbdata);
2728  /* Hide internal coding */
2729  return res > 0 ? 0 : res;
2730 }
static int ast_ivr_menu_run_internal(struct ast_channel *chan, struct ast_ivr_menu *menu, void *cbdata)
Definition: main/app.c:2640

◆ ast_linear_stream()

int ast_linear_stream ( struct ast_channel chan,
const char *  filename,
int  fd,
int  allowoverride 
)

Stream a filename (or file descriptor) as a generator.

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

Definition at line 1029 of file main/app.c.

References linear_state::allowoverride, ast_activate_generator(), ast_calloc, ast_config_AST_DATA_DIR, ast_copy_string(), ast_log, ast_strlen_zero(), linear_state::autoclose, errno, linear_state::fd, and LOG_WARNING.

1030 {
1031  struct linear_state *lin;
1032  char tmpf[256];
1033  int autoclose = 0;
1034 
1035  if (fd < 0) {
1036  if (ast_strlen_zero(filename)) {
1037  return -1;
1038  }
1039 
1040  autoclose = 1;
1041 
1042  if (filename[0] == '/') {
1043  ast_copy_string(tmpf, filename, sizeof(tmpf));
1044  } else {
1045  snprintf(tmpf, sizeof(tmpf), "%s/%s/%s", ast_config_AST_DATA_DIR, "sounds", filename);
1046  }
1047 
1048  fd = open(tmpf, O_RDONLY);
1049  if (fd < 0) {
1050  ast_log(LOG_WARNING, "Unable to open file '%s': %s\n", tmpf, strerror(errno));
1051  return -1;
1052  }
1053  }
1054 
1055  lin = ast_calloc(1, sizeof(*lin));
1056  if (!lin) {
1057  if (autoclose) {
1058  close(fd);
1059  }
1060 
1061  return -1;
1062  }
1063 
1064  lin->fd = fd;
1066  lin->autoclose = autoclose;
1067 
1068  return ast_activate_generator(chan, &linearstream, lin);
1069 }
int ast_activate_generator(struct ast_channel *chan, struct ast_generator *gen, void *params)
Definition: channel.c:2956
#define LOG_WARNING
Definition: logger.h:274
#define ast_log
Definition: astobj2.c:42
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
int autoclose
Definition: main/app.c:943
const char * ast_config_AST_DATA_DIR
Definition: options.c:158
int errno
static struct ast_generator linearstream
Definition: main/app.c:1022
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:204
int allowoverride
Definition: main/app.c:944
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401

◆ ast_lock_path()

enum AST_LOCK_RESULT ast_lock_path ( const char *  path)

Lock a filesystem path.

Parameters
paththe path to be locked
Returns
one of AST_LOCK_RESULT values
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 2397 of file main/app.c.

References AST_LOCK_FAILURE, ast_lock_path_flock(), ast_lock_path_lockfile(), AST_LOCK_TYPE_FLOCK, and AST_LOCK_TYPE_LOCKFILE.

Referenced by ast_module_reload(), test_vm_api_create_voicemail_files(), and vm_lock_path().

2398 {
2400 
2401  switch (ast_lock_type) {
2403  r = ast_lock_path_lockfile(path);
2404  break;
2405  case AST_LOCK_TYPE_FLOCK:
2406  r = ast_lock_path_flock(path);
2407  break;
2408  }
2409 
2410  return r;
2411 }
static enum AST_LOCK_RESULT ast_lock_path_lockfile(const char *path)
Definition: main/app.c:2203
static enum AST_LOCK_RESULT ast_lock_path_flock(const char *path)
Definition: main/app.c:2277
ast_lock_type
Definition: check_expr.c:35

◆ ast_play_and_prepend()

int ast_play_and_prepend ( struct ast_channel chan,
char *  playfile,
char *  recordfile,
int  maxtime_sec,
char *  fmt,
int *  duration,
int *  sound_duration,
int  beep,
int  silencethreshold,
int  maxsilence_ms 
)

Record a file based on input frm a channel. Recording is performed in 'prepend' mode which works a little differently from normal recordings This function will not play a success message due to post-recording control in the application this was added for.

Parameters
chanthe channel being recorded
playfileFilename of sound to play before recording begins
recordfileFilename to save the recording
maxtime_secLongest possible message length in seconds
fmtstring containing all formats to be recorded delimited by '|'
durationpointer to integer for storing length of the recording
sound_durationpointer to integer for storing length of the recording minus all silence
beepwhether to play a beep to prompt the recording
silencethresholdtolerance of noise levels that can be considered silence for the purpose of silence timeout, -1 for default
maxsilence_mslength of time in milliseconds which will trigger a timeout from silence, -1 for default.
Return values
-1failure or hangup
'S'Recording ended from silence timeout
't'Recording either exceeded maximum duration or the call was ended via DTMF
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 1942 of file main/app.c.

References __ast_play_and_record(), AST_RECORD_IF_EXISTS_OVERWRITE, default_acceptdtmf, default_canceldtmf, and NULL.

Referenced by vm_forwardoptions().

1943 {
1944  return __ast_play_and_record(chan, playfile, recordfile, maxtime, fmt, duration, sound_duration, beep, silencethreshold, maxsilence, NULL, 1, default_acceptdtmf, default_canceldtmf, 1, AST_RECORD_IF_EXISTS_OVERWRITE);
1945 }
static int __ast_play_and_record(struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime, const char *fmt, int *duration, int *sound_duration, int beep, int silencethreshold, int maxsilence, const char *path, int prepend, const char *acceptdtmf, const char *canceldtmf, int skip_confirmation_sound, enum ast_record_if_exists if_exists)
Definition: main/app.c:1520
static const char default_acceptdtmf[]
Definition: main/app.c:1929
static const char default_canceldtmf[]
Definition: main/app.c:1930
static int maxsilence
#define NULL
Definition: resample.c:96
static int silencethreshold

◆ ast_play_and_record()

int ast_play_and_record ( struct ast_channel chan,
const char *  playfile,
const char *  recordfile,
int  maxtime_sec,
const char *  fmt,
int *  duration,
int *  sound_duration,
int  silencethreshold,
int  maxsilence_ms,
const char *  path 
)

Record a file based on input from a channel. Use default accept and cancel DTMF. This function will play "auth-thankyou" upon successful recording.

Parameters
chanthe channel being recorded
playfileFilename of sound to play before recording begins
recordfileFilename to save the recording
maxtime_secLongest possible message length in seconds
fmtstring containing all formats to be recorded delimited by '|'
durationpointer to integer for storing length of the recording
sound_durationpointer to integer for storing length of the recording minus all silence
silencethresholdtolerance of noise levels that can be considered silence for the purpose of silence timeout, -1 for default
maxsilence_mslength of time in milliseconds which will trigger a timeout from silence, -1 for default
pathOptional filesystem path to unlock
Return values
-1failure or hangup
'S'Recording ended from silence timeout
't'Recording ended from the message exceeding the maximum duration
dtmfcharRecording ended via the return value's DTMF character for either cancel or accept.
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 1937 of file main/app.c.

References __ast_play_and_record(), AST_RECORD_IF_EXISTS_OVERWRITE, default_acceptdtmf, and default_canceldtmf.

Referenced by app_exec(), ast_record_review(), conf_rec_name(), conf_run(), and setup_privacy_args().

1938 {
1939  return __ast_play_and_record(chan, playfile, recordfile, maxtime, fmt, duration, sound_duration, 0, silencethreshold, maxsilence, path, 0, default_acceptdtmf, default_canceldtmf, 0, AST_RECORD_IF_EXISTS_OVERWRITE);
1940 }
static int __ast_play_and_record(struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime, const char *fmt, int *duration, int *sound_duration, int beep, int silencethreshold, int maxsilence, const char *path, int prepend, const char *acceptdtmf, const char *canceldtmf, int skip_confirmation_sound, enum ast_record_if_exists if_exists)
Definition: main/app.c:1520
static const char default_acceptdtmf[]
Definition: main/app.c:1929
static const char default_canceldtmf[]
Definition: main/app.c:1930
static int maxsilence
static int silencethreshold

◆ ast_play_and_record_full()

int ast_play_and_record_full ( struct ast_channel chan,
const char *  playfile,
const char *  recordfile,
int  maxtime_sec,
const char *  fmt,
int *  duration,
int *  sound_duration,
int  beep,
int  silencethreshold,
int  maxsilence_ms,
const char *  path,
const char *  acceptdtmf,
const char *  canceldtmf,
int  skip_confirmation_sound,
enum ast_record_if_exists  if_exists 
)

Record a file based on input from a channel This function will play "auth-thankyou" upon successful recording if skip_confirmation_sound is false.

Parameters
chanthe channel being recorded
playfileFilename of sound to play before recording begins. A beep is also played when playfile completes, before the recording begins.
recordfileFilename to save the recording
maxtime_secLongest possible message length in seconds
fmtstring containing all formats to be recorded delimited by '|'
durationpointer to integer for storing length of the recording
beepIf true, play a beep before recording begins (and doesn't play playfile)
sound_durationpointer to integer for storing length of the recording minus all silence
silencethresholdtolerance of noise levels that can be considered silence for the purpose of silence timeout, -1 for default
maxsilence_msLength of time in milliseconds which will trigger a timeout from silence, -1 for default
pathOptional filesystem path to unlock
acceptdtmfCharacter of DTMF to end and accept the recording
canceldtmfCharacter of DTMF to end and cancel the recording
skip_confirmation_soundIf true, don't play auth-thankyou at end. Nice for custom recording prompts in apps.
if_existsAction to take if recording already exists.
Return values
-1failure or hangup
'S'Recording ended from silence timeout
't'Recording ended from the message exceeding the maximum duration
dtmfcharRecording ended via the return value's DTMF character for either cancel or accept.
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 1932 of file main/app.c.

References __ast_play_and_record(), default_canceldtmf, and S_OR.

Referenced by play_record_review(), and record_file().

1933 {
1934  return __ast_play_and_record(chan, playfile, recordfile, maxtime, fmt, duration, sound_duration, beep, silencethreshold, maxsilence, path, 0, S_OR(acceptdtmf, ""), S_OR(canceldtmf, default_canceldtmf), skip_confirmation_sound, if_exists);
1935 }
static int __ast_play_and_record(struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime, const char *fmt, int *duration, int *sound_duration, int beep, int silencethreshold, int maxsilence, const char *path, int prepend, const char *acceptdtmf, const char *canceldtmf, int skip_confirmation_sound, enum ast_record_if_exists if_exists)
Definition: main/app.c:1520
static const char default_canceldtmf[]
Definition: main/app.c:1930
static int maxsilence
static int silencethreshold
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
Definition: strings.h:79

◆ ast_play_and_wait()

int ast_play_and_wait ( struct ast_channel chan,
const char *  fn 
)

Play a stream and wait for a digit, returning the digit that was pressed.

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

Definition at line 1410 of file main/app.c.

References ast_channel_language(), AST_DIGIT_ANY, ast_stopstream(), ast_streamfile(), ast_waitstream(), and d.

Referenced by __ast_play_and_record(), advanced_options(), ast_record_review(), ast_say_counted_adjective(), ast_say_counted_noun(), dialout(), forward_message(), get_folder(), get_folder2(), get_folder_ja(), leave_voicemail(), minivm_greet_exec(), play_message_category(), play_message_duration(), play_record_review(), valid_priv_reply(), vm_allocate_dh(), vm_authenticate(), vm_browse_messages_en(), vm_browse_messages_es(), vm_browse_messages_gr(), vm_browse_messages_he(), vm_browse_messages_it(), vm_browse_messages_ja(), vm_browse_messages_pt(), vm_browse_messages_vi(), vm_browse_messages_zh(), vm_exec(), vm_execmain(), vm_forwardoptions(), vm_instructions_en(), vm_instructions_ja(), vm_instructions_zh(), vm_intro(), vm_intro_cs(), vm_intro_de(), vm_intro_en(), vm_intro_es(), vm_intro_fr(), vm_intro_gr(), vm_intro_he(), vm_intro_is(), vm_intro_it(), vm_intro_ja(), vm_intro_multilang(), vm_intro_nl(), vm_intro_no(), vm_intro_pl(), vm_intro_pt(), vm_intro_pt_BR(), vm_intro_se(), vm_intro_vi(), vm_intro_zh(), vm_newuser_setup(), vm_options(), vm_play_folder_name(), vm_play_folder_name_gr(), vm_play_folder_name_ja(), vm_play_folder_name_pl(), vm_play_folder_name_ua(), vm_tempgreeting(), and vmauthenticate().

1411 {
1412  int d = 0;
1413 
1414  if ((d = ast_streamfile(chan, fn, ast_channel_language(chan)))) {
1415  return d;
1416  }
1417 
1418  d = ast_waitstream(chan, AST_DIGIT_ANY);
1419 
1420  ast_stopstream(chan);
1421 
1422  return d;
1423 }
int ast_streamfile(struct ast_channel *c, const char *filename, const char *preflang)
Streams a file.
Definition: file.c:1250
#define AST_DIGIT_ANY
Definition: file.h:48
static struct test_val d
int ast_waitstream(struct ast_channel *c, const char *breakon)
Waits for a stream to stop or digit to be pressed.
Definition: file.c:1776
const char * ast_channel_language(const struct ast_channel *chan)
int ast_stopstream(struct ast_channel *c)
Stops a stream.
Definition: file.c:187

◆ ast_queue_topic()

struct stasis_topic* ast_queue_topic ( const char *  queuename)

Get the Stasis Message Bus API topic for queue messages for a particular queue name.

Parameters
queuenameThe name for which to get the topic
Return values
Thetopic structure for queue messages for a given name
NULLif it failed to be found or allocated
Since
12
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 3129 of file main/app.c.

References stasis_topic_pool_get_topic().

Referenced by send_agent_complete().

3130 {
3131  return stasis_topic_pool_get_topic(queue_topic_pool, queuename);
3132 }
struct stasis_topic * stasis_topic_pool_get_topic(struct stasis_topic_pool *pool, const char *topic_name)
Find or create a topic in the pool.
Definition: stasis.c:1884
static struct stasis_topic_pool * queue_topic_pool
Definition: main/app.c:91

◆ ast_queue_topic_all()

struct stasis_topic* ast_queue_topic_all ( void  )

Get the Stasis Message Bus API topic for queue messages.

Return values
Thetopic structure for queue messages
NULLif it has not been allocated
Since
12
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 3124 of file main/app.c.

References queue_topic_all.

Referenced by load_module().

3125 {
3126  return queue_topic_all;
3127 }
static struct stasis_topic * queue_topic_all
Definition: main/app.c:90

◆ ast_read_textfile()

char* ast_read_textfile ( const char *  file)

Read a file into asterisk.

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

Definition at line 2732 of file main/app.c.

References ast_free, ast_log, ast_malloc, errno, LOG_WARNING, and NULL.

Referenced by ast_tcptls_server_start().

2733 {
2734  int fd, count = 0, res;
2735  char *output = NULL;
2736  struct stat filesize;
2737 
2738  if (stat(filename, &filesize) == -1) {
2739  ast_log(LOG_WARNING, "Error can't stat %s\n", filename);
2740  return NULL;
2741  }
2742 
2743  count = filesize.st_size + 1;
2744 
2745  if ((fd = open(filename, O_RDONLY)) < 0) {
2746  ast_log(LOG_WARNING, "Cannot open file '%s' for reading: %s\n", filename, strerror(errno));
2747  return NULL;
2748  }
2749 
2750  if ((output = ast_malloc(count))) {
2751  res = read(fd, output, count - 1);
2752  if (res == count - 1) {
2753  output[res] = '\0';
2754  } else {
2755  ast_log(LOG_WARNING, "Short read of %s (%d of %d): %s\n", filename, res, count - 1, strerror(errno));
2756  ast_free(output);
2757  output = NULL;
2758  }
2759  }
2760 
2761  close(fd);
2762 
2763  return output;
2764 }
#define LOG_WARNING
Definition: logger.h:274
#define NULL
Definition: resample.c:96
#define ast_log
Definition: astobj2.c:42
#define ast_malloc(len)
A wrapper for malloc()
Definition: astmm.h:193
int errno
#define ast_free(a)
Definition: astmm.h:182

◆ ast_record_review()

int ast_record_review ( struct ast_channel chan,
const char *  playfile,
const char *  recordfile,
int  maxtime,
const char *  fmt,
int *  duration,
const char *  path 
)

Allow to record message and have a review option.

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

Definition at line 2429 of file main/app.c.

References AST_DIGIT_ANY, ast_dsp_get_threshold_from_settings(), ast_log, ast_play_and_record(), ast_play_and_wait(), ast_stream_and_wait(), ast_verb, ast_waitfordigit(), LOG_WARNING, maxsilence, NULL, silencethreshold, and THRESHOLD_SILENCE.

Referenced by conf_rec_name(), and conf_run().

2430 {
2431  int silencethreshold;
2432  int maxsilence = 0;
2433  int res = 0;
2434  int cmd = 0;
2435  int max_attempts = 3;
2436  int attempts = 0;
2437  int recorded = 0;
2438  int message_exists = 0;
2439  /* Note that urgent and private are for flagging messages as such in the future */
2440 
2441  /* barf if no pointer passed to store duration in */
2442  if (!duration) {
2443  ast_log(LOG_WARNING, "Error ast_record_review called without duration pointer\n");
2444  return -1;
2445  }
2446 
2447  cmd = '3'; /* Want to start by recording */
2448 
2450 
2451  while ((cmd >= 0) && (cmd != 't')) {
2452  switch (cmd) {
2453  case '1':
2454  if (!message_exists) {
2455  /* In this case, 1 is to record a message */
2456  cmd = '3';
2457  break;
2458  } else {
2459  ast_stream_and_wait(chan, "vm-msgsaved", "");
2460  cmd = 't';
2461  return res;
2462  }
2463  case '2':
2464  /* Review */
2465  ast_verb(3, "Reviewing the recording\n");
2466  cmd = ast_stream_and_wait(chan, recordfile, AST_DIGIT_ANY);
2467  break;
2468  case '3':
2469  message_exists = 0;
2470  /* Record */
2471  ast_verb(3, "R%secording\n", recorded == 1 ? "e-r" : "");
2472  recorded = 1;
2473  if ((cmd = ast_play_and_record(chan, playfile, recordfile, maxtime, fmt, duration, NULL, silencethreshold, maxsilence, path)) == -1) {
2474  /* User has hung up, no options to give */
2475  return cmd;
2476  }
2477  if (cmd == '0') {
2478  break;
2479  } else if (cmd == '*') {
2480  break;
2481  } else {
2482  /* If all is well, a message exists */
2483  message_exists = 1;
2484  cmd = 0;
2485  }
2486  break;
2487  case '4':
2488  case '5':
2489  case '6':
2490  case '7':
2491  case '8':
2492  case '9':
2493  case '*':
2494  case '#':
2495  cmd = ast_play_and_wait(chan, "vm-sorry");
2496  break;
2497  default:
2498  if (message_exists) {
2499  cmd = ast_play_and_wait(chan, "vm-review");
2500  } else {
2501  if (!(cmd = ast_play_and_wait(chan, "vm-torerecord"))) {
2502  cmd = ast_waitfordigit(chan, 600);
2503  }
2504  }
2505 
2506  if (!cmd) {
2507  cmd = ast_waitfordigit(chan, 6000);
2508  }
2509  if (!cmd) {
2510  attempts++;
2511  }
2512  if (attempts > max_attempts) {
2513  cmd = 't';
2514  }
2515  }
2516  }
2517  if (cmd == 't') {
2518  cmd = 0;
2519  }
2520  return cmd;
2521 }
#define AST_DIGIT_ANY
Definition: file.h:48
#define LOG_WARNING
Definition: logger.h:274
static int maxsilence
#define NULL
Definition: resample.c:96
#define ast_verb(level,...)
Definition: logger.h:463
#define ast_log
Definition: astobj2.c:42
static int silencethreshold
int ast_play_and_record(struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime, const char *fmt, int *duration, int *sound_duration, int silencethreshold, int maxsilence, const char *path)
Record a file based on input from a channel. Use default accept and cancel DTMF. This function will p...
Definition: main/app.c:1937
int ast_stream_and_wait(struct ast_channel *chan, const char *file, const char *digits)
stream file until digit If the file name is non-empty, try to play it.
Definition: file.c:1814
int ast_play_and_wait(struct ast_channel *chan, const char *fn)
Play a stream and wait for a digit, returning the digit that was pressed.
Definition: main/app.c:1410
int ast_waitfordigit(struct ast_channel *c, int ms)
Waits for a digit.
Definition: channel.c:3180
int ast_dsp_get_threshold_from_settings(enum threshold which)
Get silence threshold from dsp.conf.
Definition: dsp.c:1996

◆ ast_replace_sigchld()

void ast_replace_sigchld ( void  )

Replace the SIGCHLD handler.

Normally, Asterisk has a SIGCHLD handler that is cleaning up all zombie processes from forking elsewhere in Asterisk. However, if you want to wait*() on the process to retrieve information about it's exit status, then this signal handler needs to be temporarily replaced.

Code that executes this function must call ast_unreplace_sigchld() after it is finished doing the wait*().

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

Definition at line 801 of file extconf.c.

References ast_mutex_lock, ast_mutex_unlock, ast_unreplace_sigchld(), safe_system_lock, and safe_system_prev_handler.

Referenced by ast_safe_fork(), ast_safe_system(), and safe_exec_prep().

802 {
803  unsigned int level;
804 
805  level = safe_system_level++;
806 
807  /* only replace the handler if it has not already been done */
808  if (level == 0) {
809  sigaction(SIGCHLD, &null_sig_handler, &safe_system_prev_handler);
810  }
811 }
static struct sigaction null_sig_handler
Definition: extconf.c:794
static unsigned int safe_system_level
Keep track of how many threads are currently trying to wait*() on a child process.
Definition: extconf.c:785
static struct sigaction safe_system_prev_handler
Definition: extconf.c:786

◆ ast_safe_execvp()

int ast_safe_execvp ( int  dualfork,
const char *  file,
char *const  argv[] 
)

Safely spawn an external program while closing file descriptors.

Note
This replaces the execvp call in all Asterisk modules
Parameters
dualforkNon-zero to simulate running the program in the background by forking twice. The option provides similar functionality to the '&' in the OS shell command "cmd &". The option allows Asterisk to run a reaper loop to watch the first fork which immediately exits after spaning the second fork. The actual program is run in the second fork.
fileexecvp(file, argv) file parameter
argvexecvp(file, argv) argv parameter

Definition at line 1180 of file asterisk.c.

References safe_exec_prep(), and safe_exec_wait().

Referenced by run_externnotify().

1181 {
1182  pid_t pid = safe_exec_prep(dualfork);
1183 
1184  if (pid == 0) {
1185  execvp(file, argv);
1186  _exit(1);
1187  /* noreturn from _exit */
1188  }
1189 
1190  return safe_exec_wait(pid);
1191 }
static pid_t safe_exec_prep(int dualfork)
fork and perform other preparations for spawning applications
Definition: asterisk.c:1093
static int safe_exec_wait(pid_t pid)
wait for spawned application to complete and unreplace sigchld
Definition: asterisk.c:1154

◆ ast_safe_fork()

int ast_safe_fork ( int  stop_reaper)

Common routine to safely fork without a chance of a signal handler firing badly in the child.

Parameters
[in]stop_reaperflag to determine if sigchld handler is replaced or not
Since
1.6.1
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 2987 of file main/app.c.

References ast_calloc, AST_LIST_INSERT_TAIL, AST_LIST_LOCK, AST_LIST_UNLOCK, ast_log, ast_pthread_create_background, AST_PTHREADT_NULL, ast_replace_sigchld(), errno, zombie::list, LOG_ERROR, LOG_WARNING, NULL, zombie::pid, shaun_of_the_dead(), and shaun_of_the_dead_thread.

Referenced by app_exec(), filestream_destructor(), launch_script(), mp3play(), send_waveform_to_fd(), spawn_mp3(), and vm_check_password_shell().

2988 {
2989  sigset_t signal_set, old_set;
2990  int pid;
2991 
2992  /* Don't let the default signal handler for children reap our status */
2993  if (stop_reaper) {
2995  }
2996 
2997  /* GCC 4.9 gives a bogus "right-hand operand of comma expression has
2998  * no effect" warning */
2999  (void) sigfillset(&signal_set);
3000  pthread_sigmask(SIG_BLOCK, &signal_set, &old_set);
3001 
3002  pid = fork();
3003 
3004  if (pid != 0) {
3005  /* Fork failed or parent */
3006  pthread_sigmask(SIG_SETMASK, &old_set, NULL);
3007  if (!stop_reaper && pid > 0) {
3008  struct zombie *cur = ast_calloc(1, sizeof(*cur));
3009  if (cur) {
3010  cur->pid = pid;
3016  ast_log(LOG_ERROR, "Shaun of the Dead wants to kill zombies, but can't?!!\n");
3018  }
3019  }
3020  }
3021  }
3022  return pid;
3023  } else {
3024  /* Child */
3025 #ifdef HAVE_CAP
3026  cap_set_proc(child_cap);
3027 #endif
3028 
3029  /* Before we unblock our signals, return our trapped signals back to the defaults */
3030  signal(SIGHUP, SIG_DFL);
3031  signal(SIGCHLD, SIG_DFL);
3032  signal(SIGINT, SIG_DFL);
3033  signal(SIGURG, SIG_DFL);
3034  signal(SIGTERM, SIG_DFL);
3035  signal(SIGPIPE, SIG_DFL);
3036  signal(SIGXFSZ, SIG_DFL);
3037 
3038  /* unblock important signal handlers */
3039  if (pthread_sigmask(SIG_UNBLOCK, &signal_set, NULL)) {
3040  ast_log(LOG_WARNING, "unable to unblock signals: %s\n", strerror(errno));
3041  _exit(1);
3042  }
3043 
3044  return pid;
3045  }
3046 }
pid_t pid
Definition: main/app.c:78
#define AST_LIST_LOCK(head)
Locks a list.
Definition: linkedlists.h:39
#define LOG_WARNING
Definition: logger.h:274
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
Definition: linkedlists.h:139
static pthread_t shaun_of_the_dead_thread
Definition: main/app.c:75
#define NULL
Definition: resample.c:96
#define ast_pthread_create_background(a, b, c, d)
Definition: utils.h:567
#define ast_log
Definition: astobj2.c:42
struct zombie::@320 list
#define AST_PTHREADT_NULL
Definition: lock.h:66
static void * shaun_of_the_dead(void *data)
Definition: main/app.c:94
void ast_replace_sigchld(void)
Replace the SIGCHLD handler.
Definition: extconf.c:801
#define LOG_ERROR
Definition: logger.h:285
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
Definition: linkedlists.h:730
int errno
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:204

◆ ast_safe_fork_cleanup()

void ast_safe_fork_cleanup ( void  )

Common routine to cleanup after fork'ed process is complete (if reaping was stopped)

Since
1.6.1
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 3048 of file main/app.c.

References ast_unreplace_sigchld().

Referenced by agi_exec_full().

3049 {
3051 }
void ast_unreplace_sigchld(void)
Restore the SIGCHLD handler.
Definition: extconf.c:815

◆ ast_safe_system()

int ast_safe_system ( const char *  s)

Safely spawn an OS shell command while closing file descriptors.

Note
This replaces the system call in all Asterisk modules
Parameters
s- OS shell command string to execute.
Warning
Command injection can happen using this call if the passed in string is created using untrusted data from an external source. It is best not to use untrusted data. However, the caller could filter out dangerous characters to avoid command injection.

Definition at line 829 of file extconf.c.

References ast_log(), ast_replace_sigchld(), ast_unreplace_sigchld(), errno, LOG_WARNING, NULL, safe_exec_prep(), safe_exec_wait(), status, WEXITSTATUS, WIFEXITED, and ast_channel::x.

Referenced by add_email_attachment(), alarmreceiver_exec(), ast_monitor_stop(), AST_TEST_DEFINE(), ast_unreplace_sigchld(), consolehandler(), convert_bdb_to_sqlite3(), mixmonitor_thread(), notify_message(), process_text_line(), remoteconsolehandler(), rotate_file(), run_externnotify(), sendmail(), sendpage(), system_exec_helper(), vm_change_password_shell(), and vmsayname_exec().

830 {
831  pid_t pid;
832 #ifdef HAVE_WORKING_FORK
833  int x;
834 #endif
835  int res;
836  int status;
837 
838 #if defined(HAVE_WORKING_FORK) || defined(HAVE_WORKING_VFORK)
840 
841 #ifdef HAVE_WORKING_FORK
842  pid = fork();
843 #else
844  pid = vfork();
845 #endif
846 
847  if (pid == 0) {
848 #ifdef HAVE_WORKING_FORK
849  /* Close file descriptors and launch system command */
850  for (x = STDERR_FILENO + 1; x < 4096; x++)
851  close(x);
852 #endif
853  execl("/bin/sh", "/bin/sh", "-c", s, (char *) NULL);
854  _exit(1);
855  } else if (pid > 0) {
856  for(;;) {
857  res = waitpid(pid, &status, 0);
858  if (res > -1) {
859  res = WIFEXITED(status) ? WEXITSTATUS(status) : -1;
860  break;
861  } else if (errno != EINTR)
862  break;
863  }
864  } else {
865  ast_log(LOG_WARNING, "Fork failed: %s\n", strerror(errno));
866  res = -1;
867  }
868 
870 #else
871  res = -1;
872 #endif
873 
874  return res;
875 }
pid_t pid
Definition: main/app.c:78
void ast_unreplace_sigchld(void)
Restore the SIGCHLD handler.
Definition: extconf.c:815
void ast_replace_sigchld(void)
Replace the SIGCHLD handler.
Definition: extconf.c:801
#define NULL
Definition: resample.c:96
static void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Definition: extconf.c:2195
#define LOG_WARNING
Definition: extconf.c:139
int errno
#define WEXITSTATUS(status)
#define WIFEXITED(status)
jack_status_t status
Definition: app_jack.c:146

◆ ast_set_lock_type()

void ast_set_lock_type ( enum AST_LOCK_TYPE  type)

Set the type of locks used by ast_lock_path()

Parameters
typethe locking type to use
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 2392 of file main/app.c.

References type.

Referenced by load_asterisk_conf().

2393 {
2394  ast_lock_type = type;
2395 }
static const char type[]
Definition: chan_ooh323.c:109
ast_lock_type
Definition: check_expr.c:35

◆ ast_str_get_encoded_str()

int ast_str_get_encoded_str ( struct ast_str **  str,
int  maxlen,
const char *  stream 
)

Decode a stream of encoded control or extended ASCII characters.

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

Definition at line 2955 of file main/app.c.

References ast_get_encoded_char(), ast_str_buffer(), ast_str_make_space, ast_str_set(), ast_str_size(), ast_str_update(), buf, and zombie::next.

Referenced by sendtext_exec(), and system_exec_helper().

2956 {
2957  char next, *buf;
2958  size_t offset = 0;
2959  size_t consumed;
2960 
2961  if (strchr(stream, '\\')) {
2962  while (!ast_get_encoded_char(stream, &next, &consumed)) {
2963  if (offset + 2 > ast_str_size(*str) && maxlen > -1) {
2964  ast_str_make_space(str, maxlen > 0 ? maxlen : (ast_str_size(*str) + 48) * 2 - 48);
2965  }
2966  if (offset + 2 > ast_str_size(*str)) {
2967  break;
2968  }
2969  buf = ast_str_buffer(*str);
2970  buf[offset++] = next;
2971  stream += consumed;
2972  }
2973  buf = ast_str_buffer(*str);
2974  buf[offset++] = '\0';
2975  ast_str_update(*str);
2976  } else {
2977  ast_str_set(str, maxlen, "%s", stream);
2978  }
2979  return 0;
2980 }
size_t ast_str_size(const struct ast_str *buf)
Returns the current maximum length (without reallocation) of the current buffer.
Definition: strings.h:699
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
#define ast_str_make_space(buf, new_len)
Definition: strings.h:780
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition: strings.h:714
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
Definition: strings.h:1065
struct zombie * next
Definition: main/app.c:79
void ast_str_update(struct ast_str *buf)
Update the length of the buffer, after using ast_str merely as a buffer.
Definition: strings.h:663
int ast_get_encoded_char(const char *stream, char *result, size_t *consumed)
Decode an encoded control or extended ASCII character.
Definition: main/app.c:2867

◆ AST_THREADSTORAGE_EXTERNAL()

AST_THREADSTORAGE_EXTERNAL ( ast_str_thread_global_buf  )

◆ ast_unlock_path()

int ast_unlock_path ( const char *  path)

Unlock a path.

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

Definition at line 2413 of file main/app.c.

References AST_LOCK_TYPE_FLOCK, AST_LOCK_TYPE_LOCKFILE, ast_unlock_path_flock(), and ast_unlock_path_lockfile().

Referenced by __ast_play_and_record(), access_counter_file(), ast_module_reload(), close_mailbox(), copy_message(), count_messages(), leave_voicemail(), msg_create_from_file(), open_mailbox(), resequence_mailbox(), save_to_folder(), and test_vm_api_create_voicemail_files().

2414 {
2415  int r = 0;
2416 
2417  switch (ast_lock_type) {
2419  r = ast_unlock_path_lockfile(path);
2420  break;
2421  case AST_LOCK_TYPE_FLOCK:
2422  r = ast_unlock_path_flock(path);
2423  break;
2424  }
2425 
2426  return r;
2427 }
static int ast_unlock_path_flock(const char *path)
Definition: main/app.c:2362
static int ast_unlock_path_lockfile(const char *path)
Definition: main/app.c:2240
ast_lock_type
Definition: check_expr.c:35

◆ ast_unreplace_sigchld()

void ast_unreplace_sigchld ( void  )

Restore the SIGCHLD handler.

This function is called after a call to ast_replace_sigchld. It restores the SIGCHLD handler that cleans up any zombie processes.

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

Definition at line 815 of file extconf.c.

References ast_mutex_lock, ast_mutex_unlock, ast_safe_system(), NULL, safe_system_level, safe_system_lock, and safe_system_prev_handler.

Referenced by ast_replace_sigchld(), ast_safe_fork_cleanup(), ast_safe_system(), safe_exec_wait(), and vmsayname_exec().

816 {
817  unsigned int level;
818 
819  level = --safe_system_level;
820 
821  /* only restore the handler if we are the last one */
822  if (level == 0) {
823  sigaction(SIGCHLD, &safe_system_prev_handler, NULL);
824  }
825 }
#define NULL
Definition: resample.c:96
static unsigned int safe_system_level
Keep track of how many threads are currently trying to wait*() on a child process.
Definition: extconf.c:785
static struct sigaction safe_system_prev_handler
Definition: extconf.c:786

◆ ast_vm_greeter_is_registered()

int ast_vm_greeter_is_registered ( void  )

Determine if a voicemail greeter provider is registered.

Since
13.0.0
Return values
0if no provider registered.
1if a provider is registered.
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 558 of file main/app.c.

References ao2_cleanup, ao2_global_obj_ref, and table.

559 {
561  int is_registered;
562 
563  table = ao2_global_obj_ref(vm_greeter_provider);
564  is_registered = table ? 1 : 0;
565  ao2_cleanup(table);
566  return is_registered;
567 }
Voicemail greeter function table definition.
#define ao2_global_obj_ref(holder)
Definition: astobj2.h:925
static char * table
Definition: cdr_odbc.c:58
#define ao2_cleanup(obj)
Definition: astobj2.h:1958

◆ ast_vm_greeter_unregister()

void ast_vm_greeter_unregister ( const char *  module_name)

Unregister the specified voicemail greeter provider.

Since
13.0.0
Parameters
Themodule name of the provider to unregister
Returns
Nothing
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 601 of file main/app.c.

References ao2_cleanup, ao2_global_obj_ref, ao2_global_obj_release, ast_vm_greeter_functions::module_name, NULL, and table.

Referenced by unload_module().

602 {
604 
605  table = ao2_global_obj_ref(vm_greeter_provider);
606  if (table && !strcmp(table->module_name, module_name)) {
607  ao2_global_obj_release(vm_greeter_provider);
608  }
609  ao2_cleanup(table);
610 }
Voicemail greeter function table definition.
#define ao2_global_obj_ref(holder)
Definition: astobj2.h:925
static char * table
Definition: cdr_odbc.c:58
const char * module_name
The name of the module that provides the voicemail greeter functionality.
#define ao2_global_obj_release(holder)
Definition: astobj2.h:865
#define ao2_cleanup(obj)
Definition: astobj2.h:1958

◆ ast_vm_index_to_foldername()

const char* ast_vm_index_to_foldername ( int  id)

Return name of folder, given an id.

Parameters
[in]idFolder id
Returns
Name of folder
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 743 of file main/app.c.

References NULL, and VM_API_CALL.

744 {
745  const char *res = NULL;
746 
747  VM_API_CALL(res, index_to_foldername, (id));
748  return res;
749 }
#define NULL
Definition: resample.c:96
#define VM_API_CALL(res, api_call, api_parms)
Definition: main/app.c:637

◆ ast_vm_is_registered()

int ast_vm_is_registered ( void  )

Determine if a voicemail provider is registered.

Since
12.0.0
Return values
0if no provider registered.
1if a provider is registered.
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 447 of file main/app.c.

References ao2_cleanup, ao2_global_obj_ref, and table.

448 {
449  struct ast_vm_functions *table;
450  int is_registered;
451 
452  table = ao2_global_obj_ref(vm_provider);
453  is_registered = table ? 1 : 0;
454  ao2_cleanup(table);
455  return is_registered;
456 }
#define ao2_global_obj_ref(holder)
Definition: astobj2.h:925
static char * table
Definition: cdr_odbc.c:58
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
Voicemail function table definition.

◆ ast_vm_mailbox_snapshot_create()

struct ast_vm_mailbox_snapshot* ast_vm_mailbox_snapshot_create ( const char *  mailbox,
const char *  context,
const char *  folder,
int  descending,
enum ast_vm_snapshot_sort_val  sort_val,
int  combine_INBOX_and_OLD 
)

Create a snapshot of a mailbox which contains information about every msg.

Parameters
mailbox,themailbox to look for
context,thecontext to look for the mailbox in
folder,OPTIONAL.When not NULL only msgs from the specified folder will be included.
descending,listthe msgs in descending order rather than ascending order.
combine_INBOX_and_OLD,Whenthis argument is set, The OLD folder will be represented in the INBOX folder of the snapshot. This allows the snapshot to represent the OLD and INBOX messages in sorted order merged together.
Return values
snapshoton success
NULLon failure
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 751 of file main/app.c.

References NULL, and VM_API_CALL.

Referenced by test_vm_api_remove_all_messages().

757 {
758  struct ast_vm_mailbox_snapshot *res = NULL;
759 
760  VM_API_CALL(res, mailbox_snapshot_create, (mailbox, context, folder, descending,
761  sort_val, combine_INBOX_and_OLD));
762  return res;
763 }
#define NULL
Definition: resample.c:96
static char mailbox[AST_MAX_MAILBOX_UNIQUEID]
Definition: chan_mgcp.c:207
#define VM_API_CALL(res, api_call, api_parms)
Definition: main/app.c:637
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:120

◆ ast_vm_mailbox_snapshot_destroy()

struct ast_vm_mailbox_snapshot* ast_vm_mailbox_snapshot_destroy ( struct ast_vm_mailbox_snapshot mailbox_snapshot)

destroy a snapshot

Parameters
mailbox_snapshotThe snapshot to destroy.
Return values
NULL
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 765 of file main/app.c.

References NULL, and VM_API_CALL.

Referenced by AST_TEST_DEFINE(), and test_vm_api_remove_all_messages().

766 {
767  struct ast_vm_mailbox_snapshot *res = NULL;
768 
769  VM_API_CALL(res, mailbox_snapshot_destroy, (mailbox_snapshot));
770  return res;
771 }
#define NULL
Definition: resample.c:96
#define VM_API_CALL(res, api_call, api_parms)
Definition: main/app.c:637

◆ ast_vm_msg_forward()

int ast_vm_msg_forward ( const char *  from_mailbox,
const char *  from_context,
const char *  from_folder,
const char *  to_mailbox,
const char *  to_context,
const char *  to_folder,
size_t  num_msgs,
const char *  msg_ids[],
int  delete_old 
)

forward a message from one mailbox to another.

from_mailbox The original mailbox the message is being forwarded from from_context The voicemail context of the from_mailbox from_folder The folder from which the message is being forwarded to_mailbox The mailbox to forward the message to to_context The voicemail context of the to_mailbox to_folder The folder to which the message is being forwarded num_msgs The number of messages being forwarded msg_ids The message IDs of the messages in from_mailbox to forward delete_old If non-zero, the forwarded messages are also deleted from from_mailbox. Otherwise, the messages will remain in the from_mailbox.

Return values
-1Failure
0Success
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 799 of file main/app.c.

References VM_API_CALL.

808 {
809  int res = 0;
810 
811  VM_API_CALL(res, msg_forward, (from_mailbox, from_context, from_folder, to_mailbox,
812  to_context, to_folder, num_msgs, msg_ids, delete_old));
813  return res;
814 }
def from_mailbox(key, val, section, pjsip, nmapped)
#define VM_API_CALL(res, api_call, api_parms)
Definition: main/app.c:637

◆ ast_vm_msg_move()

int ast_vm_msg_move ( const char *  mailbox,
const char *  context,
size_t  num_msgs,
const char *  oldfolder,
const char *  old_msg_ids[],
const char *  newfolder 
)

Move messages from one folder to another.

Parameters
mailboxThe mailbox to which the folders belong
contextThe voicemail context for the mailbox
num_msgsThe number of messages to move
oldfolderThe folder from where messages should be moved
old_msg_idsThe message IDs of the messages to move
newfolderThe folder to which messages should be moved new folder. This array must be num_msgs sized.
Return values
-1Failure
0Success
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 773 of file main/app.c.

References VM_API_CALL.

779 {
780  int res = 0;
781 
782  VM_API_CALL(res, msg_move, (mailbox, context, num_msgs, oldfolder, old_msg_ids,
783  newfolder));
784  return res;
785 }
static char mailbox[AST_MAX_MAILBOX_UNIQUEID]
Definition: chan_mgcp.c:207
#define VM_API_CALL(res, api_call, api_parms)
Definition: main/app.c:637
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:120

◆ ast_vm_msg_play()

int ast_vm_msg_play ( struct ast_channel chan,
const char *  mailbox,
const char *  context,
const char *  folder,
const char *  msg_num,
ast_vm_msg_play_cb cb 
)

Play a voicemail msg back on a channel.

Parameters
chan
mailboxmsg is in.
contextof mailbox.
foldervoicemail folder to look in.
msg_nummessage number in the voicemailbox to playback to the channel.
cb
Return values
0success
-1failure
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 816 of file main/app.c.

References context, mailbox, and VM_API_CALL.

822 {
823  int res = 0;
824 
825  VM_API_CALL(res, msg_play, (chan, mailbox, context, folder, msg_num, cb));
826  return res;
827 }
static char mailbox[AST_MAX_MAILBOX_UNIQUEID]
Definition: chan_mgcp.c:207
#define VM_API_CALL(res, api_call, api_parms)
Definition: main/app.c:637
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:120

◆ ast_vm_msg_remove()

int ast_vm_msg_remove ( const char *  mailbox,
const char *  context,
size_t  num_msgs,
const char *  folder,
const char *  msgs[] 
)

Remove/delete messages from a mailbox folder.

Parameters
mailboxThe mailbox from which to delete messages
contextThe voicemail context for the mailbox
num_msgsThe number of messages to delete
folderThe folder from which to remove messages
msgsThe message IDs of the messages to delete
Return values
-1Failure
0Success
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 787 of file main/app.c.

References VM_API_CALL.

792 {
793  int res = 0;
794 
795  VM_API_CALL(res, msg_remove, (mailbox, context, num_msgs, folder, msgs));
796  return res;
797 }
static char mailbox[AST_MAX_MAILBOX_UNIQUEID]
Definition: chan_mgcp.c:207
#define VM_API_CALL(res, api_call, api_parms)
Definition: main/app.c:637
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:120

◆ ast_vm_unregister()

void ast_vm_unregister ( const char *  module_name)

Unregister the specified voicemail provider.

Parameters
Themodule name of the provider to unregister
Returns
Nothing
Examples:
/tmp/asterisk-shallow/main/app.c.

Definition at line 490 of file main/app.c.

References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_alloc_options, ao2_cleanup, ao2_global_obj_ref, ao2_global_obj_release, ao2_global_obj_replace_unref, AO2_GLOBAL_OBJ_STATIC(), ast_log, LOG_ERROR, ast_vm_functions::module_name, NULL, RAII_VAR, table, and vm_table.

Referenced by unload_module().

491 {
492  struct ast_vm_functions *table;
493 
494  table = ao2_global_obj_ref(vm_provider);
495  if (table && !strcmp(table->module_name, module_name)) {
496  ao2_global_obj_release(vm_provider);
497  }
498  ao2_cleanup(table);
499 }
#define ao2_global_obj_ref(holder)
Definition: astobj2.h:925
static char * table
Definition: cdr_odbc.c:58
#define ao2_global_obj_release(holder)
Definition: astobj2.h:865
const char * module_name
The name of the module that provides the voicemail functionality.
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
Voicemail function table definition.