50#include <sys/capability.h> 
   84static cap_t child_cap;
 
  102            pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, 
NULL);
 
  105                if (waitpid(cur->
pid, &
status, WNOHANG) != 0) {
 
  112            pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, 
NULL);
 
  114        pthread_testcancel();
 
 
  122#define AST_MAX_FORMATS 10 
  162    for (x = strlen(collect); x < maxlen; ) {
 
 
  194    int maxlen, 
int timeout, 
char *terminator)
 
  196    int res = 0, to, fto;
 
  197    char *front, *filename;
 
  223                fto = to = 1000000000;
 
  232        res = 
ast_readstring(
c, s, maxlen, to, fto, (terminator ? terminator : 
"#"));
 
 
  249    int res, to = 2000, fto = 6000;
 
  262        fto = to = 1000000000;
 
 
  281    const char *new_args;
 
  286            "Cannot expand 'Gosub(%s)' arguments.  The app_stack module is not available.\n",
 
 
  305            "Cannot run 'Gosub(%s)'.  The app_stack module is not available.\n",
 
  310    if (autoservice_chan) {
 
  317    if (autoservice_chan) {
 
 
  339    args_len = strlen(sub_location) + strlen(sub_args) + 3;
 
  344    snprintf(args_str, args_len, 
"%s(%s)", sub_location, sub_args);
 
 
  363    is_registered = table ? 1 : 0;
 
  365    return is_registered;
 
 
  394    table->module = 
module;
 
 
  414static int provider_is_swapped = 0;
 
  421    if (provider_is_swapped) {
 
  422        ast_log(
LOG_ERROR, 
"Attempted to swap in test function table without swapping out old test table.\n");
 
  439    provider_is_swapped = 1;
 
  442void ast_vm_test_swap_table_out(
void)
 
  446    if (!provider_is_swapped) {
 
  447        ast_log(
LOG_ERROR, 
"Attempted to swap out test function table, but none is currently installed.\n");
 
  458    provider_is_swapped = 0;
 
  474    is_registered = table ? 1 : 0;
 
  476    return is_registered;
 
 
  484        ast_log(
LOG_ERROR, 
"Voicemail greeter provider missing required information.\n");
 
  488        ast_log(
LOG_ERROR, 
"Voicemail greeter provider '%s' has incorrect version\n",
 
  505    table->module = 
module;
 
 
  523static ast_vm_test_create_user_fn *ast_vm_test_create_user_func = 
NULL;
 
  524static ast_vm_test_destroy_user_fn *ast_vm_test_destroy_user_func = 
NULL;
 
  526void ast_install_vm_test_functions(ast_vm_test_create_user_fn *vm_test_create_user_func,
 
  527    ast_vm_test_destroy_user_fn *vm_test_destroy_user_func)
 
  529    ast_vm_test_create_user_func = vm_test_create_user_func;
 
  530    ast_vm_test_destroy_user_func = vm_test_destroy_user_func;
 
  533void ast_uninstall_vm_test_functions(
void)
 
  535    ast_vm_test_create_user_func = 
NULL;
 
  536    ast_vm_test_destroy_user_func = 
NULL;
 
  543        ast_verb(3, 
"No voicemail provider registered.\n");
 
 
  547#define VM_API_CALL(res, api_call, api_parms)                               \ 
  549        struct ast_vm_functions *table;                                     \ 
  550        table = ao2_global_obj_ref(vm_provider);                            \ 
  552            vm_warn_no_provider();                                          \ 
  553        } else if (table->api_call) {                                       \ 
  554            ast_module_ref(table->module);                                  \ 
  555            (res) = table->api_call api_parms;                              \ 
  556            ast_module_unref(table->module);                                \ 
  558        ao2_cleanup(table);                                                 \ 
 
  564        ast_verb(3, 
"No voicemail greeter provider registered.\n");
 
 
  568#define VM_GREETER_API_CALL(res, api_call, api_parms)                       \ 
  570        struct ast_vm_greeter_functions *table;                             \ 
  571        table = ao2_global_obj_ref(vm_greeter_provider);                    \ 
  573            vm_greeter_warn_no_provider();                                  \ 
  574        } else if (table->api_call) {                                       \ 
  575            ast_module_ref(table->module);                                  \ 
  576            (res) = table->api_call api_parms;                              \ 
  577            ast_module_unref(table->module);                                \ 
  579        ao2_cleanup(table);                                                 \ 
 
  600    VM_API_CALL(res, copy_recording_to_vm, (vm_rec_data));
 
 
  655    const char *res = 
NULL;
 
 
  666    int combine_INBOX_and_OLD)
 
  670    VM_API_CALL(res, mailbox_snapshot_create, (mailbox, context, folder, descending,
 
  671        sort_val, combine_INBOX_and_OLD));
 
 
  679    VM_API_CALL(res, mailbox_snapshot_destroy, (mailbox_snapshot));
 
 
  686    const char *oldfolder,
 
  687    const char *old_msg_ids[],
 
  688    const char *newfolder)
 
  692    VM_API_CALL(res, msg_move, (mailbox, context, num_msgs, oldfolder, old_msg_ids,
 
 
  705    VM_API_CALL(res, msg_remove, (mailbox, context, num_msgs, folder, msgs));
 
 
  710    const char *from_context,
 
  711    const char *from_folder,
 
  712    const char *to_mailbox,
 
  713    const char *to_context,
 
  714    const char *to_folder,
 
  716    const char *msg_ids[],
 
  721    VM_API_CALL(res, msg_forward, (from_mailbox, from_context, from_folder, to_mailbox,
 
  722        to_context, to_folder, num_msgs, msg_ids, delete_old));
 
 
  735    VM_API_CALL(res, msg_play, (chan, mailbox, context, folder, msg_num, cb));
 
 
  740int ast_vm_test_create_user(
const char *context, 
const char *mailbox)
 
  742    if (ast_vm_test_create_user_func) {
 
  743        return ast_vm_test_create_user_func(context, mailbox);
 
  748int ast_vm_test_destroy_user(
const char *context, 
const char *mailbox)
 
  750    if (ast_vm_test_destroy_user_func) {
 
  751        return ast_vm_test_destroy_user_func(context, mailbox);
 
  768    #define SF_BETWEEN 600 
  776    if (frequency >= 100000) {
 
  797    res = my_sleep(chan, 100);
 
  802        goto sf_stream_cleanup;
 
  811    for (ptr = digits; *ptr; ptr++) {
 
  817            res = my_sleep(chan, 500);
 
  824        } 
else if (*ptr == 
'h' || *ptr == 
'H') {
 
  832            res = my_sleep(chan, 250);
 
  841        } 
else if (strchr(
"0123456789*#ABCDabcdwWfF", *ptr)) {
 
  842            if (*ptr == 
'f' || *ptr == 
'F') {
 
  845            } 
else if (*ptr == 
'W') {
 
  853                } 
else if (*ptr == 
'#') {
 
  855                } 
else if (*ptr == 
'D') {
 
  857                } 
else if (*ptr == 
'C') {
 
  859                } 
else if (*ptr == 
'B') {
 
  861                } 
else if (*ptr == 
'A') {
 
  864                    beeps = (*ptr == 
'0') ? 10 : *ptr - 
'0';
 
  866                while (beeps-- > 0) {
 
  899            ast_log(
LOG_WARNING, 
"Illegal SF character '%c' in string. (0-9A-DwWfFhH allowed)\n", *ptr);
 
 
  915    unsigned int durationkp, 
unsigned int durationst, 
int is_external)
 
  942    res = my_sleep(chan, 100);
 
  947        goto mf_stream_cleanup;
 
  950    for (ptr = digits; *ptr; ptr++) {
 
  956            res = my_sleep(chan, 500);
 
  963        } 
else if (*ptr == 
'h' || *ptr == 
'H') {
 
  971            res = my_sleep(chan, 250);
 
  980        } 
else if (strchr(
"0123456789*#ABCwWfF", *ptr)) {
 
  981            if (*ptr == 
'f' || *ptr == 
'F') {
 
  984            } 
else if (*ptr == 
'W') {
 
  989                ast_senddigit_mf(chan, *ptr, duration, durationkp, durationst, is_external);
 
  991                    ast_senddigit_mf(chan2, *ptr, duration, durationkp, durationst, is_external);
 
 1004            res = my_sleep(chan, between);
 
 1014            ast_log(
LOG_WARNING, 
"Illegal MF character '%c' in string. (0-9*#ABCwWfFhH allowed)\n", *ptr);
 
 
 1034    int (*my_sleep)(
struct ast_channel *chan, 
int ms);
 
 1035    int (*my_senddigit)(
struct ast_channel *chan, 
char digit, 
unsigned int duration);
 
 1053    res = my_sleep(chan, 100);
 
 1055        goto dtmf_stream_cleanup;
 
 1058    for (ptr = digits; *ptr; ptr++) {
 
 1061            res = my_sleep(chan, 500);
 
 1065        } 
else if (*ptr == 
'W') {
 
 1067            res = my_sleep(chan, 1000);
 
 1071        } 
else if (strchr(
"0123456789*#abcdfABCDF", *ptr)) {
 
 1072            if (*ptr == 
'f' || *ptr == 
'F') {
 
 1077                my_senddigit(chan, *ptr, duration);
 
 1080            res = my_sleep(chan, between);
 
 1085            ast_log(
LOG_WARNING, 
"Illegal DTMF character '%c' in string. (0-9*#aAbBcCdD allowed)\n", *ptr);
 
 
 1100    if (frequency <= 0) {
 
 1106    res = 
sf_stream(chan, chan2, digits, frequency, is_external);
 
 
 1114    int between, 
unsigned int duration, 
unsigned int durationkp, 
unsigned int durationst, 
int is_external)
 
 1120    res = 
mf_stream(chan, chan2, digits, between, duration, durationkp, durationst, is_external);
 
 
 1134    res = 
dtmf_stream(chan, digits, between, duration, 0);
 
 
 1248        if (filename[0] == 
'/') {
 
 1254        fd = open(tmpf, O_RDONLY);
 
 
 1283    const char *restart,
 
 1289    char *breaks = 
NULL;
 
 1293    long pause_restart_point = 0;
 
 1301        offset = *offsetms * 8; 
 
 1308        blen += strlen(
stop);
 
 1314        blen += strlen(restart);
 
 1321            strcat(breaks, 
stop);
 
 1327            strcat(breaks, restart);
 
 1331    if ((
end = strchr(file, 
':'))) {
 
 1332        if (!strcasecmp(
end, 
":end")) {
 
 1344            if (pause_restart_point) {
 
 1346                pause_restart_point = 0;
 
 1348            else if (
end || offset < 0) {
 
 1352                ast_verb(3, 
"ControlPlayback seek to offset %ld from end\n", offset);
 
 1357            } 
else if (offset) {
 
 1358                ast_verb(3, 
"ControlPlayback seek to offset %ld\n", offset);
 
 1375            ast_debug(1, 
"we'll restart the stream here at next loop\n");
 
 1376            pause_restart_point = 0;
 
 1432    if (pause_restart_point) {
 
 1433        offset = pause_restart_point;
 
 1443        *offsetms = offset / 8; 
 
 
 1457    const char *restart,
 
 1462    return control_streamfile(chan, file, fwd, rev, 
stop, 
suspend, restart, 
skipms, offsetms, 
NULL, cb);
 
 
 1466               const char *fwd, 
const char *rev,
 
 1468               const char *restart, 
int skipms, 
long *offsetms)
 
 1470    return control_streamfile(chan, file, fwd, rev, 
stop, 
suspend, restart, 
skipms, offsetms, 
NULL, 
NULL);
 
 
 1474    const char *fwd, 
const char *rev, 
const char *
stop, 
const char *
suspend,
 
 1475    const char *restart, 
int skipms, 
const char *lang, 
long *offsetms)
 
 1477    return control_streamfile(chan, file, fwd, rev, 
stop, 
suspend, restart, 
skipms, offsetms, lang, 
NULL);
 
 
 1510        ast_log(
LOG_NOTICE, 
"Media control operation 'reverse' not supported for media type 'tone'\n");
 
 1513        ast_log(
LOG_NOTICE, 
"Media control operation 'forward' not supported for media type 'tone'\n");
 
 
 1525    const char **tone_indication,
 
 1526    const char **tone_zone)
 
 1528    *tone_indication = 
strsep(&tone_parser, 
";");
 
 1535    if (!(strncmp(tone_parser, 
"tonezone=", 9))) {
 
 1536        *tone_zone = tone_parser + 9;
 
 
 1552    const char *tone_indication = 
NULL;
 
 1553    const char *tone_zone = 
NULL;
 
 1554    char *tone_uri_parser;
 
 1562    if (
parse_tone_uri(tone_uri_parser, &tone_indication, &tone_zone)) {
 
 
 1665    size = 
sizeof(*silence) + 
datalen;
 
 1673    silence->
data.
ptr = (
void *)(silence + 1);
 
 
 1694    if (!chan || !orig_format) {
 
 
 1728    const char *recordfile, 
int maxtime, 
const char *fmt, 
int *duration,
 
 1730    const char *path, 
int prepend, 
const char *acceptdtmf, 
const char *canceldtmf,
 
 1736    int x, fmtcnt = 1, res = -1, outmsg = 0;
 
 1739    char *stringp = 
NULL;
 
 1744    int olddspsilence = 0;
 
 1749    SCOPE_ENTER(3, 
"%s: play: '%s'  record: '%s'  path: '%s'  prepend: %d\n",
 
 1752    ioflags = O_CREAT|O_WRONLY;
 
 1754    switch (if_exists) {
 
 1762        ioflags |= O_APPEND;
 
 1783    ast_debug(1, 
"play_and_record: %s, %s, '%s'\n", playfile ? playfile : 
"<None>", recordfile, fmt);
 
 1786    if (playfile || beep) {
 
 1802        strncat(prependfile, 
"-prepend", 
sizeof(prependfile) - strlen(prependfile) - 1);
 
 1803        ast_trace(-1, 
"Prepending to '%s'\n", prependfile);
 
 1810    ast_debug(1, 
"Recording Formats: sfmts=%s\n", fmts);
 
 1813    while ((fmt = 
strsep(&stringp, 
"|"))) {
 
 1823        sfmt[fmtcnt++] = fmt;
 
 1827    for (x = 0; x < fmtcnt; x++) {
 
 1829        ast_trace(-1, 
"x=%d, open writing:  %s format: %s, %p\n", x, prepend ? prependfile : recordfile, sfmt[x], others[x]);
 
 1871        time_t pause_start = 0;
 
 1872        int paused_secs = 0;
 
 1873        int pausedsilence = 0;
 
 1877                ast_debug(1, 
"One waitfor failed, trying another\n");
 
 1909                    for (x = 0; x < fmtcnt; x++) {
 
 1910                        if (prepend && !others[x]) {
 
 1923                    if (olddspsilence > dspsilence) {
 
 1924                        totalsilence += olddspsilence;
 
 1926                    olddspsilence = dspsilence;
 
 1930                        pausedsilence = dspsilence;
 
 1931                    } 
else if (dspsilence > pausedsilence) {
 
 1933                        dspsilence -= pausedsilence;
 
 1941                        ast_verb(3, 
"Recording automatically stopped after a silence of %d seconds\n", dspsilence/1000);
 
 1977                    ast_verb(3, 
"Message canceled by control\n");
 
 1982                    ast_verb(3, 
"Message ended by control\n");
 
 1987                    ast_verb(3, 
"Message %spaused by control\n",
 
 1988                        paused ? 
"" : 
"un");
 
 1990                        pause_start = time(
NULL);
 
 1992                        paused_secs += time(
NULL) - pause_start;
 
 1996                    ast_verb(3, 
"Message %smuted by control\n",
 
 2002                    if (muted && !rfmt) {
 
 2003                        ast_verb(3, 
"Setting read format to linear mode\n");
 
 2012            if (maxtime && !paused) {
 
 2014                if (maxtime < (
end - start - paused_secs)) {
 
 2015                    ast_verb(3, 
"Took too long, cutting it short...\n");
 
 2031        ast_log(
LOG_WARNING, 
"Error creating writestream '%s', format '%s'\n", recordfile, sfmt[x]);
 
 2050    if (sound_duration) {
 
 2051        *sound_duration = *duration;
 
 2056        if (olddspsilence <= dspsilence) {
 
 2057            totalsilence += dspsilence;
 
 2060        if (sound_duration) {
 
 2061            if (totalsilence > 0) {
 
 2062                *sound_duration -= (totalsilence - 200) / 1000;
 
 2064            if (*sound_duration < 0) {
 
 2065                *sound_duration = 0;
 
 2069        if (dspsilence > 0) {
 
 2070            *duration -= (dspsilence - 200) / 1000;
 
 2073        if (*duration < 0) {
 
 2077        for (x = 0; x < fmtcnt; x++) {
 
 2086            if (res > 0 && dspsilence) {
 
 2093    } 
else if (prepend && outmsg) {
 
 2097        for (x = 0; x < fmtcnt; x++) {
 
 2098            snprintf(
comment, 
sizeof(
comment), 
"Opening the real file %s.%s\n", recordfile, sfmt[x]);
 
 2103            if (!realfiles[x]) {
 
 2120            ast_trace(-1, 
"Recording Format: sfmts=%s, prependfile %s, recordfile %s\n", sfmt[x], prependfile, recordfile);
 
 2121            ast_trace(-1, 
"Deleting the prepend file %s.%s\n", recordfile, sfmt[x]);
 
 2125        for (x = 0; x < fmtcnt; x++) {
 
 2137    if ((outmsg == 2) && (!skip_confirmation_sound)) {
 
 
 2149int 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 beep, 
int silencethreshold, 
int maxsilence, 
const char *path, 
const char *acceptdtmf, 
const char *canceldtmf, 
int skip_confirmation_sound, 
enum ast_record_if_exists if_exists)
 
 2151    return __ast_play_and_record(chan, playfile, recordfile, maxtime, fmt, duration, sound_duration, beep, 
silencethreshold, 
maxsilence, path, 0, 
S_OR(acceptdtmf, 
""), 
S_OR(canceldtmf, 
default_canceldtmf), skip_confirmation_sound, if_exists);
 
 
 2156    return __ast_play_and_record(chan, playfile, recordfile, maxtime, fmt, duration, sound_duration, 0, 
silencethreshold, 
maxsilence, path, 0, 
default_acceptdtmf, 
default_canceldtmf, 0, 
AST_RECORD_IF_EXISTS_OVERWRITE);
 
 
 2161    return __ast_play_and_record(chan, playfile, recordfile, maxtime, fmt, duration, sound_duration, beep, 
silencethreshold, 
maxsilence, 
NULL, 1, 
default_acceptdtmf, 
default_canceldtmf, 1, 
AST_RECORD_IF_EXISTS_OVERWRITE);
 
 
 2175        if ((cat = strchr(tmp, 
'@'))) {
 
 
 2196    char group[80] = 
"", category[80] = 
"";
 
 2205    len = 
sizeof(*gi) + strlen(
group) + 1;
 
 2224        gi->
group = (
char *) gi + 
sizeof(*gi);
 
 2227            gi->
category = (
char *) gi + 
sizeof(*gi) + strlen(
group) + 1;
 
 
 2263    regex_t regexbuf_group;
 
 2264    regex_t regexbuf_category;
 
 2273    if (regcomp(®exbuf_group, groupmatch, REG_EXTENDED | REG_NOSUB)) {
 
 2280        regfree(®exbuf_group);
 
 2292    regfree(®exbuf_group);
 
 2294        regfree(®exbuf_category);
 
 
 2306        if (gi->
chan == old) {
 
 2308        } 
else if (gi->
chan == 
new) {
 
 
 2359    char *scan, *wasdelim = 
NULL;
 
 2362    if (!
array || !arraylen) {
 
 2374    for (argc = 0; *scan && (argc < arraylen - 1); argc++) {
 
 2376        for (; *scan; scan++) {
 
 2379            } 
else if (*scan == 
')') {
 
 2383            } 
else if (*scan == 
'[') {
 
 2385            } 
else if (*scan == 
']') {
 
 2389            } 
else if (*scan == 
'"' && delim != 
'"') {
 
 2393                    memmove(scan, scan + 1, strlen(scan));
 
 2396            } 
else if (*scan == 
'\\') {
 
 2399                    memmove(scan, scan + 1, strlen(scan));
 
 2403            } 
else if ((*scan == delim) && !
paren && !
quote && !bracket) {
 
 2413    if (*scan || (scan > 
buf && (scan - 1) == wasdelim)) {
 
 2414        array[argc++] = scan;
 
 
 2426    int lp = strlen(path);
 
 2432    snprintf(fs, strlen(path) + 19, 
"%s/.lock-%08lx", path, (
unsigned long)
ast_random());
 
 2440    snprintf(s, strlen(path) + 9, 
"%s/.lock", path);
 
 2442    while (((res = link(fs, s)) < 0) && (
errno == EEXIST) && (time(
NULL) - start < 5)) {
 
 2452        ast_debug(1, 
"Locked path '%s'\n", path);
 
 
 2464    snprintf(s, strlen(path) + 9, 
"%s/%s", path, 
".lock");
 
 2466    if ((res = unlink(s))) {
 
 2469        ast_debug(1, 
"Unlocked path '%s'\n", path);
 
 
 2501    struct stat st, ost;
 
 2505    snprintf(fs, strlen(path) + 19, 
"%s/lock", path);
 
 2506    if (lstat(fs, &st) == 0) {
 
 2507        if ((st.st_mode & S_IFMT) == S_IFLNK) {
 
 2509                    "'%s': it's already a symbolic link\n",
 
 2513        if (st.st_nlink > 1) {
 
 2515                    "'%s': %u hard links exist\n",
 
 2516                    fs, (
unsigned int) st.st_nlink);
 
 2520    if ((fd = open(fs, O_WRONLY | O_CREAT, 0600)) < 0) {
 
 2522                fs, strerror(
errno));
 
 2540        ((res = fcntl(pl->
fd, F_SETLK, fcntl(pl->
fd, F_GETFL) | O_NONBLOCK)) < 0) &&
 
 2542        ((res = flock(pl->
fd, LOCK_EX | LOCK_NB)) < 0) &&
 
 2544            (
errno == EWOULDBLOCK) &&
 
 2545            (time(
NULL) - start < 5))
 
 2549                path, strerror(
errno));
 
 2560    if (lstat(fs, &st) != 0 && fstat(pl->
fd, &ost) != 0 &&
 
 2561            st.st_dev != ost.st_dev &&
 
 2562            st.st_ino != ost.st_ino) {
 
 2564                "file changed underneath us\n", fs);
 
 2574    ast_debug(1, 
"Locked path '%s'\n", path);
 
 
 2597        snprintf(s, strlen(
path) + 19, 
"%s/lock", 
path);
 
 2602        ast_debug(1, 
"Failed to unlock path '%s': " 
 2603                "lock not found\n", 
path);
 
 
 2652    int max_attempts = 3;
 
 2655    int message_exists = 0;
 
 2668    while ((cmd >= 0) && (cmd != 
't')) {
 
 2671            if (!message_exists) {
 
 2682            ast_verb(3, 
"Reviewing the recording\n");
 
 2688            ast_verb(3, 
"R%secording\n", recorded == 1 ? 
"e-r" : 
"");
 
 2696            } 
else if (cmd == 
'*') {
 
 2715            if (message_exists) {
 
 2729            if (attempts > max_attempts) {
 
 
 2740#define RES_UPONE (1 << 16) 
 2741#define RES_EXIT  (1 << 17) 
 2742#define RES_REPEAT (1 << 18) 
 2743#define RES_RESTART ((1 << 19) | RES_REPEAT) 
 2754    switch (option->
action) {
 
 2758        return RES_EXIT | (((
unsigned long)(option->
adata)) & 0xffff);
 
 2791        ivr_func = option->
adata;
 
 2792        res = ivr_func(chan, cbdata);
 
 2801        while ((n = 
strsep(&
c, 
";"))) {
 
 
 2831        if ((!strncasecmp(menu->
options[
x].
option, option, strlen(option))) &&
 
 
 2845        if (strlen(
exten) >= maxexten - 1) {
 
 2854    return res > 0 ? 0 : res;
 
 
 2875                ast_debug(1, 
"IVR Dispatch of '%s' (pos %d) yields %d\n", 
exten, pos, res);
 
 2905                    ast_debug(1, 
"Got start of extension, %c\n", res);
 
 2913                            ast_debug(1, 
"Invalid extension entered, going to 'i'!\n");
 
 2918                            ast_debug(1, 
"Aborting on invalid entry, with no 'i' option!\n");
 
 2933        if (!strcasecmp(
exten, 
"s")) {
 
 
 2946    return res > 0 ? 0 : res;
 
 
 2951    int fd, count = 0, res;
 
 2952    char *output = 
NULL;
 
 2953    struct stat filesize;
 
 2955    if (stat(filename, &filesize) == -1) {
 
 2960    count = filesize.st_size + 1;
 
 2962    if ((fd = open(filename, O_RDONLY)) < 0) {
 
 2968        res = read(fd, output, count - 1);
 
 2969        if (res == count - 1) {
 
 
 2986    int curarg, res = 0;
 
 2987    unsigned int argloc;
 
 2991    if (flaglen == 32) {
 
 3003        curarg = *s++ & 0x7f;   
 
 3004        argloc = 
options[curarg].arg_index;
 
 3007            int parsequotes = (s[1] == 
'"') ? 1 : 0;
 
 3012                if (*s == 
'(' && !
quote) {
 
 3014                } 
else if (*s == 
')' && !
quote) {
 
 3017                } 
else if (*s == 
'"' && parsequotes) {
 
 3022                } 
else if (*s == 
'\\') {
 
 3026                    } 
else if (
quote && s[1] == 
'"') {
 
 3040            if ((s = strchr(s, 
')'))) {
 
 3042                    args[argloc - 1] = arg;
 
 3046                ast_log(
LOG_WARNING, 
"Missing closing parenthesis for argument '%c' in string '%s'\n", curarg, arg);
 
 3050        } 
else if (argloc) {
 
 3051            args[argloc - 1] = 
"";
 
 3056        if (flaglen == 32) {
 
 
 3078    unsigned int i, found = 0;
 
 3079    for (i = 32; i < 128 && found < 
len; i++) {
 
 
 3097    if (*stream == 
'\\') {
 
 3099        switch (*(stream + 1)) {
 
 3111            if (strchr(
"0123456789ABCDEFabcdef", *(stream + 2)) && *(stream + 2) != 
'\0') {
 
 3113                if (*(stream + 2) <= 
'9') {
 
 3114                    *
result = *(stream + 2) - 
'0';
 
 3115                } 
else if (*(stream + 2) <= 
'F') {
 
 3116                    *
result = *(stream + 2) - 
'A' + 10;
 
 3118                    *
result = *(stream + 2) - 
'a' + 10;
 
 3121                ast_log(
LOG_ERROR, 
"Illegal character '%c' in hexadecimal string\n", *(stream + 2));
 
 3125            if (strchr(
"0123456789ABCDEFabcdef", *(stream + 3)) && *(stream + 3) != 
'\0') {
 
 3128                if (*(stream + 3) <= 
'9') {
 
 3129                    *
result += *(stream + 3) - 
'0';
 
 3130                } 
else if (*(stream + 3) <= 
'F') {
 
 3131                    *
result += *(stream + 3) - 
'A' + 10;
 
 3133                    *
result += *(stream + 3) - 
'a' + 10;
 
 3140            for (i = 2; ; i++) {
 
 3141                if (strchr(
"01234567", *(stream + i)) && *(stream + i) != 
'\0') {
 
 3145                    *
result += *(stream + i) - 
'0';
 
 
 3181    if (strchr(stream, 
'\\')) {
 
 3190            buf[offset++] = next;
 
 3194        buf[offset++] = 
'\0';
 
 
 3209    sigset_t signal_set, old_set;
 
 3219    (void) sigfillset(&signal_set);
 
 3220    pthread_sigmask(SIG_BLOCK, &signal_set, &old_set);
 
 3226        pthread_sigmask(SIG_SETMASK, &old_set, 
NULL);
 
 3227        if (!stop_reaper && pid > 0) {
 
 3236                        ast_log(
LOG_ERROR, 
"Shaun of the Dead wants to kill zombies, but can't?!!\n");
 
 3246        cap_set_proc(child_cap);
 
 3250        signal(SIGHUP, SIG_DFL);
 
 3251        signal(SIGCHLD, SIG_DFL);
 
 3252        signal(SIGINT, SIG_DFL);
 
 3253        signal(SIGURG, SIG_DFL);
 
 3254        signal(SIGTERM, SIG_DFL);
 
 3255        signal(SIGPIPE, SIG_DFL);
 
 3256        signal(SIGXFSZ, SIG_DFL);
 
 3259        if (pthread_sigmask(SIG_UNBLOCK, &signal_set, 
NULL)) {
 
 
 3277#ifdef HAVE_LONG_DOUBLE_WIDER 
 3279    #define FMT "%30Lf%9s" 
 3282    #define FMT "%30lf%9s" 
 3288    res = sscanf(timestr, 
FMT, &amount, u);
 
 3290    if (res == 0 || res == EOF) {
 
 3293    } 
else if (res == 2) {
 
 3311            if (toupper(u[1]) == 
'S') {
 
 3316            } 
else if (u[1] == 
'\0') {
 
 3340    *
result = amount > INT_MAX ? INT_MAX : (int) amount;
 
 
 3357    cap_free(child_cap);
 
 
 3369    child_cap = cap_from_text(
"cap_net_admin-eip");
 
 
static const struct ast_vm_functions vm_table
static int messagecount(const char *mailbox_id, const char *folder)
static int inboxcount(const char *mailbox, int *newmsgs, int *oldmsgs)
static int silencethreshold
static int has_voicemail(const char *mailbox, const char *folder)
Determines if the given folder has messages.
static int inboxcount2(const char *mailbox, int *urgentmsgs, int *newmsgs, int *oldmsgs)
Check the given mailbox's message count.
static int sayname(struct ast_channel *chan, const char *mailbox, const char *context)
char * strsep(char **str, const char *delims)
void closefrom(int lowfd)
static struct ast_str * prompt
Asterisk main include file. File version handling, generic pbx functions.
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
#define ast_strdup(str)
A wrapper for strdup()
#define ast_strdupa(s)
duplicate a string in memory from the stack
#define ast_calloc(num, len)
A wrapper for calloc()
#define ast_malloc(len)
A wrapper for malloc()
#define AO2_GLOBAL_OBJ_STATIC(name)
Define a global object holder to be used to hold an ao2 object, statically initialized.
@ AO2_ALLOC_OPT_LOCK_NOLOCK
#define ao2_global_obj_replace_unref(holder, obj)
Replace an ao2 object in the global holder, throwing away any old object.
#define ao2_global_obj_ref(holder)
Get a reference to the object stored in the global holder.
#define ao2_alloc_options(data_size, destructor_fn, options)
#define ao2_global_obj_release(holder)
Release the ao2 object held in the global holder.
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
static void suspend(struct cc_core_instance *core_instance)
General Asterisk PBX channel definitions.
int ast_waitfordigit(struct ast_channel *c, int ms)
Waits for a digit.
const char * ast_channel_name(const struct ast_channel *chan)
int ast_autoservice_stop(struct ast_channel *chan)
Stop servicing a channel for us...
int ast_activate_generator(struct ast_channel *chan, struct ast_generator *gen, void *params)
int ast_readstring_full(struct ast_channel *c, char *s, int len, int timeout, int rtimeout, char *enders, int audiofd, int ctrlfd)
int ast_queue_hangup(struct ast_channel *chan)
Queue a hangup frame.
int ast_senddigit(struct ast_channel *chan, char digit, unsigned int duration)
Send a DTMF digit to a channel.
struct ast_silence_generator * ast_channel_start_silence_generator(struct ast_channel *chan)
Starts a silence generator on the given channel.
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
struct ast_flags * ast_channel_flags(struct ast_channel *chan)
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.
int ast_check_hangup_locked(struct ast_channel *chan)
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.
int ast_autoservice_start(struct ast_channel *chan)
Automatically service a channel for us...
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
int ast_senddigit_mf_end(struct ast_channel *chan)
End sending an MF digit to a channel.
int ast_senddigit_external(struct ast_channel *chan, char digit, unsigned int duration)
Send a DTMF digit to a channel from an external thread.
int ast_set_read_format(struct ast_channel *chan, struct ast_format *format)
Sets read format on channel chan.
struct ast_frame * ast_read_noaudio(struct ast_channel *chan)
Reads a frame, returning AST_FRAME_NULL frame if audio.
struct ast_tone_zone * ast_channel_zone(const struct ast_channel *chan)
struct ast_format * ast_channel_writeformat(struct ast_channel *chan)
int ast_set_write_format(struct ast_channel *chan, struct ast_format *format)
Sets write format on channel chan.
const char * ast_channel_language(const struct ast_channel *chan)
int ast_senddigit_mf(struct ast_channel *chan, char digit, unsigned int duration, unsigned int durationkp, unsigned int durationst, int is_external)
Send an MF digit to a channel.
struct ast_filestream * ast_channel_stream(const struct ast_channel *chan)
struct ast_pbx * ast_channel_pbx(const struct ast_channel *chan)
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
int ast_readstring(struct ast_channel *c, char *s, int len, int timeout, int rtimeout, char *enders)
Reads multiple digits.
int ast_indicate(struct ast_channel *chan, int condition)
Indicates condition of channel.
int ast_safe_sleep(struct ast_channel *chan, int ms)
Wait for a specified amount of time, looking for hangups.
#define AST_MAX_EXTENSION
struct ast_format * ast_channel_readformat(struct ast_channel *chan)
Convenient Signal Processing routines.
void ast_dsp_set_threshold(struct ast_dsp *dsp, int threshold)
Set the minimum average magnitude threshold to determine talking by the DSP.
void ast_dsp_free(struct ast_dsp *dsp)
int ast_dsp_silence(struct ast_dsp *dsp, struct ast_frame *f, int *totalsilence)
Process the audio frame for silence.
int ast_dsp_get_threshold_from_settings(enum threshold which)
Get silence threshold from dsp.conf.
struct ast_dsp * ast_dsp_new(void)
Allocates a new dsp, assumes 8khz for internal sample rate.
Generic File Format Support. Should be included by clients of the file handling routines....
off_t ast_tellstream(struct ast_filestream *fs)
Tell where we are in a stream.
int ast_waitstream_fr_w_cb(struct ast_channel *c, const char *breakon, const char *forward, const char *rewind, int ms, ast_waitstream_fr_cb cb)
Same as waitstream_fr but allows a callback to be alerted when a user fastforwards or rewinds the fil...
struct ast_frame * ast_readframe(struct ast_filestream *s)
Read a frame from a filestream.
void() ast_waitstream_fr_cb(struct ast_channel *chan, long ms, enum ast_waitstream_fr_cb_values val)
callback used during dtmf controlled file playback to indicate location of playback in a file after r...
int ast_stopstream(struct ast_channel *c)
Stops a stream.
int ast_writestream(struct ast_filestream *fs, struct ast_frame *f)
Writes a frame to a stream.
int ast_seekstream(struct ast_filestream *fs, off_t sample_offset, int whence)
Seeks into stream.
int ast_stream_rewind(struct ast_filestream *fs, off_t ms)
Rewind stream ms.
int ast_filerename(const char *oldname, const char *newname, const char *fmt)
Renames a file.
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.
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_streamfile(struct ast_channel *c, const char *filename, const char *preflang)
Streams a file.
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.
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.
int ast_truncstream(struct ast_filestream *fs)
Trunc stream at current location.
int ast_closestream(struct ast_filestream *f)
Closes a stream.
int ast_filedelete(const char *filename, const char *fmt)
Deletes a file.
int ast_waitstream(struct ast_channel *c, const char *breakon)
Waits for a stream to stop or digit to be pressed.
static int array(struct ast_channel *chan, const char *cmd, char *var, const char *value)
static int quote(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
#define SCOPE_EXIT_RTN_VALUE(__return_value,...)
#define SCOPE_ENTER(level,...)
#define ast_trace(level,...)
Application convenience functions, designed to give consistent look and feel to Asterisk apps.
@ AST_GETDATA_EMPTY_END_TERMINATED
@ AST_LOCK_PATH_NOT_FOUND
void ast_replace_sigchld(void)
Replace the SIGCHLD handler.
#define VM_GREETER_MODULE_VERSION
#define VM_MODULE_VERSION
AST_LOCK_TYPE
Type of locking to use in ast_lock_path / ast_unlock_path.
void() ast_vm_msg_play_cb(struct ast_channel *chan, const char *playfile, int duration)
Voicemail playback callback function definition.
@ AST_RECORD_IF_EXISTS_FAIL
@ AST_RECORD_IF_EXISTS_APPEND
@ AST_RECORD_IF_EXISTS_OVERWRITE
@ AST_RECORD_IF_EXISTS_ERROR
void ast_unreplace_sigchld(void)
Restore the SIGCHLD handler.
void ast_frame_dtor(struct ast_frame *frame)
NULL-safe wrapper for ast_frfree, good for RAII_VAR.
#define AST_FRIENDLY_OFFSET
Offset into a frame's data buffer.
@ AST_CONTROL_RECORD_CANCEL
@ AST_CONTROL_STREAM_RESTART
@ AST_CONTROL_STREAM_SUSPEND
@ AST_CONTROL_STREAM_REVERSE
@ AST_CONTROL_RECORD_STOP
@ AST_CONTROL_RECORD_MUTE
@ AST_CONTROL_STREAM_STOP
@ AST_CONTROL_STREAM_FORWARD
@ AST_CONTROL_RECORD_SUSPEND
#define ast_debug(level,...)
Log a DEBUG message.
#define ast_verb(level,...)
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.
int ast_playtones_start(struct ast_channel *chan, int vol, const char *tonelist, int interruptible)
Start playing a list of tones on a channel.
void ast_playtones_stop(struct ast_channel *chan)
Stop playing tones on a channel.
struct ast_tone_zone_sound * ast_get_indication_tone(const struct ast_tone_zone *zone, const char *indication)
Locate a tone zone sound.
static struct ast_tone_zone * ast_tone_zone_unref(struct ast_tone_zone *tz)
Release a reference to an ast_tone_zone.
struct ast_tone_zone * ast_get_indication_zone(const char *country)
locate ast_tone_zone
Asterisk JSON abstraction layer.
A set of macros to manage forward-linked lists.
#define AST_RWLIST_REMOVE_CURRENT
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
#define AST_LIST_HEAD_STATIC(name, type)
Defines a structure to be used to hold a list of specified type, statically initialized.
#define AST_RWLIST_TRAVERSE_SAFE_BEGIN
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
#define AST_RWLIST_HEAD_STATIC(name, type)
Defines a structure to be used to hold a read/write list of specified type, statically initialized.
#define AST_LIST_EMPTY(head)
Checks whether the specified list contains any entries.
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
#define AST_RWLIST_TRAVERSE_SAFE_END
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
#define AST_LIST_LOCK(head)
Locks a list.
#define AST_RWLIST_TRAVERSE
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
#define AST_RWLIST_INSERT_TAIL
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
#define AST_LIST_FIRST(head)
Returns the first entry contained in a list.
#define AST_LIST_NEXT(elm, field)
Returns the next entry in the list after the given entry.
Asterisk locking-related definitions:
#define AST_PTHREADT_NULL
const char * ast_app_expand_sub_args(struct ast_channel *chan, const char *args)
Add missing context/exten to subroutine argument string.
static enum control_tone_frame_response_result control_tone_frame_response(struct ast_channel *chan, struct ast_frame *fr, struct ast_tone_zone_sound *ts, const char *tone, int *paused)
int ast_app_group_get_count(const char *group, const char *category)
Get the current channel count of the specified group and category.
int __ast_vm_greeter_register(const struct ast_vm_greeter_functions *vm_table, struct ast_module *module)
Set voicemail greeter function callbacks.
static int global_maxsilence
static int ast_ivr_menu_run_internal(struct ast_channel *chan, struct ast_ivr_menu *menu, void *cbdata)
int ast_sf_stream(struct ast_channel *chan, struct ast_channel *peer, struct ast_channel *chan2, const char *digits, int frequency, int is_external)
Send a string of SF digits to a channel.
int ast_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 beep, int silencethreshold, int maxsilence, const char *path, const char *acceptdtmf, const char *canceldtmf, int skip_confirmation_sound, enum ast_record_if_exists if_exists)
Record a file based on input from a channel This function will play "auth-thankyou" upon successful r...
int ast_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...
void ast_safe_fork_cleanup(void)
Common routine to cleanup after fork'ed process is complete (if reaping was stopped)
#define VM_API_CALL(res, api_call, api_parms)
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_messagecount(const char *mailbox_id, const char *folder)
Get the number of messages in a given mailbox folder.
static int parse_options(const struct ast_app_option *options, void *_flags, char **args, char *optstr, int flaglen)
static int ast_unlock_path_flock(const char *path)
int __ast_vm_register(const struct ast_vm_functions *vm_table, struct ast_module *module)
Set voicemail function callbacks.
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.
static int option_exists(struct ast_ivr_menu *menu, char *option)
int ast_get_encoded_char(const char *stream, char *result, size_t *consumed)
Decode an encoded control or extended ASCII character.
int ast_linear_stream(struct ast_channel *chan, const char *filename, int fd, int allowoverride)
Stream a filename (or file descriptor) as a generator.
int ast_control_streamfile_w_cb(struct ast_channel *chan, const char *file, const char *fwd, const char *rev, const char *stop, const char *suspend, const char *restart, int skipms, long *offsetms, ast_waitstream_fr_cb cb)
Stream a file with fast forward, pause, reverse, restart.
static const char default_acceptdtmf[]
int app_init(void)
Initialize the application core.
static pthread_t shaun_of_the_dead_thread
int ast_play_and_prepend(struct ast_channel *chan, char *playfile, char *recordfile, int maxtime, char *fmt, int *duration, int *sound_duration, int beep, int silencethreshold, int maxsilence)
Record a file based on input frm a channel. Recording is performed in 'prepend' mode which works a li...
static int control_streamfile(struct ast_channel *chan, const char *file, const char *fwd, const char *rev, const char *stop, const char *suspend, const char *restart, int skipms, long *offsetms, const char *lang, ast_waitstream_fr_cb cb)
int ast_app_group_update(struct ast_channel *old, struct ast_channel *new)
Update all group counting for a channel to a new one.
void ast_dtmf_stream_external(struct ast_channel *chan, const char *digits, int between, unsigned int duration)
Send a string of DTMF digits to a channel from an external thread.
int ast_vm_msg_play(struct ast_channel *chan, const char *mailbox, const char *context, const char *folder, const char *msg_num, ast_vm_msg_play_cb *cb)
Play a voicemail msg back on a channel.
static int global_silence_threshold
struct stasis_topic * ast_queue_topic(const char *queuename)
Get the Stasis Message Bus API topic for queue messages for a particular queue name.
static int linear_generator(struct ast_channel *chan, void *data, int len, int samples)
static int ast_unlock_path_lockfile(const char *path)
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 const struct ast_app_stack_funcs * app_stack_callbacks
int ast_control_streamfile(struct ast_channel *chan, const char *file, const char *fwd, const char *rev, const char *stop, const char *suspend, const char *restart, int skipms, long *offsetms)
Stream a file with fast forward, pause, reverse, restart.
static int dtmf_stream(struct ast_channel *chan, const char *digits, int between, unsigned int duration, int is_external)
static int option_matchmore(struct ast_ivr_menu *menu, char *option)
static struct ast_frame * make_silence(const struct ast_frame *orig)
Construct a silence frame of the same duration as orig.
int ast_app_parse_timelen(const char *timestr, int *result, enum ast_timelen unit)
Common routine to parse time lengths, with optional time unit specifier.
void ast_vm_greeter_unregister(const char *module_name)
Unregister the specified voicemail greeter provider.
static struct ast_generator linearstream
int ast_control_tone(struct ast_channel *chan, const char *tone)
Controls playback of a tone.
enum ast_getdata_result ast_app_getdata(struct ast_channel *c, const char *prompt, char *s, int maxlen, int timeout)
Plays a stream and gets DTMF data from a channel.
static enum AST_LOCK_RESULT ast_lock_path_lockfile(const char *path)
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, enum ast_record_if_exists if_exists)
static enum AST_LOCK_RESULT ast_lock_path_flock(const char *path)
static const char default_canceldtmf[]
static struct stasis_topic_pool * queue_topic_pool
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.
int ast_app_group_set_channel(struct ast_channel *chan, const char *data)
Set the group for a channel, splitting the provided data into group and category, if specified.
int ast_app_group_list_wrlock(void)
Write Lock the group count list.
static struct stasis_topic * queue_topic_all
Define Stasis Message Bus API topic objects.
enum AST_LOCK_RESULT ast_lock_path(const char *path)
Lock a filesystem path.
char * ast_read_textfile(const char *filename)
Read a file into asterisk.
int ast_app_has_voicemail(const char *mailboxes, const char *folder)
Determine if a given mailbox has any voicemail If folder is NULL, defaults to "INBOX"....
static void path_lock_destroy(struct path_lock *obj)
int ast_safe_fork(int stop_reaper)
Common routine to safely fork without a chance of a signal handler firing badly in the child.
static int sf_stream(struct ast_channel *chan, struct ast_channel *chan2, const char *digits, int frequency, int is_external)
static void app_cleanup(void)
void ast_install_stack_functions(const struct ast_app_stack_funcs *funcs)
Set stack application function callbacks.
#define VM_GREETER_API_CALL(res, api_call, api_parms)
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_vm_msg_forward(const char *from_mailbox, const char *from_context, const char *from_folder, const char *to_mailbox, const char *to_context, const char *to_folder, size_t num_msgs, const char *msg_ids[], int delete_old)
forward a message from one mailbox to another.
static int external_sleep(struct ast_channel *chan, int ms)
control_tone_frame_response_result
@ CONTROL_TONE_RESPONSE_FAILED
@ CONTROL_TONE_RESPONSE_NORMAL
@ CONTROL_TONE_RESPONSE_FINISHED
static int read_newoption(struct ast_channel *chan, struct ast_ivr_menu *menu, char *exten, int maxexten)
struct ast_vm_mailbox_snapshot * ast_vm_mailbox_snapshot_destroy(struct ast_vm_mailbox_snapshot *mailbox_snapshot)
destroy a snapshot
enum ast_getdata_result ast_app_getdata_terminator(struct ast_channel *c, const char *prompt, char *s, int maxlen, int timeout, char *terminator)
Plays a stream and gets DTMF data from a channel.
int ast_app_copy_recording_to_vm(struct ast_vm_recording_data *vm_rec_data)
param[in] vm_rec_data Contains data needed to make the recording. retval 0 voicemail successfully cre...
int ast_vm_greeter_is_registered(void)
Determine if a voicemail greeter provider is registered.
int ast_app_group_list_unlock(void)
Unlock the group count list.
static int mf_stream(struct ast_channel *chan, struct ast_channel *chan2, const char *digits, int between, unsigned int duration, unsigned int durationkp, unsigned int durationst, int is_external)
void ast_vm_unregister(const char *module_name)
Unregister the specified voicemail provider.
static void * shaun_of_the_dead(void *data)
void ast_set_lock_type(enum AST_LOCK_TYPE type)
Set the type of locks used by ast_lock_path()
int ast_app_inboxcount(const char *mailboxes, int *newmsgs, int *oldmsgs)
Determine number of new/old messages in a mailbox.
static int vm_greeter_warnings
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.
int ast_control_streamfile_lang(struct ast_channel *chan, const char *file, const char *fwd, const char *rev, const char *stop, const char *suspend, const char *restart, int skipms, const char *lang, long *offsetms)
Version of ast_control_streamfile() which allows the language of the media file to be specified.
int ast_app_sayname(struct ast_channel *chan, const char *mailbox_id)
Play a recorded user name for the mailbox to the specified channel.
int ast_ivr_menu_run(struct ast_channel *chan, struct ast_ivr_menu *menu, void *cbdata)
Runs an IVR menu.
const char * ast_vm_index_to_foldername(int id)
Return name of folder, given an id.
int ast_app_inboxcount2(const char *mailboxes, int *urgentmsgs, int *newmsgs, int *oldmsgs)
Determine number of urgent/new/old messages in a mailbox.
int ast_vm_msg_move(const char *mailbox, const char *context, size_t num_msgs, const char *oldfolder, const char *old_msg_ids[], const char *newfolder)
Move messages from one folder to another.
static void vm_greeter_warn_no_provider(void)
struct ast_group_info * ast_app_group_list_head(void)
Get the head of the group count list.
void ast_app_options2str64(const struct ast_app_option *options, struct ast_flags64 *flags, char *buf, size_t len)
Given a list of options array, return an option string based on passed flags.
int ast_app_group_discard(struct ast_channel *chan)
Discard all group counting for a channel.
int ast_play_and_record(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)
Record a file based on input from a channel. Use default accept and cancel DTMF. This function will p...
int ast_vm_is_registered(void)
Determine if a voicemail provider is registered.
static int set_read_to_slin(struct ast_channel *chan, struct ast_format **orig_format)
Sets a channel's read format to ast_format_slin, recording its original format.
struct stasis_topic * ast_queue_topic_all(void)
Get the Stasis Message Bus API topic for queue messages.
static void vm_warn_no_provider(void)
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.
struct ast_vm_mailbox_snapshot * ast_vm_mailbox_snapshot_create(const char *mailbox, const char *context, const char *folder, int descending, enum ast_vm_snapshot_sort_val sort_val, int combine_INBOX_and_OLD)
Create a snapshot of a mailbox which contains information about every msg.
int ast_dtmf_stream(struct ast_channel *chan, struct ast_channel *peer, const char *digits, int between, unsigned int duration)
Send a string of DTMF digits to a channel.
int ast_mf_stream(struct ast_channel *chan, struct ast_channel *peer, struct ast_channel *chan2, const char *digits, int between, unsigned int duration, unsigned int durationkp, unsigned int durationst, int is_external)
Send a string of MF digits to a channel.
int ast_app_parse_options(const struct ast_app_option *options, struct ast_flags *flags, char **args, char *optstr)
Parses a string containing application options and sets flags/arguments.
int ast_app_dtget(struct ast_channel *chan, const char *context, char *collect, size_t size, int maxlen, int timeout)
This function presents a dialtone and reads an extension into 'collect' which must be a pointer to a ...
int ast_vm_msg_remove(const char *mailbox, const char *context, size_t num_msgs, const char *folder, const char *msgs[])
Remove/delete messages from a mailbox folder.
int ast_unlock_path(const char *path)
Unlock a path.
static int parse_tone_uri(char *tone_parser, const char **tone_indication, const char **tone_zone)
static int ivr_dispatch(struct ast_channel *chan, struct ast_ivr_option *option, char *exten, void *cbdata)
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.
char * ast_get_encoded_str(const char *stream, char *result, size_t result_size)
Decode a stream of encoded control or extended ASCII characters.
int ast_app_group_list_rdlock(void)
Read Lock the group count list.
static void linear_release(struct ast_channel *chan, void *params)
void ast_close_fds_above_n(int n)
Common routine for child processes, to close all fds prior to exec(2)
static void * linear_alloc(struct ast_channel *chan, void *params)
Asterisk module definitions.
#define ast_module_unref(mod)
Release a reference to the module.
#define ast_module_running_ref(mod)
Hold a reference to the module if it is running.
@ AST_MODULE_LOAD_DECLINE
Module has failed to load, may be in an inconsistent state.
#define ast_opt_transmit_silence
Asterisk file paths, configured in asterisk.conf.
const char * ast_config_AST_DATA_DIR
Core PBX routines and definitions.
int ast_exists_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Determine whether an extension exists.
int ast_ignore_pattern(const char *context, const char *pattern)
Checks to see if a number should be ignored.
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)
int ast_parseable_goto(struct ast_channel *chan, const char *goto_string)
#define ast_poll(a, b, c)
static struct stasis_rest_handlers mailboxes
REST handler for /api-docs/mailboxes.json.
Stasis Message Bus API. See Stasis Message Bus API for detailed documentation.
struct stasis_topic * stasis_topic_pool_get_topic(struct stasis_topic_pool *pool, const char *topic_name)
Find or create a topic in the pool.
struct stasis_topic * stasis_topic_create(const char *name)
Create a new topic.
struct stasis_topic_pool * stasis_topic_pool_create(struct stasis_topic *pooled_topic)
Create a topic pool that routes messages from dynamically generated topics to the given topic.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one.
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
static force_inline int attribute_pure ast_strlen_zero(const char *s)
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
#define ast_str_make_space(buf, new_len)
void ast_str_update(struct ast_str *buf)
Update the length of the buffer, after using ast_str merely as a buffer.
char *attribute_pure ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
size_t attribute_pure ast_str_size(const struct ast_str *buf)
Returns the current maximum length (without reallocation) of the current buffer.
char * ast_strsep(char **s, const char sep, uint32_t flags)
Act like strsep but ignore separators inside quotes.
A structure to hold the description of an application 'option'.
Stack applications callback functions.
void *int(* run_sub)(struct ast_channel *chan, const char *args, int ignore_hangup)
Callback for the routine to run a subroutine on a channel.
const char *(* expand_sub_args)(struct ast_channel *chan, const char *args)
Add missing context/exten to Gosub application argument string.
Main Channel structure associated with a channel.
char exten[AST_MAX_EXTENSION]
This structure is allocated by file.c in one chunk, together with buf_size and desc_size bytes of mem...
Structure used to handle a large number of boolean flags == used only in app_dial?
Structure used to handle boolean flags.
struct ast_format * format
Data structure associated with a single frame of data.
struct ast_frame_subclass subclass
enum ast_frame_type frametype
union ast_frame::@239 data
void *(* alloc)(struct ast_channel *chan, void *params)
struct ast_group_info::@223 group_list
struct ast_channel * chan
Support for dynamic strings.
const char * data
Description of a tone.
A set of tones for a given locale.
Voicemail function table definition.
unsigned int module_version
The version of this function table.
const char * module_name
The name of the module that provides the voicemail functionality.
Voicemail greeter function table definition.
const char * module_name
The name of the module that provides the voicemail greeter functionality.
Structure used for ast_copy_recording_to_vm in order to cleanly supply data needed for making the rec...
struct ast_format * origwfmt
struct path_lock::@315 le
#define ast_test_suite_event_notify(s, f,...)
Definitions to aid in the use of thread local storage.
#define AST_THREADSTORAGE_PUBLIC(name)
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
#define ast_test_flag64(p, flag)
#define ast_pthread_create_background(a, b, c, d)
#define ast_clear_flag(p, flag)
long int ast_random(void)
#define ast_set_flag64(p, flag)
#define ast_set_flag(p, flag)