23 #ifndef _ASTERISK_APP_H
24 #define _ASTERISK_APP_H
31 #if defined(__cplusplus) || defined(c_plusplus)
81 #define AST_IVR_FLAG_AUTORESTART (1 << 0)
83 #define AST_IVR_DECLARE_MENU(holder, title, flags, foo...) \
84 static struct ast_ivr_option __options_##holder[] = foo;\
85 static struct ast_ivr_menu holder = { title, flags, __options_##holder }
160 struct ast_channel *macro_chan,
const char *macro_name,
const char *macro_args);
284 int (*inboxcount_func)(
const char *mailbox,
int *newmsgs,
int *oldmsgs),
285 int (*inboxcount2_func)(
const char *mailbox,
int *urgentmsgs,
int *newmsgs,
int *oldmsgs),
286 int (*messagecount_func)(
const char *
context,
const char *mailbox,
const char *folder),
287 int (*sayname_func)(
struct ast_channel *chan,
const char *mailbox,
const char *context));
432 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 silencethreshold,
int maxsilence_ms,
const char *path,
const char *
acceptdtmf,
const char *canceldtmf);
555 #define AST_APP_ARG(name) char *name
572 #define AST_DECLARE_APP_ARGS(name, arglist) AST_DEFINE_APP_ARGS_TYPE(, arglist) name = { 0, }
588 #define AST_DEFINE_APP_ARGS_TYPE(type, arglist) \
604 #define AST_STANDARD_APP_ARGS(args, parse) \
605 args.argc = __ast_app_separate_args(parse, ',', 1, args.argv, ((sizeof(args) - offsetof(typeof(args), argv)) / sizeof(args.argv[0])))
606 #define AST_STANDARD_RAW_ARGS(args, parse) \
607 args.argc = __ast_app_separate_args(parse, ',', 0, args.argv, ((sizeof(args) - offsetof(typeof(args), argv)) / sizeof(args.argv[0])))
619 #define AST_NONSTANDARD_APP_ARGS(args, parse, sep) \
620 args.argc = __ast_app_separate_args(parse, sep, 1, args.argv, ((sizeof(args) - offsetof(typeof(args), argv)) / sizeof(args.argv[0])))
621 #define AST_NONSTANDARD_RAW_ARGS(args, parse, sep) \
622 args.argc = __ast_app_separate_args(parse, sep, 0, args.argv, ((sizeof(args) - offsetof(typeof(args), argv)) / sizeof(args.argv[0])))
640 #define ast_app_separate_args(a,b,c,d) __ast_app_separate_args(a,b,1,c,d)
662 #define BEGIN_OPTIONS {
663 #define END_OPTIONS }
712 #define AST_APP_OPTIONS(holder, options...) \
713 static const struct ast_app_option holder[128] = options
721 #define AST_APP_OPTION(option, flagno) \
722 [option] = { .flag = flagno }
732 #define AST_APP_OPTION_ARG(option, flagno, argno) \
733 [option] = { .flag = flagno, .arg_index = argno + 1 }
768 int ast_app_dtget(
struct ast_channel *chan,
const char *context,
char *collect,
size_t size,
int maxlen,
int timeout);
771 int ast_record_review(
struct ast_channel *chan,
const char *playfile,
const char *recordfile,
int maxtime,
const char *fmt,
int *duration,
const char *path);
824 #if defined(__cplusplus) || defined(c_plusplus)
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...
Main Channel structure associated with a channel.
int ast_safe_system(const char *s)
Safely spawn an external program while closing file descriptors.
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_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 silencethreshold, int maxsilence_ms, const char *path, const char *acceptdtmf, const char *canceldtmf)
Record a file based on input from a channel This function will play "auth-thankyou" upon successful r...
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_safe_fork(int stop_reaper)
Common routine to safely fork without a chance of a signal handler firing badly in the child...
String manipulation functions.
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_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.
AST_THREADSTORAGE_EXTERNAL(ast_str_thread_global_buf)
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_has_voicemail(const char *mailbox, 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_parse_timelen(const char *timestr, int *result, enum ast_timelen defunit)
Common routine to parse time lengths, with optional time unit specifier.
char * ast_get_encoded_str(const char *stream, char *result, size_t result_len)
Decode a stream of encoded control or extended ASCII characters.
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.
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_unlock_path(const char *path)
Unlock a path.
void ast_safe_fork_cleanup(void)
Common routine to cleanup after fork'ed process is complete (if reaping was stopped) ...
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_group_discard(struct ast_channel *chan)
Discard all group counting for a channel.
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.
int(* ast_ivr_callback)(struct ast_channel *chan, char *option, void *cbdata)
Callback function for IVR.
Definitions to aid in the use of thread local storage.
Structure used to handle a large number of boolean flags == used only in app_dial?
void ast_unreplace_sigchld(void)
Restore the SIGCHLD handler.
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.
static char beep[AST_MAX_BUF]
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_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_play_and_wait(struct ast_channel *chan, const char *fn)
Play a stream and wait for a digit, returning the digit that was pressed.
enum AST_LOCK_RESULT ast_lock_path(const char *path)
Lock a filesystem path.
A structure to hold the description of an application 'option'.
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_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...
static int silencethreshold
int ast_app_inboxcount(const char *mailbox, int *newmsgs, int *oldmsgs)
Determine number of new/old messages in a mailbox.
int ast_app_sayname(struct ast_channel *chan, const char *mailbox, const char *context)
Given a mailbox and context, play that mailbox owner's name to the channel specified.
int ast_app_inboxcount2(const char *mailbox, int *urgentmsgs, int *newmsgs, int *oldmsgs)
Determine number of urgent/new/old messages in a mailbox.
int ast_app_group_list_wrlock(void)
Write Lock the group count list.
struct ast_group_info * ast_app_group_list_head(void)
Get the head of the group count list.
uint64_t flag
The flag bit that represents this option.
int ast_get_encoded_char(const char *stream, char *result, size_t *consumed)
Decode an encoded control or extended ASCII character.
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
static int array(struct ast_channel *chan, const char *cmd, char *var, const char *value)
const char * ast_app_expand_sub_args(struct ast_channel *chan, const char *args)
Add missing context/exten to subroutine argument string.
Stack applications callback functions.
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
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_ivr_menu_run(struct ast_channel *c, struct ast_ivr_menu *menu, void *cbdata)
Runs an IVR menu.
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.
void ast_close_fds_above_n(int n)
Common routine for child processes, to close all fds prior to exec(2)
void ast_install_stack_functions(const struct ast_app_stack_funcs *funcs)
Set stack application function callbacks.
unsigned int arg_index
The index of the entry in the arguments array that should be used for this option's argument...
Structure used to handle boolean flags.
void ast_install_vm_functions(int(*has_voicemail_func)(const char *mailbox, const char *folder), int(*inboxcount_func)(const char *mailbox, int *newmsgs, int *oldmsgs), int(*inboxcount2_func)(const char *mailbox, int *urgentmsgs, int *newmsgs, int *oldmsgs), int(*messagecount_func)(const char *context, const char *mailbox, const char *folder), int(*sayname_func)(struct ast_channel *chan, const char *mailbox, const char *context))
Set voicemail function callbacks.
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_app_group_list_unlock(void)
Unlock the group count list.
int ast_app_group_update(struct ast_channel *oldchan, struct ast_channel *newchan)
Update all group counting for a channel to a new one.
void ast_set_lock_type(enum AST_LOCK_TYPE type)
Set the type of locks used by ast_lock_path()
AST_LOCK_TYPE
Type of locking to use in ast_lock_path / ast_unlock_path.
int ast_app_group_get_count(const char *group, const char *category)
Get the current channel count of the specified group and category.
static struct ast_str * prompt
static char context[AST_MAX_CONTEXT]
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_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.
int ast_app_messagecount(const char *context, const char *mailbox, const char *folder)
Check number of messages in a given context, mailbox, and folder.
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_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_group_list_rdlock(void)
Read Lock the group count list.
char * ast_read_textfile(const char *file)
Read a file into asterisk.
void ast_replace_sigchld(void)
Replace the SIGCHLD handler.
static char mailbox[AST_MAX_EXTENSION]
void ast_uninstall_vm_functions(void)