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"

Include dependency graph for include/asterisk/app.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_mwi_blob
 Object that represents an MWI update with some additional application defined data. More...
struct  ast_mwi_state
 The structure that contains MWI state. More...
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...

Defines

#define AST_APP_ARG(name)   char *name
 Define an application argument.
#define AST_APP_OPTION(option, flagno)   [option] = { .flag = flagno }
 Declares an application option that does not accept an argument.
#define AST_APP_OPTION_ARG(option, flagno, argno)   [option] = { .flag = flagno, .arg_index = argno + 1 }
 Declares an application option that accepts an argument.
#define AST_APP_OPTIONS(holder, options...)   static const struct ast_app_option holder[128] = options
 Declares an array of options for an application.
#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(, arglist) name = { 0, }
 Declare a structure to hold an application's arguments.
#define AST_DEFINE_APP_ARGS_TYPE(type, arglist)
 Define a structure type to hold an application's arguments.
#define ast_delete_mwi_state(mailbox, context)   ast_delete_mwi_state_full(mailbox, context, NULL)
 Delete MWI state cached by stasis.
#define AST_IVR_DECLARE_MENU(holder, title, flags, foo...)
#define AST_IVR_FLAG_AUTORESTART   (1 << 0)
#define AST_MAX_MAILBOX_UNIQUEID   (AST_MAX_EXTENSION + AST_MAX_CONTEXT + 2)
#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.
#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_publish_mwi_state(mailbox, context, new_msgs, old_msgs)   ast_publish_mwi_state_full(mailbox, context, new_msgs, old_msgs, NULL, NULL)
 Publish a MWI state update via stasis.
#define ast_publish_mwi_state_channel(mailbox, context, new_msgs, old_msgs, channel_id)   ast_publish_mwi_state_full(mailbox, context, new_msgs, old_msgs, channel_id, NULL)
 Publish a MWI state update associated with some channel.
#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.
#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_info ? ast_module_info->self : NULL)
 See __ast_vm_greeter_register().
#define ast_vm_register(vm_table)   __ast_vm_register(vm_table, ast_module_info ? ast_module_info->self : NULL)
 See __ast_vm_register().
#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.
typedef int( ast_has_voicemail_fn )(const char *mailboxes, const char *folder)
 Determines if the given folder has messages.
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.
typedef int( ast_inboxcount_fn )(const char *mailboxes, int *newmsgs, int *oldmsgs)
 Gets the number of messages that exist for the mailbox list.
typedef int( ast_ivr_callback )(struct ast_channel *chan, char *option, void *cbdata)
 Callback function for IVR.
typedef int( ast_messagecount_fn )(const char *mailbox_id, const char *folder)
 Gets the number of messages that exist in a mailbox folder.
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.
typedef const char *( ast_vm_index_to_foldername_fn )(int id)
 Convert the mailbox folder id to a folder name.
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.
typedef struct
ast_vm_mailbox_snapshot *( 
ast_vm_mailbox_snapshot_destroy_fn )(struct ast_vm_mailbox_snapshot *mailbox_snapshot)
 destroy a snapshot
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.
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.
typedef void( ast_vm_msg_play_cb )(struct ast_channel *chan, const char *playfile, int duration)
 Voicemail playback callback function definition.
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.
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.

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.
int __ast_vm_greeter_register (const struct ast_vm_greeter_functions *vm_table, struct ast_module *module)
 Set voicemail greeter function callbacks.
int __ast_vm_register (const struct ast_vm_functions *vm_table, struct ast_module *module)
 Set voicemail function callbacks.
int app_init (void)
 Initialize the application core.
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
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.
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.
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.
const char * ast_app_expand_sub_args (struct ast_channel *chan, const char *args)
 Add missing context/exten to subroutine argument string.
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.
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.
int ast_app_group_discard (struct ast_channel *chan)
 Discard all group counting for a channel.
int ast_app_group_get_count (const char *group, const char *category)
 Get the current channel count of the specified group and category.
struct ast_group_infoast_app_group_list_head (void)
 Get the head of the group count list.
int ast_app_group_list_rdlock (void)
 Read Lock the group count list.
int ast_app_group_list_unlock (void)
 Unlock the group count list.
int ast_app_group_list_wrlock (void)
 Write Lock the group count list.
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.
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.
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.
int ast_app_group_update (struct ast_channel *oldchan, struct ast_channel *newchan)
 Update all group counting for a channel to a new one.
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.
int ast_app_inboxcount (const char *mailboxes, int *newmsgs, int *oldmsgs)
 Determine number of new/old messages in a mailbox.
int ast_app_inboxcount2 (const char *mailboxes, int *urgentmsgs, int *newmsgs, int *oldmsgs)
 Determine number of urgent/new/old messages in a mailbox.
int ast_app_messagecount (const char *mailbox_id, const char *folder)
 Get the number of messages in a given mailbox folder.
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.
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.
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.
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.
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.
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.
int ast_app_sayname (struct ast_channel *chan, const char *mailbox_id)
 Play a recorded user name for the mailbox to the specified channel.
void ast_close_fds_above_n (int n)
 Common routine for child processes, to close all fds prior to exec(2).
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.
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.
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.
int ast_control_tone (struct ast_channel *chan, const char *tone)
 Controls playback of a tone.
int ast_delete_mwi_state_full (const char *mailbox, const char *context, struct ast_eid *eid)
 Delete MWI state cached by stasis with all parameters.
int ast_dtmf_stream (struct ast_channel *chan, struct ast_channel *peer, const char *digits, int between, unsigned int duration)
 Send DTMF to a channel.
int ast_get_encoded_char (const char *stream, char *result, size_t *consumed)
 Decode an encoded control or extended ASCII character.
char * ast_get_encoded_str (const char *stream, char *result, size_t result_len)
 Decode a stream of encoded control or extended ASCII characters.
void ast_install_stack_functions (const struct ast_app_stack_funcs *funcs)
 Set stack application function callbacks.
int ast_ivr_menu_run (struct ast_channel *c, struct ast_ivr_menu *menu, void *cbdata)
 Runs an IVR menu.
int ast_linear_stream (struct ast_channel *chan, const char *filename, int fd, int allowoverride)
 Stream a filename (or file descriptor) as a generator.
enum AST_LOCK_RESULT ast_lock_path (const char *path)
 Lock a filesystem path.
struct stasis_messageast_mwi_blob_create (struct ast_mwi_state *mwi_state, struct stasis_message_type *message_type, struct ast_json *blob)
 Creates a ast_mwi_blob message.
struct ast_mwi_stateast_mwi_create (const char *mailbox, const char *context)
 Create a ast_mwi_state object.
struct stasis_cacheast_mwi_state_cache (void)
 Backend cache for ast_mwi_topic_cached().
struct stasis_message_typeast_mwi_state_type (void)
 Get the Stasis Message Bus API message type for MWI messages.
struct stasis_topicast_mwi_topic (const char *uniqueid)
 Get the Stasis Message Bus API topic for MWI messages on a unique ID.
struct stasis_topicast_mwi_topic_all (void)
 Get the Stasis Message Bus API topic for MWI messages.
struct stasis_topicast_mwi_topic_cached (void)
 Get the Stasis Message Bus API caching topic for MWI messages.
struct stasis_message_typeast_mwi_vm_app_type (void)
 Get the Stasis Message Bus API message type for voicemail application specific messages.
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.
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.
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.
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.
int ast_publish_mwi_state_full (const char *mailbox, const char *context, int new_msgs, int old_msgs, const char *channel_id, struct ast_eid *eid)
 Publish a MWI state update via stasis with all parameters.
struct stasis_topicast_queue_topic (const char *queuename)
 Get the Stasis Message Bus API topic for queue messages for a particular queue name.
struct stasis_topicast_queue_topic_all (void)
 Get the Stasis Message Bus API topic for queue messages.
char * ast_read_textfile (const char *file)
 Read a file into asterisk.
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.
void ast_replace_sigchld (void)
 Replace the SIGCHLD handler.
int ast_safe_fork (int stop_reaper)
 Common routine to safely fork without a chance of a signal handler firing badly in the child.
void ast_safe_fork_cleanup (void)
 Common routine to cleanup after fork'ed process is complete (if reaping was stopped).
int ast_safe_system (const char *s)
 Safely spawn an external program while closing file descriptors.
void ast_set_lock_type (enum AST_LOCK_TYPE type)
 Set the type of locks used by ast_lock_path().
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.
 AST_THREADSTORAGE_EXTERNAL (ast_str_thread_global_buf)
int ast_unlock_path (const char *path)
 Unlock a path.
void ast_unreplace_sigchld (void)
 Restore the SIGCHLD handler.
int ast_vm_greeter_is_registered (void)
 Determine if a voicemail greeter provider is registered.
void ast_vm_greeter_unregister (const char *module_name)
 Unregister the specified voicemail greeter provider.
const char * ast_vm_index_to_foldername (int id)
 Return name of folder, given an id.
int ast_vm_is_registered (void)
 Determine if a voicemail provider is registered.
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.
struct ast_vm_mailbox_snapshotast_vm_mailbox_snapshot_destroy (struct ast_vm_mailbox_snapshot *mailbox_snapshot)
 destroy a snapshot
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.
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.
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.
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.
void ast_vm_unregister (const char *module_name)
 Unregister the specified voicemail provider.


Detailed Description

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

Definition in file include/asterisk/app.h.


Define Documentation

#define AST_APP_ARG ( name   )     char *name

Define an application argument.

Parameters:
name The name of the argument

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

Referenced by acf_curl_helper(), acf_if(), acf_isexten_exec(), acf_jabberreceive_read(), acf_jabberstatus_read(), acf_mailbox_exists(), acf_meetme_info(), 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(), aMYSQL_connect(), aMYSQL_fetch(), aMYSQL_nextresult(), aMYSQL_query(), aMYSQL_set(), app_exec(), applicationmap_handler(), aqm_exec(), array(), ast_eivr_senddtmf(), ast_queue_log(), asyncgoto_exec(), auth_exec(), background_detect_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_callback(), celgenuserevent_exec(), chanavail_exec(), channel_admin_exec(), chanspy_exec(), cli_odbc_read(), cli_odbc_write(), conf_exec(), confbridge_exec(), config_function_read(), controlplayback_exec(), count_exec(), create_addr(), cut_internal(), dahdi_call(), determine_starting_point(), dial_exec_full(), dialgroup_write(), dictate_exec(), directory_exec(), disa_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(), find_table_cb(), forkcdr_exec(), func_confbridge_helper(), func_confbridge_info(), func_header_read(), func_mixmonitor_read(), func_read_header(), 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(), misdn_call(), misdn_check_l2l1(), misdn_facility_exec(), misdn_request(), mixmonitor_exec(), msg_send_exec(), multicast_rtp_request(), originate_exec(), ospauth_exec(), ospfinished_exec(), osplookup_exec(), ospnext_exec(), oss_call(), oss_request(), 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_waitexten(), peek_read(), pickupchan_exec(), pjsip_acf_channel_read(), pjsip_acf_dial_contacts_read(), pjsip_aor_function_read(), pjsip_contact_function_read(), pjsip_endpoint_function_read(), play_moh_exec(), playback_exec(), pp_each_extension_helper(), pp_each_user_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(), rcvfax_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(), sayunixtime_exec(), senddtmf_exec(), sendfax_exec(), sendurl_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(), sndfax_exec(), softhangup_exec(), sorcery_function_read(), speech_background(), speech_load(), srv_result_read(), stackpeek_read(), start_moh_exec(), start_monitor_exec(), stop_mixmonitor_full(), strreplace(), talk_detect_fn_write(), transfer_exec(), unicast_rtp_request(), unshift_push(), upqm_exec(), userevent_exec(), verbose_exec(), vm_box_exists(), vm_check_password_shell(), vm_exec(), vm_execmain(), vm_playmsgexec(), volume_write(), xmpp_join_exec(), xmpp_leave_exec(), xmpp_send_exec(), xmpp_sendgroup_exec(), xmpp_status_exec(), and zapateller_exec().

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

Declares an application option that does not accept an argument.

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

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

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

Declares an application option that accepts an argument.

Parameters:
option The single character representing the option
flagno The flag index to be set if this option is present
argno The index into the argument array where the argument should be placed
See also:
AST_APP_OPTIONS, ast_app_parse_options

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

Referenced by AST_TEST_DEFINE().

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

Declares an array of options for an application.

Parameters:
holder The name of the array to be created
options The 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
        OPT_ARG_ARRAY_SIZE,
  };

  AST_APP_OPTIONS(my_app_options, {
        AST_APP_OPTION('j', OPT_JUMP),
        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 1304 of file include/asterisk/app.h.

Referenced by AST_TEST_DEFINE().

#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(, arglist) name = { 0, }

Declare a structure to hold an application's arguments.

Parameters:
name The name of the structure
arglist The 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 1164 of file include/asterisk/app.h.

Referenced by acf_curl_helper(), acf_if(), acf_isexten_exec(), acf_jabberreceive_read(), acf_jabberstatus_read(), acf_mailbox_exists(), acf_meetme_info(), 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(), aMYSQL_connect(), aMYSQL_fetch(), aMYSQL_nextresult(), aMYSQL_query(), aMYSQL_set(), app_exec(), applicationmap_handler(), aqm_exec(), array(), ast_eivr_senddtmf(), ast_queue_log(), asyncgoto_exec(), auth_exec(), background_detect_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_callback(), celgenuserevent_exec(), chanavail_exec(), channel_admin_exec(), chanspy_exec(), cli_odbc_read(), cli_odbc_write(), conf_exec(), confbridge_exec(), config_function_read(), controlplayback_exec(), count_exec(), create_addr(), cut_internal(), dahdi_call(), determine_starting_point(), dial_exec_full(), dialgroup_write(), dictate_exec(), directory_exec(), disa_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(), find_table_cb(), forkcdr_exec(), func_confbridge_helper(), func_confbridge_info(), func_header_read(), func_mixmonitor_read(), func_read_header(), 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(), misdn_call(), misdn_check_l2l1(), misdn_facility_exec(), misdn_request(), mixmonitor_exec(), msg_send_exec(), multicast_rtp_request(), originate_exec(), ospauth_exec(), ospfinished_exec(), osplookup_exec(), ospnext_exec(), oss_call(), oss_request(), 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_waitexten(), peek_read(), pickupchan_exec(), pjsip_acf_channel_read(), pjsip_acf_dial_contacts_read(), pjsip_aor_function_read(), pjsip_contact_function_read(), pjsip_endpoint_function_read(), play_moh_exec(), playback_exec(), pp_each_extension_helper(), pp_each_user_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(), rcvfax_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(), sayunixtime_exec(), senddtmf_exec(), sendfax_exec(), sendurl_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(), sndfax_exec(), softhangup_exec(), sorcery_function_read(), speech_background(), speech_load(), srv_result_read(), stackpeek_read(), start_moh_exec(), start_monitor_exec(), stop_mixmonitor_full(), strreplace(), talk_detect_fn_write(), transfer_exec(), unicast_rtp_request(), unshift_push(), upqm_exec(), userevent_exec(), verbose_exec(), vm_box_exists(), vm_check_password_shell(), vm_exec(), vm_execmain(), vm_playmsgexec(), volume_write(), xmpp_join_exec(), xmpp_leave_exec(), xmpp_send_exec(), xmpp_sendgroup_exec(), xmpp_status_exec(), and zapateller_exec().

#define AST_DEFINE_APP_ARGS_TYPE ( type,
arglist   ) 

Value:

struct type { \
      unsigned int argc; \
      char *argv[0]; \
      arglist \
   }
Define a structure type to hold an application's arguments.

Parameters:
type The name of the structure type
arglist The 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 1180 of file include/asterisk/app.h.

#define ast_delete_mwi_state ( mailbox,
context   )     ast_delete_mwi_state_full(mailbox, context, NULL)

Delete MWI state cached by stasis.

Since:
12.2.0
Parameters:
[in] mailbox The mailbox identifier string.
[in] context The context this mailbox resides in (NULL or "" if only using mailbox)
Return values:
0 Success
-1 Failure

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

Referenced by mwi_observe_delete().

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

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

#define AST_IVR_FLAG_AUTORESTART   (1 << 0)

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

#define AST_MAX_MAILBOX_UNIQUEID   (AST_MAX_EXTENSION + AST_MAX_CONTEXT + 2)

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

Referenced by build_peer().

#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:
args An argument structure defined using AST_DECLARE_APP_ARGS
parse A modifiable buffer containing the input to be parsed
sep A 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 1211 of file include/asterisk/app.h.

Referenced by acf_if(), acf_jabberreceive_read(), acf_jabberstatus_read(), acf_mailbox_exists(), agent_function_read(), aMYSQL_connect(), aMYSQL_fetch(), aMYSQL_nextresult(), aMYSQL_query(), aMYSQL_set(), ast_queue_log(), 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(), misdn_call(), misdn_request(), multicast_rtp_request(), oss_call(), oss_request(), pbx_builtin_setvar_multiple(), record_exec(), redirecting_read(), redirecting_write(), regex(), request(), sip_request_call(), unicast_rtp_request(), vm_check_password_shell(), and xmpp_status_exec().

#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_publish_mwi_state ( mailbox,
context,
new_msgs,
old_msgs   )     ast_publish_mwi_state_full(mailbox, context, new_msgs, old_msgs, NULL, NULL)

Publish a MWI state update via stasis.

Since:
12
Parameters:
[in] mailbox The mailbox identifier string.
[in] context The context this mailbox resides in (NULL or "" if only using mailbox)
[in] new_msgs The number of new messages in this mailbox
[in] old_msgs The number of old messages in this mailbox
Return values:
0 Success
-1 Failure

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

Referenced by handle_request_notify(), mwi_observe_delete(), mwi_post_event(), and notify_message().

#define ast_publish_mwi_state_channel ( mailbox,
context,
new_msgs,
old_msgs,
channel_id   )     ast_publish_mwi_state_full(mailbox, context, new_msgs, old_msgs, channel_id, NULL)

Publish a MWI state update associated with some channel.

Since:
12
Parameters:
[in] mailbox The mailbox identifier string.
[in] context The context this mailbox resides in (NULL or "" if only using mailbox)
[in] new_msgs The number of new messages in this mailbox
[in] old_msgs The number of old messages in this mailbox
[in] channel_id A unique identifier for a channel associated with this change in mailbox state
Return values:
0 Success
-1 Failure

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

Referenced by queue_mwi_event().

#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:
args An argument structure defined using AST_DECLARE_APP_ARGS
parse A 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 1196 of file include/asterisk/app.h.

Referenced by acf_curl_helper(), acf_isexten_exec(), acf_jabberreceive_read(), acf_jabberstatus_read(), acf_meetme_info(), 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(), auth_exec(), background_detect_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_callback(), celgenuserevent_exec(), chanavail_exec(), channel_admin_exec(), chanspy_exec(), cli_odbc_read(), cli_odbc_write(), conf_exec(), confbridge_exec(), config_function_read(), connectedline_write(), controlplayback_exec(), count_exec(), cut_internal(), dial_exec_full(), dialgroup_write(), dictate_exec(), directory_exec(), disa_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(), find_table_cb(), forkcdr_exec(), func_confbridge_helper(), func_confbridge_info(), func_header_read(), func_mixmonitor_read(), func_read_header(), 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(), misdn_check_l2l1(), misdn_facility_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_waitexten(), pickupchan_exec(), pjsip_acf_channel_read(), pjsip_acf_dial_contacts_read(), pjsip_aor_function_read(), pjsip_contact_function_read(), pjsip_endpoint_function_read(), play_moh_exec(), playback_exec(), pp_each_extension_helper(), pp_each_user_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(), rcvfax_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(), sayunixtime_exec(), senddtmf_exec(), sendfax_exec(), sendurl_exec(), shared_read(), shared_write(), shift_pop(), sip_acf_channel_read(), sla_trunk_exec(), smdi_msg_read(), smdi_msg_retrieve_read(), sms_exec(), sndfax_exec(), softhangup_exec(), sorcery_function_read(), speech_background(), speech_load(), srv_result_read(), stackpeek_read(), start_moh_exec(), start_monitor_exec(), stop_mixmonitor_full(), strreplace(), talk_detect_fn_write(), transfer_exec(), unshift_push(), upqm_exec(), userevent_exec(), verbose_exec(), vm_box_exists(), vm_exec(), vm_execmain(), vm_playmsgexec(), volume_write(), xmpp_join_exec(), xmpp_leave_exec(), xmpp_send_exec(), xmpp_sendgroup_exec(), xmpp_status_exec(), and zapateller_exec().

#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_info ? ast_module_info->self : NULL)

See __ast_vm_greeter_register().

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

Referenced by load_module().

#define ast_vm_register ( vm_table   )     __ast_vm_register(vm_table, ast_module_info ? ast_module_info->self : NULL)

See __ast_vm_register().

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

Referenced by load_module().

#define BEGIN_OPTIONS   {

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

#define END_OPTIONS   }

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

#define VM_GREETER_MODULE_VERSION   1

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

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

Referenced by __ast_vm_greeter_register().

#define VM_MODULE_VERSION   2

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

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

Referenced by __ast_vm_register().


Typedef Documentation

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_data A record containing filename and voicemail txt info.
Return values:
0 on success
-1 on failure

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

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

Determines if the given folder has messages.

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

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

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:
mailboxes Comma or space delimited list of mailboxes (user). If no context is found, uses 'default' for the context.
urgentmsgs Where to put the count of urgent messages. (Can be NULL)
newmsgs Where to put the count of new messages. (Can be NULL)
oldmsgs Where 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:
0 on success
-1 on failure

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

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

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

Parameters:
mailboxes Comma or space delimited list of mailboxes (user). If no context is found, uses 'default' for the context.
newmsgs Where to put the count of new messages. (Can be NULL)
oldmsgs Where 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:
0 on success
-1 on failure

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

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.

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_id The mailbox name.
folder The 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 392 of file include/asterisk/app.h.

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:
chan Where to play the recorded name file.
mailbox_id The mailbox name.
Return values:
0 Name played without interruption
dtmf ASCII value of the DTMF which interrupted playback.
-1 Unable to locate mailbox or hangup occurred.

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

typedef const char*( ast_vm_index_to_foldername_fn)(int id)

Convert the mailbox folder id to a folder name.

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

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

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:
user The user part of user.
context The context part of user. Must be explicit.
folder When not NULL only msgs from the specified folder will be included.
descending list the msgs in descending order rather than ascending order.
sort_val What to sort in the snapshot.
combine_INBOX_and_OLD When 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:
snapshot on success
NULL on failure

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

destroy a snapshot

Parameters:
mailbox_snapshot The snapshot to destroy.
Note:
Only used by voicemail unit tests.
Return values:
NULL 

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

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:
-1 Failure
0 Success

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

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:
mailbox The mailbox to which the folders belong
context The voicemail context for the mailbox
num_msgs The number of messages to move
oldfolder The folder from where messages should be moved
old_msg_ids The message IDs of the messages to move
newfolder The 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:
-1 Failure
0 Success

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

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

Voicemail playback callback function definition.

Parameters:
chan Channel to play the file back on.
playfile Location of file on disk
duration of file in seconds. This will be zero if msg is very short or has an unknown duration.
Examples:
/tmp/asterisk-trunk/trunk/main/app.c.

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

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 
mailbox msg is in.
context of mailbox.
folder voicemail folder to look in.
msg_num message number in the voicemailbox to playback to the channel.
cb 
Note:
Only used by voicemail unit tests.
Return values:
0 success
-1 failure

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

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:
mailbox The mailbox from which to delete messages
context The voicemail context for the mailbox
num_msgs The number of messages to delete
folder The folder from which to remove messages
msgs The message IDs of the messages to delete
Note:
Only used by voicemail unit tests.
Return values:
-1 Failure
0 Success

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


Enumeration Type Documentation

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 1069 of file include/asterisk/app.h.

01069                         {
01070    AST_GETDATA_FAILED = -1,
01071    AST_GETDATA_COMPLETE = 0,
01072    AST_GETDATA_TIMEOUT = 1,
01073    AST_GETDATA_INTERRUPTED = 2,
01074    /*! indicates a user terminated empty string rather than an empty string resulting
01075     * from a timeout or other factors */
01076    AST_GETDATA_EMPTY_END_TERMINATED = 3,
01077 };

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.

00049              {
00050    AST_ACTION_UPONE, /*!< adata is unused */
00051    AST_ACTION_EXIT,  /*!< adata is the return value for ast_ivr_menu_run if channel was not hungup */
00052    AST_ACTION_CALLBACK, /*!< adata is an ast_ivr_callback */
00053    AST_ACTION_PLAYBACK, /*!< adata is file to play */
00054    AST_ACTION_BACKGROUND,  /*!< adata is file to play */
00055    AST_ACTION_PLAYLIST, /*!< adata is list of files, separated by ; to play */
00056    AST_ACTION_MENU,  /*!< adata is a pointer to an ast_ivr_menu */
00057    AST_ACTION_REPEAT,   /*!< adata is max # of repeats, cast to a pointer */
00058    AST_ACTION_RESTART,  /*!< adata is like repeat, but resets repeats to 0 */
00059    AST_ACTION_TRANSFER, /*!< adata is a string with exten\verbatim[@context]\endverbatim */
00060    AST_ACTION_WAITOPTION,  /*!< adata is a timeout, or 0 for defaults */
00061    AST_ACTION_NOOP,  /*!< adata is unused */
00062    AST_ACTION_BACKLIST, /*!< adata is list of files separated by ; allows interruption */
00063 } ast_ivr_action;

Enumerator:
AST_LOCK_SUCCESS 
AST_LOCK_TIMEOUT 
AST_LOCK_PATH_NOT_FOUND 
AST_LOCK_FAILURE 

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

01079                      {
01080    AST_LOCK_SUCCESS = 0,
01081    AST_LOCK_TIMEOUT = -1,
01082    AST_LOCK_PATH_NOT_FOUND = -2,
01083    AST_LOCK_FAILURE = -3,
01084 };

Type of locking to use in ast_lock_path / ast_unlock_path.

Enumerator:
AST_LOCK_TYPE_LOCKFILE 
AST_LOCK_TYPE_FLOCK 

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

01087                    {
01088    AST_LOCK_TYPE_LOCKFILE = 0,
01089    AST_LOCK_TYPE_FLOCK = 1,
01090 };

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 987 of file include/asterisk/app.h.

00987                           {
00988    /*! Return an Error State for IF_Exists */
00989    AST_RECORD_IF_EXISTS_ERROR = -1,
00990    /*! Fail the recording. */
00991    AST_RECORD_IF_EXISTS_FAIL,
00992    /*! Overwrite the existing recording. */
00993    AST_RECORD_IF_EXISTS_OVERWRITE,
00994    /*! Append to the existing recording. */
00995    AST_RECORD_IF_EXISTS_APPEND,
00996 };

Enumerator:
TIMELEN_HOURS 
TIMELEN_MINUTES 
TIMELEN_SECONDS 
TIMELEN_MILLISECONDS 

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

00113                  {
00114    TIMELEN_HOURS,
00115    TIMELEN_MINUTES,
00116    TIMELEN_SECONDS,
00117    TIMELEN_MILLISECONDS,
00118 };

Enumerator:
AST_VM_SNAPSHOT_SORT_BY_ID 
AST_VM_SNAPSHOT_SORT_BY_TIME 

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

00295                               {
00296    AST_VM_SNAPSHOT_SORT_BY_ID = 0,
00297    AST_VM_SNAPSHOT_SORT_BY_TIME,
00298 };


Function Documentation

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:
buf The string to be parsed (this must be a writable copy, as it will be modified)
delim The character to be used to delimit arguments
remove_chars Remove backslashes and quote characters, while parsing
array An array of 'char *' to be filled in with pointers to the found arguments
arraylen The 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-trunk/trunk/main/app.c.

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

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

Referenced by ast_app_separate_args().

02105 {
02106    int argc;
02107    char *scan, *wasdelim = NULL;
02108    int paren = 0, quote = 0, bracket = 0;
02109 
02110    if (!array || !arraylen) {
02111       return 0;
02112    }
02113 
02114    memset(array, 0, arraylen * sizeof(*array));
02115 
02116    if (!buf) {
02117       return 0;
02118    }
02119 
02120    scan = buf;
02121 
02122    for (argc = 0; *scan && (argc < arraylen - 1); argc++) {
02123       array[argc] = scan;
02124       for (; *scan; scan++) {
02125          if (*scan == '(') {
02126             paren++;
02127          } else if (*scan == ')') {
02128             if (paren) {
02129                paren--;
02130             }
02131          } else if (*scan == '[') {
02132             bracket++;
02133          } else if (*scan == ']') {
02134             if (bracket) {
02135                bracket--;
02136             }
02137          } else if (*scan == '"' && delim != '"') {
02138             quote = quote ? 0 : 1;
02139             if (remove_chars) {
02140                /* Remove quote character from argument */
02141                memmove(scan, scan + 1, strlen(scan));
02142                scan--;
02143             }
02144          } else if (*scan == '\\') {
02145             if (remove_chars) {
02146                /* Literal character, don't parse */
02147                memmove(scan, scan + 1, strlen(scan));
02148             } else {
02149                scan++;
02150             }
02151          } else if ((*scan == delim) && !paren && !quote && !bracket) {
02152             wasdelim = scan;
02153             *scan++ = '\0';
02154             break;
02155          }
02156       }
02157    }
02158 
02159    /* If the last character in the original string was the delimiter, then
02160     * there is one additional argument. */
02161    if (*scan || (scan > buf && (scan - 1) == wasdelim)) {
02162       array[argc++] = scan;
02163    }
02164 
02165    return argc;
02166 }

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_table Voicemail greeter function table to install.
module Pointer to the module implementing the interface
Return values:
0 on success.
-1 on error.
Examples:
/tmp/asterisk-trunk/trunk/main/app.c.

Definition at line 590 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, LOG_ERROR, LOG_WARNING, ast_vm_greeter_functions::module_name, ast_vm_greeter_functions::module_version, NULL, RAII_VAR, table, and VM_GREETER_MODULE_VERSION.

00591 {
00592    RAII_VAR(struct ast_vm_greeter_functions *, table, NULL, ao2_cleanup);
00593 
00594    if (!vm_table->module_name) {
00595       ast_log(LOG_ERROR, "Voicemail greeter provider missing required information.\n");
00596       return -1;
00597    }
00598    if (vm_table->module_version != VM_GREETER_MODULE_VERSION) {
00599       ast_log(LOG_ERROR, "Voicemail greeter provider '%s' has incorrect version\n",
00600          vm_table->module_name);
00601       return -1;
00602    }
00603 
00604    table = ao2_global_obj_ref(vm_greeter_provider);
00605    if (table) {
00606       ast_log(LOG_WARNING, "Voicemail greeter provider already registered by %s.\n",
00607          table->module_name);
00608       return -1;
00609    }
00610 
00611    table = ao2_alloc_options(sizeof(*table), NULL, AO2_ALLOC_OPT_LOCK_NOLOCK);
00612    if (!table) {
00613       return -1;
00614    }
00615    *table = *vm_table;
00616    table->module = module;
00617 
00618    ao2_global_obj_replace_unref(vm_greeter_provider, table);
00619    return 0;
00620 }

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

Set voicemail function callbacks.

Parameters:
vm_table Voicemail function table to install.
module Pointer to the module implementing the interface
Return values:
0 on success.
-1 on error.
Examples:
/tmp/asterisk-trunk/trunk/main/app.c.

Definition at line 479 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, LOG_ERROR, LOG_WARNING, ast_vm_functions::module_name, ast_vm_functions::module_version, NULL, RAII_VAR, table, and VM_MODULE_VERSION.

00480 {
00481    RAII_VAR(struct ast_vm_functions *, table, NULL, ao2_cleanup);
00482 
00483    if (!vm_table->module_name) {
00484       ast_log(LOG_ERROR, "Voicemail provider missing required information.\n");
00485       return -1;
00486    }
00487    if (vm_table->module_version != VM_MODULE_VERSION) {
00488       ast_log(LOG_ERROR, "Voicemail provider '%s' has incorrect version\n",
00489          vm_table->module_name);
00490       return -1;
00491    }
00492 
00493    table = ao2_global_obj_ref(vm_provider);
00494    if (table) {
00495       ast_log(LOG_WARNING, "Voicemail provider already registered by %s.\n",
00496          table->module_name);
00497       return -1;
00498    }
00499 
00500    table = ao2_alloc_options(sizeof(*table), NULL, AO2_ALLOC_OPT_LOCK_NOLOCK);
00501    if (!table) {
00502       return -1;
00503    }
00504    *table = *vm_table;
00505    table->module = module;
00506 
00507    ao2_global_obj_replace_unref(vm_provider, table);
00508    return 0;
00509 }

int app_init ( void   ) 

Initialize the application core.

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

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

References app_cleanup(), ast_mwi_state_type(), ast_mwi_vm_app_type(), ast_register_cleanup(), mwi_state_cache, mwi_state_get_id(), mwi_topic_all, mwi_topic_cached, mwi_topic_pool, queue_topic_all, queue_topic_pool, stasis_cache_create(), stasis_caching_topic_create(), STASIS_MESSAGE_TYPE_INIT, stasis_topic_create(), and stasis_topic_pool_create().

Referenced by main().

03366 {
03367    ast_register_cleanup(app_cleanup);
03368 
03369    if (STASIS_MESSAGE_TYPE_INIT(ast_mwi_state_type) != 0) {
03370       return -1;
03371    }
03372    if (STASIS_MESSAGE_TYPE_INIT(ast_mwi_vm_app_type) != 0) {
03373       return -1;
03374    }
03375    mwi_topic_all = stasis_topic_create("stasis_mwi_topic");
03376    if (!mwi_topic_all) {
03377       return -1;
03378    }
03379    mwi_state_cache = stasis_cache_create(mwi_state_get_id);
03380    if (!mwi_state_cache) {
03381       return -1;
03382    }
03383    mwi_topic_cached = stasis_caching_topic_create(mwi_topic_all, mwi_state_cache);
03384    if (!mwi_topic_cached) {
03385       return -1;
03386    }
03387    mwi_topic_pool = stasis_topic_pool_create(mwi_topic_all);
03388    if (!mwi_topic_pool) {
03389       return -1;
03390    }
03391    queue_topic_all = stasis_topic_create("stasis_queue_topic");
03392    if (!queue_topic_all) {
03393       return -1;
03394    }
03395    queue_topic_pool = stasis_topic_pool_create(queue_topic_all);
03396    if (!queue_topic_pool) {
03397       return -1;
03398    }
03399    return 0;
03400 }

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-trunk/trunk/main/app.c.

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

References VM_API_CALL.

Referenced by copy_to_voicemail().

00708 {
00709    int res = -1;
00710 
00711    VM_API_CALL(res, copy_recording_to_vm, (vm_rec_data));
00712    return res;
00713 }

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:
chan struct.
context 
collect 
size 
maxlen 
timeout timeout in milliseconds
Returns:
0 if extension does not exist, 1 if extension exists
Examples:
/tmp/asterisk-trunk/trunk/main/app.c.

Definition at line 187 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().

00188 {
00189    struct ast_tone_zone_sound *ts;
00190    int res = 0, x = 0;
00191 
00192    if (maxlen > size) {
00193       maxlen = size;
00194    }
00195 
00196    if (!timeout) {
00197       if (ast_channel_pbx(chan) && ast_channel_pbx(chan)->dtimeoutms) {
00198          timeout = ast_channel_pbx(chan)->dtimeoutms;
00199       } else {
00200          timeout = 5000;
00201       }
00202    }
00203 
00204    if ((ts = ast_get_indication_tone(ast_channel_zone(chan), "dial"))) {
00205       res = ast_playtones_start(chan, 0, ts->data, 0);
00206       ts = ast_tone_zone_sound_unref(ts);
00207    } else {
00208       ast_log(LOG_NOTICE, "Huh....? no dial for indications?\n");
00209    }
00210 
00211    for (x = strlen(collect); x < maxlen; ) {
00212       res = ast_waitfordigit(chan, timeout);
00213       if (!ast_ignore_pattern(context, collect)) {
00214          ast_playtones_stop(chan);
00215       }
00216       if (res < 1) {
00217          break;
00218       }
00219       if (res == '#') {
00220          break;
00221       }
00222       collect[x++] = res;
00223       if (!ast_matchmore_extension(chan, context, collect, 1,
00224          S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL))) {
00225          break;
00226       }
00227    }
00228 
00229    if (res >= 0) {
00230       res = ast_exists_extension(chan, context, collect, 1,
00231          S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL)) ? 1 : 0;
00232    }
00233 
00234    return res;
00235 }

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_chan A channel to place into autoservice while the macro is run
macro_chan Channel to execute macro on.
macro_args Macro application argument string.
Return values:
0 success
-1 on error
Examples:
/tmp/asterisk-trunk/trunk/main/app.c.

Definition at line 321 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_debug, ast_log, LOG_WARNING, pbx_exec(), and pbx_findapp().

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

00322 {
00323    struct ast_app *macro_app;
00324    int res;
00325 
00326    macro_app = pbx_findapp("Macro");
00327    if (!macro_app) {
00328       ast_log(LOG_WARNING,
00329          "Cannot run 'Macro(%s)'.  The application is not available.\n", macro_args);
00330       return -1;
00331    }
00332    if (autoservice_chan) {
00333       ast_autoservice_start(autoservice_chan);
00334    }
00335 
00336    ast_debug(4, "%s Original location: %s,%s,%d\n", ast_channel_name(macro_chan),
00337       ast_channel_context(macro_chan), ast_channel_exten(macro_chan),
00338       ast_channel_priority(macro_chan));
00339 
00340    res = pbx_exec(macro_chan, macro_app, macro_args);
00341    ast_debug(4, "Macro exited with status %d\n", res);
00342 
00343    /*
00344     * Assume anything negative from Macro is an error.
00345     * Anything else is success.
00346     */
00347    if (res < 0) {
00348       res = -1;
00349    } else {
00350       res = 0;
00351    }
00352 
00353    ast_debug(4, "%s Ending location: %s,%s,%d\n", ast_channel_name(macro_chan),
00354       ast_channel_context(macro_chan), ast_channel_exten(macro_chan),
00355       ast_channel_priority(macro_chan));
00356 
00357    if (autoservice_chan) {
00358       ast_autoservice_stop(autoservice_chan);
00359    }
00360    return res;
00361 }

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_chan A channel to place into autoservice while the subroutine is run
sub_chan Channel to execute subroutine on.
sub_args Gosub application argument string.
ignore_hangup TRUE if a hangup does not stop execution of the routine.
Return values:
0 success
-1 on error
Examples:
/tmp/asterisk-trunk/trunk/main/app.c.

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

References app_stack_callbacks, ast_autoservice_start(), ast_autoservice_stop(), ast_log, ast_module_ref, ast_module_unref, 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(), page_exec(), run_app_helper(), and try_calling().

00413 {
00414    const struct ast_app_stack_funcs *funcs;
00415    int res;
00416 
00417    funcs = app_stack_callbacks;
00418    if (!funcs || !funcs->run_sub) {
00419       ast_log(LOG_WARNING,
00420          "Cannot run 'Gosub(%s)'.  The app_stack module is not available.\n",
00421          sub_args);
00422       return -1;
00423    }
00424    ast_module_ref(funcs->module);
00425 
00426    if (autoservice_chan) {
00427       ast_autoservice_start(autoservice_chan);
00428    }
00429 
00430    res = funcs->run_sub(sub_chan, sub_args, ignore_hangup);
00431    ast_module_unref(funcs->module);
00432 
00433    if (autoservice_chan) {
00434       ast_autoservice_stop(autoservice_chan);
00435    }
00436    return res;
00437 }

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

Add missing context/exten to subroutine argument string.

Parameters:
chan Channel to obtain context/exten.
args Gosub application argument string.
Fills in the optional context and exten from the given channel.

Return values:
New-args Gosub argument string on success. Must be freed.
NULL on error.
Examples:
/tmp/asterisk-trunk/trunk/main/app.c.

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

References app_stack_callbacks, ast_log, ast_module_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(), begin_dial_prerun(), and dial_exec_full().

00394 {
00395    const struct ast_app_stack_funcs *funcs;
00396    const char *new_args;
00397 
00398    funcs = app_stack_callbacks;
00399    if (!funcs || !funcs->expand_sub_args) {
00400       ast_log(LOG_WARNING,
00401          "Cannot expand 'Gosub(%s)' arguments.  The app_stack module is not available.\n",
00402          args);
00403       return NULL;
00404    }
00405    ast_module_ref(funcs->module);
00406 
00407    new_args = funcs->expand_sub_args(chan, args);
00408    ast_module_unref(funcs->module);
00409    return new_args;
00410 }

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:
c Which channel one is interacting with
prompt File 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".
s The location where the DTMF data will be stored
maxlen Max Length of the data
timeout Timeout 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:
c The channel to read from
prompt The file to stream to the channel
s The string to read in to. Must be at least the size of your length
maxlen How many digits to read (maximum)
timeout set timeout to 0 for "standard" timeouts. Set timeout to -1 for "ludicrous time" (essentially never times out)
Examples:
/tmp/asterisk-trunk/trunk/main/app.c.

Definition at line 245 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, and strsep().

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

00246 {
00247    int res = 0, to, fto;
00248    char *front, *filename;
00249 
00250    /* XXX Merge with full version? XXX */
00251 
00252    if (maxlen)
00253       s[0] = '\0';
00254 
00255    if (!prompt)
00256       prompt = "";
00257 
00258    filename = ast_strdupa(prompt);
00259    while ((front = strsep(&filename, "&"))) {
00260       if (!ast_strlen_zero(front)) {
00261          res = ast_streamfile(c, front, ast_channel_language(c));
00262          if (res)
00263             continue;
00264       }
00265       if (ast_strlen_zero(filename)) {
00266          /* set timeouts for the last prompt */
00267          fto = ast_channel_pbx(c) ? ast_channel_pbx(c)->rtimeoutms : 6000;
00268          to = ast_channel_pbx(c) ? ast_channel_pbx(c)->dtimeoutms : 2000;
00269 
00270          if (timeout > 0) {
00271             fto = to = timeout;
00272          }
00273          if (timeout < 0) {
00274             fto = to = 1000000000;
00275          }
00276       } else {
00277          /* there is more than one prompt, so
00278           * get rid of the long timeout between
00279           * prompts, and make it 50ms */
00280          fto = 50;
00281          to = ast_channel_pbx(c) ? ast_channel_pbx(c)->dtimeoutms : 2000;
00282       }
00283       res = ast_readstring(c, s, maxlen, to, fto, "#");
00284       if (res == AST_GETDATA_EMPTY_END_TERMINATED) {
00285          return res;
00286       }
00287       if (!ast_strlen_zero(s)) {
00288          return res;
00289       }
00290    }
00291 
00292    return res;
00293 }

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-trunk/trunk/main/app.c.

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

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

Referenced by handle_getdata().

00299 {
00300    int res, to = 2000, fto = 6000;
00301 
00302    if (!ast_strlen_zero(prompt)) {
00303       res = ast_streamfile(c, prompt, ast_channel_language(c));
00304       if (res < 0) {
00305          return res;
00306       }
00307    }
00308 
00309    if (timeout > 0) {
00310       fto = to = timeout;
00311    }
00312    if (timeout < 0) {
00313       fto = to = 1000000000;
00314    }
00315 
00316    res = ast_readstring_full(c, s, maxlen, to, fto, "#", audiofd, ctrlfd);
00317 
00318    return res;
00319 }

int ast_app_group_discard ( struct ast_channel chan  ) 

Discard all group counting for a channel.

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

Definition at line 2064 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().

02065 {
02066    struct ast_group_info *gi = NULL;
02067 
02068    AST_RWLIST_WRLOCK(&groups);
02069    AST_RWLIST_TRAVERSE_SAFE_BEGIN(&groups, gi, group_list) {
02070       if (gi->chan == chan) {
02071          AST_RWLIST_REMOVE_CURRENT(group_list);
02072          ast_free(gi);
02073       }
02074    }
02075    AST_RWLIST_TRAVERSE_SAFE_END;
02076    AST_RWLIST_UNLOCK(&groups);
02077 
02078    return 0;
02079 }

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-trunk/trunk/main/app.c.

Definition at line 1985 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().

01986 {
01987    struct ast_group_info *gi = NULL;
01988    int count = 0;
01989 
01990    if (ast_strlen_zero(group)) {
01991       return 0;
01992    }
01993 
01994    AST_RWLIST_RDLOCK(&groups);
01995    AST_RWLIST_TRAVERSE(&groups, gi, group_list) {
01996       if (!strcasecmp(gi->group, group) && (ast_strlen_zero(category) || (!ast_strlen_zero(gi->category) && !strcasecmp(gi->category, category)))) {
01997          count++;
01998       }
01999    }
02000    AST_RWLIST_UNLOCK(&groups);
02001 
02002    return count;
02003 }

struct ast_group_info* ast_app_group_list_head ( void   )  [read]

Get the head of the group count list.

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

Definition at line 2091 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().

02092 {
02093    return AST_RWLIST_FIRST(&groups);
02094 }

int ast_app_group_list_rdlock ( void   ) 

Read Lock the group count list.

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

Definition at line 2086 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().

02087 {
02088    return AST_RWLIST_RDLOCK(&groups);
02089 }

int ast_app_group_list_unlock ( void   ) 

Unlock the group count list.

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

Definition at line 2096 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().

02097 {
02098    return AST_RWLIST_UNLOCK(&groups);
02099 }

int ast_app_group_list_wrlock ( void   ) 

Write Lock the group count list.

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

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

References AST_RWLIST_WRLOCK.

02082 {
02083    return AST_RWLIST_WRLOCK(&groups);
02084 }

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-trunk/trunk/main/app.c.

Definition at line 2005 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().

02006 {
02007    struct ast_group_info *gi = NULL;
02008    regex_t regexbuf_group;
02009    regex_t regexbuf_category;
02010    int count = 0;
02011 
02012    if (ast_strlen_zero(groupmatch)) {
02013       ast_log(LOG_NOTICE, "groupmatch empty\n");
02014       return 0;
02015    }
02016 
02017    /* if regex compilation fails, return zero matches */
02018    if (regcomp(&regexbuf_group, groupmatch, REG_EXTENDED | REG_NOSUB)) {
02019       ast_log(LOG_ERROR, "Regex compile failed on: %s\n", groupmatch);
02020       return 0;
02021    }
02022 
02023    if (!ast_strlen_zero(category) && regcomp(&regexbuf_category, category, REG_EXTENDED | REG_NOSUB)) {
02024       ast_log(LOG_ERROR, "Regex compile failed on: %s\n", category);
02025       regfree(&regexbuf_group);
02026       return 0;
02027    }
02028 
02029    AST_RWLIST_RDLOCK(&groups);
02030    AST_RWLIST_TRAVERSE(&groups, gi, group_list) {
02031       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)))) {
02032          count++;
02033       }
02034    }
02035    AST_RWLIST_UNLOCK(&groups);
02036 
02037    regfree(&regexbuf_group);
02038    if (!ast_strlen_zero(category)) {
02039       regfree(&regexbuf_category);
02040    }
02041 
02042    return count;
02043 }

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-trunk/trunk/main/app.c.

Definition at line 1938 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().

01939 {
01940    int res = 0;
01941    char group[80] = "", category[80] = "";
01942    struct ast_group_info *gi = NULL;
01943    size_t len = 0;
01944 
01945    if (ast_app_group_split_group(data, group, sizeof(group), category, sizeof(category))) {
01946       return -1;
01947    }
01948 
01949    /* Calculate memory we will need if this is new */
01950    len = sizeof(*gi) + strlen(group) + 1;
01951    if (!ast_strlen_zero(category)) {
01952       len += strlen(category) + 1;
01953    }
01954 
01955    AST_RWLIST_WRLOCK(&groups);
01956    AST_RWLIST_TRAVERSE_SAFE_BEGIN(&groups, gi, group_list) {
01957       if ((gi->chan == chan) && ((ast_strlen_zero(category) && ast_strlen_zero(gi->category)) || (!ast_strlen_zero(gi->category) && !strcasecmp(gi->category, category)))) {
01958          AST_RWLIST_REMOVE_CURRENT(group_list);
01959          ast_free(gi);
01960          break;
01961       }
01962    }
01963    AST_RWLIST_TRAVERSE_SAFE_END;
01964 
01965    if (ast_strlen_zero(group)) {
01966       /* Enable unsetting the group */
01967    } else if ((gi = ast_calloc(1, len))) {
01968       gi->chan = chan;
01969       gi->group = (char *) gi + sizeof(*gi);
01970       strcpy(gi->group, group);
01971       if (!ast_strlen_zero(category)) {
01972          gi->category = (char *) gi + sizeof(*gi) + strlen(group) + 1;
01973          strcpy(gi->category, category);
01974       }
01975       AST_RWLIST_INSERT_TAIL(&groups, gi, group_list);
01976    } else {
01977       res = -1;
01978    }
01979 
01980    AST_RWLIST_UNLOCK(&groups);
01981 
01982    return res;
01983 }

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-trunk/trunk/main/app.c.

Definition at line 1911 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().

01912 {
01913    int res = 0;
01914    char tmp[256];
01915    char *grp = NULL, *cat = NULL;
01916 
01917    if (!ast_strlen_zero(data)) {
01918       ast_copy_string(tmp, data, sizeof(tmp));
01919       grp = tmp;
01920       if ((cat = strchr(tmp, '@'))) {
01921          *cat++ = '\0';
01922       }
01923    }
01924 
01925    if (!ast_strlen_zero(grp)) {
01926       ast_copy_string(group, grp, group_max);
01927    } else {
01928       *group = '\0';
01929    }
01930 
01931    if (!ast_strlen_zero(cat)) {
01932       ast_copy_string(category, cat, category_max);
01933    }
01934 
01935    return res;
01936 }

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-trunk/trunk/main/app.c.

Definition at line 2045 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().

02046 {
02047    struct ast_group_info *gi = NULL;
02048 
02049    AST_RWLIST_WRLOCK(&groups);
02050    AST_RWLIST_TRAVERSE_SAFE_BEGIN(&groups, gi, group_list) {
02051       if (gi->chan == old) {
02052          gi->chan = new;
02053       } else if (gi->chan == new) {
02054          AST_RWLIST_REMOVE_CURRENT(group_list);
02055          ast_free(gi);
02056       }
02057    }
02058    AST_RWLIST_TRAVERSE_SAFE_END;
02059    AST_RWLIST_UNLOCK(&groups);
02060 
02061    return 0;
02062 }

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:
1 Mailbox has voicemail
0 No new voicemail in specified mailbox
-1 Failure
Since:
1.0
Examples:
/tmp/asterisk-trunk/trunk/main/app.c.

Definition at line 693 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(), and unistim_send_mwi_to_peer().

00694 {
00695    int res = 0;
00696 
00697    VM_API_CALL(res, has_voicemail, (mailboxes, folder));
00698    return res;
00699 }

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] mailboxes Mailbox specification in the format /code mbox[@context][&mbox2[@context2]][...] /code
[out] newmsgs Number of messages in the "INBOX" folder. Includes number of messages in the "Urgent" folder, if any.
[out] oldmsgs Number of messages in the "Old" folder.
Return values:
0 Success
-1 Failure
Examples:
/tmp/asterisk-trunk/trunk/main/app.c.

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

References inboxcount(), and VM_API_CALL.

Referenced by sip_send_mwi_to_peer(), and update_registry().

00716 {
00717    int res = 0;
00718 
00719    if (newmsgs) {
00720       *newmsgs = 0;
00721    }
00722    if (oldmsgs) {
00723       *oldmsgs = 0;
00724    }
00725 
00726    VM_API_CALL(res, inboxcount, (mailboxes, newmsgs, oldmsgs));
00727    return res;
00728 }

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] mailboxes the mailbox context to use
[out] urgentmsgs the urgent message count
[out] newmsgs the new message count
[out] oldmsgs the old message count
Returns:
Returns 0 for success, negative upon error
Since:
1.6.1
Examples:
/tmp/asterisk-trunk/trunk/main/app.c.

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

References inboxcount2(), and VM_API_CALL.

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

00731 {
00732    int res = 0;
00733 
00734    if (newmsgs) {
00735       *newmsgs = 0;
00736    }
00737    if (oldmsgs) {
00738       *oldmsgs = 0;
00739    }
00740    if (urgentmsgs) {
00741       *urgentmsgs = 0;
00742    }
00743 
00744    VM_API_CALL(res, inboxcount2, (mailboxes, urgentmsgs, newmsgs, oldmsgs));
00745    return res;
00746 }

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

Get the number of messages in a given mailbox folder.

Parameters:
[in] mailbox_id Mailbox name
[in] folder The 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-trunk/trunk/main/app.c.

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

References messagecount(), and VM_API_CALL.

Referenced by acf_vmcount_exec().

00757 {
00758    int res = 0;
00759 
00760    VM_API_CALL(res, messagecount, (mailbox_id, folder));
00761    return res;
00762 }

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:
options The array of possible options declared with AST_APP_OPTIONS
flags The flags of the options that you wish to populate the buffer with
buf The buffer to fill with the string of options
len The maximum length of buf
Examples:
/tmp/asterisk-trunk/trunk/main/app.c.

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

References ast_test_flag64.

02828 {
02829    unsigned int i, found = 0;
02830    for (i = 32; i < 128 && found < len; i++) {
02831       if (ast_test_flag64(flags, options[i].flag)) {
02832          buf[found++] = i;
02833       }
02834    }
02835    buf[found] = '\0';
02836 }

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:
options The array of possible options declared with AST_APP_OPTIONS
flags The flag structure to have option flags set
args The array of argument pointers to hold arguments found
optstr The 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-trunk/trunk/main/app.c.

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

References parse_options().

Referenced by agent_login_exec(), app_exec(), AST_TEST_DEFINE(), auth_exec(), bridge_exec(), bridgewait_exec(), cdr_read_callback(), cdr_write_callback(), chanspy_exec(), connectedline_write(), controlplayback_exec(), 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(), sendurl_exec(), sla_trunk_exec(), smdi_msg_retrieve_read(), sms_exec(), softhangup_exec(), speech_background(), start_monitor_exec(), vm_exec(), vm_execmain(), and volume_write().

02818 {
02819    return parse_options(options, flags, args, optstr, 32);
02820 }

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:
options The array of possible options declared with AST_APP_OPTIONS
flags The 64-bit flag structure to have option flags set
args The array of argument pointers to hold arguments found
optstr The 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-trunk/trunk/main/app.c.

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

References parse_options().

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

02823 {
02824    return parse_options(options, flags, args, optstr, 64);
02825 }

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] timestr String to parse
[in] defunit Default unit type
[out] result Resulting value, specified in milliseconds
Return values:
0 Success
-1 Failure
Since:
1.8
Examples:
/tmp/asterisk-trunk/trunk/main/app.c.

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

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

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

03030 {
03031    int res;
03032    char u[10];
03033 #ifdef HAVE_LONG_DOUBLE_WIDER
03034    long double amount;
03035    #define FMT "%30Lf%9s"
03036 #else
03037    double amount;
03038    #define FMT "%30lf%9s"
03039 #endif
03040    if (!timestr) {
03041       return -1;
03042    }
03043 
03044    res = sscanf(timestr, FMT, &amount, u);
03045 
03046    if (res == 0 || res == EOF) {
03047 #undef FMT
03048       return -1;
03049    } else if (res == 2) {
03050       switch (u[0]) {
03051       case 'h':
03052       case 'H':
03053          unit = TIMELEN_HOURS;
03054          break;
03055       case 's':
03056       case 'S':
03057          unit = TIMELEN_SECONDS;
03058          break;
03059       case 'm':
03060       case 'M':
03061          if (toupper(u[1]) == 'S') {
03062             unit = TIMELEN_MILLISECONDS;
03063          } else if (u[1] == '\0') {
03064             unit = TIMELEN_MINUTES;
03065          }
03066          break;
03067       }
03068    }
03069 
03070    switch (unit) {
03071    case TIMELEN_HOURS:
03072       amount *= 60;
03073       /* fall-through */
03074    case TIMELEN_MINUTES:
03075       amount *= 60;
03076       /* fall-through */
03077    case TIMELEN_SECONDS:
03078       amount *= 1000;
03079       /* fall-through */
03080    case TIMELEN_MILLISECONDS:
03081       ;
03082    }
03083    *result = amount > INT_MAX ? INT_MAX : (int) amount;
03084    return 0;
03085 }

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_chan A channel to place into autoservice while the macro is run
macro_chan Channel to execute macro on.
macro_name The name of the macro to run.
macro_args The arguments to pass to the macro.
Return values:
0 success
-1 on error
Examples:
/tmp/asterisk-trunk/trunk/main/app.c.

Definition at line 363 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().

00364 {
00365    int res;
00366    char *args_str;
00367    size_t args_len;
00368 
00369    if (ast_strlen_zero(macro_args)) {
00370       return ast_app_exec_macro(autoservice_chan, macro_chan, macro_name);
00371    }
00372 
00373    /* Create the Macro application argument string. */
00374    args_len = strlen(macro_name) + strlen(macro_args) + 2;
00375    args_str = ast_malloc(args_len);
00376    if (!args_str) {
00377       return -1;
00378    }
00379    snprintf(args_str, args_len, "%s,%s", macro_name, macro_args);
00380 
00381    res = ast_app_exec_macro(autoservice_chan, macro_chan, args_str);
00382    ast_free(args_str);
00383    return res;
00384 }

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_chan A channel to place into autoservice while the subroutine is run
sub_chan Channel to execute subroutine on.
sub_location The location of the subroutine to run.
sub_args The arguments to pass to the subroutine.
ignore_hangup TRUE if a hangup does not stop execution of the routine.
Return values:
0 success
-1 on error
Examples:
/tmp/asterisk-trunk/trunk/main/app.c.

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

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

Referenced by ast_channel_connected_line_sub(), and ast_channel_redirecting_sub().

00440 {
00441    int res;
00442    char *args_str;
00443    size_t args_len;
00444 
00445    if (ast_strlen_zero(sub_args)) {
00446       return ast_app_exec_sub(autoservice_chan, sub_chan, sub_location, ignore_hangup);
00447    }
00448 
00449    /* Create the Gosub application argument string. */
00450    args_len = strlen(sub_location) + strlen(sub_args) + 3;
00451    args_str = ast_malloc(args_len);
00452    if (!args_str) {
00453       return -1;
00454    }
00455    snprintf(args_str, args_len, "%s(%s)", sub_location, sub_args);
00456 
00457    res = ast_app_exec_sub(autoservice_chan, sub_chan, args_str, ignore_hangup);
00458    ast_free(args_str);
00459    return res;
00460 }

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:
chan Where to play the recorded name file.
mailbox_id The mailbox name.
Return values:
0 Name played without interruption
dtmf ASCII value of the DTMF which interrupted playback.
-1 Unable to locate mailbox or hangup occurred.
Examples:
/tmp/asterisk-trunk/trunk/main/app.c.

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

References sayname(), and VM_GREETER_API_CALL.

Referenced by play_mailbox_owner(), and spy_sayname().

00749 {
00750    int res = -1;
00751 
00752    VM_GREETER_API_CALL(res, sayname, (chan, mailbox_id));
00753    return res;
00754 }

void ast_close_fds_above_n ( int  n  ) 

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

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

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

References closefrom().

Referenced by app_exec(), ast_safe_system(), icesencode(), launch_script(), main(), mp3play(), NBScatplay(), send_waveform_to_fd(), spawn_mp3(), spawn_ras(), and vm_check_password_shell().

02954 {
02955    closefrom(n + 1);
02956 }

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:
chan Channel
file File to play.
fwd,rev,stop,pause,restart DTMF keys for media control
skipms Number of milliseconds to skip for fwd/rev.
offsetms Number 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:
0 on success
Non-zero on failure
Examples:
/tmp/asterisk-trunk/trunk/main/app.c.

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

References control_streamfile(), and NULL.

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

01228 {
01229    return control_streamfile(chan, file, fwd, rev, stop, suspend, restart, skipms, offsetms, NULL, NULL);
01230 }

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:
0 on success
Non-zero on failure
Examples:
/tmp/asterisk-trunk/trunk/main/app.c.

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

References control_streamfile(), and NULL.

Referenced by play_on_channel().

01235 {
01236    return control_streamfile(chan, file, fwd, rev, stop, suspend, restart, skipms, offsetms, lang, NULL);
01237 }

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 
file filename
fwd,rev,stop,pause,restart,skipms,offsetms 
cb waitstream 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-trunk/trunk/main/app.c.

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

References control_streamfile(), and NULL.

01220 {
01221    return control_streamfile(chan, file, fwd, rev, stop, suspend, restart, skipms, offsetms, NULL, cb);
01222 }

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

Controls playback of a tone.

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

Definition at line 1304 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().

01305 {
01306    struct ast_tone_zone *zone = NULL;
01307    struct ast_tone_zone_sound *ts;
01308    int paused = 0;
01309    int res = 0;
01310 
01311    const char *tone_indication = NULL;
01312    const char *tone_zone = NULL;
01313    char *tone_uri_parser;
01314 
01315    if (ast_strlen_zero(tone)) {
01316       return -1;
01317    }
01318 
01319    tone_uri_parser = ast_strdupa(tone);
01320 
01321    if (parse_tone_uri(tone_uri_parser, &tone_indication, &tone_zone)) {
01322       return -1;
01323    }
01324 
01325    if (tone_zone) {
01326       zone = ast_get_indication_zone(tone_zone);
01327    }
01328 
01329    ts = ast_get_indication_tone(zone ? zone : ast_channel_zone(chan), tone_indication);
01330 
01331    if (ast_playtones_start(chan, 0, ts ? ts->data : tone_indication, 0)) {
01332       return -1;
01333    }
01334 
01335    for (;;) {
01336       struct ast_frame *fr;
01337 
01338       if (ast_waitfor(chan, -1) < 0) {
01339          res = -1;
01340          break;
01341       }
01342 
01343       fr = ast_read_noaudio(chan);
01344 
01345       if (!fr) {
01346          res = -1;
01347          break;
01348       }
01349 
01350       if (fr->frametype != AST_FRAME_CONTROL) {
01351          continue;
01352       }
01353 
01354       res = control_tone_frame_response(chan, fr, ts, tone_indication, &paused);
01355       if (res == CONTROL_TONE_RESPONSE_FINISHED) {
01356          res = 0;
01357          break;
01358       } else if (res == CONTROL_TONE_RESPONSE_FAILED) {
01359          res = -1;
01360          break;
01361       }
01362    }
01363 
01364    if (ts) {
01365       ast_tone_zone_sound_unref(ts);
01366    }
01367 
01368    if (zone) {
01369       ast_tone_zone_unref(zone);
01370    }
01371 
01372    return res;
01373 }

int ast_delete_mwi_state_full ( const char *  mailbox,
const char *  context,
struct ast_eid eid 
)

Delete MWI state cached by stasis with all parameters.

Since:
12.2.0
Parameters:
[in] mailbox The mailbox identifier string.
[in] context The context this mailbox resides in (NULL or "" if only using mailbox)
[in] eid The EID of the server that originally published the message
Return values:
0 Success
-1 Failure
Examples:
/tmp/asterisk-trunk/trunk/main/app.c.

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

References ao2_cleanup, ast_eid_default, ast_mwi_state_cache(), ast_mwi_state_type(), ast_mwi_topic(), mwi_state_create_message(), NULL, RAII_VAR, stasis_cache_clear_create(), stasis_cache_get_by_eid(), stasis_message_data(), stasis_publish(), and ast_mwi_state::uniqueid.

03238 {
03239    RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
03240    struct stasis_message *cached_msg;
03241    struct stasis_message *clear_msg;
03242    struct ast_mwi_state *mwi_state;
03243    struct stasis_topic *mailbox_specific_topic;
03244 
03245    msg = mwi_state_create_message(mailbox, context, 0, 0, NULL, eid);
03246    if (!msg) {
03247       return -1;
03248    }
03249 
03250    mwi_state = stasis_message_data(msg);
03251 
03252    /*
03253     * XXX As far as stasis is concerned, all MWI events are local.
03254     *
03255     * For now, it is assumed that there is only one entity
03256     * maintaining the state of a particular mailbox.
03257     *
03258     * If we ever have multiple MWI event entities maintaining
03259     * the same mailbox that wish to delete their cached entry
03260     * we will need to do something about the race condition
03261     * potential between checking the cache and removing the
03262     * cache entry.
03263     */
03264    cached_msg = stasis_cache_get_by_eid(ast_mwi_state_cache(),
03265       ast_mwi_state_type(), mwi_state->uniqueid, &ast_eid_default);
03266    if (!cached_msg) {
03267       /* Nothing to clear */
03268       return -1;
03269    }
03270    ao2_cleanup(cached_msg);
03271 
03272    mailbox_specific_topic = ast_mwi_topic(mwi_state->uniqueid);
03273    if (!mailbox_specific_topic) {
03274       return -1;
03275    }
03276 
03277    clear_msg = stasis_cache_clear_create(msg);
03278    if (clear_msg) {
03279       stasis_publish(mailbox_specific_topic, clear_msg);
03280    }
03281    ao2_cleanup(clear_msg);
03282    return 0;
03283 }

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

Send DTMF to a channel.

Parameters:
chan The channel that will receive the DTMF frames
peer (optional) Peer channel that will be autoserviced while the primary channel is receiving DTMF
digits This 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.
between This 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.
duration This is the duration that each DTMF digit should have.
Examples:
/tmp/asterisk-trunk/trunk/main/app.c.

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

References ast_autoservice_start(), ast_autoservice_stop(), ast_channel_start_silence_generator(), ast_channel_stop_silence_generator(), AST_CONTROL_FLASH, ast_indicate(), ast_log, ast_opt_transmit_silence, ast_safe_sleep(), ast_senddigit(), LOG_WARNING, and NULL.

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

00869 {
00870    const char *ptr;
00871    int res;
00872    struct ast_silence_generator *silgen = NULL;
00873 
00874    if (!between) {
00875       between = 100;
00876    }
00877 
00878    if (peer && ast_autoservice_start(peer)) {
00879       return -1;
00880    }
00881 
00882    /* Need a quiet time before sending digits. */
00883    if (ast_opt_transmit_silence) {
00884       silgen = ast_channel_start_silence_generator(chan);
00885    }
00886    res = ast_safe_sleep(chan, 100);
00887    if (res) {
00888       goto dtmf_stream_cleanup;
00889    }
00890 
00891    for (ptr = digits; *ptr; ptr++) {
00892       if (*ptr == 'w') {
00893          /* 'w' -- wait half a second */
00894          if ((res = ast_safe_sleep(chan, 500))) {
00895             break;
00896          }
00897       } else if (*ptr == 'W') {
00898          /* 'W' -- wait a second */
00899          if ((res = ast_safe_sleep(chan, 1000))) {
00900             break;
00901          }
00902       } else if (strchr("0123456789*#abcdfABCDF", *ptr)) {
00903          if (*ptr == 'f' || *ptr == 'F') {
00904             /* ignore return values if not supported by channel */
00905             ast_indicate(chan, AST_CONTROL_FLASH);
00906          } else {
00907             /* Character represents valid DTMF */
00908             ast_senddigit(chan, *ptr, duration);
00909          }
00910          /* pause between digits */
00911          if ((res = ast_safe_sleep(chan, between))) {
00912             break;
00913          }
00914       } else {
00915          ast_log(LOG_WARNING, "Illegal DTMF character '%c' in string. (0-9*#aAbBcCdD allowed)\n", *ptr);
00916       }
00917    }
00918 
00919 dtmf_stream_cleanup:
00920    if (silgen) {
00921       ast_channel_stop_silence_generator(chan, silgen);
00922    }
00923    if (peer && ast_autoservice_stop(peer)) {
00924       res = -1;
00925    }
00926 
00927    return res;
00928 }

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

Decode an encoded control or extended ASCII character.

Parameters:
[in] stream String to decode
[out] result Decoded character
[out] consumed Number of characters used in stream to encode the character
Return values:
-1 Stream is of zero length
0 Success
Examples:
/tmp/asterisk-trunk/trunk/main/app.c.

Definition at line 2838 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().

02839 {
02840    int i;
02841    *consumed = 1;
02842    *result = 0;
02843    if (ast_strlen_zero(stream)) {
02844       *consumed = 0;
02845       return -1;
02846    }
02847 
02848    if (*stream == '\\') {
02849       *consumed = 2;
02850       switch (*(stream + 1)) {
02851       case 'n':
02852          *result = '\n';
02853          break;
02854       case 'r':
02855          *result = '\r';
02856          break;
02857       case 't':
02858          *result = '\t';
02859          break;
02860       case 'x':
02861          /* Hexadecimal */
02862          if (strchr("0123456789ABCDEFabcdef", *(stream + 2)) && *(stream + 2) != '\0') {
02863             *consumed = 3;
02864             if (*(stream + 2) <= '9') {
02865                *result = *(stream + 2) - '0';
02866             } else if (*(stream + 2) <= 'F') {
02867                *result = *(stream + 2) - 'A' + 10;
02868             } else {
02869                *result = *(stream + 2) - 'a' + 10;
02870             }
02871          } else {
02872             ast_log(LOG_ERROR, "Illegal character '%c' in hexadecimal string\n", *(stream + 2));
02873             return -1;
02874          }
02875 
02876          if (strchr("0123456789ABCDEFabcdef", *(stream + 3)) && *(stream + 3) != '\0') {
02877             *consumed = 4;
02878             *result <<= 4;
02879             if (*(stream + 3) <= '9') {
02880                *result += *(stream + 3) - '0';
02881             } else if (*(stream + 3) <= 'F') {
02882                *result += *(stream + 3) - 'A' + 10;
02883             } else {
02884                *result += *(stream + 3) - 'a' + 10;
02885             }
02886          }
02887          break;
02888       case '0':
02889          /* Octal */
02890          *consumed = 2;
02891          for (i = 2; ; i++) {
02892             if (strchr("01234567", *(stream + i)) && *(stream + i) != '\0') {
02893                (*consumed)++;
02894                ast_debug(5, "result was %d, ", *result);
02895                *result <<= 3;
02896                *result += *(stream + i) - '0';
02897                ast_debug(5, "is now %d\n", *result);
02898             } else {
02899                break;
02900             }
02901          }
02902          break;
02903       default:
02904          *result = *(stream + 1);
02905       }
02906    } else {
02907       *result = *stream;
02908       *consumed = 1;
02909    }
02910    return 0;
02911 }

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] stream Encoded string
[out] result Decoded string
[in] result_len Maximum size of the result buffer
Returns:
A pointer to the result string
Examples:
/tmp/asterisk-trunk/trunk/main/app.c.

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

References ast_get_encoded_char().

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

02914 {
02915    char *cur = result;
02916    size_t consumed;
02917 
02918    while (cur < result + result_size - 1 && !ast_get_encoded_char(stream, cur, &consumed)) {
02919       cur++;
02920       stream += consumed;
02921    }
02922    *cur = '\0';
02923    return result;
02924 }

void ast_install_stack_functions ( const struct ast_app_stack_funcs funcs  ) 

Set stack application function callbacks.

Since:
11
Parameters:
funcs Stack applications callback functions.
Examples:
/tmp/asterisk-trunk/trunk/main/app.c.

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

References app_stack_callbacks.

Referenced by load_module(), and unload_module().

00389 {
00390    app_stack_callbacks = funcs;
00391 }

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-trunk/trunk/main/app.c.

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

References ast_ivr_menu_run_internal().

Referenced by skel_exec().

02697 {
02698    int res = ast_ivr_menu_run_internal(chan, menu, cbdata);
02699    /* Hide internal coding */
02700    return res > 0 ? 0 : res;
02701 }

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-trunk/trunk/main/app.c.

Definition at line 1018 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, linearstream, and LOG_WARNING.

01019 {
01020    struct linear_state *lin;
01021    char tmpf[256];
01022    int res = -1;
01023    int autoclose = 0;
01024    if (fd < 0) {
01025       if (ast_strlen_zero(filename)) {
01026          return -1;
01027       }
01028       autoclose = 1;
01029       if (filename[0] == '/') {
01030          ast_copy_string(tmpf, filename, sizeof(tmpf));
01031       } else {
01032          snprintf(tmpf, sizeof(tmpf), "%s/%s/%s", ast_config_AST_DATA_DIR, "sounds", filename);
01033       }
01034       if ((fd = open(tmpf, O_RDONLY)) < 0) {
01035          ast_log(LOG_WARNING, "Unable to open file '%s': %s\n", tmpf, strerror(errno));
01036          return -1;
01037       }
01038    }
01039    if ((lin = ast_calloc(1, sizeof(*lin)))) {
01040       lin->fd = fd;
01041       lin->allowoverride = allowoverride;
01042       lin->autoclose = autoclose;
01043       res = ast_activate_generator(chan, &linearstream, lin);
01044    }
01045    return res;
01046 }

enum AST_LOCK_RESULT ast_lock_path ( const char *  path  ) 

Lock a filesystem path.

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

Definition at line 2368 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().

02369 {
02370    enum AST_LOCK_RESULT r = AST_LOCK_FAILURE;
02371 
02372    switch (ast_lock_type) {
02373    case AST_LOCK_TYPE_LOCKFILE:
02374       r = ast_lock_path_lockfile(path);
02375       break;
02376    case AST_LOCK_TYPE_FLOCK:
02377       r = ast_lock_path_flock(path);
02378       break;
02379    }
02380 
02381    return r;
02382 }

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:
chan the channel being recorded
playfile Filename of sound to play before recording begins
recordfile Filename to save the recording
maxtime_sec Longest possible message length in seconds
fmt string containing all formats to be recorded delimited by '|'
duration pointer to integer for storing length of the recording
sound_duration pointer to integer for storing length of the recording minus all silence
beep whether to play a beep to prompt the recording
silencethreshold tolerance of noise levels that can be considered silence for the purpose of silence timeout, -1 for default
maxsilence_ms length of time in milliseconds which will trigger a timeout from silence, -1 for default.
Return values:
-1 failure or hangup
'S' Recording ended from silence timeout
't' Recording either exceeded maximum duration or the call was ended via DTMF
Examples:
/tmp/asterisk-trunk/trunk/main/app.c.

Definition at line 1904 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().

01905 {
01906    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);
01907 }

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:
chan the channel being recorded
playfile Filename of sound to play before recording begins
recordfile Filename to save the recording
maxtime_sec Longest possible message length in seconds
fmt string containing all formats to be recorded delimited by '|'
duration pointer to integer for storing length of the recording
sound_duration pointer to integer for storing length of the recording minus all silence
silencethreshold tolerance of noise levels that can be considered silence for the purpose of silence timeout, -1 for default
maxsilence_ms length of time in milliseconds which will trigger a timeout from silence, -1 for default
path Optional filesystem path to unlock
Return values:
-1 failure or hangup
'S' Recording ended from silence timeout
't' Recording ended from the message exceeding the maximum duration
dtmfchar Recording ended via the return value's DTMF character for either cancel or accept.
Examples:
/tmp/asterisk-trunk/trunk/main/app.c.

Definition at line 1899 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().

01900 {
01901    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);
01902 }

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:
chan the channel being recorded
playfile Filename of sound to play before recording begins. A beep is also played when playfile completes, before the recording begins.
recordfile Filename to save the recording
maxtime_sec Longest possible message length in seconds
fmt string containing all formats to be recorded delimited by '|'
duration pointer to integer for storing length of the recording
beep If true, play a beep before recording begins (and doesn't play playfile)
sound_duration pointer to integer for storing length of the recording minus all silence
silencethreshold tolerance of noise levels that can be considered silence for the purpose of silence timeout, -1 for default
maxsilence_ms Length of time in milliseconds which will trigger a timeout from silence, -1 for default
path Optional filesystem path to unlock
acceptdtmf Character of DTMF to end and accept the recording
canceldtmf Character of DTMF to end and cancel the recording
skip_confirmation_sound If true, don't play auth-thankyou at end. Nice for custom recording prompts in apps.
if_exists Action to take if recording already exists.
Return values:
-1 failure or hangup
'S' Recording ended from silence timeout
't' Recording ended from the message exceeding the maximum duration
dtmfchar Recording ended via the return value's DTMF character for either cancel or accept.
Examples:
/tmp/asterisk-trunk/trunk/main/app.c.

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

References __ast_play_and_record(), default_canceldtmf, and S_OR.

Referenced by play_record_review(), and record_file().

01895 {
01896    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);
01897 }

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-trunk/trunk/main/app.c.

Definition at line 1375 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(), 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_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(), 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().

01376 {
01377    int d = 0;
01378 
01379    if ((d = ast_streamfile(chan, fn, ast_channel_language(chan)))) {
01380       return d;
01381    }
01382 
01383    d = ast_waitstream(chan, AST_DIGIT_ANY);
01384 
01385    ast_stopstream(chan);
01386 
01387    return d;
01388 }

int ast_publish_mwi_state_full ( const char *  mailbox,
const char *  context,
int  new_msgs,
int  old_msgs,
const char *  channel_id,
struct ast_eid eid 
)

Publish a MWI state update via stasis with all parameters.

Since:
12
Parameters:
[in] mailbox The mailbox identifier string.
[in] context The context this mailbox resides in (NULL or "" if only using mailbox)
[in] new_msgs The number of new messages in this mailbox
[in] old_msgs The number of old messages in this mailbox
[in] channel_id A unique identifier for a channel associated with this change in mailbox state
[in] eid The EID of the server that originally published the message
Return values:
0 Success
-1 Failure
Examples:
/tmp/asterisk-trunk/trunk/main/app.c.

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

References ao2_cleanup, ast_mwi_topic(), mwi_state_create_message(), NULL, RAII_VAR, stasis_message_data(), stasis_publish(), and ast_mwi_state::uniqueid.

Referenced by asterisk_publication_mailboxstate(), publish_mwi_to_stasis(), and xmpp_pubsub_handle_event().

03216 {
03217    struct ast_mwi_state *mwi_state;
03218    RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
03219    struct stasis_topic *mailbox_specific_topic;
03220 
03221    message = mwi_state_create_message(mailbox, context, new_msgs, old_msgs, channel_id, eid);
03222    if (!message) {
03223       return -1;
03224    }
03225 
03226    mwi_state = stasis_message_data(message);
03227    mailbox_specific_topic = ast_mwi_topic(mwi_state->uniqueid);
03228    if (!mailbox_specific_topic) {
03229       return -1;
03230    }
03231 
03232    stasis_publish(mailbox_specific_topic, message);
03233 
03234    return 0;
03235 }

char* ast_read_textfile ( const char *  file  ) 

Read a file into asterisk.

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

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

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

02704 {
02705    int fd, count = 0, res;
02706    char *output = NULL;
02707    struct stat filesize;
02708 
02709    if (stat(filename, &filesize) == -1) {
02710       ast_log(LOG_WARNING, "Error can't stat %s\n", filename);
02711       return NULL;
02712    }
02713 
02714    count = filesize.st_size + 1;
02715 
02716    if ((fd = open(filename, O_RDONLY)) < 0) {
02717       ast_log(LOG_WARNING, "Cannot open file '%s' for reading: %s\n", filename, strerror(errno));
02718       return NULL;
02719    }
02720 
02721    if ((output = ast_malloc(count))) {
02722       res = read(fd, output, count - 1);
02723       if (res == count - 1) {
02724          output[res] = '\0';
02725       } else {
02726          ast_log(LOG_WARNING, "Short read of %s (%d of %d): %s\n", filename, res, count - 1, strerror(errno));
02727          ast_free(output);
02728          output = NULL;
02729       }
02730    }
02731 
02732    close(fd);
02733 
02734    return output;
02735 }

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-trunk/trunk/main/app.c.

Definition at line 2400 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().

02401 {
02402    int silencethreshold;
02403    int maxsilence = 0;
02404    int res = 0;
02405    int cmd = 0;
02406    int max_attempts = 3;
02407    int attempts = 0;
02408    int recorded = 0;
02409    int message_exists = 0;
02410    /* Note that urgent and private are for flagging messages as such in the future */
02411 
02412    /* barf if no pointer passed to store duration in */
02413    if (!duration) {
02414       ast_log(LOG_WARNING, "Error ast_record_review called without duration pointer\n");
02415       return -1;
02416    }
02417 
02418    cmd = '3';   /* Want to start by recording */
02419 
02420    silencethreshold = ast_dsp_get_threshold_from_settings(THRESHOLD_SILENCE);
02421 
02422    while ((cmd >= 0) && (cmd != 't')) {
02423       switch (cmd) {
02424       case '1':
02425          if (!message_exists) {
02426             /* In this case, 1 is to record a message */
02427             cmd = '3';
02428             break;
02429          } else {
02430             ast_stream_and_wait(chan, "vm-msgsaved", "");
02431             cmd = 't';
02432             return res;
02433          }
02434       case '2':
02435          /* Review */
02436          ast_verb(3, "Reviewing the recording\n");
02437          cmd = ast_stream_and_wait(chan, recordfile, AST_DIGIT_ANY);
02438          break;
02439       case '3':
02440          message_exists = 0;
02441          /* Record */
02442          ast_verb(3, "R%secording\n", recorded == 1 ? "e-r" : "");
02443          recorded = 1;
02444          if ((cmd = ast_play_and_record(chan, playfile, recordfile, maxtime, fmt, duration, NULL, silencethreshold, maxsilence, path)) == -1) {
02445             /* User has hung up, no options to give */
02446             return cmd;
02447          }
02448          if (cmd == '0') {
02449             break;
02450          } else if (cmd == '*') {
02451             break;
02452          } else {
02453             /* If all is well, a message exists */
02454             message_exists = 1;
02455             cmd = 0;
02456          }
02457          break;
02458       case '4':
02459       case '5':
02460       case '6':
02461       case '7':
02462       case '8':
02463       case '9':
02464       case '*':
02465       case '#':
02466          cmd = ast_play_and_wait(chan, "vm-sorry");
02467          break;
02468       default:
02469          if (message_exists) {
02470             cmd = ast_play_and_wait(chan, "vm-review");
02471          } else {
02472             if (!(cmd = ast_play_and_wait(chan, "vm-torerecord"))) {
02473                cmd = ast_waitfordigit(chan, 600);
02474             }
02475          }
02476 
02477          if (!cmd) {
02478             cmd = ast_waitfordigit(chan, 6000);
02479          }
02480          if (!cmd) {
02481             attempts++;
02482          }
02483          if (attempts > max_attempts) {
02484             cmd = 't';
02485          }
02486       }
02487    }
02488    if (cmd == 't') {
02489       cmd = 0;
02490    }
02491    return cmd;
02492 }

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-trunk/trunk/main/app.c.

Definition at line 1067 of file extconf.c.

References safe_system_prev_handler.

Referenced by ast_safe_fork(), and ast_safe_system().

01068 {
01069    unsigned int level;
01070 
01071    level = safe_system_level++;
01072 
01073    /* only replace the handler if it has not already been done */
01074    if (level == 0) {
01075       sigaction(SIGCHLD, &null_sig_handler, &safe_system_prev_handler);
01076    }
01077 }

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_reaper flag to determine if sigchld handler is replaced or not
Since:
1.6.1
Examples:
/tmp/asterisk-trunk/trunk/main/app.c.

Definition at line 2958 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, and shaun_of_the_dead().

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

02959 {
02960    sigset_t signal_set, old_set;
02961    int pid;
02962 
02963    /* Don't let the default signal handler for children reap our status */
02964    if (stop_reaper) {
02965       ast_replace_sigchld();
02966    }
02967 
02968    /* GCC 4.9 gives a bogus "right-hand operand of comma expression has
02969     * no effect" warning */
02970    (void) sigfillset(&signal_set);
02971    pthread_sigmask(SIG_BLOCK, &signal_set, &old_set);
02972 
02973    pid = fork();
02974 
02975    if (pid != 0) {
02976       /* Fork failed or parent */
02977       pthread_sigmask(SIG_SETMASK, &old_set, NULL);
02978       if (!stop_reaper && pid > 0) {
02979          struct zombie *cur = ast_calloc(1, sizeof(*cur));
02980          if (cur) {
02981             cur->pid = pid;
02982             AST_LIST_LOCK(&zombies);
02983             AST_LIST_INSERT_TAIL(&zombies, cur, list);
02984             AST_LIST_UNLOCK(&zombies);
02985             if (shaun_of_the_dead_thread == AST_PTHREADT_NULL) {
02986                if (ast_pthread_create_background(&shaun_of_the_dead_thread, NULL, shaun_of_the_dead, NULL)) {
02987                   ast_log(LOG_ERROR, "Shaun of the Dead wants to kill zombies, but can't?!!\n");
02988                   shaun_of_the_dead_thread = AST_PTHREADT_NULL;
02989                }
02990             }
02991          }
02992       }
02993       return pid;
02994    } else {
02995       /* Child */
02996 #ifdef HAVE_CAP
02997       cap_t cap = cap_from_text("cap_net_admin-eip");
02998 
02999       if (cap_set_proc(cap)) {
03000          ast_log(LOG_WARNING, "Unable to remove capabilities.\n");
03001       }
03002       cap_free(cap);
03003 #endif
03004 
03005       /* Before we unblock our signals, return our trapped signals back to the defaults */
03006       signal(SIGHUP, SIG_DFL);
03007       signal(SIGCHLD, SIG_DFL);
03008       signal(SIGINT, SIG_DFL);
03009       signal(SIGURG, SIG_DFL);
03010       signal(SIGTERM, SIG_DFL);
03011       signal(SIGPIPE, SIG_DFL);
03012       signal(SIGXFSZ, SIG_DFL);
03013 
03014       /* unblock important signal handlers */
03015       if (pthread_sigmask(SIG_UNBLOCK, &signal_set, NULL)) {
03016          ast_log(LOG_WARNING, "unable to unblock signals: %s\n", strerror(errno));
03017          _exit(1);
03018       }
03019 
03020       return pid;
03021    }
03022 }

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-trunk/trunk/main/app.c.

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

References ast_unreplace_sigchld().

Referenced by agi_exec_full(), and run_ras().

03025 {
03026    ast_unreplace_sigchld();
03027 }

int ast_safe_system ( const char *  s  ) 

Safely spawn an external program while closing file descriptors.

Note:
This replaces the system call in all Asterisk modules

Definition at line 1095 of file extconf.c.

References ast_log, ast_replace_sigchld(), ast_unreplace_sigchld(), errno, LOG_WARNING, NULL, status, WEXITSTATUS, and WIFEXITED.

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

01096 {
01097    pid_t pid;
01098 #ifdef HAVE_WORKING_FORK
01099    int x;
01100 #endif
01101    int res;
01102    int status;
01103 
01104 #if defined(HAVE_WORKING_FORK) || defined(HAVE_WORKING_VFORK)
01105    ast_replace_sigchld();
01106 
01107 #ifdef HAVE_WORKING_FORK
01108    pid = fork();
01109 #else
01110    pid = vfork();
01111 #endif   
01112 
01113    if (pid == 0) {
01114 #ifdef HAVE_WORKING_FORK
01115       /* Close file descriptors and launch system command */
01116       for (x = STDERR_FILENO + 1; x < 4096; x++)
01117          close(x);
01118 #endif
01119       execl("/bin/sh", "/bin/sh", "-c", s, (char *) NULL);
01120       _exit(1);
01121    } else if (pid > 0) {
01122       for(;;) {
01123          res = waitpid(pid, &status, 0);
01124          if (res > -1) {
01125             res = WIFEXITED(status) ? WEXITSTATUS(status) : -1;
01126             break;
01127          } else if (errno != EINTR) 
01128             break;
01129       }
01130    } else {
01131       ast_log(LOG_WARNING, "Fork failed: %s\n", strerror(errno));
01132       res = -1;
01133    }
01134 
01135    ast_unreplace_sigchld();
01136 #else
01137    res = -1;
01138 #endif
01139 
01140    return res;
01141 }

void ast_set_lock_type ( enum AST_LOCK_TYPE  type  ) 

Set the type of locks used by ast_lock_path().

Parameters:
type the locking type to use
Examples:
/tmp/asterisk-trunk/trunk/main/app.c.

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

Referenced by ast_readconfig().

02364 {
02365    ast_lock_type = type;
02366 }

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-trunk/trunk/main/app.c.

Definition at line 2926 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().

02927 {
02928    char next, *buf;
02929    size_t offset = 0;
02930    size_t consumed;
02931 
02932    if (strchr(stream, '\\')) {
02933       while (!ast_get_encoded_char(stream, &next, &consumed)) {
02934          if (offset + 2 > ast_str_size(*str) && maxlen > -1) {
02935             ast_str_make_space(str, maxlen > 0 ? maxlen : (ast_str_size(*str) + 48) * 2 - 48);
02936          }
02937          if (offset + 2 > ast_str_size(*str)) {
02938             break;
02939          }
02940          buf = ast_str_buffer(*str);
02941          buf[offset++] = next;
02942          stream += consumed;
02943       }
02944       buf = ast_str_buffer(*str);
02945       buf[offset++] = '\0';
02946       ast_str_update(*str);
02947    } else {
02948       ast_str_set(str, maxlen, "%s", stream);
02949    }
02950    return 0;
02951 }

AST_THREADSTORAGE_EXTERNAL ( ast_str_thread_global_buf   ) 

int ast_unlock_path ( const char *  path  ) 

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-trunk/trunk/main/app.c.

Definition at line 1081 of file extconf.c.

References NULL, and safe_system_prev_handler.

Referenced by ast_safe_fork_cleanup(), and ast_safe_system().

01082 {
01083    unsigned int level;
01084 
01085    level = --safe_system_level;
01086 
01087    /* only restore the handler if we are the last one */
01088    if (level == 0) {
01089       sigaction(SIGCHLD, &safe_system_prev_handler, NULL);
01090    }
01091 }

int ast_vm_greeter_is_registered ( void   ) 

Determine if a voicemail greeter provider is registered.

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

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

References ao2_cleanup, ao2_global_obj_ref, and table.

00580 {
00581    struct ast_vm_greeter_functions *table;
00582    int is_registered;
00583 
00584    table = ao2_global_obj_ref(vm_greeter_provider);
00585    is_registered = table ? 1 : 0;
00586    ao2_cleanup(table);
00587    return is_registered;
00588 }

void ast_vm_greeter_unregister ( const char *  module_name  ) 

Unregister the specified voicemail greeter provider.

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

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

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

Referenced by unload_module().

00623 {
00624    struct ast_vm_greeter_functions *table;
00625 
00626    table = ao2_global_obj_ref(vm_greeter_provider);
00627    if (table && !strcmp(table->module_name, module_name)) {
00628       ao2_global_obj_release(vm_greeter_provider);
00629    }
00630    ao2_cleanup(table);
00631 }

const char* ast_vm_index_to_foldername ( int  id  ) 

Return name of folder, given an id.

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

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

References NULL, and VM_API_CALL.

00765 {
00766    const char *res = NULL;
00767 
00768    VM_API_CALL(res, index_to_foldername, (id));
00769    return res;
00770 }

int ast_vm_is_registered ( void   ) 

Determine if a voicemail provider is registered.

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

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

References ao2_cleanup, ao2_global_obj_ref, and table.

00469 {
00470    struct ast_vm_functions *table;
00471    int is_registered;
00472 
00473    table = ao2_global_obj_ref(vm_provider);
00474    is_registered = table ? 1 : 0;
00475    ao2_cleanup(table);
00476    return is_registered;
00477 }

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 
) [read]

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

Parameters:
mailbox,the mailbox to look for
context,the context to look for the mailbox in
folder,OPTIONAL. When not NULL only msgs from the specified folder will be included.
descending,list the msgs in descending order rather than ascending order.
combine_INBOX_and_OLD,When 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.
Return values:
snapshot on success
NULL on failure
Examples:
/tmp/asterisk-trunk/trunk/main/app.c.

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

References NULL, and VM_API_CALL.

Referenced by test_vm_api_remove_all_messages().

00778 {
00779    struct ast_vm_mailbox_snapshot *res = NULL;
00780 
00781    VM_API_CALL(res, mailbox_snapshot_create, (mailbox, context, folder, descending,
00782       sort_val, combine_INBOX_and_OLD));
00783    return res;
00784 }

struct ast_vm_mailbox_snapshot* ast_vm_mailbox_snapshot_destroy ( struct ast_vm_mailbox_snapshot mailbox_snapshot  )  [read]

destroy a snapshot

Parameters:
mailbox_snapshot The snapshot to destroy.
Return values:
NULL 
Examples:
/tmp/asterisk-trunk/trunk/main/app.c.

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

References NULL, and VM_API_CALL.

Referenced by AST_TEST_DEFINE(), and test_vm_api_remove_all_messages().

00787 {
00788    struct ast_vm_mailbox_snapshot *res = NULL;
00789 
00790    VM_API_CALL(res, mailbox_snapshot_destroy, (mailbox_snapshot));
00791    return res;
00792 }

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:
-1 Failure
0 Success
Examples:
/tmp/asterisk-trunk/trunk/main/app.c.

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

References VM_API_CALL.

00829 {
00830    int res = 0;
00831 
00832    VM_API_CALL(res, msg_forward, (from_mailbox, from_context, from_folder, to_mailbox,
00833       to_context, to_folder, num_msgs, msg_ids, delete_old));
00834    return res;
00835 }

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:
mailbox The mailbox to which the folders belong
context The voicemail context for the mailbox
num_msgs The number of messages to move
oldfolder The folder from where messages should be moved
old_msg_ids The message IDs of the messages to move
newfolder The folder to which messages should be moved new folder. This array must be num_msgs sized.
Return values:
-1 Failure
0 Success
Examples:
/tmp/asterisk-trunk/trunk/main/app.c.

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

References VM_API_CALL.

00800 {
00801    int res = 0;
00802 
00803    VM_API_CALL(res, msg_move, (mailbox, context, num_msgs, oldfolder, old_msg_ids,
00804       newfolder));
00805    return res;
00806 }

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 
mailbox msg is in.
context of mailbox.
folder voicemail folder to look in.
msg_num message number in the voicemailbox to playback to the channel.
cb 
Return values:
0 success
-1 failure
Examples:
/tmp/asterisk-trunk/trunk/main/app.c.

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

References VM_API_CALL.

00843 {
00844    int res = 0;
00845 
00846    VM_API_CALL(res, msg_play, (chan, mailbox, context, folder, msg_num, cb));
00847    return res;
00848 }

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:
mailbox The mailbox from which to delete messages
context The voicemail context for the mailbox
num_msgs The number of messages to delete
folder The folder from which to remove messages
msgs The message IDs of the messages to delete
Return values:
-1 Failure
0 Success
Examples:
/tmp/asterisk-trunk/trunk/main/app.c.

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

References VM_API_CALL.

00813 {
00814    int res = 0;
00815 
00816    VM_API_CALL(res, msg_remove, (mailbox, context, num_msgs, folder, msgs));
00817    return res;
00818 }

void ast_vm_unregister ( const char *  module_name  ) 

Unregister the specified voicemail provider.

Parameters:
The module name of the provider to unregister
Returns:
Nothing
Examples:
/tmp/asterisk-trunk/trunk/main/app.c.

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

References ao2_cleanup, ao2_global_obj_ref, ao2_global_obj_release, ast_vm_functions::module_name, and table.

Referenced by unload_module().

00512 {
00513    struct ast_vm_functions *table;
00514 
00515    table = ao2_global_obj_ref(vm_provider);
00516    if (table && !strcmp(table->module_name, module_name)) {
00517       ao2_global_obj_release(vm_provider);
00518    }
00519    ao2_cleanup(table);
00520 }


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