23 #ifndef _ASTERISK_APP_H
24 #define _ASTERISK_APP_H
36 #if defined(__cplusplus) || defined(c_plusplus)
40 AST_THREADSTORAGE_EXTERNAL(ast_str_thread_global_buf);
106 #define AST_IVR_FLAG_AUTORESTART (1 << 0)
108 #define AST_IVR_DECLARE_MENU(holder, title, flags, foo...) \
109 static struct ast_ivr_option __options_##holder[] = foo;\
110 static struct ast_ivr_menu holder = { title, flags, __options_##holder }
116 TIMELEN_MILLISECONDS,
127 AST_GETDATA_FAILED = -1,
128 AST_GETDATA_COMPLETE = 0,
129 AST_GETDATA_TIMEOUT = 1,
130 AST_GETDATA_INTERRUPTED = 2,
208 const char *(*expand_sub_args)(
struct ast_channel *chan,
const char *args);
278 struct ast_channel *sub_chan,
const char *sub_location,
const char *sub_args,
int ignore_hangup);
280 enum ast_vm_snapshot_sort_val {
281 AST_VM_SNAPSHOT_SORT_BY_ID = 0,
282 AST_VM_SNAPSHOT_SORT_BY_TIME,
297 unsigned int msg_number;
430 const char *context,
const char *folder,
int descending,
431 enum ast_vm_snapshot_sort_val sort_val,
int combine_INBOX_and_OLD);
461 const char *oldfolder,
const char *old_msg_ids[],
const char *newfolder);
478 const char *folder,
const char *msgs[]);
500 const char *from_folder,
const char *to_mailbox,
const char *to_context,
501 const char *to_folder,
size_t num_msgs,
const char *msg_ids[],
int delete_old);
521 #define VM_MODULE_VERSION 2
573 #define ast_vm_register(vm_table) __ast_vm_register(vm_table, AST_MODULE_SELF)
582 #ifdef TEST_FRAMEWORK
595 void ast_vm_test_swap_table_out(
void);
598 #define VM_GREETER_MODULE_VERSION 1
640 #define ast_vm_greeter_register(vm_table) __ast_vm_greeter_register(vm_table, AST_MODULE_SELF)
650 #ifdef TEST_FRAMEWORK
651 typedef int (ast_vm_test_create_user_fn)(
const char *context,
const char *user);
652 typedef int (ast_vm_test_destroy_user_fn)(
const char *context,
const char *user);
654 void ast_install_vm_test_functions(ast_vm_test_create_user_fn *vm_test_create_user_func,
655 ast_vm_test_destroy_user_fn *vm_test_destroy_user_func);
657 void ast_uninstall_vm_test_functions(
void);
703 int ast_app_inboxcount2(
const char *mailboxes,
int *urgentmsgs,
int *newmsgs,
int *oldmsgs);
755 enum ast_vm_snapshot_sort_val sort_val,
756 int combine_INBOX_and_OLD);
783 const char *oldfolder,
784 const char *old_msg_ids[],
785 const char *newfolder);
823 const char *from_context,
824 const char *from_folder,
825 const char *to_mailbox,
826 const char *to_context,
827 const char *to_folder,
829 const char *msg_ids[],
852 #ifdef TEST_FRAMEWORK
853 int ast_vm_test_destroy_user(
const char *context,
const char *mailbox);
854 int ast_vm_test_create_user(
const char *context,
const char *mailbox);
871 int ast_safe_execvp(
int dualfork,
const char *file,
char *
const argv[]);
964 int between,
unsigned int duration,
unsigned int durationkp,
unsigned int durationst,
int is_external);
1029 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);
1039 const char *fwd,
const char *rev,
const char *
stop,
const char *suspend,
1040 const char *restart,
int skipms,
const char *lang,
long *offsetms);
1068 const char *restart,
1117 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);
1139 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);
1160 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);
1162 enum AST_LOCK_RESULT {
1163 AST_LOCK_SUCCESS = 0,
1164 AST_LOCK_TIMEOUT = -1,
1165 AST_LOCK_PATH_NOT_FOUND = -2,
1166 AST_LOCK_FAILURE = -3,
1171 AST_LOCK_TYPE_LOCKFILE = 0,
1172 AST_LOCK_TYPE_FLOCK = 1,
1230 #define AST_APP_ARG(name) char *name
1247 #define AST_DECLARE_APP_ARGS(name, arglist) AST_DEFINE_APP_ARGS_TYPE(argtype_##name, arglist) name = { 0, }
1264 #define AST_DEFINE_APP_ARGS_TYPE(type, arglist) \
1265 struct __subtype_##type { arglist }; \
1267 unsigned int argc; \
1269 char *argv[sizeof(struct __subtype_##type) / sizeof(char*)]; \
1270 struct { arglist }; \
1283 #define AST_STANDARD_APP_ARGS(args, parse) \
1284 args.argc = __ast_app_separate_args(parse, ',', 1, args.argv, ((sizeof(args) - offsetof(typeof(args), argv)) / sizeof(args.argv[0])))
1285 #define AST_STANDARD_RAW_ARGS(args, parse) \
1286 args.argc = __ast_app_separate_args(parse, ',', 0, args.argv, ((sizeof(args) - offsetof(typeof(args), argv)) / sizeof(args.argv[0])))
1298 #define AST_NONSTANDARD_APP_ARGS(args, parse, sep) \
1299 args.argc = __ast_app_separate_args(parse, sep, 1, args.argv, ((sizeof(args) - offsetof(typeof(args), argv)) / sizeof(args.argv[0])))
1300 #define AST_NONSTANDARD_RAW_ARGS(args, parse, sep) \
1301 args.argc = __ast_app_separate_args(parse, sep, 0, args.argv, ((sizeof(args) - offsetof(typeof(args), argv)) / sizeof(args.argv[0])))
1319 #define ast_app_separate_args(a,b,c,d) __ast_app_separate_args(a,b,1,c,d)
1341 #define BEGIN_OPTIONS {
1342 #define END_OPTIONS }
1391 #define AST_APP_OPTIONS(holder, options...) \
1392 static const struct ast_app_option holder[128] = options
1400 #define AST_APP_OPTION(option, flagno) \
1401 [option] = { .flag = flagno }
1411 #define AST_APP_OPTION_ARG(option, flagno, argno) \
1412 [option] = { .flag = flagno, .arg_index = argno + 1 }
1451 int ast_app_dtget(
struct ast_channel *chan,
const char *context,
char *collect,
size_t size,
int maxlen,
int timeout);
1454 int ast_record_review(
struct ast_channel *chan,
const char *playfile,
const char *recordfile,
int maxtime,
const char *fmt,
int *duration,
const char *path);
1534 #if defined(__cplusplus) || defined(c_plusplus)
void ast_install_stack_functions(const struct ast_app_stack_funcs *funcs)
Set stack application function callbacks.
unsigned int module_version
The version of this function table.
int ast_vm_is_registered(void)
Determine if a voicemail provider is registered.
int ast_vm_greeter_is_registered(void)
Determine if a voicemail greeter provider is registered.
int ast_dtmf_stream(struct ast_channel *chan, struct ast_channel *peer, const char *digits, int between, unsigned int duration)
Send a string of DTMF digits to a channel.
Main Channel structure associated with a channel.
enum ast_getdata_result 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.
struct ast_module * module
The module for the voicemail provider.
void( ast_waitstream_fr_cb)(struct ast_channel *chan, long ms, enum ast_waitstream_fr_cb_values val)
callback used during dtmf controlled file playback to indicate location of playback in a file after r...
int __ast_vm_register(const struct ast_vm_functions *vm_table, struct ast_module *module)
Set voicemail function callbacks.
void ast_set_lock_type(enum AST_LOCK_TYPE type)
Set the type of locks used by ast_lock_path()
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_unreplace_sigchld(void)
Restore the SIGCHLD handler.
String manipulation functions.
int( ast_has_voicemail_fn)(const char *mailboxes, const char *folder)
Determines if the given folder has messages.
struct ast_group_info * ast_app_group_list_head(void)
Get the head of the group count list.
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_sayname(struct ast_channel *chan, const char *mailbox_id)
Play a recorded user name for the mailbox to the specified channel.
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...
char context[AST_MAX_CONTEXT]
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.
Stasis Message Bus API. See Stasis Message Bus API for detailed documentation.
int( ast_inboxcount2_fn)(const char *mailboxes, int *urgentmsgs, int *newmsgs, int *oldmsgs)
Gets the number of messages that exist for the mailbox list.
Voicemail greeter function table definition.
static struct stasis_rest_handlers mailboxes
REST handler for /api-docs/mailboxes.json.
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.
struct stasis_topic * ast_queue_topic_all(void)
Get the Stasis Message Bus API topic for queue messages.
void ast_close_fds_above_n(int n)
Common routine for child processes, to close all fds prior to exec(2)
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.
int ast_control_tone(struct ast_channel *chan, const char *tone)
Controls playback of a tone.
void( ast_vm_msg_play_cb)(struct ast_channel *chan, const char *playfile, int duration)
Voicemail playback callback function definition.
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.
void ast_vm_unregister(const char *module_name)
Unregister the specified voicemail provider.
#define AST_DECLARE_STRING_FIELDS(field_list)
Declare the fields needed in a structure.
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 li...
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.
Generic File Format Support. Should be included by clients of the file handling routines. File service providers should instead include mod_format.h.
int ast_unlock_path(const char *path)
Unlock a path.
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.
Definitions to aid in the use of thread local storage.
static int inboxcount2(const char *mailbox, int *urgentmsgs, int *newmsgs, int *oldmsgs)
Check the given mailbox's message count.
Structure used to handle a large number of boolean flags == used only in app_dial?
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.
char * ast_read_textfile(const char *file)
Read a file into asterisk.
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_linear_stream(struct ast_channel *chan, const char *filename, int fd, int allowoverride)
Stream a filename (or file descriptor) as a generator.
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.
enum AST_LOCK_RESULT ast_lock_path(const char *path)
Lock a filesystem path.
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_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 fu...
int ast_ivr_menu_run(struct ast_channel *c, struct ast_ivr_menu *menu, void *cbdata)
Runs an IVR menu.
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_sayname_fn)(struct ast_channel *chan, const char *mailbox_id)
Play a recorded user name for the mailbox to the specified channel.
A structure to hold the description of an application 'option'.
void ast_safe_fork_cleanup(void)
Common routine to cleanup after fork'ed process is complete (if reaping was stopped) ...
#define AST_STRING_FIELD(name)
Declare a string field.
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.
struct ast_vm_mailbox_snapshot *( ast_vm_mailbox_snapshot_destroy_fn)(struct ast_vm_mailbox_snapshot *mailbox_snapshot)
destroy a snapshot
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 r...
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.
A set of macros to manage forward-linked lists.
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.
int ast_get_encoded_char(const char *stream, char *result, size_t *consumed)
Decode an encoded control or extended ASCII character.
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.
void ast_replace_sigchld(void)
Replace the SIGCHLD handler.
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.
struct ast_vm_mailbox_snapshot * ast_vm_mailbox_snapshot_destroy(struct ast_vm_mailbox_snapshot *mailbox_snapshot)
destroy a snapshot
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_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.
enum ast_getdata_result ast_app_getdata_terminator(struct ast_channel *c, const char *prompt, char *s, int maxlen, int timeout, char *terminator)
Plays a stream and gets DTMF data from a channel.
struct ast_module * module
The module for the voicemail greeter provider.
void ast_vm_greeter_unregister(const char *module_name)
Unregister the specified voicemail greeter provider.
#define AST_LIST_HEAD_NOLOCK(name, type)
Defines a structure to be used to hold a list of specified type (with no lock).
uint64_t flag
The flag bit that represents this option.
int( ast_messagecount_fn)(const char *mailbox_id, const char *folder)
Gets the number of messages that exist in a mailbox folder.
int __ast_vm_greeter_register(const struct ast_vm_greeter_functions *vm_table, struct ast_module *module)
Set voicemail greeter function callbacks.
Support for dynamic strings.
int ast_safe_system(const char *s)
Safely spawn an OS shell command while closing file descriptors.
int( ast_ivr_callback)(struct ast_channel *chan, char *option, void *cbdata)
Callback function for IVR.
struct ast_vm_mailbox_snapshot * ast_vm_mailbox_snapshot_create(const char *mailbox, const char *context, const char *folder, int descending, enum ast_vm_snapshot_sort_val sort_val, int combine_INBOX_and_OLD)
Create a snapshot of a mailbox which contains information about every msg.
const char * module_name
The name of the module that provides the voicemail greeter functionality.
const char * ast_vm_index_to_foldername(int id)
Return name of folder, given an id.
Stack applications callback functions.
int ast_safe_fork(int stop_reaper)
Common routine to safely fork without a chance of a signal handler firing badly in the child...
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 p...
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.
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
int ast_app_group_list_unlock(void)
Unlock the group count list.
int ast_sf_stream(struct ast_channel *chan, struct ast_channel *peer, struct ast_channel *chan2, const char *digits, int frequency, int is_external)
Send a string of SF digits to a channel.
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_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_inboxcount_fn)(const char *mailboxes, int *newmsgs, int *oldmsgs)
Gets the number of messages that exist for the mailbox 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.
unsigned int arg_index
The index of the entry in the arguments array that should be used for this option's argument...
structure to hold users read from users.conf
Structure used to handle boolean flags.
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(* run_sub)(struct ast_channel *chan, const char *args, int ignore_hangup)
Callback for the routine to run a subroutine on a channel.
int ast_app_messagecount(const char *mailbox_id, const char *folder)
Get the number of messages in a given mailbox folder.
const char * module_name
The name of the module that provides the voicemail functionality.
Structure used for ast_copy_recording_to_vm in order to cleanly supply data needed for making the rec...
int ast_app_group_list_rdlock(void)
Read Lock the group count list.
static int has_voicemail(const char *mailbox, const char *folder)
Determines if the given folder has messages.
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.
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_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.
unsigned int module_version
The version of this function table.
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_app_group_discard(struct ast_channel *chan)
Discard all group counting for a channel.
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.
struct stasis_topic * ast_queue_topic(const char *queuename)
Get the Stasis Message Bus API topic for queue messages for a particular queue name.
int ast_mf_stream(struct ast_channel *chan, struct ast_channel *peer, struct ast_channel *chan2, const char *digits, int between, unsigned int duration, unsigned int durationkp, unsigned int durationst, int is_external)
Send a string of MF digits to a channel.
Voicemail function table definition.
const char *( ast_vm_index_to_foldername_fn)(int id)
Convert the mailbox folder id to a folder name.
AST_LOCK_TYPE
Type of locking to use in ast_lock_path / ast_unlock_path.
int ast_safe_execvp(int dualfork, const char *file, char *const argv[])
Safely spawn an external program while closing file descriptors.
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 cre...
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...
void ast_dtmf_stream_external(struct ast_channel *chan, const char *digits, int between, unsigned int duration)
Send a string of DTMF digits to a channel from an external thread.
int ast_app_group_list_wrlock(void)
Write Lock the group count list.
int app_init(void)
Initialize the application core.
int ast_app_group_get_count(const char *group, const char *category)
Get the current channel count of the specified group and category.
int ast_app_inboxcount(const char *mailboxes, int *newmsgs, int *oldmsgs)
Determine number of new/old messages in a mailbox.