This graph shows which files directly or indirectly include this file:
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_group_info |
struct | ast_ivr_menu |
struct | ast_ivr_option |
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_DECLARE_APP_ARGS(name, arglist) |
Declare a structure to hold the application's arguments. | |
#define | AST_IVR_DECLARE_MENU(holder, title, flags, foo...) |
#define | AST_IVR_FLAG_AUTORESTART (1 << 0) |
#define | AST_NONSTANDARD_APP_ARGS(args, parse, sep) args.argc = ast_app_separate_args(parse, sep, args.argv, (sizeof(args) - sizeof(args.argc)) / sizeof(args.argv[0])) |
Performs the 'nonstandard' argument separation process for an application. | |
#define | AST_STANDARD_APP_ARGS(args, parse) args.argc = ast_app_separate_args(parse, '|', args.argv, (sizeof(args) - sizeof(args.argc)) / sizeof(args.argv[0])) |
Performs the 'standard' argument separation process for an application. | |
#define | BEGIN_OPTIONS { |
#define | END_OPTIONS } |
Typedefs | |
typedef int(*) | ast_ivr_callback (struct ast_channel *chan, char *option, void *cbdata) |
Callback function for IVR. | |
Enumerations | |
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 } |
Functions | |
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_getdata (struct ast_channel *c, 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, 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) |
int | ast_app_group_get_count (const char *group, const char *category) |
ast_group_info * | ast_app_group_list_head (void) |
int | ast_app_group_list_lock (void) |
int | ast_app_group_list_unlock (void) |
int | ast_app_group_match_get_count (const char *groupmatch, const char *category) |
int | ast_app_group_set_channel (struct ast_channel *chan, const char *data) |
int | ast_app_group_split_group (const char *data, char *group, int group_max, char *category, int category_max) |
int | ast_app_group_update (struct ast_channel *old, struct ast_channel *new) |
int | ast_app_has_voicemail (const char *mailbox, const char *folder) |
int | ast_app_inboxcount (const char *mailbox, int *newmsgs, int *oldmsgs) |
int | ast_app_messagecount (const char *context, const char *mailbox, const char *folder) |
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. | |
unsigned int | ast_app_separate_args (char *buf, char delim, char **array, int arraylen) |
Separate a string into arguments in an array. | |
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) |
int | ast_dtmf_stream (struct ast_channel *chan, struct ast_channel *peer, const char *digits, int between) |
Send DTMF to a channel. | |
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(*messagecount_func)(const char *context, const char *mailbox, const char *folder)) |
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) |
enum AST_LOCK_RESULT | ast_lock_path (const char *path) |
Lock a filesystem path. | |
int | ast_play_and_prepend (struct ast_channel *chan, char *playfile, char *recordfile, int maxtime_sec, char *fmt, int *duration, int beep, int silencethreshold, int maxsilence_ms) |
int | ast_play_and_record (struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime_sec, const char *fmt, int *duration, int silencethreshold, int maxsilence_ms, const char *path) |
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 silencethreshold, int maxsilence_ms, const char *path, const char *acceptdtmf, const char *canceldtmf) |
int | ast_play_and_wait (struct ast_channel *chan, const char *fn) |
char * | ast_read_textfile (const char *file) |
int | ast_record_review (struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime, const char *fmt, int *duration, const char *path) |
void | ast_replace_sigchld (void) |
Replace the SIGCHLD handler. | |
int | ast_safe_system (const char *s) |
void | ast_uninstall_vm_functions (void) |
int | ast_unlock_path (const char *path) |
void | ast_unreplace_sigchld (void) |
Restore the SIGCHLD handler. |
Definition in file app.h.
Define an application argument.
name | The name of the argument |
Definition at line 244 of file app.h.
Referenced by __login_exec(), acf_channel_read(), acf_curl_exec(), acf_odbc_read(), acf_odbc_write(), acf_rand_exec(), acf_sprintf(), acf_strftime(), acf_strptime(), acf_vmcount_exec(), add_agent(), admin_exec(), app_exec(), aqm_exec(), array(), astman_get_variables(), asyncgoto_exec(), auth_exec(), cdr_read(), cdr_write(), chanavail_exec(), checkmd5(), conf_exec(), count_exec(), cut_internal(), dictate_exec(), directory_exec(), disa_exec(), filter(), find_conf(), func_header_read(), function_agent(), function_db_delete(), function_db_exists(), function_db_read(), function_db_write(), function_enum(), function_fieldqty(), function_realtime_read(), function_realtime_write(), gosub_exec(), gosubif_exec(), hash_read(), hash_write(), hasvoicemail_exec(), init_acf_query(), isAnsweringMachine(), math(), misdn_check_l2l1(), mixmonitor_exec(), ospauth_exec(), ospfinished_exec(), osplookup_exec(), ospnext_exec(), pbx_builtin_background(), pbx_builtin_waitexten(), playback_exec(), pqm_exec(), privacy_exec(), ql_exec(), queue_exec(), read_exec(), record_exec(), regex(), reload_queues(), rqm_exec(), sayunixtime_exec(), sendimage_exec(), sendtext_exec(), transfer_exec(), upqm_exec(), userevent_exec(), vm_box_exists(), vm_exec(), and vm_execmain().
#define AST_APP_OPTION | ( | option, | |||
flagno | ) | [option] = { .flag = flagno } |
Declares an application option that does not accept an argument.
option | The single character representing the option | |
flagno | The flag index to be set if this option is present |
#define AST_APP_OPTION_ARG | ( | option, | |||
flagno, | |||||
argno | ) | [option] = { .flag = flagno, .arg_index = argno + 1 } |
Declares an application option that accepts an argument.
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 |
#define AST_APP_OPTIONS | ( | holder, | |||
options... | ) | static const struct ast_app_option holder[128] = options |
Declares an array of options for an application.
holder | The name of the array to be created | |
options | The actual options to be placed into the array |
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 { OPT_JUMP = (1 << 0), OPT_BLAH = (1 << 1), OPT_BLORT = (1 << 2), } my_app_option_flags; enum { 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, } my_app_option_args; 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_parseoptions(my_app_options, &opts, opt_args, options)) { LOCAL_USER_REMOVE(u); return -1; } }
#define AST_DECLARE_APP_ARGS | ( | name, | |||
arglist | ) |
Value:
struct { \ unsigned int argc; \ char *argv[0]; \ arglist \ } name
name | The name of the structure | |
arglist | The list of arguments, defined using AST_APP_ARG |
Definition at line 261 of file app.h.
Referenced by __login_exec(), acf_channel_read(), acf_curl_exec(), acf_odbc_read(), acf_odbc_write(), acf_rand_exec(), acf_sprintf(), acf_strftime(), acf_strptime(), acf_vmcount_exec(), add_agent(), admin_exec(), app_exec(), aqm_exec(), array(), astman_get_variables(), asyncgoto_exec(), auth_exec(), cdr_read(), cdr_write(), chanavail_exec(), checkmd5(), conf_exec(), count_exec(), cut_internal(), dictate_exec(), directory_exec(), disa_exec(), filter(), find_conf(), func_header_read(), function_agent(), function_db_delete(), function_db_exists(), function_db_read(), function_db_write(), function_enum(), function_fieldqty(), function_realtime_read(), function_realtime_write(), gosub_exec(), gosubif_exec(), hash_read(), hash_write(), hasvoicemail_exec(), init_acf_query(), isAnsweringMachine(), math(), misdn_check_l2l1(), mixmonitor_exec(), ospauth_exec(), ospfinished_exec(), osplookup_exec(), ospnext_exec(), pbx_builtin_background(), pbx_builtin_waitexten(), playback_exec(), pqm_exec(), privacy_exec(), ql_exec(), queue_exec(), read_exec(), record_exec(), regex(), reload_queues(), rqm_exec(), sayunixtime_exec(), sendimage_exec(), sendtext_exec(), transfer_exec(), upqm_exec(), userevent_exec(), vm_box_exists(), vm_exec(), and vm_execmain().
#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 }
#define AST_NONSTANDARD_APP_ARGS | ( | args, | |||
parse, | |||||
sep | ) | args.argc = ast_app_separate_args(parse, sep, args.argv, (sizeof(args) - sizeof(args.argc)) / sizeof(args.argv[0])) |
Performs the 'nonstandard' argument separation process for an application.
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 |
Definition at line 290 of file app.h.
Referenced by acf_odbc_write(), add_agent(), array(), find_conf(), function_agent(), function_db_delete(), function_db_exists(), function_db_read(), function_db_write(), gosubif_exec(), hash_read(), init_acf_query(), record_exec(), regex(), and reload_queues().
#define AST_STANDARD_APP_ARGS | ( | args, | |||
parse | ) | args.argc = ast_app_separate_args(parse, '|', args.argv, (sizeof(args) - sizeof(args.argc)) / sizeof(args.argv[0])) |
Performs the 'standard' argument separation process for an application.
args | An argument structure defined using AST_DECLARE_APP_ARGS | |
parse | A modifiable buffer containing the input to be parsed |
Definition at line 277 of file app.h.
Referenced by __login_exec(), acf_channel_read(), acf_curl_exec(), acf_odbc_read(), acf_odbc_write(), acf_rand_exec(), acf_sprintf(), acf_strftime(), acf_strptime(), acf_vmcount_exec(), admin_exec(), app_exec(), aqm_exec(), array(), astman_get_variables(), asyncgoto_exec(), auth_exec(), cdr_read(), cdr_write(), chanavail_exec(), checkmd5(), conf_exec(), count_exec(), cut_internal(), dictate_exec(), directory_exec(), disa_exec(), filter(), func_header_read(), function_enum(), function_fieldqty(), function_realtime_read(), function_realtime_write(), gosub_exec(), hash_read(), hash_write(), hasvoicemail_exec(), isAnsweringMachine(), math(), misdn_check_l2l1(), mixmonitor_exec(), ospauth_exec(), ospfinished_exec(), osplookup_exec(), ospnext_exec(), pbx_builtin_background(), pbx_builtin_waitexten(), playback_exec(), pqm_exec(), privacy_exec(), ql_exec(), queue_exec(), read_exec(), rqm_exec(), sayunixtime_exec(), sendimage_exec(), sendtext_exec(), transfer_exec(), upqm_exec(), userevent_exec(), vm_box_exists(), vm_exec(), and vm_execmain().
typedef int(*) ast_ivr_callback(struct ast_channel *chan, char *option, void *cbdata) |
enum ast_ivr_action |
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[] |
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 37 of file app.h.
00037 { 00038 AST_ACTION_UPONE, /*!< adata is unused */ 00039 AST_ACTION_EXIT, /*!< adata is the return value for ast_ivr_menu_run if channel was not hungup */ 00040 AST_ACTION_CALLBACK, /*!< adata is an ast_ivr_callback */ 00041 AST_ACTION_PLAYBACK, /*!< adata is file to play */ 00042 AST_ACTION_BACKGROUND, /*!< adata is file to play */ 00043 AST_ACTION_PLAYLIST, /*!< adata is list of files, separated by ; to play */ 00044 AST_ACTION_MENU, /*!< adata is a pointer to an ast_ivr_menu */ 00045 AST_ACTION_REPEAT, /*!< adata is max # of repeats, cast to a pointer */ 00046 AST_ACTION_RESTART, /*!< adata is like repeat, but resets repeats to 0 */ 00047 AST_ACTION_TRANSFER, /*!< adata is a string with exten[@context] */ 00048 AST_ACTION_WAITOPTION, /*!< adata is a timeout, or 0 for defaults */ 00049 AST_ACTION_NOOP, /*!< adata is unused */ 00050 AST_ACTION_BACKLIST, /*!< adata is list of files separated by ; allows interruption */ 00051 } ast_ivr_action;
enum AST_LOCK_RESULT |
Definition at line 186 of file app.h.
00186 { 00187 AST_LOCK_SUCCESS = 0, 00188 AST_LOCK_TIMEOUT = -1, 00189 AST_LOCK_PATH_NOT_FOUND = -2, 00190 AST_LOCK_FAILURE = -3, 00191 };
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.
Definition at line 65 of file app.c.
References ast_exists_extension(), ast_get_indication_tone(), ast_ignore_pattern(), ast_log(), ast_matchmore_extension(), ast_playtones_start(), ast_playtones_stop(), ast_waitfordigit(), ast_channel::cid, ast_callerid::cid_num, tone_zone_sound::data, ast_pbx::dtimeout, LOG_NOTICE, ast_channel::pbx, and ast_channel::zone.
Referenced by builtin_atxfer(), and builtin_blindtransfer().
00066 { 00067 struct tone_zone_sound *ts; 00068 int res=0, x=0; 00069 00070 if (maxlen > size) 00071 maxlen = size; 00072 00073 if (!timeout && chan->pbx) 00074 timeout = chan->pbx->dtimeout; 00075 else if (!timeout) 00076 timeout = 5; 00077 00078 ts = ast_get_indication_tone(chan->zone,"dial"); 00079 if (ts && ts->data[0]) 00080 res = ast_playtones_start(chan, 0, ts->data, 0); 00081 else 00082 ast_log(LOG_NOTICE,"Huh....? no dial for indications?\n"); 00083 00084 for (x = strlen(collect); x < maxlen; ) { 00085 res = ast_waitfordigit(chan, timeout); 00086 if (!ast_ignore_pattern(context, collect)) 00087 ast_playtones_stop(chan); 00088 if (res < 1) 00089 break; 00090 if (res == '#') 00091 break; 00092 collect[x++] = res; 00093 if (!ast_matchmore_extension(chan, context, collect, 1, chan->cid.cid_num)) 00094 break; 00095 } 00096 if (res >= 0) 00097 res = ast_exists_extension(chan, context, collect, 1, chan->cid.cid_num) ? 1 : 0; 00098 return res; 00099 }
int ast_app_getdata | ( | struct ast_channel * | c, | |
char * | prompt, | |||
char * | s, | |||
int | maxlen, | |||
int | timeout | |||
) |
Plays a stream and gets DTMF data from a channel.
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) |
Definition at line 107 of file app.c.
References AST_DIGIT_ANY, ast_readstring(), ast_stopstream(), ast_strdupa, ast_streamfile(), ast_waitstream(), ast_pbx::dtimeout, ast_channel::pbx, result, ast_pbx::rtimeout, and strsep().
Referenced by __login_exec(), auth_exec(), conf_exec(), dictate_exec(), find_conf(), read_exec(), testclient_exec(), testserver_exec(), and vm_exec().
00108 { 00109 int res=0,to,fto, result=0; 00110 /* XXX Merge with full version? XXX */ 00111 if (maxlen) 00112 s[0] = '\0'; 00113 if (prompt) { 00114 char *front; 00115 char *temp = ast_strdupa(prompt); 00116 while(!res && (front = strsep(&temp, "&"))) { 00117 if( (res = ast_streamfile(c, front, c->language)) ) { 00118 res = 0; 00119 break; 00120 } 00121 if(!res && !result) 00122 result = ast_waitstream(c, AST_DIGIT_ANY); 00123 if(result) 00124 break; 00125 ast_stopstream(c); 00126 } 00127 } 00128 fto = c->pbx ? c->pbx->rtimeout * 1000 : 6000; 00129 to = c->pbx ? c->pbx->dtimeout * 1000 : 2000; 00130 00131 if (timeout > 0) 00132 fto = to = timeout; 00133 if (timeout < 0) 00134 fto = to = 1000000000; 00135 res = ast_readstring(c, s, maxlen, to, fto, "#"); 00136 if(result) { 00137 char tmp[256]; 00138 snprintf(tmp, sizeof(tmp), "%c%s", result, s); 00139 snprintf(s, sizeof(tmp), "%s", tmp); 00140 } 00141 return res; 00142 }
int ast_app_getdata_full | ( | struct ast_channel * | c, | |
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.
Definition at line 145 of file app.c.
References ast_readstring_full(), and ast_streamfile().
Referenced by handle_getdata().
00146 { 00147 int res, to, fto; 00148 if (prompt) { 00149 res = ast_streamfile(c, prompt, c->language); 00150 if (res < 0) 00151 return res; 00152 } 00153 fto = 6000; 00154 to = 2000; 00155 if (timeout > 0) 00156 fto = to = timeout; 00157 if (timeout < 0) 00158 fto = to = 1000000000; 00159 res = ast_readstring_full(c, s, maxlen, to, fto, "#", audiofd, ctrlfd); 00160 return res; 00161 }
int ast_app_group_discard | ( | struct ast_channel * | chan | ) |
Discard all group counting for a channel
Definition at line 912 of file app.c.
References AST_LIST_LOCK, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, AST_LIST_UNLOCK, ast_group_info::chan, and free.
Referenced by ast_channel_free().
00913 { 00914 struct ast_group_info *gi = NULL; 00915 00916 AST_LIST_LOCK(&groups); 00917 AST_LIST_TRAVERSE_SAFE_BEGIN(&groups, gi, list) { 00918 if (gi->chan == chan) { 00919 AST_LIST_REMOVE_CURRENT(&groups, list); 00920 free(gi); 00921 } 00922 } 00923 AST_LIST_TRAVERSE_SAFE_END 00924 AST_LIST_UNLOCK(&groups); 00925 00926 return 0; 00927 }
int ast_app_group_get_count | ( | const char * | group, | |
const char * | category | |||
) |
Get the current channel count of the specified group and category.
Definition at line 855 of file app.c.
References AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_strlen_zero(), ast_group_info::category, and ast_group_info::group.
Referenced by group_count_function_read().
00856 { 00857 struct ast_group_info *gi = NULL; 00858 int count = 0; 00859 00860 if (ast_strlen_zero(group)) 00861 return 0; 00862 00863 AST_LIST_LOCK(&groups); 00864 AST_LIST_TRAVERSE(&groups, gi, list) { 00865 if (!strcasecmp(gi->group, group) && (ast_strlen_zero(category) || !strcasecmp(gi->category, category))) 00866 count++; 00867 } 00868 AST_LIST_UNLOCK(&groups); 00869 00870 return count; 00871 }
struct ast_group_info* ast_app_group_list_head | ( | void | ) |
Get the head of the group count list
Definition at line 934 of file app.c.
References AST_LIST_FIRST.
Referenced by group_function_read(), group_list_function_read(), and group_show_channels().
00935 { 00936 return AST_LIST_FIRST(&groups); 00937 }
int ast_app_group_list_lock | ( | void | ) |
Lock the group count list
Definition at line 929 of file app.c.
References AST_LIST_LOCK.
Referenced by group_function_read(), group_list_function_read(), and group_show_channels().
00930 { 00931 return AST_LIST_LOCK(&groups); 00932 }
int ast_app_group_list_unlock | ( | void | ) |
Unlock the group count list
Definition at line 939 of file app.c.
References AST_LIST_UNLOCK.
Referenced by group_function_read(), group_list_function_read(), and group_show_channels().
00940 { 00941 return AST_LIST_UNLOCK(&groups); 00942 }
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.
Definition at line 873 of file app.c.
References AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_strlen_zero(), ast_group_info::category, and ast_group_info::group.
Referenced by group_match_count_function_read().
00874 { 00875 struct ast_group_info *gi = NULL; 00876 regex_t regexbuf; 00877 int count = 0; 00878 00879 if (ast_strlen_zero(groupmatch)) 00880 return 0; 00881 00882 /* if regex compilation fails, return zero matches */ 00883 if (regcomp(®exbuf, groupmatch, REG_EXTENDED | REG_NOSUB)) 00884 return 0; 00885 00886 AST_LIST_LOCK(&groups); 00887 AST_LIST_TRAVERSE(&groups, gi, list) { 00888 if (!regexec(®exbuf, gi->group, 0, NULL, 0) && (ast_strlen_zero(category) || !strcasecmp(gi->category, category))) 00889 count++; 00890 } 00891 AST_LIST_UNLOCK(&groups); 00892 00893 regfree(®exbuf); 00894 00895 return count; 00896 }
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.
Definition at line 816 of file app.c.
References ast_app_group_split_group(), AST_LIST_INSERT_TAIL, AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_strlen_zero(), calloc, ast_group_info::category, ast_group_info::chan, ast_group_info::group, group, and len.
Referenced by group_function_write().
00817 { 00818 int res = 0; 00819 char group[80] = "", category[80] = ""; 00820 struct ast_group_info *gi = NULL; 00821 size_t len = 0; 00822 00823 if (ast_app_group_split_group(data, group, sizeof(group), category, sizeof(category))) 00824 return -1; 00825 00826 /* Calculate memory we will need if this is new */ 00827 len = sizeof(*gi) + strlen(group) + 1; 00828 if (!ast_strlen_zero(category)) 00829 len += strlen(category) + 1; 00830 00831 AST_LIST_LOCK(&groups); 00832 AST_LIST_TRAVERSE(&groups, gi, list) { 00833 if (gi->chan == chan && !strcasecmp(gi->group, group) && (ast_strlen_zero(category) || (!ast_strlen_zero(gi->category) && !strcasecmp(gi->category, category)))) 00834 break; 00835 } 00836 00837 if (!gi && (gi = calloc(1, len))) { 00838 gi->chan = chan; 00839 gi->group = (char *) gi + sizeof(*gi); 00840 strcpy(gi->group, group); 00841 if (!ast_strlen_zero(category)) { 00842 gi->category = (char *) gi + sizeof(*gi) + strlen(group) + 1; 00843 strcpy(gi->category, category); 00844 } 00845 AST_LIST_INSERT_TAIL(&groups, gi, list); 00846 } else { 00847 res = -1; 00848 } 00849 00850 AST_LIST_UNLOCK(&groups); 00851 00852 return res; 00853 }
int ast_app_group_split_group | ( | const char * | data, | |
char * | group, | |||
int | group_max, | |||
char * | category, | |||
int | category_max | |||
) |
Split a group string into group and category, returning a default category if none is provided.
Definition at line 789 of file app.c.
References ast_strlen_zero().
Referenced by ast_app_group_set_channel(), group_count_function_read(), and group_match_count_function_read().
00790 { 00791 int res=0; 00792 char tmp[256]; 00793 char *grp=NULL, *cat=NULL; 00794 00795 if (!ast_strlen_zero(data)) { 00796 ast_copy_string(tmp, data, sizeof(tmp)); 00797 grp = tmp; 00798 cat = strchr(tmp, '@'); 00799 if (cat) { 00800 *cat = '\0'; 00801 cat++; 00802 } 00803 } 00804 00805 if (!ast_strlen_zero(grp)) 00806 ast_copy_string(group, grp, group_max); 00807 else 00808 res = -1; 00809 00810 if (!ast_strlen_zero(cat)) 00811 ast_copy_string(category, cat, category_max); 00812 00813 return res; 00814 }
int ast_app_group_update | ( | struct ast_channel * | old, | |
struct ast_channel * | new | |||
) |
Update all group counting for a channel to a new one
Definition at line 898 of file app.c.
References AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, and ast_group_info::chan.
00899 { 00900 struct ast_group_info *gi = NULL; 00901 00902 AST_LIST_LOCK(&groups); 00903 AST_LIST_TRAVERSE(&groups, gi, list) { 00904 if (gi->chan == old) 00905 gi->chan = new; 00906 } 00907 AST_LIST_UNLOCK(&groups); 00908 00909 return 0; 00910 }
int ast_app_has_voicemail | ( | const char * | mailbox, | |
const char * | folder | |||
) |
Determine if a given mailbox has any voicemail
Definition at line 183 of file app.c.
References ast_has_voicemail_func, ast_verbose(), option_verbose, and VERBOSE_PREFIX_3.
Referenced by action_mailboxstatus(), has_voicemail(), notify_new_message(), play_dialtone(), and run_externnotify().
00184 { 00185 static int warned = 0; 00186 if (ast_has_voicemail_func) 00187 return ast_has_voicemail_func(mailbox, folder); 00188 00189 if ((option_verbose > 2) && !warned) { 00190 ast_verbose(VERBOSE_PREFIX_3 "Message check requested for mailbox %s/folder %s but voicemail not loaded.\n", mailbox, folder ? folder : "INBOX"); 00191 warned++; 00192 } 00193 return 0; 00194 }
int ast_app_inboxcount | ( | const char * | mailbox, | |
int * | newmsgs, | |||
int * | oldmsgs | |||
) |
Determine number of new/old messages in a mailbox
Definition at line 197 of file app.c.
References ast_inboxcount_func, ast_verbose(), option_verbose, and VERBOSE_PREFIX_3.
Referenced by action_mailboxcount(), notify_new_message(), sip_send_mwi_to_peer(), and update_registry().
00198 { 00199 static int warned = 0; 00200 if (newmsgs) 00201 *newmsgs = 0; 00202 if (oldmsgs) 00203 *oldmsgs = 0; 00204 if (ast_inboxcount_func) 00205 return ast_inboxcount_func(mailbox, newmsgs, oldmsgs); 00206 00207 if (!warned && (option_verbose > 2)) { 00208 warned++; 00209 ast_verbose(VERBOSE_PREFIX_3 "Message count requested for mailbox %s but voicemail not loaded.\n", mailbox); 00210 } 00211 00212 return 0; 00213 }
int ast_app_messagecount | ( | const char * | context, | |
const char * | mailbox, | |||
const char * | folder | |||
) |
Determine number of messages in a given mailbox and folder
Definition at line 215 of file app.c.
References ast_messagecount_func, ast_verbose(), option_verbose, and VERBOSE_PREFIX_3.
Referenced by acf_vmcount_exec(), and hasvoicemail_exec().
00216 { 00217 static int warned = 0; 00218 if (ast_messagecount_func) 00219 return ast_messagecount_func(context, mailbox, folder); 00220 00221 if (!warned && (option_verbose > 2)) { 00222 warned++; 00223 ast_verbose(VERBOSE_PREFIX_3 "Message count requested for mailbox %s@%s/%s but voicemail not loaded.\n", mailbox, context, folder); 00224 } 00225 00226 return 0; 00227 }
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.
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 |
Definition at line 1379 of file app.c.
References ast_app_option::arg_index, ast_clear_flag, AST_FLAGS_ALL, ast_log(), ast_set_flag, LOG_WARNING, and s.
Referenced by app_exec(), auth_exec(), cdr_read(), cdr_write(), chanspy_exec(), conf_exec(), extenspy_exec(), mixmonitor_exec(), page_exec(), pbx_builtin_background(), pbx_builtin_resetcdr(), pbx_builtin_waitexten(), read_exec(), vm_exec(), and vm_execmain().
01380 { 01381 char *s; 01382 int curarg; 01383 unsigned int argloc; 01384 char *arg; 01385 int res = 0; 01386 01387 ast_clear_flag(flags, AST_FLAGS_ALL); 01388 01389 if (!optstr) 01390 return 0; 01391 01392 s = optstr; 01393 while (*s) { 01394 curarg = *s++ & 0x7f; /* the array (in app.h) has 128 entries */ 01395 ast_set_flag(flags, options[curarg].flag); 01396 argloc = options[curarg].arg_index; 01397 if (*s == '(') { 01398 /* Has argument */ 01399 arg = ++s; 01400 if ((s = strchr(s, ')'))) { 01401 if (argloc) 01402 args[argloc - 1] = arg; 01403 *s++ = '\0'; 01404 } else { 01405 ast_log(LOG_WARNING, "Missing closing parenthesis for argument '%c' in string '%s'\n", curarg, arg); 01406 res = -1; 01407 break; 01408 } 01409 } else if (argloc) { 01410 args[argloc - 1] = NULL; 01411 } 01412 } 01413 01414 return res; 01415 }
unsigned int ast_app_separate_args | ( | char * | buf, | |
char | delim, | |||
char ** | array, | |||
int | arraylen | |||
) |
Separate a string into arguments in an array.
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 | |
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) |
The array will be completely zeroed by this function before it populates any entries.
Definition at line 944 of file app.c.
References quote().
Referenced by app_exec(), chanspy_exec(), common_exec(), controlplayback_exec(), extenspy_exec(), pbx_builtin_setvar(), speech_background(), and speech_load().
00945 { 00946 int argc; 00947 char *scan; 00948 int paren = 0, quote = 0; 00949 00950 if (!buf || !array || !arraylen) 00951 return 0; 00952 00953 memset(array, 0, arraylen * sizeof(*array)); 00954 00955 scan = buf; 00956 00957 for (argc = 0; *scan && (argc < arraylen - 1); argc++) { 00958 array[argc] = scan; 00959 for (; *scan; scan++) { 00960 if (*scan == '(') 00961 paren++; 00962 else if (*scan == ')') { 00963 if (paren) 00964 paren--; 00965 } else if (*scan == '"' && delim != '"') { 00966 quote = quote ? 0 : 1; 00967 /* Remove quote character from argument */ 00968 memmove(scan, scan + 1, strlen(scan)); 00969 scan--; 00970 } else if (*scan == '\\') { 00971 /* Literal character, don't parse */ 00972 memmove(scan, scan + 1, strlen(scan)); 00973 } else if ((*scan == delim) && !paren && !quote) { 00974 *scan++ = '\0'; 00975 break; 00976 } 00977 } 00978 } 00979 00980 if (*scan) 00981 array[argc++] = scan; 00982 00983 return argc; 00984 }
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 | |||
) |
Stream a file with fast forward, pause, reverse, restart.
Definition at line 377 of file app.c.
References ast_channel::_state, ast_answer(), ast_log(), ast_seekstream(), AST_STATE_UP, ast_stopstream(), ast_streamfile(), ast_tellstream(), ast_waitfordigit(), ast_waitstream_fr(), LOG_DEBUG, option_debug, and ast_channel::stream.
Referenced by controlplayback_exec(), handle_controlstreamfile(), and wait_file().
00381 { 00382 char *breaks = NULL; 00383 char *end = NULL; 00384 int blen = 2; 00385 int res; 00386 long pause_restart_point = 0; 00387 00388 if (stop) 00389 blen += strlen(stop); 00390 if (pause) 00391 blen += strlen(pause); 00392 if (restart) 00393 blen += strlen(restart); 00394 00395 if (blen > 2) { 00396 breaks = alloca(blen + 1); 00397 breaks[0] = '\0'; 00398 if (stop) 00399 strcat(breaks, stop); 00400 if (pause) 00401 strcat(breaks, pause); 00402 if (restart) 00403 strcat(breaks, restart); 00404 } 00405 if (chan->_state != AST_STATE_UP) 00406 res = ast_answer(chan); 00407 00408 if (file) { 00409 if ((end = strchr(file,':'))) { 00410 if (!strcasecmp(end, ":end")) { 00411 *end = '\0'; 00412 end++; 00413 } 00414 } 00415 } 00416 00417 for (;;) { 00418 ast_stopstream(chan); 00419 res = ast_streamfile(chan, file, chan->language); 00420 if (!res) { 00421 if (pause_restart_point) { 00422 ast_seekstream(chan->stream, pause_restart_point, SEEK_SET); 00423 pause_restart_point = 0; 00424 } 00425 else if (end) { 00426 ast_seekstream(chan->stream, 0, SEEK_END); 00427 end = NULL; 00428 }; 00429 res = ast_waitstream_fr(chan, breaks, fwd, rev, skipms); 00430 } 00431 00432 if (res < 1) 00433 break; 00434 00435 /* We go at next loop if we got the restart char */ 00436 if (restart && strchr(restart, res)) { 00437 if (option_debug) 00438 ast_log(LOG_DEBUG, "we'll restart the stream here at next loop\n"); 00439 pause_restart_point = 0; 00440 continue; 00441 } 00442 00443 if (pause && strchr(pause, res)) { 00444 pause_restart_point = ast_tellstream(chan->stream); 00445 for (;;) { 00446 ast_stopstream(chan); 00447 res = ast_waitfordigit(chan, 1000); 00448 if (!res) 00449 continue; 00450 else if (res == -1 || strchr(pause, res) || (stop && strchr(stop, res))) 00451 break; 00452 } 00453 if (res == *pause) { 00454 res = 0; 00455 continue; 00456 } 00457 } 00458 00459 if (res == -1) 00460 break; 00461 00462 /* if we get one of our stop chars, return it to the calling function */ 00463 if (stop && strchr(stop, res)) 00464 break; 00465 } 00466 00467 ast_stopstream(chan); 00468 00469 return res; 00470 }
int ast_dtmf_stream | ( | struct ast_channel * | chan, | |
struct ast_channel * | peer, | |||
const char * | digits, | |||
int | between | |||
) |
Send DTMF to a channel.
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. |
Definition at line 229 of file app.c.
References ast_autoservice_start(), ast_autoservice_stop(), AST_CONTROL_FLASH, ast_indicate(), ast_log(), ast_safe_sleep(), ast_senddigit(), ast_waitfor(), and LOG_WARNING.
Referenced by ast_bridge_call(), misdn_send_digit(), senddtmf_exec(), test1_client(), test1_server(), testclient_exec(), and testserver_exec().
00230 { 00231 const char *ptr; 00232 int res = 0; 00233 00234 if (!between) 00235 between = 100; 00236 00237 if (peer) 00238 res = ast_autoservice_start(peer); 00239 00240 if (!res) 00241 res = ast_waitfor(chan, 100); 00242 00243 /* ast_waitfor will return the number of remaining ms on success */ 00244 if (res < 0) 00245 return res; 00246 00247 for (ptr = digits; *ptr; ptr++) { 00248 if (*ptr == 'w') { 00249 /* 'w' -- wait half a second */ 00250 if ((res = ast_safe_sleep(chan, 500))) 00251 break; 00252 } else if (strchr("0123456789*#abcdfABCDF", *ptr)) { 00253 /* Character represents valid DTMF */ 00254 if (*ptr == 'f' || *ptr == 'F') { 00255 /* ignore return values if not supported by channel */ 00256 ast_indicate(chan, AST_CONTROL_FLASH); 00257 } else 00258 ast_senddigit(chan, *ptr); 00259 /* pause between digits */ 00260 if ((res = ast_safe_sleep(chan, between))) 00261 break; 00262 } else 00263 ast_log(LOG_WARNING, "Illegal DTMF character '%c' in string. (0-9*#aAbBcCdD allowed)\n",*ptr); 00264 } 00265 00266 if (peer) { 00267 /* Stop autoservice on the peer channel, but don't overwrite any error condition 00268 that has occurred previously while acting on the primary channel */ 00269 if (ast_autoservice_stop(peer) && !res) 00270 res = -1; 00271 } 00272 00273 return res; 00274 }
void ast_install_vm_functions | ( | int(*)(const char *mailbox, const char *folder) | has_voicemail_func, | |
int(*)(const char *mailbox, int *newmsgs, int *oldmsgs) | inboxcount_func, | |||
int(*)(const char *context, const char *mailbox, const char *folder) | messagecount_func | |||
) |
Definition at line 167 of file app.c.
References ast_has_voicemail_func, ast_inboxcount_func, and ast_messagecount_func.
Referenced by load_module().
00170 { 00171 ast_has_voicemail_func = has_voicemail_func; 00172 ast_inboxcount_func = inboxcount_func; 00173 ast_messagecount_func = messagecount_func; 00174 }
int ast_ivr_menu_run | ( | struct ast_channel * | c, | |
struct ast_ivr_menu * | menu, | |||
void * | cbdata | |||
) |
Runs an IVR menu.
Definition at line 1341 of file app.c.
References ast_ivr_menu_run_internal().
Referenced by skel_exec().
01342 { 01343 int res = ast_ivr_menu_run_internal(chan, menu, cbdata); 01344 /* Hide internal coding */ 01345 return res > 0 ? 0 : res; 01346 }
int ast_linear_stream | ( | struct ast_channel * | chan, | |
const char * | filename, | |||
int | fd, | |||
int | allowoverride | |||
) |
Stream a filename (or file descriptor) as a generator.
Definition at line 348 of file app.c.
References ast_activate_generator(), ast_calloc, ast_config_AST_DATA_DIR, ast_log(), ast_strlen_zero(), linear_state::autoclose, linearstream, and LOG_WARNING.
00349 { 00350 struct linear_state *lin; 00351 char tmpf[256]; 00352 int res = -1; 00353 int autoclose = 0; 00354 if (fd < 0) { 00355 if (ast_strlen_zero(filename)) 00356 return -1; 00357 autoclose = 1; 00358 if (filename[0] == '/') 00359 ast_copy_string(tmpf, filename, sizeof(tmpf)); 00360 else 00361 snprintf(tmpf, sizeof(tmpf), "%s/%s/%s", (char *)ast_config_AST_DATA_DIR, "sounds", filename); 00362 fd = open(tmpf, O_RDONLY); 00363 if (fd < 0){ 00364 ast_log(LOG_WARNING, "Unable to open file '%s': %s\n", tmpf, strerror(errno)); 00365 return -1; 00366 } 00367 } 00368 if ((lin = ast_calloc(1, sizeof(*lin)))) { 00369 lin->fd = fd; 00370 lin->allowoverride = allowoverride; 00371 lin->autoclose = autoclose; 00372 res = ast_activate_generator(chan, &linearstream, lin); 00373 } 00374 return res; 00375 }
enum AST_LOCK_RESULT ast_lock_path | ( | const char * | path | ) |
Lock a filesystem path.
path | the path to be locked |
Definition at line 986 of file app.c.
References AST_LOCK_FAILURE, AST_LOCK_PATH_NOT_FOUND, AST_LOCK_SUCCESS, AST_LOCK_TIMEOUT, ast_log(), ast_random(), LOG_DEBUG, LOG_ERROR, LOG_WARNING, option_debug, and s.
Referenced by vm_lock_path().
00987 { 00988 char *s; 00989 char *fs; 00990 int res; 00991 int fd; 00992 int lp = strlen(path); 00993 time_t start; 00994 00995 if (!(s = alloca(lp + 10)) || !(fs = alloca(lp + 20))) { 00996 ast_log(LOG_WARNING, "Out of memory!\n"); 00997 return AST_LOCK_FAILURE; 00998 } 00999 01000 snprintf(fs, strlen(path) + 19, "%s/.lock-%08lx", path, ast_random()); 01001 fd = open(fs, O_WRONLY | O_CREAT | O_EXCL, 0600); 01002 if (fd < 0) { 01003 ast_log(LOG_ERROR, "Unable to create lock file '%s': %s\n", path, strerror(errno)); 01004 return AST_LOCK_PATH_NOT_FOUND; 01005 } 01006 close(fd); 01007 01008 snprintf(s, strlen(path) + 9, "%s/.lock", path); 01009 start = time(NULL); 01010 while (((res = link(fs, s)) < 0) && (errno == EEXIST) && (time(NULL) - start < 5)) 01011 usleep(1); 01012 01013 unlink(fs); 01014 01015 if (res) { 01016 ast_log(LOG_WARNING, "Failed to lock path '%s': %s\n", path, strerror(errno)); 01017 return AST_LOCK_TIMEOUT; 01018 } else { 01019 if (option_debug) 01020 ast_log(LOG_DEBUG, "Locked path '%s'\n", path); 01021 return AST_LOCK_SUCCESS; 01022 } 01023 }
int ast_play_and_prepend | ( | struct ast_channel * | chan, | |
char * | playfile, | |||
char * | recordfile, | |||
int | maxtime_sec, | |||
char * | fmt, | |||
int * | duration, | |||
int | beep, | |||
int | silencethreshold, | |||
int | maxsilence_ms | |||
) |
Record a message and prepend the message to the given record file after playing the optional playfile (or a beep), storing the duration in 'duration' and with a maximum
permitted silence time in milliseconds of 'maxsilence' under 'silencethreshold' or use '-1' for either or both parameters for defaults.
Definition at line 782 of file app.c.
References __ast_play_and_record().
Referenced by vm_forwardoptions().
00783 { 00784 return __ast_play_and_record(chan, playfile, recordfile, maxtime, fmt, duration, beep, silencethreshold, maxsilence, NULL, 1, default_acceptdtmf, default_canceldtmf); 00785 }
int ast_play_and_record | ( | struct ast_channel * | chan, | |
const char * | playfile, | |||
const char * | recordfile, | |||
int | maxtime_sec, | |||
const char * | fmt, | |||
int * | duration, | |||
int | silencethreshold, | |||
int | maxsilence_ms, | |||
const char * | path | |||
) |
Record a file for a max amount of time (in seconds), in a given list of formats separated by '|', outputting the duration of the recording, and with a maximum
permitted silence time in milliseconds of 'maxsilence' under 'silencethreshold' or use '-1' for either or both parameters for defaults. calls ast_unlock_path() on 'path' if passed
Definition at line 777 of file app.c.
References __ast_play_and_record().
Referenced by app_exec(), ast_record_review(), and conf_run().
00778 { 00779 return __ast_play_and_record(chan, playfile, recordfile, maxtime, fmt, duration, 0, silencethreshold, maxsilence, path, 0, default_acceptdtmf, default_canceldtmf); 00780 }
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 | silencethreshold, | |||
int | maxsilence_ms, | |||
const char * | path, | |||
const char * | acceptdtmf, | |||
const char * | canceldtmf | |||
) |
Definition at line 772 of file app.c.
References __ast_play_and_record(), and S_OR.
Referenced by play_record_review().
00773 { 00774 return __ast_play_and_record(chan, playfile, recordfile, maxtime, fmt, duration, 0, silencethreshold, maxsilence, path, 0, S_OR(acceptdtmf, default_acceptdtmf), S_OR(canceldtmf, default_canceldtmf)); 00775 }
int ast_play_and_wait | ( | struct ast_channel * | chan, | |
const char * | fn | |||
) |
Play a stream and wait for a digit, returning the digit that was pressed
Definition at line 472 of file app.c.
References AST_DIGIT_ANY, ast_stopstream(), ast_streamfile(), and ast_waitstream().
Referenced by __ast_play_and_record(), advanced_options(), ast_record_review(), dialout(), forward_message(), get_folder(), get_folder2(), leave_voicemail(), 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_it(), vm_browse_messages_pt(), vm_execmain(), vm_forwardoptions(), vm_instructions(), vm_intro(), vm_intro_cz(), vm_intro_de(), vm_intro_en(), vm_intro_es(), vm_intro_fr(), vm_intro_gr(), vm_intro_it(), vm_intro_nl(), vm_intro_no(), vm_intro_pl(), vm_intro_pt(), vm_intro_pt_BR(), vm_intro_ru(), vm_intro_se(), vm_newuser(), vm_options(), vm_play_folder_name(), vm_play_folder_name_gr(), vm_play_folder_name_pl(), vm_tempgreeting(), and vmauthenticate().
00473 { 00474 int d; 00475 d = ast_streamfile(chan, fn, chan->language); 00476 if (d) 00477 return d; 00478 d = ast_waitstream(chan, AST_DIGIT_ANY); 00479 ast_stopstream(chan); 00480 return d; 00481 }
char* ast_read_textfile | ( | const char * | file | ) |
Read a file into asterisk
Definition at line 1348 of file app.c.
References ast_log(), ast_malloc, free, and LOG_WARNING.
Referenced by readfile_exec().
01349 { 01350 int fd; 01351 char *output = NULL; 01352 struct stat filesize; 01353 int count = 0; 01354 int res; 01355 if (stat(filename, &filesize) == -1) { 01356 ast_log(LOG_WARNING, "Error can't stat %s\n", filename); 01357 return NULL; 01358 } 01359 count = filesize.st_size + 1; 01360 fd = open(filename, O_RDONLY); 01361 if (fd < 0) { 01362 ast_log(LOG_WARNING, "Cannot open file '%s' for reading: %s\n", filename, strerror(errno)); 01363 return NULL; 01364 } 01365 if ((output = ast_malloc(count))) { 01366 res = read(fd, output, count - 1); 01367 if (res == count - 1) { 01368 output[res] = '\0'; 01369 } else { 01370 ast_log(LOG_WARNING, "Short read of %s (%d of %d): %s\n", filename, res, count - 1, strerror(errno)); 01371 free(output); 01372 output = NULL; 01373 } 01374 } 01375 close(fd); 01376 return output; 01377 }
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
Definition at line 1047 of file app.c.
References AST_DIGIT_ANY, ast_log(), ast_play_and_record(), ast_play_and_wait(), ast_stream_and_wait(), ast_verbose(), ast_waitfordigit(), ast_group_info::chan, LOG_WARNING, maxsilence, silencethreshold, and VERBOSE_PREFIX_3.
Referenced by conf_run().
01048 { 01049 int silencethreshold = 128; 01050 int maxsilence=0; 01051 int res = 0; 01052 int cmd = 0; 01053 int max_attempts = 3; 01054 int attempts = 0; 01055 int recorded = 0; 01056 int message_exists = 0; 01057 /* Note that urgent and private are for flagging messages as such in the future */ 01058 01059 /* barf if no pointer passed to store duration in */ 01060 if (duration == NULL) { 01061 ast_log(LOG_WARNING, "Error ast_record_review called without duration pointer\n"); 01062 return -1; 01063 } 01064 01065 cmd = '3'; /* Want to start by recording */ 01066 01067 while ((cmd >= 0) && (cmd != 't')) { 01068 switch (cmd) { 01069 case '1': 01070 if (!message_exists) { 01071 /* In this case, 1 is to record a message */ 01072 cmd = '3'; 01073 break; 01074 } else { 01075 ast_stream_and_wait(chan, "vm-msgsaved", chan->language, ""); 01076 cmd = 't'; 01077 return res; 01078 } 01079 case '2': 01080 /* Review */ 01081 ast_verbose(VERBOSE_PREFIX_3 "Reviewing the recording\n"); 01082 cmd = ast_stream_and_wait(chan, recordfile, chan->language, AST_DIGIT_ANY); 01083 break; 01084 case '3': 01085 message_exists = 0; 01086 /* Record */ 01087 if (recorded == 1) 01088 ast_verbose(VERBOSE_PREFIX_3 "Re-recording\n"); 01089 else 01090 ast_verbose(VERBOSE_PREFIX_3 "Recording\n"); 01091 recorded = 1; 01092 cmd = ast_play_and_record(chan, playfile, recordfile, maxtime, fmt, duration, silencethreshold, maxsilence, path); 01093 if (cmd == -1) { 01094 /* User has hung up, no options to give */ 01095 return cmd; 01096 } 01097 if (cmd == '0') { 01098 break; 01099 } else if (cmd == '*') { 01100 break; 01101 } 01102 else { 01103 /* If all is well, a message exists */ 01104 message_exists = 1; 01105 cmd = 0; 01106 } 01107 break; 01108 case '4': 01109 case '5': 01110 case '6': 01111 case '7': 01112 case '8': 01113 case '9': 01114 case '*': 01115 case '#': 01116 cmd = ast_play_and_wait(chan, "vm-sorry"); 01117 break; 01118 default: 01119 if (message_exists) { 01120 cmd = ast_play_and_wait(chan, "vm-review"); 01121 } 01122 else { 01123 cmd = ast_play_and_wait(chan, "vm-torerecord"); 01124 if (!cmd) 01125 cmd = ast_waitfordigit(chan, 600); 01126 } 01127 01128 if (!cmd) 01129 cmd = ast_waitfordigit(chan, 6000); 01130 if (!cmd) { 01131 attempts++; 01132 } 01133 if (attempts > max_attempts) { 01134 cmd = 't'; 01135 } 01136 } 01137 } 01138 if (cmd == 't') 01139 cmd = 0; 01140 return cmd; 01141 }
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 temporaraly replaced.
Code that executes this function *must* call ast_unreplace_sigchld() after it is finished doing the wait*().
Definition at line 745 of file asterisk.c.
References ast_mutex_lock(), ast_mutex_unlock(), and null_sig_handler().
Referenced by ast_safe_system().
00746 { 00747 unsigned int level; 00748 00749 ast_mutex_lock(&safe_system_lock); 00750 level = safe_system_level++; 00751 00752 /* only replace the handler if it has not already been done */ 00753 if (level == 0) 00754 safe_system_prev_handler = signal(SIGCHLD, null_sig_handler); 00755 00756 ast_mutex_unlock(&safe_system_lock); 00757 }
int ast_safe_system | ( | const char * | s | ) |
Safely spawn an external program while closing file descriptors
Definition at line 773 of file asterisk.c.
References ast_log(), ast_opt_high_priority, ast_replace_sigchld(), ast_set_priority(), ast_unreplace_sigchld(), and LOG_WARNING.
Referenced by alarmreceiver_exec(), ast_closestream(), ast_monitor_change_fname(), ast_monitor_start(), ast_monitor_stop(), consolehandler(), make_email_file(), mixmonitor_thread(), process_text_line(), remoteconsolehandler(), run_externnotify(), sendmail(), sendpage(), system_exec_helper(), and vm_change_password_shell().
00774 { 00775 pid_t pid; 00776 #ifdef HAVE_WORKING_FORK 00777 int x; 00778 #endif 00779 int res; 00780 struct rusage rusage; 00781 int status; 00782 00783 #if defined(HAVE_WORKING_FORK) || defined(HAVE_WORKING_VFORK) 00784 ast_replace_sigchld(); 00785 00786 #ifdef HAVE_WORKING_FORK 00787 pid = fork(); 00788 #else 00789 pid = vfork(); 00790 #endif 00791 00792 if (pid == 0) { 00793 #ifdef HAVE_WORKING_FORK 00794 if (ast_opt_high_priority) 00795 ast_set_priority(0); 00796 /* Close file descriptors and launch system command */ 00797 for (x = STDERR_FILENO + 1; x < 4096; x++) 00798 close(x); 00799 #endif 00800 execl("/bin/sh", "/bin/sh", "-c", s, (char *) NULL); 00801 _exit(1); 00802 } else if (pid > 0) { 00803 for(;;) { 00804 res = wait4(pid, &status, 0, &rusage); 00805 if (res > -1) { 00806 res = WIFEXITED(status) ? WEXITSTATUS(status) : -1; 00807 break; 00808 } else if (errno != EINTR) 00809 break; 00810 } 00811 } else { 00812 ast_log(LOG_WARNING, "Fork failed: %s\n", strerror(errno)); 00813 res = -1; 00814 } 00815 00816 ast_unreplace_sigchld(); 00817 #else 00818 res = -1; 00819 #endif 00820 00821 return res; 00822 }
void ast_uninstall_vm_functions | ( | void | ) |
Definition at line 176 of file app.c.
References ast_has_voicemail_func, ast_inboxcount_func, and ast_messagecount_func.
Referenced by unload_module().
00177 { 00178 ast_has_voicemail_func = NULL; 00179 ast_inboxcount_func = NULL; 00180 ast_messagecount_func = NULL; 00181 }
int ast_unlock_path | ( | const char * | path | ) |
Unlock a path
Definition at line 1025 of file app.c.
References ast_log(), LOG_DEBUG, LOG_ERROR, LOG_WARNING, option_debug, and s.
Referenced by __ast_play_and_record(), copy_message(), count_messages(), last_message_index(), leave_voicemail(), resequence_mailbox(), and save_to_folder().
01026 { 01027 char *s; 01028 int res; 01029 01030 if (!(s = alloca(strlen(path) + 10))) { 01031 ast_log(LOG_WARNING, "Out of memory!\n"); 01032 return -1; 01033 } 01034 01035 snprintf(s, strlen(path) + 9, "%s/%s", path, ".lock"); 01036 01037 if ((res = unlink(s))) 01038 ast_log(LOG_ERROR, "Could not unlock path '%s': %s\n", path, strerror(errno)); 01039 else { 01040 if (option_debug) 01041 ast_log(LOG_DEBUG, "Unlocked path '%s'\n", path); 01042 } 01043 01044 return res; 01045 }
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.
Definition at line 759 of file asterisk.c.
References ast_mutex_lock(), and ast_mutex_unlock().
Referenced by agi_exec_full(), and ast_safe_system().
00760 { 00761 unsigned int level; 00762 00763 ast_mutex_lock(&safe_system_lock); 00764 level = --safe_system_level; 00765 00766 /* only restore the handler if we are the last one */ 00767 if (level == 0) 00768 signal(SIGCHLD, safe_system_prev_handler); 00769 00770 ast_mutex_unlock(&safe_system_lock); 00771 }