#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <signal.h>
#include <errno.h>
#include <unistd.h>
#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <regex.h>
#include "asterisk.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/file.h"
#include "asterisk/app.h"
#include "asterisk/dsp.h"
#include "asterisk/logger.h"
#include "asterisk/options.h"
#include "asterisk/utils.h"
#include "asterisk/lock.h"
#include "asterisk/indications.h"
#include "asterisk/linkedlists.h"
Include dependency graph for app.c:

Go to the source code of this file.
Data Structures | |
| struct | linear_state |
Defines | |
| #define | MAX_OTHER_FORMATS 10 |
| #define | RES_EXIT (1 << 17) |
| #define | RES_REPEAT (1 << 18) |
| #define | RES_RESTART ((1 << 19) | RES_REPEAT) |
| #define | RES_UPONE (1 << 16) |
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_getvoice (struct ast_channel *c, char *dest, char *dstfmt, char *prompt, int silence, int maxsec) |
| int | ast_app_group_discard (struct ast_channel *chan) |
| int | ast_app_group_get_count (char *group, 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 (char *groupmatch, char *category) |
| int | ast_app_group_set_channel (struct ast_channel *chan, char *data) |
| int | ast_app_group_split_group (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_messagecount (const char *mailbox, int *newmsgs, int *oldmsgs) |
| 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, char *digits, int between) |
| void | ast_install_vm_functions (int(*has_voicemail_func)(const char *mailbox, const char *folder), int(*messagecount_func)(const char *mailbox, int *newmsgs, int *oldmsgs)) |
| int | ast_ivr_menu_run (struct ast_channel *chan, struct ast_ivr_menu *menu, void *cbdata) |
| Runs an IVR menu. | |
| static int | ast_ivr_menu_run_internal (struct ast_channel *chan, struct ast_ivr_menu *menu, void *cbdata) |
| int | ast_linear_stream (struct ast_channel *chan, const char *filename, int fd, int allowoverride) |
| static | AST_LIST_HEAD_STATIC (groups, ast_group_info) |
| 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, char *fmt, int *duration, int beep, int silencethreshold, int maxsilence) |
| int | ast_play_and_record (struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime, const char *fmt, int *duration, int silencethreshold, int maxsilence, const char *path) |
| int | ast_play_and_record_full (struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime, const char *fmt, int *duration, int silencethreshold, int maxsilence, 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 *filename) |
| 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_uninstall_vm_functions (void) |
| int | ast_unlock_path (const char *path) |
| static int | ivr_dispatch (struct ast_channel *chan, struct ast_ivr_option *option, char *exten, void *cbdata) |
| static void * | linear_alloc (struct ast_channel *chan, void *params) |
| static int | linear_generator (struct ast_channel *chan, void *data, int len, int samples) |
| static void | linear_release (struct ast_channel *chan, void *params) |
| static int | option_exists (struct ast_ivr_menu *menu, char *option) |
| static int | option_matchmore (struct ast_ivr_menu *menu, char *option) |
| static int | read_newoption (struct ast_channel *chan, struct ast_ivr_menu *menu, char *exten, int maxexten) |
Variables | |
| static int(*) | ast_has_voicemail_func (const char *mailbox, const char *folder) = NULL |
| static int(*) | ast_messagecount_func (const char *mailbox, int *newmsgs, int *oldmsgs) = NULL |
| static char | default_acceptdtmf [] = "#" |
| static char | default_canceldtmf [] = "0" |
| static int | global_maxsilence = 0 |
| static int | global_silence_threshold = 128 |
| static struct ast_generator | linearstream |
Definition in file app.c.
| #define MAX_OTHER_FORMATS 10 |
Definition at line 53 of file app.c.
Referenced by ast_play_and_prepend(), and ast_play_and_record_full().
| #define RES_EXIT (1 << 17) |
Definition at line 1360 of file app.c.
Referenced by ast_ivr_menu_run_internal(), and ivr_dispatch().
| #define RES_REPEAT (1 << 18) |
Definition at line 1361 of file app.c.
Referenced by ast_ivr_menu_run_internal(), and ivr_dispatch().
| #define RES_RESTART ((1 << 19) | RES_REPEAT) |
Definition at line 1362 of file app.c.
Referenced by ast_ivr_menu_run_internal(), and ivr_dispatch().
| #define RES_UPONE (1 << 16) |
Definition at line 1359 of file app.c.
Referenced by ast_ivr_menu_run_internal(), and ivr_dispatch().
| 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 64 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().
00065 { 00066 struct tone_zone_sound *ts; 00067 int res=0, x=0; 00068 00069 if(maxlen > size) 00070 maxlen = size; 00071 00072 if(!timeout && chan->pbx) 00073 timeout = chan->pbx->dtimeout; 00074 else if(!timeout) 00075 timeout = 5; 00076 00077 ts = ast_get_indication_tone(chan->zone,"dial"); 00078 if (ts && ts->data[0]) 00079 res = ast_playtones_start(chan, 0, ts->data, 0); 00080 else 00081 ast_log(LOG_NOTICE,"Huh....? no dial for indications?\n"); 00082 00083 for (x = strlen(collect); strlen(collect) < maxlen; ) { 00084 res = ast_waitfordigit(chan, timeout); 00085 if (!ast_ignore_pattern(context, collect)) 00086 ast_playtones_stop(chan); 00087 if (res < 1) 00088 break; 00089 if (res == '#') 00090 break; 00091 collect[x++] = res; 00092 if (!ast_matchmore_extension(chan, context, collect, 1, chan->cid.cid_num)) 00093 break; 00094 } 00095 if (res >= 0) { 00096 if (ast_exists_extension(chan, context, collect, 1, chan->cid.cid_num)) 00097 res = 1; 00098 else 00099 res = 0; 00100 } 00101 return res; 00102 }
| 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.
| timeout | set timeout to 0 for "standard" timeouts. Set timeout to -1 for "ludicrous time" (essentially never times out) |
Definition at line 108 of file app.c.
References ast_readstring(), ast_streamfile(), ast_pbx::dtimeout, ast_channel::language, ast_channel::pbx, and ast_pbx::rtimeout.
Referenced by __login_exec(), auth_exec(), conf_exec(), dictate_exec(), find_conf(), read_exec(), testclient_exec(), testserver_exec(), and vm_exec().
00109 { 00110 int res,to,fto; 00111 /* XXX Merge with full version? XXX */ 00112 if (maxlen) 00113 s[0] = '\0'; 00114 if (prompt) { 00115 res = ast_streamfile(c, prompt, c->language); 00116 if (res < 0) 00117 return res; 00118 } 00119 fto = c->pbx ? c->pbx->rtimeout * 1000 : 6000; 00120 to = c->pbx ? c->pbx->dtimeout * 1000 : 2000; 00121 00122 if (timeout > 0) 00123 fto = to = timeout; 00124 if (timeout < 0) 00125 fto = to = 1000000000; 00126 res = ast_readstring(c, s, maxlen, to, fto, "#"); 00127 return res; 00128 }
| 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 131 of file app.c.
References ast_readstring_full(), ast_streamfile(), and ast_channel::language.
Referenced by handle_getdata().
00132 { 00133 int res,to,fto; 00134 if (prompt) { 00135 res = ast_streamfile(c, prompt, c->language); 00136 if (res < 0) 00137 return res; 00138 } 00139 fto = 6000; 00140 to = 2000; 00141 if (timeout > 0) 00142 fto = to = timeout; 00143 if (timeout < 0) 00144 fto = to = 1000000000; 00145 res = ast_readstring_full(c, s, maxlen, to, fto, "#", audiofd, ctrlfd); 00146 return res; 00147 }
| int ast_app_getvoice | ( | struct ast_channel * | c, | |
| char * | dest, | |||
| char * | dstfmt, | |||
| char * | prompt, | |||
| int | silence, | |||
| int | maxsec | |||
| ) |
Record voice (after playing prompt if specified), waiting for silence (in ms) up to a given timeout (in s) or '#'
Definition at line 149 of file app.c.
References ast_dsp_free(), ast_dsp_new(), ast_dsp_silence(), AST_FORMAT_SLINEAR, AST_FRAME_DTMF, AST_FRAME_VOICE, ast_frfree(), ast_log(), ast_read(), ast_set_read_format(), ast_streamfile(), ast_waitfor(), ast_waitstream(), ast_writefile(), ast_writestream(), ast_dsp::f, ast_frame::frametype, ast_channel::language, LOG_NOTICE, LOG_WARNING, ast_channel::name, ast_channel::readformat, ast_frame::samples, ast_frame::subclass, and total.
00150 { 00151 int res; 00152 struct ast_filestream *writer; 00153 int rfmt; 00154 int totalms=0, total; 00155 00156 struct ast_frame *f; 00157 struct ast_dsp *sildet; 00158 /* Play prompt if requested */ 00159 if (prompt) { 00160 res = ast_streamfile(c, prompt, c->language); 00161 if (res < 0) 00162 return res; 00163 res = ast_waitstream(c,""); 00164 if (res < 0) 00165 return res; 00166 } 00167 rfmt = c->readformat; 00168 res = ast_set_read_format(c, AST_FORMAT_SLINEAR); 00169 if (res < 0) { 00170 ast_log(LOG_WARNING, "Unable to set to linear mode, giving up\n"); 00171 return -1; 00172 } 00173 sildet = ast_dsp_new(); 00174 if (!sildet) { 00175 ast_log(LOG_WARNING, "Unable to create silence detector :(\n"); 00176 return -1; 00177 } 00178 writer = ast_writefile(dest, dstfmt, "Voice file", 0, 0, 0666); 00179 if (!writer) { 00180 ast_log(LOG_WARNING, "Unable to open file '%s' in format '%s' for writing\n", dest, dstfmt); 00181 ast_dsp_free(sildet); 00182 return -1; 00183 } 00184 for(;;) { 00185 if ((res = ast_waitfor(c, 2000)) < 0) { 00186 ast_log(LOG_NOTICE, "Waitfor failed while recording file '%s' format '%s'\n", dest, dstfmt); 00187 break; 00188 } 00189 if (res) { 00190 f = ast_read(c); 00191 if (!f) { 00192 ast_log(LOG_NOTICE, "Hungup while recording file '%s' format '%s'\n", dest, dstfmt); 00193 break; 00194 } 00195 if ((f->frametype == AST_FRAME_DTMF) && (f->subclass == '#')) { 00196 /* Ended happily with DTMF */ 00197 ast_frfree(f); 00198 break; 00199 } else if (f->frametype == AST_FRAME_VOICE) { 00200 ast_dsp_silence(sildet, f, &total); 00201 if (total > silence) { 00202 /* Ended happily with silence */ 00203 ast_frfree(f); 00204 break; 00205 } 00206 totalms += f->samples / 8; 00207 if (totalms > maxsec * 1000) { 00208 /* Ended happily with too much stuff */ 00209 ast_log(LOG_NOTICE, "Constraining voice on '%s' to %d seconds\n", c->name, maxsec); 00210 ast_frfree(f); 00211 break; 00212 } 00213 res = ast_writestream(writer, f); 00214 if (res < 0) { 00215 ast_log(LOG_WARNING, "Failed to write to stream at %s!\n", dest); 00216 ast_frfree(f); 00217 break; 00218 } 00219 00220 } 00221 ast_frfree(f); 00222 } 00223 } 00224 res = ast_set_read_format(c, rfmt); 00225 if (res) 00226 ast_log(LOG_WARNING, "Unable to restore read format on '%s'\n", c->name); 00227 ast_dsp_free(sildet); 00228 ast_closestream(writer); 00229 return 0; 00230 }
| int ast_app_group_discard | ( | struct ast_channel * | chan | ) |
Discard all group counting for a channel
Definition at line 1134 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, free, and list.
Referenced by ast_channel_free().
01135 { 01136 struct ast_group_info *gi = NULL; 01137 01138 AST_LIST_LOCK(&groups); 01139 AST_LIST_TRAVERSE_SAFE_BEGIN(&groups, gi, list) { 01140 if (gi->chan == chan) { 01141 AST_LIST_REMOVE_CURRENT(&groups, list); 01142 free(gi); 01143 } 01144 } 01145 AST_LIST_TRAVERSE_SAFE_END 01146 AST_LIST_UNLOCK(&groups); 01147 01148 return 0; 01149 }
| int ast_app_group_get_count | ( | char * | group, | |
| char * | category | |||
| ) |
Get the current channel count of the specified group and category.
Definition at line 1077 of file app.c.
References AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_strlen_zero(), ast_group_info::category, ast_group_info::group, and list.
Referenced by group_check_exec(), group_count_exec(), and group_count_function_read().
01078 { 01079 struct ast_group_info *gi = NULL; 01080 int count = 0; 01081 01082 if (ast_strlen_zero(group)) 01083 return 0; 01084 01085 AST_LIST_LOCK(&groups); 01086 AST_LIST_TRAVERSE(&groups, gi, list) { 01087 if (!strcasecmp(gi->group, group) && (ast_strlen_zero(category) || (!ast_strlen_zero(gi->category) && !strcasecmp(gi->category, category)))) 01088 count++; 01089 } 01090 AST_LIST_UNLOCK(&groups); 01091 01092 return count; 01093 }
| struct ast_group_info* ast_app_group_list_head | ( | void | ) |
Get the head of the group count list
Definition at line 1156 of file app.c.
References AST_LIST_FIRST.
Referenced by group_function_read(), group_list_function_read(), and group_show_channels().
01157 { 01158 return AST_LIST_FIRST(&groups); 01159 }
| int ast_app_group_list_lock | ( | void | ) |
Lock the group count list
Definition at line 1151 of file app.c.
References AST_LIST_LOCK.
Referenced by group_function_read(), group_list_function_read(), and group_show_channels().
01152 { 01153 return AST_LIST_LOCK(&groups); 01154 }
| int ast_app_group_list_unlock | ( | void | ) |
Unlock the group count list
Definition at line 1161 of file app.c.
References AST_LIST_UNLOCK.
Referenced by group_function_read(), group_list_function_read(), and group_show_channels().
01162 { 01163 return AST_LIST_UNLOCK(&groups); 01164 }
| int ast_app_group_match_get_count | ( | char * | groupmatch, | |
| char * | category | |||
| ) |
Get the current channel count of all groups that match the specified pattern and category.
Definition at line 1095 of file app.c.
References AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_strlen_zero(), ast_group_info::category, ast_group_info::group, and list.
Referenced by group_match_count_exec(), and group_match_count_function_read().
01096 { 01097 struct ast_group_info *gi = NULL; 01098 regex_t regexbuf; 01099 int count = 0; 01100 01101 if (ast_strlen_zero(groupmatch)) 01102 return 0; 01103 01104 /* if regex compilation fails, return zero matches */ 01105 if (regcomp(®exbuf, groupmatch, REG_EXTENDED | REG_NOSUB)) 01106 return 0; 01107 01108 AST_LIST_LOCK(&groups); 01109 AST_LIST_TRAVERSE(&groups, gi, list) { 01110 if (!regexec(®exbuf, gi->group, 0, NULL, 0) && (ast_strlen_zero(category) || (!ast_strlen_zero(gi->category) && !strcasecmp(gi->category, category)))) 01111 count++; 01112 } 01113 AST_LIST_UNLOCK(&groups); 01114 01115 regfree(®exbuf); 01116 01117 return count; 01118 }
| int ast_app_group_set_channel | ( | struct ast_channel * | chan, | |
| char * | data | |||
| ) |
Set the group for a channel, splitting the provided data into group and category, if specified.
Definition at line 1034 of file app.c.
References ast_app_group_split_group(), AST_LIST_INSERT_TAIL, AST_LIST_LOCK, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, AST_LIST_UNLOCK, ast_strlen_zero(), calloc, ast_group_info::category, ast_group_info::chan, free, group, ast_group_info::group, and list.
Referenced by dial_exec_full(), group_function_write(), and group_set_exec().
01035 { 01036 int res = 0; 01037 char group[80] = "", category[80] = ""; 01038 struct ast_group_info *gi = NULL; 01039 size_t len = 0; 01040 01041 if (ast_app_group_split_group(data, group, sizeof(group), category, sizeof(category))) 01042 return -1; 01043 01044 /* Calculate memory we will need if this is new */ 01045 len = sizeof(*gi) + strlen(group) + 1; 01046 if (!ast_strlen_zero(category)) 01047 len += strlen(category) + 1; 01048 01049 AST_LIST_LOCK(&groups); 01050 AST_LIST_TRAVERSE_SAFE_BEGIN(&groups, gi, list) { 01051 if ((gi->chan == chan) && ((ast_strlen_zero(category) && ast_strlen_zero(gi->category)) || (!ast_strlen_zero(gi->category) && !strcasecmp(gi->category, category)))) { 01052 AST_LIST_REMOVE_CURRENT(&groups, list); 01053 free(gi); 01054 break; 01055 } 01056 } 01057 AST_LIST_TRAVERSE_SAFE_END 01058 01059 if ((gi = calloc(1, len))) { 01060 gi->chan = chan; 01061 gi->group = (char *) gi + sizeof(*gi); 01062 strcpy(gi->group, group); 01063 if (!ast_strlen_zero(category)) { 01064 gi->category = (char *) gi + sizeof(*gi) + strlen(group) + 1; 01065 strcpy(gi->category, category); 01066 } 01067 AST_LIST_INSERT_TAIL(&groups, gi, list); 01068 } else { 01069 res = -1; 01070 } 01071 01072 AST_LIST_UNLOCK(&groups); 01073 01074 return res; 01075 }
| int ast_app_group_split_group | ( | 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 1007 of file app.c.
References ast_strlen_zero().
Referenced by ast_app_group_set_channel(), group_check_exec(), group_count_exec(), group_count_function_read(), group_match_count_exec(), and group_match_count_function_read().
01008 { 01009 int res=0; 01010 char tmp[256]; 01011 char *grp=NULL, *cat=NULL; 01012 01013 if (!ast_strlen_zero(data)) { 01014 ast_copy_string(tmp, data, sizeof(tmp)); 01015 grp = tmp; 01016 cat = strchr(tmp, '@'); 01017 if (cat) { 01018 *cat = '\0'; 01019 cat++; 01020 } 01021 } 01022 01023 if (!ast_strlen_zero(grp)) 01024 ast_copy_string(group, grp, group_max); 01025 else 01026 res = -1; 01027 01028 if (!ast_strlen_zero(cat)) 01029 ast_copy_string(category, cat, category_max); 01030 01031 return res; 01032 }
| int ast_app_group_update | ( | struct ast_channel * | oldchan, | |
| struct ast_channel * | newchan | |||
| ) |
Update all group counting for a channel to a new one
Definition at line 1120 of file app.c.
References AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_group_info::chan, and list.
01121 { 01122 struct ast_group_info *gi = NULL; 01123 01124 AST_LIST_LOCK(&groups); 01125 AST_LIST_TRAVERSE(&groups, gi, list) { 01126 if (gi->chan == old) 01127 gi->chan = new; 01128 } 01129 AST_LIST_UNLOCK(&groups); 01130 01131 return 0; 01132 }
| int ast_app_has_voicemail | ( | const char * | mailbox, | |
| const char * | folder | |||
| ) |
Determine if a given mailbox has any voicemail
Definition at line 248 of file app.c.
References ast_has_voicemail_func, ast_verbose(), option_verbose, and VERBOSE_PREFIX_3.
Referenced by action_mailboxstatus(), do_monitor(), has_voicemail(), notify_new_message(), play_dialtone(), and update_registry().
00249 { 00250 static int warned = 0; 00251 if (ast_has_voicemail_func) 00252 return ast_has_voicemail_func(mailbox, folder); 00253 00254 if ((option_verbose > 2) && !warned) { 00255 ast_verbose(VERBOSE_PREFIX_3 "Message check requested for mailbox %s/folder %s but voicemail not loaded.\n", mailbox, folder ? folder : "INBOX"); 00256 warned++; 00257 } 00258 return 0; 00259 }
| int ast_app_messagecount | ( | const char * | mailbox, | |
| int * | newmsgs, | |||
| int * | oldmsgs | |||
| ) |
Determine number of new/old messages in a mailbox
Definition at line 262 of file app.c.
References ast_messagecount_func, ast_verbose(), option_verbose, and VERBOSE_PREFIX_3.
Referenced by action_mailboxcount(), do_housekeeping(), notify_new_message(), sip_send_mwi_to_peer(), and update_registry().
00263 { 00264 static int warned = 0; 00265 if (newmsgs) 00266 *newmsgs = 0; 00267 if (oldmsgs) 00268 *oldmsgs = 0; 00269 if (ast_messagecount_func) 00270 return ast_messagecount_func(mailbox, newmsgs, oldmsgs); 00271 00272 if (!warned && (option_verbose > 2)) { 00273 warned++; 00274 ast_verbose(VERBOSE_PREFIX_3 "Message count requested for mailbox %s but voicemail not loaded.\n", mailbox); 00275 } 00276 00277 return 0; 00278 }
| 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 1596 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(), chanspy_exec(), conf_exec(), dial_exec_full(), mixmonitor_exec(), page_exec(), pbx_builtin_background(), pbx_builtin_resetcdr(), pbx_builtin_waitexten(), vm_exec(), and vm_execmain().
01597 { 01598 char *s; 01599 int curarg; 01600 unsigned int argloc; 01601 char *arg; 01602 int res = 0; 01603 01604 ast_clear_flag(flags, AST_FLAGS_ALL); 01605 01606 if (!optstr) 01607 return 0; 01608 01609 s = optstr; 01610 while (*s) { 01611 curarg = *s++ & 0x7f; 01612 ast_set_flag(flags, options[curarg].flag); 01613 argloc = options[curarg].arg_index; 01614 if (*s == '(') { 01615 /* Has argument */ 01616 arg = ++s; 01617 while (*s && (*s != ')')) 01618 s++; 01619 if (*s) { 01620 if (argloc) 01621 args[argloc - 1] = arg; 01622 *s++ = '\0'; 01623 } else { 01624 ast_log(LOG_WARNING, "Missing closing parenthesis for argument '%c' in string '%s'\n", curarg, arg); 01625 res = -1; 01626 } 01627 } else if (argloc) { 01628 args[argloc - 1] = NULL; 01629 } 01630 } 01631 01632 return res; 01633 }
| 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 1166 of file app.c.
Referenced by add_agent(), app_exec(), astman_get_variables(), builtin_function_cdr_read(), builtin_function_cdr_write(), builtin_function_checkmd5(), builtin_function_math(), chanspy_exec(), controlplayback_exec(), cut_internal(), dictate_exec(), function_db_exists(), function_db_read(), function_db_write(), pbx_builtin_background(), pbx_builtin_setvar(), pbx_builtin_waitexten(), read_exec(), record_exec(), vm_exec(), and vm_execmain().
01167 { 01168 int argc; 01169 char *scan; 01170 int paren = 0; 01171 01172 if (!buf || !array || !arraylen) 01173 return 0; 01174 01175 memset(array, 0, arraylen * sizeof(*array)); 01176 01177 scan = buf; 01178 01179 for (argc = 0; *scan && (argc < arraylen - 1); argc++) { 01180 array[argc] = scan; 01181 for (; *scan; scan++) { 01182 if (*scan == '(') 01183 paren++; 01184 else if (*scan == ')') { 01185 if (paren) 01186 paren--; 01187 } else if ((*scan == delim) && !paren) { 01188 *scan++ = '\0'; 01189 break; 01190 } 01191 } 01192 } 01193 01194 if (*scan) 01195 array[argc++] = scan; 01196 01197 return argc; 01198 }
| 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 431 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(), ast_channel::language, LOG_DEBUG, and ast_channel::stream.
Referenced by controlplayback_exec(), handle_controlstreamfile(), and wait_file().
00435 { 00436 char *breaks = NULL; 00437 char *end = NULL; 00438 int blen = 2; 00439 int res; 00440 long pause_restart_point = 0; 00441 00442 if (stop) 00443 blen += strlen(stop); 00444 if (pause) 00445 blen += strlen(pause); 00446 if (restart) 00447 blen += strlen(restart); 00448 00449 if (blen > 2) { 00450 breaks = alloca(blen + 1); 00451 breaks[0] = '\0'; 00452 if (stop) 00453 strcat(breaks, stop); 00454 if (pause) 00455 strcat(breaks, pause); 00456 if (restart) 00457 strcat(breaks, restart); 00458 } 00459 if (chan->_state != AST_STATE_UP) 00460 res = ast_answer(chan); 00461 00462 if (file) { 00463 if ((end = strchr(file,':'))) { 00464 if (!strcasecmp(end, ":end")) { 00465 *end = '\0'; 00466 end++; 00467 } 00468 } 00469 } 00470 00471 for (;;) { 00472 ast_stopstream(chan); 00473 res = ast_streamfile(chan, file, chan->language); 00474 if (!res) { 00475 if (pause_restart_point) { 00476 ast_seekstream(chan->stream, pause_restart_point, SEEK_SET); 00477 pause_restart_point = 0; 00478 } 00479 else if (end) { 00480 ast_seekstream(chan->stream, 0, SEEK_END); 00481 end = NULL; 00482 }; 00483 res = ast_waitstream_fr(chan, breaks, fwd, rev, skipms); 00484 } 00485 00486 if (res < 1) 00487 break; 00488 00489 /* We go at next loop if we got the restart char */ 00490 if (restart && strchr(restart, res)) { 00491 ast_log(LOG_DEBUG, "we'll restart the stream here at next loop\n"); 00492 pause_restart_point = 0; 00493 continue; 00494 } 00495 00496 if (pause && strchr(pause, res)) { 00497 pause_restart_point = ast_tellstream(chan->stream); 00498 for (;;) { 00499 ast_stopstream(chan); 00500 res = ast_waitfordigit(chan, 1000); 00501 if (!res) 00502 continue; 00503 else if (res == -1 || strchr(pause, res) || (stop && strchr(stop, res))) 00504 break; 00505 } 00506 if (res == *pause) { 00507 res = 0; 00508 continue; 00509 } 00510 } 00511 00512 if (res == -1) 00513 break; 00514 00515 /* if we get one of our stop chars, return it to the calling function */ 00516 if (stop && strchr(stop, res)) 00517 break; 00518 } 00519 00520 ast_stopstream(chan); 00521 00522 return res; 00523 }
| int ast_dtmf_stream | ( | struct ast_channel * | chan, | |
| struct ast_channel * | peer, | |||
| char * | digits, | |||
| int | between | |||
| ) |
Send DTMF to chan (optionally entertain peer)
Definition at line 280 of file app.c.
References ast_autoservice_start(), ast_autoservice_stop(), AST_FRAME_DTMF, ast_log(), ast_safe_sleep(), ast_waitfor(), ast_write(), and LOG_WARNING.
Referenced by ast_bridge_call(), dial_exec_full(), misdn_send_digit(), senddtmf_exec(), testclient_exec(), and testserver_exec().
00281 { 00282 char *ptr; 00283 int res = 0; 00284 struct ast_frame f; 00285 if (!between) 00286 between = 100; 00287 00288 if (peer) 00289 res = ast_autoservice_start(peer); 00290 00291 if (!res) { 00292 res = ast_waitfor(chan,100); 00293 if (res > -1) { 00294 for (ptr=digits; *ptr; ptr++) { 00295 if (*ptr == 'w') { 00296 res = ast_safe_sleep(chan, 500); 00297 if (res) 00298 break; 00299 continue; 00300 } 00301 memset(&f, 0, sizeof(f)); 00302 f.frametype = AST_FRAME_DTMF; 00303 f.subclass = *ptr; 00304 f.src = "ast_dtmf_stream"; 00305 if (strchr("0123456789*#abcdABCD",*ptr)==NULL) { 00306