34 #ifdef HAVE_SYS_STAT_H
41 #include <sys/types.h>
43 #ifndef HAVE_CLOSEFROM
47 #include <sys/capability.h>
82 pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
85 if (waitpid(cur->
pid, &status, WNOHANG) != 0) {
92 pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
102 #define AST_MAX_FORMATS 10
144 for (x = strlen(collect); x < maxlen; ) {
180 int res = 0, to, fto;
181 char *front, *filename;
192 while ((front =
strsep(&filename,
"&"))) {
207 fto = to = 1000000000;
233 int res, to = 2000, fto = 6000;
246 fto = to = 1000000000;
262 "Cannot run 'Macro(%s)'. The application is not available.\n", macro_args);
265 if (autoservice_chan) {
269 ast_debug(4,
"%s Original location: %s,%s,%d\n", macro_chan->
name,
272 res =
pbx_exec(macro_chan, macro_app, macro_args);
273 ast_debug(4,
"Macro exited with status %d\n", res);
285 ast_debug(4,
"%s Ending location: %s,%s,%d\n", macro_chan->
name,
288 if (autoservice_chan) {
305 args_len = strlen(macro_name) + strlen(macro_args) + 2;
310 snprintf(args_str, args_len,
"%s,%s", macro_name, macro_args);
327 const char *new_args;
332 "Cannot expand 'Gosub(%s)' arguments. The app_stack module is not available.\n",
349 if (!funcs || !funcs->
run_sub) {
351 "Cannot run 'Gosub(%s)'. The app_stack module is not available.\n",
357 if (autoservice_chan) {
361 res = funcs->
run_sub(sub_chan, sub_args, ignore_hangup);
364 if (autoservice_chan) {
377 return ast_app_exec_sub(autoservice_chan, sub_chan, sub_location, ignore_hangup);
381 args_len = strlen(sub_location) + strlen(sub_args) + 3;
386 snprintf(args_str, args_len,
"%s(%s)", sub_location, sub_args);
388 res =
ast_app_exec_sub(autoservice_chan, sub_chan, args_str, ignore_hangup);
400 int (*inboxcount_func)(
const char *mailbox,
int *newmsgs,
int *oldmsgs),
401 int (*inboxcount2_func)(
const char *mailbox,
int *urgentmsgs,
int *newmsgs,
int *oldmsgs),
402 int (*messagecount_func)(
const char *
context,
const char *mailbox,
const char *folder),
403 int (*sayname_func)(
struct ast_channel *chan,
const char *mailbox,
const char *context))
423 static int warned = 0;
428 if (warned++ % 10 == 0) {
429 ast_verb(3,
"Message check requested for mailbox %s/folder %s but voicemail not loaded.\n", mailbox, folder ? folder :
"INBOX");
437 static int warned = 0;
448 if (warned++ % 10 == 0) {
449 ast_verb(3,
"Message count requested for mailbox %s but voicemail not loaded.\n", mailbox);
457 static int warned = 0;
471 if (warned++ % 10 == 0) {
472 ast_verb(3,
"Message count requested for mailbox %s but voicemail not loaded.\n", mailbox);
488 static int warned = 0;
495 ast_verb(3,
"Message count requested for mailbox %s@%s/%s but voicemail not loaded.\n", mailbox, context, folder);
531 for (ptr = digits; *ptr; ptr++) {
537 }
else if (strchr(
"0123456789*#abcdfABCDF", *ptr)) {
539 if (*ptr ==
'f' || *ptr ==
'F') {
550 ast_log(
LOG_WARNING,
"Illegal DTMF character '%c' in string. (0-9*#aAbBcCdD allowed)\n", *ptr);
664 if (filename[0] ==
'/') {
669 if ((fd = open(tmpf, O_RDONLY)) < 0) {
684 const char *fwd,
const char *rev,
686 const char *restart,
int skipms,
long *offsetms)
692 long pause_restart_point = 0;
699 offset = *offsetms * 8;
703 blen += strlen(stop);
706 blen += strlen(suspend);
709 blen += strlen(restart);
716 strcat(breaks, stop);
719 strcat(breaks, suspend);
722 strcat(breaks, restart);
729 if ((end = strchr(file,
':'))) {
730 if (!strcasecmp(end,
":end")) {
740 if (pause_restart_point) {
742 pause_restart_point = 0;
744 else if (end || offset < 0) {
748 ast_verb(3,
"ControlPlayback seek to offset %ld from end\n", offset);
754 ast_verb(3,
"ControlPlayback seek to offset %ld\n", offset);
766 if (restart && strchr(restart, res)) {
767 ast_debug(1,
"we'll restart the stream here at next loop\n");
768 pause_restart_point = 0;
772 if (suspend && strchr(suspend, res)) {
778 }
else if (res == -1 || strchr(suspend, res) || (stop && strchr(stop, res))) {
782 if (res == *suspend) {
793 if (stop && strchr(stop, res)) {
798 if (pause_restart_point) {
799 offset = pause_restart_point;
809 *offsetms = offset / 8;
813 if (res > 0 || chan->
stream) {
862 static int __ast_play_and_record(
struct ast_channel *chan,
const char *playfile,
const char *recordfile,
int maxtime,
const char *fmt,
int *duration,
int *sound_duration,
int beep,
int silencethreshold,
int maxsilence,
const char *path,
int prepend,
const char *
acceptdtmf,
const char *canceldtmf,
int skip_confirmation_sound)
867 int x, fmtcnt = 1, res = -1, outmsg = 0;
870 char *stringp = NULL;
875 int olddspsilence = 0;
878 char prependfile[80];
880 if (silencethreshold < 0) {
884 if (maxsilence < 0) {
894 ast_debug(1,
"play_and_record: %s, %s, '%s'\n", playfile ? playfile :
"<None>", recordfile, fmt);
895 snprintf(comment,
sizeof(comment),
"Playing %s, Recording to: %s on %s\n", playfile ? playfile :
"<None>", recordfile, chan->
name);
897 if (playfile || beep) {
911 strncat(prependfile,
"-prepend",
sizeof(prependfile) - strlen(prependfile) - 1);
918 ast_debug(1,
"Recording Formats: sfmts=%s\n", fmts);
921 while ((fmt =
strsep(&stringp,
"|"))) {
929 end = start = time(NULL);
930 for (x = 0; x < fmtcnt; x++) {
932 ast_verb(3,
"x=%d, open writing: %s format: %s, %p\n", x, prepend ? prependfile : recordfile, sfmt[x], others[x]);
943 if (maxsilence > 0) {
974 ast_debug(1,
"One waitfor failed, trying another\n");
991 for (x = 0; x < fmtcnt; x++) {
992 if (prepend && !others[x]) {
999 if (maxsilence > 0) {
1002 if (olddspsilence > dspsilence) {
1003 totalsilence += olddspsilence;
1005 olddspsilence = dspsilence;
1007 if (dspsilence > maxsilence) {
1009 ast_verb(3,
"Recording automatically stopped after a silence of %d seconds\n", dspsilence/1000);
1046 if (maxtime < (end - start)) {
1047 ast_verb(3,
"Took too long, cutting it short...\n");
1063 ast_log(
LOG_WARNING,
"Error creating writestream '%s', format '%s'\n", recordfile, sfmt[x]);
1082 if (sound_duration) {
1083 *sound_duration = *duration;
1088 if (olddspsilence <= dspsilence) {
1089 totalsilence += dspsilence;
1092 if (sound_duration) {
1093 if (totalsilence > 0) {
1094 *sound_duration -= (totalsilence - 200) / 1000;
1096 if (*sound_duration < 0) {
1097 *sound_duration = 0;
1101 if (dspsilence > 0) {
1102 *duration -= (dspsilence - 200) / 1000;
1104 if (*duration < 0) {
1108 for (x = 0; x < fmtcnt; x++) {
1117 if (res > 0 && dspsilence) {
1124 }
else if (outmsg) {
1128 for (x = 0; x < fmtcnt; x++) {
1129 snprintf(comment,
sizeof(comment),
"Opening the real file %s.%s\n", recordfile, sfmt[x]);
1130 realfiles[x] =
ast_readfile(recordfile, sfmt[x], comment, O_RDONLY, 0, 0);
1134 if (!realfiles[x]) {
1151 ast_verb(4,
"Recording Format: sfmts=%s, prependfile %s, recordfile %s\n", sfmt[x], prependfile, recordfile);
1155 for (x = 0; x < fmtcnt; x++) {
1166 if ((outmsg == 2) && (!skip_confirmation_sound)) {
1178 int ast_play_and_record_full(
struct ast_channel *chan,
const char *playfile,
const char *recordfile,
int maxtime,
const char *fmt,
int *duration,
int *sound_duration,
int silencethreshold,
int maxsilence,
const char *path,
const char *
acceptdtmf,
const char *canceldtmf)
1180 return __ast_play_and_record(chan, playfile, recordfile, maxtime, fmt, duration, sound_duration, 0, silencethreshold, maxsilence, path, 0,
S_OR(acceptdtmf,
default_acceptdtmf),
S_OR(canceldtmf,
default_canceldtmf), 0);
1185 return __ast_play_and_record(chan, playfile, recordfile, maxtime, fmt, duration, sound_duration, 0, silencethreshold, maxsilence, path, 0,
default_acceptdtmf,
default_canceldtmf, 0);
1190 return __ast_play_and_record(chan, playfile, recordfile, maxtime, fmt, duration, sound_duration, beep, silencethreshold, maxsilence, NULL, 1,
default_acceptdtmf,
default_canceldtmf, 1);
1199 char *grp = NULL, *cat = NULL;
1204 if ((cat = strchr(tmp,
'@'))) {
1225 char group[80] =
"", category[80] =
"";
1234 len =
sizeof(*gi) + strlen(group) + 1;
1251 }
else if ((gi =
calloc(1, len))) {
1253 gi->
group = (
char *) gi +
sizeof(*gi);
1254 strcpy(gi->
group, group);
1256 gi->
category = (
char *) gi +
sizeof(*gi) + strlen(group) + 1;
1292 regex_t regexbuf_group;
1293 regex_t regexbuf_category;
1302 if (regcomp(®exbuf_group, groupmatch, REG_EXTENDED | REG_NOSUB)) {
1307 if (!
ast_strlen_zero(category) && regcomp(®exbuf_category, category, REG_EXTENDED | REG_NOSUB)) {
1309 regfree(®exbuf_group);
1321 regfree(®exbuf_group);
1323 regfree(®exbuf_category);
1335 if (gi->
chan == old) {
1337 }
else if (gi->
chan ==
new) {
1354 if (gi->
chan == chan) {
1385 #undef ast_app_separate_args
1391 char *scan, *wasdelim = NULL;
1394 if (!array || !arraylen) {
1398 memset(array, 0, arraylen *
sizeof(*array));
1406 for (argc = 0; *scan && (argc < arraylen - 1); argc++) {
1408 for (; *scan; scan++) {
1411 }
else if (*scan ==
')') {
1415 }
else if (*scan ==
'[') {
1417 }
else if (*scan ==
']') {
1421 }
else if (*scan ==
'"' && delim !=
'"') {
1425 memmove(scan, scan + 1, strlen(scan));
1428 }
else if (*scan ==
'\\') {
1431 memmove(scan, scan + 1, strlen(scan));
1435 }
else if ((*scan == delim) && !paren && !
quote && !bracket) {
1445 if (*scan || (scan > buf && (scan - 1) == wasdelim)) {
1446 array[argc++] = scan;
1464 int lp = strlen(path);
1470 snprintf(fs, strlen(path) + 19,
"%s/.lock-%08lx", path, (
unsigned long)
ast_random());
1478 snprintf(s, strlen(path) + 9,
"%s/.lock", path);
1480 while (((res = link(fs, s)) < 0) && (
errno == EEXIST) && (time(NULL) - start < 5)) {
1490 ast_debug(1,
"Locked path '%s'\n", path);
1502 snprintf(s, strlen(path) + 9,
"%s/%s", path,
".lock");
1504 if ((res = unlink(s))) {
1507 ast_debug(1,
"Unlocked path '%s'\n", path);
1539 struct stat st, ost;
1543 snprintf(fs, strlen(path) + 19,
"%s/lock", path);
1544 if (lstat(fs, &st) == 0) {
1545 if ((st.st_mode & S_IFMT) == S_IFLNK) {
1547 "'%s': it's already a symbolic link\n",
1551 if (st.st_nlink > 1) {
1553 "'%s': %u hard links exist\n",
1554 fs, (
unsigned int) st.st_nlink);
1558 if ((fd = open(fs, O_WRONLY | O_CREAT, 0600)) < 0) {
1560 fs, strerror(
errno));
1578 ((res = fcntl(pl->
fd, F_SETLK, fcntl(pl->
fd, F_GETFL) | O_NONBLOCK)) < 0) &&
1580 ((res = flock(pl->
fd, LOCK_EX | LOCK_NB)) < 0) &&
1582 (
errno == EWOULDBLOCK) &&
1583 (time(NULL) - start < 5))
1587 path, strerror(
errno));
1598 if (lstat(fs, &st) != 0 && fstat(pl->
fd, &ost) != 0 &&
1599 st.st_dev != ost.st_dev &&
1600 st.st_ino != ost.st_ino) {
1602 "file changed underneath us\n", fs);
1612 ast_debug(1,
"Locked path '%s'\n", path);
1626 if (!strcmp(p->
path, path)) {
1635 snprintf(s, strlen(path) + 19,
"%s/lock", path);
1641 "lock not found\n", path);
1690 int max_attempts = 3;
1693 int message_exists = 0;
1706 while ((cmd >= 0) && (cmd !=
't')) {
1709 if (!message_exists) {
1720 ast_verb(3,
"Reviewing the recording\n");
1726 ast_verb(3,
"R%secording\n", recorded == 1 ?
"e-r" :
"");
1728 if ((cmd =
ast_play_and_record(chan, playfile, recordfile, maxtime, fmt, duration, NULL, silencethreshold, maxsilence, path)) == -1) {
1734 }
else if (cmd ==
'*') {
1753 if (message_exists) {
1767 if (attempts > max_attempts) {
1778 #define RES_UPONE (1 << 16)
1779 #define RES_EXIT (1 << 17)
1780 #define RES_REPEAT (1 << 18)
1781 #define RES_RESTART ((1 << 19) | RES_REPEAT)
1792 switch (option->
action) {
1796 return RES_EXIT | (((
unsigned long)(option->
adata)) & 0xffff);
1829 ivr_func = option->
adata;
1830 res = ivr_func(chan, cbdata);
1839 while ((n =
strsep(&c,
";"))) {
1869 if ((!strncasecmp(menu->
options[x].
option, option, strlen(option))) &&
1883 if (strlen(exten) >= maxexten - 1) {
1889 exten[strlen(exten) + 1] =
'\0';
1890 exten[strlen(exten)] = res;
1892 return res > 0 ? 0 : res;
1913 ast_debug(1,
"IVR Dispatch of '%s' (pos %d) yields %d\n", exten, pos, res);
1930 if ((maxretries > 0) && (retries >= maxretries)) {
1931 ast_debug(1,
"Max retries %d exceeded\n", maxretries);
1943 ast_debug(1,
"Got start of extension, %c\n", res);
1951 ast_debug(1,
"Invalid extension entered, going to 'i'!\n");
1956 ast_debug(1,
"Aborting on invalid entry, with no 'i' option!\n");
1961 ast_debug(1,
"New existing extension: %s\n", exten);
1969 ast_debug(1,
"Stopping option '%s', res is %d\n", exten, res);
1971 if (!strcasecmp(exten,
"s")) {
1984 return res > 0 ? 0 : res;
1989 int fd, count = 0, res;
1990 char *output = NULL;
1991 struct stat filesize;
1993 if (stat(filename, &filesize) == -1) {
1998 count = filesize.st_size + 1;
2000 if ((fd = open(filename, O_RDONLY)) < 0) {
2006 res = read(fd, output, count - 1);
2007 if (res == count - 1) {
2024 int curarg, res = 0;
2025 unsigned int argloc;
2029 if (flaglen == 32) {
2041 curarg = *s++ & 0x7f;
2045 int parsequotes = (s[1] ==
'"') ? 1 : 0;
2050 if (*s ==
'(' && !
quote) {
2052 }
else if (*s ==
')' && !
quote) {
2055 }
else if (*s ==
'"' && parsequotes) {
2060 }
else if (*s ==
'\\') {
2064 }
else if (
quote && s[1] ==
'"') {
2078 if ((s = strchr(s,
')'))) {
2080 args[argloc - 1] = arg;
2084 ast_log(
LOG_WARNING,
"Missing closing parenthesis for argument '%c' in string '%s'\n", curarg, arg);
2088 }
else if (argloc) {
2089 args[argloc - 1] =
"";
2091 if (flaglen == 32) {
2113 unsigned int i, found = 0;
2114 for (i = 32; i < 128 && found <
len; i++) {
2132 if (*stream ==
'\\') {
2134 switch (*(stream + 1)) {
2146 if (strchr(
"0123456789ABCDEFabcdef", *(stream + 2)) && *(stream + 2) !=
'\0') {
2148 if (*(stream + 2) <=
'9') {
2149 *result = *(stream + 2) -
'0';
2150 }
else if (*(stream + 2) <=
'F') {
2151 *result = *(stream + 2) -
'A' + 10;
2153 *result = *(stream + 2) -
'a' + 10;
2156 ast_log(
LOG_ERROR,
"Illegal character '%c' in hexadecimal string\n", *(stream + 2));
2160 if (strchr(
"0123456789ABCDEFabcdef", *(stream + 3)) && *(stream + 3) !=
'\0') {
2163 if (*(stream + 3) <=
'9') {
2164 *result += *(stream + 3) -
'0';
2165 }
else if (*(stream + 3) <=
'F') {
2166 *result += *(stream + 3) -
'A' + 10;
2168 *result += *(stream + 3) -
'a' + 10;
2175 for (i = 2; ; i++) {
2176 if (strchr(
"01234567", *(stream + i)) && *(stream + i) !=
'\0') {
2178 ast_debug(5,
"result was %d, ", *result);
2180 *result += *(stream + i) -
'0';
2188 *result = *(stream + 1);
2216 if (strchr(stream,
'\\')) {
2225 buf[offset++] =
next;
2229 buf[offset++] =
'\0';
2244 sigset_t signal_set, old_set;
2252 sigfillset(&signal_set);
2253 pthread_sigmask(SIG_BLOCK, &signal_set, &old_set);
2259 pthread_sigmask(SIG_SETMASK, &old_set, NULL);
2260 if (!stop_reaper && pid > 0) {
2269 ast_log(
LOG_ERROR,
"Shaun of the Dead wants to kill zombies, but can't?!!\n");
2279 cap_t cap = cap_from_text(
"cap_net_admin-eip");
2281 if (cap_set_proc(cap)) {
2288 signal(SIGHUP, SIG_DFL);
2289 signal(SIGCHLD, SIG_DFL);
2290 signal(SIGINT, SIG_DFL);
2291 signal(SIGURG, SIG_DFL);
2292 signal(SIGTERM, SIG_DFL);
2293 signal(SIGPIPE, SIG_DFL);
2294 signal(SIGXFSZ, SIG_DFL);
2297 if (pthread_sigmask(SIG_UNBLOCK, &signal_set, NULL)) {
2315 #ifdef HAVE_LONG_DOUBLE_WIDER
2317 #define FMT "%30Lf%9s"
2320 #define FMT "%30lf%9s"
2326 res = sscanf(timestr,
FMT, &amount, u);
2328 if (res == 0 || res == EOF) {
2331 }
else if (res == 2) {
2343 if (toupper(u[1]) ==
'S') {
2345 }
else if (u[1] ==
'\0') {
2365 *result = amount > INT_MAX ? INT_MAX : (int) amount;
int ast_play_and_record(struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime_sec, const char *fmt, int *duration, int *sound_duration, int silencethreshold, int maxsilence_ms, const char *path)
Record a file based on input from a channel. Use default accept and cancel DTMF. This function will p...
int ast_safe_sleep(struct ast_channel *chan, int ms)
Wait for a specified amount of time, looking for hangups.
union ast_frame_subclass subclass
int ast_matchmore_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Looks to see if adding anything to this extension might match something. (exists ^ canmatch) ...
static char exten[AST_MAX_EXTENSION]
Main Channel structure associated with a channel.
char * str
Subscriber phone number (Malloced)
int ast_streamfile(struct ast_channel *c, const char *filename, const char *preflang)
Streams a file.
#define AST_LIST_LOCK(head)
Locks a list.
Asterisk locking-related definitions:
Asterisk main include file. File version handling, generic pbx functions.
#define AST_LIST_FIRST(head)
Returns the first entry contained in a list.
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...
void ast_module_unref(struct ast_module *)
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.
struct ast_party_caller caller
Channel Caller ID information.
struct ast_tone_zone * zone
int ast_autoservice_start(struct ast_channel *chan)
Automatically service a channel for us...
char * strsep(char **str, const char *delims)
struct ast_app * pbx_findapp(const char *app)
Look up an application.
AST_THREADSTORAGE_PUBLIC(ast_str_thread_global_buf)
int ast_safe_fork(int stop_reaper)
Common routine to safely fork without a chance of a signal handler firing badly in the child...
#define AST_RWLIST_HEAD_STATIC(name, type)
Defines a structure to be used to hold a read/write list of specified type, statically initialized...
int pbx_exec(struct ast_channel *c, struct ast_app *app, const char *data)
Execute an application.
static const char default_acceptdtmf[]
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...
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
int ast_control_streamfile(struct ast_channel *chan, const char *file, const char *fwd, const char *rev, const char *stop, const char *pause, const char *restart, int skipms, long *offsetms)
Stream a file with fast forward, pause, reverse, restart.
int ast_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_activate_generator(struct ast_channel *chan, struct ast_generator *gen, void *params)
int ast_indicate(struct ast_channel *chan, int condition)
Indicates condition of channel.
size_t ast_str_size(const struct ast_str *buf)
Returns the current maximum length (without reallocation) of the current buffer.
void ast_dsp_free(struct ast_dsp *dsp)
Convenient Signal Processing routines.
static int option_matchmore(struct ast_ivr_menu *menu, char *option)
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
char context[AST_MAX_CONTEXT]
const char *(* expand_sub_args)(struct ast_channel *chan, const char *args)
Add missing context/exten to Gosub application argument string.
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.
#define ast_set_flag(p, flag)
char * ast_get_encoded_str(const char *stream, char *result, size_t result_len)
Decode a stream of encoded control or extended ASCII characters.
static int(* ast_messagecount_func)(const char *context, const char *mailbox, const char *folder)
static int global_silence_threshold
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
static struct ast_app_stack_funcs * app_stack_callbacks
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
static void linear_release(struct ast_channel *chan, void *params)
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.
struct ast_dsp * ast_dsp_new(void)
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
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.
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
static int(* ast_sayname_func)(struct ast_channel *chan, const char *mailbox, const char *context)
int ast_ignore_pattern(const char *context, const char *pattern)
Checks to see if a number should be ignored.
static int(* ast_inboxcount_func)(const char *mailbox, int *newmsgs, int *oldmsgs)
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.
#define ast_set_flag64(p, flag)
#define AST_LIST_EMPTY(head)
Checks whether the specified list contains any entries.
static void path_lock_destroy(struct path_lock *obj)
#define ast_opt_transmit_silence
static int(* ast_has_voicemail_func)(const char *mailbox, const char *folder)
Generic File Format Support. Should be included by clients of the file handling routines. File service providers should instead include mod_format.h.
void ast_playtones_stop(struct ast_channel *chan)
Stop playing tones on a channel.
Definitions to aid in the use of thread local storage.
int ast_senddigit(struct ast_channel *chan, char digit, unsigned int duration)
Send a DTMF digit to a channel.
int ast_filedelete(const char *filename, const char *fmt)
Deletes a file.
Structure used to handle a large number of boolean flags == used only in app_dial?
static int option_exists(struct ast_ivr_menu *menu, char *option)
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
static int parse_options(const struct ast_app_option *options, void *_flags, char **args, char *optstr, int flaglen)
void closefrom(int lowfd)
static int ast_unlock_path_lockfile(const char *path)
#define ast_verb(level,...)
void ast_unreplace_sigchld(void)
Restore the SIGCHLD handler.
static int ivr_dispatch(struct ast_channel *chan, struct ast_ivr_option *option, char *exten, void *cbdata)
off_t ast_tellstream(struct ast_filestream *fs)
Tell where we are in a stream.
static int ast_unlock_path_flock(const char *path)
#define ast_pthread_create_background(a, b, c, d)
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.
static int(* ast_inboxcount2_func)(const char *mailbox, int *urgentmsgs, int *newmsgs, int *oldmsgs)
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
struct ast_party_id id
Caller party ID.
int ast_set_write_format(struct ast_channel *chan, format_t format)
Sets write format on channel chan Set write format for channel to whichever component of "format" is ...
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
int ast_set_read_format(struct ast_channel *chan, format_t format)
Sets read format on channel chan Set read format for channel to whichever component of "format" is be...
#define ast_debug(level,...)
Log a DEBUG message.
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'.
General Asterisk PBX channel definitions.
#define AST_FRIENDLY_OFFSET
Offset into a frame's data buffer.
Asterisk file paths, configured in asterisk.conf.
static int quote(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
int ast_str_make_space(struct ast_str **buf, size_t new_len)
int(* run_sub)(struct ast_channel *chan, const char *args, int ignore_hangup)
Callback for the routine to run a subroutine on a channel.
#define AST_PTHREADT_NULL
static force_inline int attribute_pure ast_strlen_zero(const char *s)
#define ast_poll(a, b, c)
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_parseable_goto(struct ast_channel *chan, const char *goto_string)
#define AST_MAX_EXTENSION
#define AST_RWLIST_TRAVERSE
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
long int ast_random(void)
#define AST_RWLIST_REMOVE_CURRENT
static struct ast_tone_zone_sound * ast_tone_zone_sound_unref(struct ast_tone_zone_sound *ts)
Release a reference to an ast_tone_zone_sound.
A set of macros to manage forward-linked lists.
int ast_waitstream_fr(struct ast_channel *c, const char *breakon, const char *forward, const char *rewind, int ms)
Same as waitstream but allows stream to be forwarded or rewound.
static const char default_canceldtmf[]
int ast_app_inboxcount(const char *mailbox, int *newmsgs, int *oldmsgs)
Determine number of new/old messages in a mailbox.
int ast_exists_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Determine whether an extension exists.
static void * linear_alloc(struct ast_channel *chan, void *params)
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.
Core PBX routines and definitions.
int ast_autoservice_stop(struct ast_channel *chan)
Stop servicing a channel for us...
#define AST_RWLIST_TRAVERSE_SAFE_BEGIN
struct ast_channel * chan
int ast_app_inboxcount2(const char *mailbox, int *urgentmsgs, int *newmsgs, int *oldmsgs)
Determine number of urgent/new/old messages in a mailbox.
#define AST_LIST_HEAD_STATIC(name, type)
Defines a structure to be used to hold a list of specified type, statically initialized.
int ast_app_group_list_wrlock(void)
Write Lock the group count list.
void ast_dsp_set_threshold(struct ast_dsp *dsp, int threshold)
Set threshold value for silence.
struct ast_silence_generator * ast_channel_start_silence_generator(struct ast_channel *chan)
Starts a silence generator on the given channel.
struct ast_group_info * ast_app_group_list_head(void)
Get the head of the group count list.
const char * ast_config_AST_DATA_DIR
#define ast_strdupa(s)
duplicate a string in memory from the stack
char * ast_getformatname(format_t format)
Get the name of a format.
static enum AST_LOCK_RESULT ast_lock_path_flock(const char *path)
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
int ast_get_encoded_char(const char *stream, char *result, size_t *consumed)
Decode an encoded control or extended ASCII character.
static int linear_generator(struct ast_channel *chan, void *data, int len, int samples)
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
static enum AST_LOCK_RESULT ast_lock_path_lockfile(const char *path)
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.
struct ast_frame * ast_readframe(struct ast_filestream *s)
Read a frame from a filestream.
Stack applications callback functions.
int ast_stream_rewind(struct ast_filestream *fs, off_t ms)
Rewind stream ms.
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
enum ast_channel_state _state
struct ast_tone_zone_sound * ast_get_indication_tone(const struct ast_tone_zone *zone, const char *indication)
Locate a tone zone sound.
const ast_string_field name
struct ast_filestream * ast_writefile(const char *filename, const char *type, const char *comment, int flags, int check, mode_t mode)
Starts writing a file.
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
int ast_seekstream(struct ast_filestream *fs, off_t sample_offset, int whence)
Seeks into stream.
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
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.
void ast_channel_stop_silence_generator(struct ast_channel *chan, struct ast_silence_generator *state)
Stops a previously-started silence generator on the given channel.
void *(* alloc)(struct ast_channel *chan, void *params)
static int __ast_play_and_record(struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime, const char *fmt, int *duration, int *sound_duration, int beep, int silencethreshold, int maxsilence, const char *path, int prepend, const char *acceptdtmf, const char *canceldtmf, int skip_confirmation_sound)
int ast_ivr_menu_run(struct ast_channel *c, struct ast_ivr_menu *menu, void *cbdata)
Runs an IVR menu.
int ast_stream_and_wait(struct ast_channel *chan, const char *file, const char *digits)
stream file until digit If the file name is non-empty, try to play it.
unsigned int __ast_app_separate_args(char *buf, char delim, int remove_chars, char **array, int arraylen)
Separate a string into arguments in an array.
int ast_closestream(struct ast_filestream *f)
Closes a stream.
void ast_close_fds_above_n(int n)
Common routine for child processes, to close all fds prior to exec(2)
int ast_write(struct ast_channel *chan, struct ast_frame *frame)
Write a frame to a channel This function writes the given frame to the indicated channel.
static void suspend(struct cc_core_instance *core_instance)
static pthread_t shaun_of_the_dead_thread
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.
#define ast_clear_flag(p, flag)
static int read_newoption(struct ast_channel *chan, struct ast_ivr_menu *menu, char *exten, int maxexten)
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_truncstream(struct ast_filestream *fs)
Trunc stream at current location.
int ast_waitfordigit(struct ast_channel *c, int ms)
Waits for a digit.
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...
struct path_lock::@217 le
int ast_app_group_list_unlock(void)
Unlock the group count list.
int ast_dsp_silence(struct ast_dsp *dsp, struct ast_frame *f, int *totalsilence)
Return non-zero if this is silence. Updates "totalsilence" with the total number of seconds of silenc...
#define AST_RWLIST_INSERT_TAIL
static void * shaun_of_the_dead(void *data)
int ast_app_group_update(struct ast_channel *oldchan, struct ast_channel *newchan)
Update all group counting for a channel to a new one.
This structure is allocated by file.c in one chunk, together with buf_size and desc_size bytes of mem...
#define AST_FORMAT_SLINEAR
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
void ast_str_update(struct ast_str *buf)
Update the length of the buffer, after using ast_str merely as a buffer.
void ast_set_lock_type(enum AST_LOCK_TYPE type)
Set the type of locks used by ast_lock_path()
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
static struct ast_generator linearstream
ast_app: A registered application
struct ast_group_info::@157 group_list
int ast_writestream(struct ast_filestream *fs, struct ast_frame *f)
Writes a frame to a stream.
int ast_waitstream(struct ast_channel *c, const char *breakon)
Waits for a stream to stop or digit to be pressed.
int ast_readstring_full(struct ast_channel *c, char *s, int len, int timeout, int rtimeout, char *enders, int audiofd, int ctrlfd)
int ast_answer(struct ast_channel *chan)
Answer a channel.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
Data structure associated with a single frame of data.
struct ast_filestream * ast_readfile(const char *filename, const char *type, const char *comment, int flags, int check, mode_t mode)
Starts reading from a file.
int ast_playtones_start(struct ast_channel *chan, int vol, const char *tonelist, int interruptible)
Start playing a list of tones on a channel.
unsigned int ast_app_separate_args(char *buf, char delim, char **array, int arraylen)
int ast_filerename(const char *oldname, const char *newname, const char *fmt)
Renames a file.
AST_LOCK_TYPE
Type of locking to use in ast_lock_path / ast_unlock_path.
const char * data
Description of a tone.
int ast_app_group_get_count(const char *group, const char *category)
Get the current channel count of the specified group and category.
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
enum ast_frame_type frametype
static struct ast_str * prompt
static char context[AST_MAX_CONTEXT]
int ast_readstring(struct ast_channel *c, char *s, int len, int timeout, int rtimeout, char *enders)
Reads multiple digits.
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.
struct ast_filestream * stream
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.
static int global_maxsilence
int ast_dsp_get_threshold_from_settings(enum threshold which)
Get silence threshold from dsp.conf.
Asterisk module definitions.
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.
union ast_frame::@172 data
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.
unsigned char valid
TRUE if the number information is valid/present.
#define AST_RWLIST_TRAVERSE_SAFE_END
static enum AST_LOCK_TYPE ast_lock_type
const ast_string_field language
char exten[AST_MAX_EXTENSION]
int ast_stopstream(struct ast_channel *c)
Stops a stream.
void ast_replace_sigchld(void)
Replace the SIGCHLD handler.
static char mailbox[AST_MAX_EXTENSION]
#define ASTERISK_FILE_VERSION(file, version)
Register/unregister a source code file with the core.
static int ast_ivr_menu_run_internal(struct ast_channel *chan, struct ast_ivr_menu *menu, void *cbdata)
void ast_uninstall_vm_functions(void)
struct ast_module * ast_module_ref(struct ast_module *)
struct ast_party_number number
Subscriber phone number.
#define ast_test_flag64(p, flag)