Thu Oct 11 06:37:43 2012

Asterisk developer's documentation


Module: Dial plan applications

Applications support the dialplan. They register dynamically with. More...


Files

file  app_adsiprog.c
 Program Asterisk ADSI Scripts into phone.
file  app_alarmreceiver.c
 Central Station Alarm receiver for Ademco Contact ID.
file  app_amd.c
 Answering machine detection.
file  app_authenticate.c
 Execute arbitrary authenticate commands.
file  app_cdr.c
 Applications connected with CDR engine.
file  app_celgenuserevent.c
 Generate User-Defined CEL event.
file  app_chanisavail.c
 Check if Channel is Available.
file  app_channelredirect.c
 ChannelRedirect application.
file  app_chanspy.c
 ChanSpy: Listen in on any channel.
file  app_confbridge.c
 Conference Bridge application.
file  app_controlplayback.c
 Trivial application to control playback of a sound file.
file  app_dahdibarge.c
 DAHDI Barge support.
file  app_dahdiras.c
 Execute an ISDN RAS.
file  app_db.c
 Database access functions.
file  app_dial.c
 dial() & retrydial() - Trivial application to dial a channel and send an URL on answer
file  app_dictate.c
 Virtual Dictation Machine Application For Asterisk.
file  app_directed_pickup.c
 Directed Call Pickup Support.
file  app_directory.c
 Provide a directory of extensions.
file  app_disa.c
 DISA -- Direct Inward System Access Application.
file  app_dumpchan.c
 Application to dump channel variables.
file  app_echo.c
 Echo application -- play back what you hear to evaluate latency.
file  app_exec.c
 Exec application.
file  app_externalivr.c
 External IVR application interface.
file  app_festival.c
 Connect to festival.
file  app_flash.c
 App to flash a DAHDI trunk.
file  app_followme.c
 Find-Me Follow-Me application.
file  app_forkcdr.c
 Fork CDR application.
file  app_getcpeid.c
 Get ADSI CPE ID.
file  app_ices.c
 Stream to an icecast server via ICES (see contrib/asterisk-ices.xml).
file  app_image.c
 App to transmit an image.
file  app_ivrdemo.c
 IVR Demo application.
file  app_jack.c
 Jack Application.
file  app_macro.c
 Dial plan macro Implementation.
file  app_meetme.c
 Meet me conference bridge and Shared Line Appearances.
file  app_milliwatt.c
 Digital Milliwatt Test.
file  app_minivm.c
 MiniVoiceMail - A Minimal Voicemail System for Asterisk.
file  app_mixmonitor.c
 MixMonitor() - Record a call and mix the audio during the recording.
file  app_morsecode.c
 Morsecode application.
file  app_mp3.c
 Silly application to play an MP3 file -- uses mpg123.
file  app_nbscat.c
 Silly application to play an NBScat file -- uses nbscat8k.
file  app_originate.c
 Originate application.
file  app_osplookup.c
 Open Settlement Protocol (OSP) Applications.
file  app_page.c
 page() - Paging application
file  app_parkandannounce.c
 ParkAndAnnounce application for Asterisk.
file  app_playback.c
 Trivial application to playback a sound file.
file  app_playtones.c
 Playtones application.
file  app_privacy.c
 Block all calls without Caller*ID, require phone # to be entered.
file  app_queue.c
 True call queues with optional send URL on answer.
file  app_read.c
 Trivial application to read a variable.
file  app_readexten.c
 Trivial application to read an extension into a variable.
file  app_readfile.c
 ReadFile application -- Reads in a File for you.
file  app_record.c
 Trivial application to record a sound file.
file  app_saycounted.c
 Applications to decline words according to current language.
file  app_sayunixtime.c
 SayUnixTime application.
file  app_senddtmf.c
 App to send DTMF digits.
file  app_sendtext.c
 App to transmit a text message.
file  app_setcallerid.c
 App to set callerid presentation.
file  app_skel.c
 Skeleton application.
file  app_sms.c
 SMS application - ETSI ES 201 912 protocol 1 implementation.
file  app_softhangup.c
 SoftHangup application.
file  app_speech_utils.c
 Speech Recognition Utility Applications.
file  app_stack.c
 Stack applications Gosub, Return, etc.
file  app_system.c
 Execute arbitrary system commands.
file  app_talkdetect.c
 Playback a file with audio detect.
file  app_test.c
 Applications to test connection and produce report in text file.
file  app_transfer.c
 Transfer a caller.
file  app_url.c
 App to transmit a URL.
file  app_userevent.c
 UserEvent application -- send manager event.
file  app_verbose.c
 Verbose logging application.
file  app_voicemail.c
 Comedian Mail - Voicemail System.
file  app_waitforring.c
 Wait for Ring Application.
file  app_waitforsilence.c
 Wait for Silence
  • Waits for up to 'x' milliseconds of silence, 'y' times
  • WaitForSilence(500,2) will wait for 1/2 second of silence, twice
  • WaitForSilence(1000,1) will wait for 1 second of silence, once
  • WaitForSilence(300,3,10) will wait for 300ms of silence, 3 times, and return after 10sec
    .

file  app_waituntil.c
 Sleep until the given epoch.
file  app_while.c
 While Loop Implementation.
file  app_zapateller.c
 Playback the special information tone to get rid of telemarketers.
file  res_ael_share.c
 Shareable AEL code -- mainly between internal and external modules.
file  res_fax.c
 Generic FAX Resource for FAX technology resource modules.
file  res_format_attr_h263.c
 H.263 Format Attribute Module.
file  res_format_attr_h264.c
 H.264 Format Attribute Module.
file  res_realtime.c
 RealTime CLI.

Functions

static int iax2_prov_app (struct ast_channel *chan, const char *data)
static int pbx_builtin_answer (struct ast_channel *, const char *)
static int pbx_builtin_background (struct ast_channel *, const char *)
static int pbx_builtin_busy (struct ast_channel *, const char *)
static int pbx_builtin_congestion (struct ast_channel *, const char *)
static int pbx_builtin_execiftime (struct ast_channel *, const char *)
static int pbx_builtin_goto (struct ast_channel *, const char *)
static int pbx_builtin_gotoiftime (struct ast_channel *, const char *)
static int pbx_builtin_hangup (struct ast_channel *, const char *)
static int pbx_builtin_proceeding (struct ast_channel *, const char *)
static int pbx_builtin_progress (struct ast_channel *, const char *)
static int pbx_builtin_resetcdr (struct ast_channel *, const char *)
static int pbx_builtin_ringing (struct ast_channel *, const char *)
static int pbx_builtin_setamaflags (struct ast_channel *, const char *)
static int pbx_builtin_wait (struct ast_channel *, const char *)
static int pbx_builtin_waitexten (struct ast_channel *, const char *)

Detailed Description

Applications support the dialplan. They register dynamically with.

Asterisk Dial Plan Applications

See also:
ast_register_application() and unregister with

ast_unregister_application()

See also

Function Documentation

static int iax2_prov_app ( struct ast_channel chan,
const char *  data 
) [static]

iax2provision

Definition at line 12079 of file chan_iax2.c.

References iax2_trunk_peer::addr, ast_channel_tech(), ast_channel_tech_pvt(), ast_inet_ntoa(), ast_log(), ast_strdupa, ast_strlen_zero(), ast_verb, iax2_provision(), LOG_NOTICE, PTR_TO_CALLNO, and iax2_trunk_peer::sockfd.

Referenced by load_module().

12080 {
12081    int res;
12082    char *sdata;
12083    char *opts;
12084    int force =0;
12085    unsigned short callno = PTR_TO_CALLNO(ast_channel_tech_pvt(chan));
12086    if (ast_strlen_zero(data))
12087       data = "default";
12088    sdata = ast_strdupa(data);
12089    opts = strchr(sdata, '|');
12090    if (opts)
12091       *opts='\0';
12092 
12093    if (ast_channel_tech(chan) != &iax2_tech) {
12094       ast_log(LOG_NOTICE, "Can't provision a non-IAX device!\n");
12095       return -1;
12096    } 
12097    if (!callno || !iaxs[callno] || !iaxs[callno]->addr.sin_addr.s_addr) {
12098       ast_log(LOG_NOTICE, "Can't provision something with no IP?\n");
12099       return -1;
12100    }
12101    res = iax2_provision(&iaxs[callno]->addr, iaxs[callno]->sockfd, NULL, sdata, force);
12102    ast_verb(3, "Provisioned IAXY at '%s' with '%s'= %d\n",
12103       ast_inet_ntoa(iaxs[callno]->addr.sin_addr),
12104       sdata, res);
12105    return res;
12106 }

static int pbx_builtin_answer ( struct ast_channel chan,
const char *  data 
) [static]

Definition at line 10522 of file pbx.c.

References __ast_answer(), args, AST_APP_ARG, AST_DECLARE_APP_ARGS, AST_STANDARD_APP_ARGS, AST_STATE_UP, ast_strdupa, ast_strlen_zero(), and parse().

10523 {
10524    int delay = 0;
10525    int answer_cdr = 1;
10526    char *parse;
10527    AST_DECLARE_APP_ARGS(args,
10528       AST_APP_ARG(delay);
10529       AST_APP_ARG(answer_cdr);
10530    );
10531 
10532    if (ast_strlen_zero(data)) {
10533       return __ast_answer(chan, 0, 1);
10534    }
10535 
10536    parse = ast_strdupa(data);
10537 
10538    AST_STANDARD_APP_ARGS(args, parse);
10539 
10540    if (!ast_strlen_zero(args.delay) && (ast_channel_state(chan) != AST_STATE_UP))
10541       delay = atoi(data);
10542 
10543    if (delay < 0) {
10544       delay = 0;
10545    }
10546 
10547    if (!ast_strlen_zero(args.answer_cdr) && !strcasecmp(args.answer_cdr, "nocdr")) {
10548       answer_cdr = 0;
10549    }
10550 
10551    return __ast_answer(chan, delay, answer_cdr);
10552 }

static int pbx_builtin_background ( struct ast_channel chan,
const char *  data 
) [static]

Definition at line 10881 of file pbx.c.

References args, ast_answer(), AST_APP_ARG, ast_app_parse_options(), ast_canmatch_extension(), ast_channel_caller(), ast_channel_context(), ast_channel_context_set(), ast_channel_exten_set(), ast_channel_flags(), ast_channel_language(), ast_channel_lock, ast_channel_name(), ast_channel_priority_set(), ast_channel_unlock, AST_DECLARE_APP_ARGS, AST_DIGIT_ANY, AST_FLAG_DISABLE_WORKAROUNDS, ast_log(), ast_matchmore_extension(), AST_STANDARD_APP_ARGS, AST_STATE_UP, ast_stopstream(), ast_strdupa, ast_streamfile(), ast_strip(), ast_strlen_zero(), ast_test_flag, ast_waitstream(), ast_waitstream_exten(), BACKGROUND_MATCHEXTEN, BACKGROUND_NOANSWER, background_opts, BACKGROUND_PLAYBACK, BACKGROUND_SKIP, ast_flags::flags, LOG_WARNING, parse(), pbx_builtin_getvar_helper(), pbx_builtin_setvar_helper(), S_COR, and strsep().

10882 {
10883    int res = 0;
10884    int mres = 0;
10885    struct ast_flags flags = {0};
10886    char *parse, exten[2] = "";
10887    AST_DECLARE_APP_ARGS(args,
10888       AST_APP_ARG(filename);
10889       AST_APP_ARG(options);
10890       AST_APP_ARG(lang);
10891       AST_APP_ARG(context);
10892    );
10893 
10894    if (ast_strlen_zero(data)) {
10895       ast_log(LOG_WARNING, "Background requires an argument (filename)\n");
10896       return -1;
10897    }
10898 
10899    parse = ast_strdupa(data);
10900 
10901    AST_STANDARD_APP_ARGS(args, parse);
10902 
10903    if (ast_strlen_zero(args.lang))
10904       args.lang = (char *)ast_channel_language(chan); /* XXX this is const */
10905 
10906    if (ast_strlen_zero(args.context)) {
10907       const char *context;
10908       ast_channel_lock(chan);
10909       if ((context = pbx_builtin_getvar_helper(chan, "MACRO_CONTEXT"))) {
10910          args.context = ast_strdupa(context);
10911       } else {
10912          args.context = ast_strdupa(ast_channel_context(chan));
10913       }
10914       ast_channel_unlock(chan);
10915    }
10916 
10917    if (args.options) {
10918       if (!strcasecmp(args.options, "skip"))
10919          flags.flags = BACKGROUND_SKIP;
10920       else if (!strcasecmp(args.options, "noanswer"))
10921          flags.flags = BACKGROUND_NOANSWER;
10922       else
10923          ast_app_parse_options(background_opts, &flags, NULL, args.options);
10924    }
10925 
10926    /* Answer if need be */
10927    if (ast_channel_state(chan) != AST_STATE_UP) {
10928       if (ast_test_flag(&flags, BACKGROUND_SKIP)) {
10929          goto done;
10930       } else if (!ast_test_flag(&flags, BACKGROUND_NOANSWER)) {
10931          res = ast_answer(chan);
10932       }
10933    }
10934 
10935    if (!res) {
10936       char *back = ast_strip(args.filename);
10937       char *front;
10938 
10939       ast_stopstream(chan);      /* Stop anything playing */
10940       /* Stream the list of files */
10941       while (!res && (front = strsep(&back, "&")) ) {
10942          if ( (res = ast_streamfile(chan, front, args.lang)) ) {
10943             ast_log(LOG_WARNING, "ast_streamfile failed on %s for %s\n", ast_channel_name(chan), (char*)data);
10944             res = 0;
10945             mres = 1;
10946             break;
10947          }
10948          if (ast_test_flag(&flags, BACKGROUND_PLAYBACK)) {
10949             res = ast_waitstream(chan, "");
10950          } else if (ast_test_flag(&flags, BACKGROUND_MATCHEXTEN)) {
10951             res = ast_waitstream_exten(chan, args.context);
10952          } else {
10953             res = ast_waitstream(chan, AST_DIGIT_ANY);
10954          }
10955          ast_stopstream(chan);
10956       }
10957    }
10958 
10959    /*
10960     * If the single digit DTMF is an extension in the specified context, then
10961     * go there and signal no DTMF.  Otherwise, we should exit with that DTMF.
10962     * If we're in Macro, we'll exit and seek that DTMF as the beginning of an
10963     * extension in the Macro's calling context.  If we're not in Macro, then
10964     * we'll simply seek that extension in the calling context.  Previously,
10965     * someone complained about the behavior as it related to the interior of a
10966     * Gosub routine, and the fix (#14011) inadvertently broke FreePBX
10967     * (#14940).  This change should fix both of these situations, but with the
10968     * possible incompatibility that if a single digit extension does not exist
10969     * (but a longer extension COULD have matched), it would have previously
10970     * gone immediately to the "i" extension, but will now need to wait for a
10971     * timeout.
10972     *
10973     * Later, we had to add a flag to disable this workaround, because AGI
10974     * users can EXEC Background and reasonably expect that the DTMF code will
10975     * be returned (see #16434).
10976     */
10977    if (!ast_test_flag(ast_channel_flags(chan), AST_FLAG_DISABLE_WORKAROUNDS)
10978       && (exten[0] = res)
10979       && ast_canmatch_extension(chan, args.context, exten, 1,
10980          S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL))
10981       && !ast_matchmore_extension(chan, args.context, exten, 1,
10982          S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL))) {
10983       char buf[2] = { 0, };
10984       snprintf(buf, sizeof(buf), "%c", res);
10985       ast_channel_exten_set(chan, buf);
10986       ast_channel_context_set(chan, args.context);
10987       ast_channel_priority_set(chan, 0);
10988       res = 0;
10989    }
10990 done:
10991    pbx_builtin_setvar_helper(chan, "BACKGROUNDSTATUS", mres ? "FAILED" : "SUCCESS");
10992    return res;
10993 }

static int pbx_builtin_busy ( struct ast_channel chan,
const char *  data 
) [static]

Definition at line 10490 of file pbx.c.

References ast_cdr_busy(), ast_channel_cdr(), AST_CONTROL_BUSY, ast_indicate(), ast_setstate(), AST_STATE_BUSY, AST_STATE_UP, and wait_for_hangup().

Referenced by __ast_pbx_run().

10491 {
10492    ast_indicate(chan, AST_CONTROL_BUSY);
10493    /* Don't change state of an UP channel, just indicate
10494       busy in audio */
10495    if (ast_channel_state(chan) != AST_STATE_UP) {
10496       ast_setstate(chan, AST_STATE_BUSY);
10497       ast_cdr_busy(ast_channel_cdr(chan));
10498    }
10499    wait_for_hangup(chan, data);
10500    return -1;
10501 }

static int pbx_builtin_congestion ( struct ast_channel chan,
const char *  data 
) [static]

Definition at line 10506 of file pbx.c.

References ast_cdr_congestion(), ast_channel_cdr(), AST_CONTROL_CONGESTION, ast_indicate(), ast_setstate(), AST_STATE_BUSY, AST_STATE_UP, and wait_for_hangup().

Referenced by __ast_pbx_run().

10507 {
10508    ast_indicate(chan, AST_CONTROL_CONGESTION);
10509    /* Don't change state of an UP channel, just indicate
10510       congestion in audio */
10511    if (ast_channel_state(chan) != AST_STATE_UP) {
10512       ast_setstate(chan, AST_STATE_BUSY);
10513       ast_cdr_congestion(ast_channel_cdr(chan));
10514    }
10515    wait_for_hangup(chan, data);
10516    return -1;
10517 }

static int pbx_builtin_execiftime ( struct ast_channel chan,
const char *  data 
) [static]

Definition at line 10737 of file pbx.c.

References ast_build_timing(), ast_check_timing(), ast_destroy_timing(), ast_log(), ast_strdupa, ast_strlen_zero(), LOG_WARNING, pbx_exec(), pbx_findapp(), S_OR, and strsep().

10738 {
10739    char *s, *appname;
10740    struct ast_timing timing;
10741    struct ast_app *app;
10742    static const char * const usage = "ExecIfTime requires an argument:\n  <time range>,<days of week>,<days of month>,<months>[,<timezone>]?<appname>[(<appargs>)]";
10743 
10744    if (ast_strlen_zero(data)) {
10745       ast_log(LOG_WARNING, "%s\n", usage);
10746       return -1;
10747    }
10748 
10749    appname = ast_strdupa(data);
10750 
10751    s = strsep(&appname, "?"); /* Separate the timerange and application name/data */
10752    if (!appname) {   /* missing application */
10753       ast_log(LOG_WARNING, "%s\n", usage);
10754       return -1;
10755    }
10756 
10757    if (!ast_build_timing(&timing, s)) {
10758       ast_log(LOG_WARNING, "Invalid Time Spec: %s\nCorrect usage: %s\n", s, usage);
10759       ast_destroy_timing(&timing);
10760       return -1;
10761    }
10762 
10763    if (!ast_check_timing(&timing))  { /* outside the valid time window, just return */
10764       ast_destroy_timing(&timing);
10765       return 0;
10766    }
10767    ast_destroy_timing(&timing);
10768 
10769    /* now split appname(appargs) */
10770    if ((s = strchr(appname, '('))) {
10771       char *e;
10772       *s++ = '\0';
10773       if ((e = strrchr(s, ')')))
10774          *e = '\0';
10775       else
10776          ast_log(LOG_WARNING, "Failed to find closing parenthesis\n");
10777    }
10778 
10779 
10780    if ((app = pbx_findapp(appname))) {
10781       return pbx_exec(chan, app, S_OR(s, ""));
10782    } else {
10783       ast_log(LOG_WARNING, "Cannot locate application %s\n", appname);
10784       return -1;
10785    }
10786 }

static int pbx_builtin_goto ( struct ast_channel chan,
const char *  data 
) [static]

Goto

Definition at line 10998 of file pbx.c.

References ast_channel_context(), ast_channel_exten(), ast_channel_priority(), ast_parseable_goto(), and ast_verb.

Referenced by pbx_builtin_gotoif(), and pbx_builtin_gotoiftime().

10999 {
11000    int res = ast_parseable_goto(chan, data);
11001    if (!res)
11002       ast_verb(3, "Goto (%s,%s,%d)\n", ast_channel_context(chan), ast_channel_exten(chan), ast_channel_priority(chan) + 1);
11003    return res;
11004 }

static int pbx_builtin_gotoiftime ( struct ast_channel chan,
const char *  data 
) [static]

Definition at line 10683 of file pbx.c.

References ast_build_timing(), ast_channel_lock, ast_channel_unlock, ast_check_timing2(), ast_debug, ast_destroy_timing(), ast_log(), ast_strdupa, ast_strlen_zero(), ast_tvnow(), LOG_WARNING, pbx_builtin_getvar_helper(), pbx_builtin_goto(), pbx_builtin_setvar_helper(), and strsep().

10684 {
10685    char *s, *ts, *branch1, *branch2, *branch;
10686    struct ast_timing timing;
10687    const char *ctime;
10688    struct timeval tv = ast_tvnow();
10689    long timesecs;
10690 
10691    if (!chan) {
10692       ast_log(LOG_WARNING, "GotoIfTime requires a channel on which to operate\n");
10693       return -1;
10694    }
10695 
10696    if (ast_strlen_zero(data)) {
10697       ast_log(LOG_WARNING, "GotoIfTime requires an argument:\n  <time range>,<days of week>,<days of month>,<months>[,<timezone>]?'labeliftrue':'labeliffalse'\n");
10698       return -1;
10699    }
10700 
10701    ts = s = ast_strdupa(data);
10702 
10703    ast_channel_lock(chan);
10704    if ((ctime = pbx_builtin_getvar_helper(chan, "TESTTIME")) && sscanf(ctime, "%ld", &timesecs) == 1) {
10705       tv.tv_sec = timesecs;
10706    } else if (ctime) {
10707       ast_log(LOG_WARNING, "Using current time to evaluate\n");
10708       /* Reset when unparseable */
10709       pbx_builtin_setvar_helper(chan, "TESTTIME", NULL);
10710    }
10711    ast_channel_unlock(chan);
10712 
10713    /* Separate the Goto path */
10714    strsep(&ts, "?");
10715    branch1 = strsep(&ts,":");
10716    branch2 = strsep(&ts,"");
10717 
10718    /* struct ast_include include contained garbage here, fixed by zeroing it on get_timerange */
10719    if (ast_build_timing(&timing, s) && ast_check_timing2(&timing, tv)) {
10720       branch = branch1;
10721    } else {
10722       branch = branch2;
10723    }
10724    ast_destroy_timing(&timing);
10725 
10726    if (ast_strlen_zero(branch)) {
10727       ast_debug(1, "Not taking any branch\n");
10728       return 0;
10729    }
10730 
10731    return pbx_builtin_goto(chan, branch);
10732 }

static int pbx_builtin_hangup ( struct ast_channel chan,
const char *  data 
) [static]

Definition at line 10616 of file pbx.c.

References AST_CAUSE_NORMAL_CLEARING, ast_channel_hangupcause(), ast_channel_hangupcause_set(), ast_channel_lock, ast_channel_unlock, ast_log(), ast_set_hangupsource(), AST_SOFTHANGUP_EXPLICIT, ast_softhangup_nolock(), ast_str2cause(), ast_strlen_zero(), cause, and LOG_WARNING.

10617 {
10618    int cause;
10619 
10620    ast_set_hangupsource(chan, "dialplan/builtin", 0);
10621 
10622    if (!ast_strlen_zero(data)) {
10623       cause = ast_str2cause(data);
10624       if (cause <= 0) {
10625          if (sscanf(data, "%30d", &cause) != 1 || cause <= 0) {
10626             ast_log(LOG_WARNING, "Invalid cause given to Hangup(): \"%s\"\n", data);
10627             cause = 0;
10628          }
10629       }
10630    } else {
10631       cause = 0;
10632    }
10633 
10634    ast_channel_lock(chan);
10635    if (cause <= 0) {
10636       cause = ast_channel_hangupcause(chan);
10637       if (cause <= 0) {
10638          cause = AST_CAUSE_NORMAL_CLEARING;
10639       }
10640    }
10641    ast_channel_hangupcause_set(chan, cause);
10642    ast_softhangup_nolock(chan, AST_SOFTHANGUP_EXPLICIT);
10643    ast_channel_unlock(chan);
10644 
10645    return -1;
10646 }

static int pbx_builtin_proceeding ( struct ast_channel chan,
const char *  data 
) [static]

Definition at line 10463 of file pbx.c.

References AST_CONTROL_PROCEEDING, and ast_indicate().

10464 {
10465    ast_indicate(chan, AST_CONTROL_PROCEEDING);
10466    return 0;
10467 }

static int pbx_builtin_progress ( struct ast_channel chan,
const char *  data 
) [static]

Definition at line 10472 of file pbx.c.

References AST_CONTROL_PROGRESS, and ast_indicate().

10473 {
10474    ast_indicate(chan, AST_CONTROL_PROGRESS);
10475    return 0;
10476 }

static int pbx_builtin_resetcdr ( struct ast_channel chan,
const char *  data 
) [static]

Definition at line 10586 of file pbx.c.

References args, ast_app_parse_options(), ast_cdr_reset(), ast_channel_cdr(), ast_strdupa, ast_strlen_zero(), and resetcdr_opts.

10587 {
10588    char *args;
10589    struct ast_flags flags = { 0 };
10590 
10591    if (!ast_strlen_zero(data)) {
10592       args = ast_strdupa(data);
10593       ast_app_parse_options(resetcdr_opts, &flags, NULL, args);
10594    }
10595 
10596    ast_cdr_reset(ast_channel_cdr(chan), &flags);
10597 
10598    return 0;
10599 }

static int pbx_builtin_ringing ( struct ast_channel chan,
const char *  data 
) [static]

Definition at line 10481 of file pbx.c.

References AST_CONTROL_RINGING, and ast_indicate().

10482 {
10483    ast_indicate(chan, AST_CONTROL_RINGING);
10484    return 0;
10485 }

static int pbx_builtin_setamaflags ( struct ast_channel chan,
const char *  data 
) [static]

Definition at line 10604 of file pbx.c.

References ast_cdr_setamaflags(), ast_channel_lock, and ast_channel_unlock.

10605 {
10606    /* Copy the AMA Flags as specified */
10607    ast_channel_lock(chan);
10608    ast_cdr_setamaflags(chan, data ? data : "");
10609    ast_channel_unlock(chan);
10610    return 0;
10611 }

static int pbx_builtin_wait ( struct ast_channel chan,
const char *  data 
) [static]

Definition at line 10791 of file pbx.c.

References ast_app_parse_timelen(), ast_safe_sleep(), and TIMELEN_SECONDS.

10792 {
10793    int ms;
10794 
10795    /* Wait for "n" seconds */
10796    if (!ast_app_parse_timelen(data, &ms, TIMELEN_SECONDS) && ms > 0) {
10797       return ast_safe_sleep(chan, ms);
10798    }
10799    return 0;
10800 }

static int pbx_builtin_waitexten ( struct ast_channel chan,
const char *  data 
) [static]

Definition at line 10805 of file pbx.c.

References args, AST_APP_ARG, ast_app_parse_options(), ast_app_parse_timelen(), ast_channel_caller(), ast_channel_context(), ast_channel_exten(), ast_channel_name(), ast_channel_pbx(), ast_channel_priority(), ast_channel_zone(), ast_check_hangup(), AST_CONTROL_HOLD, AST_CONTROL_UNHOLD, AST_DECLARE_APP_ARGS, ast_exists_extension(), ast_get_indication_tone(), ast_indicate(), ast_indicate_data(), ast_log(), ast_playtones_start(), ast_playtones_stop(), AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), ast_test_flag, ast_tone_zone_sound_unref(), ast_tonepair_start(), ast_verb, ast_waitfordigit(), ast_tone_zone_sound::data, LOG_WARNING, parse(), raise_exception(), ast_pbx::rtimeoutms, S_COR, S_OR, set_ext_pri(), TIMELEN_SECONDS, WAITEXTEN_DIALTONE, WAITEXTEN_MOH, and waitexten_opts.

10806 {
10807    int ms, res;
10808    struct ast_flags flags = {0};
10809    char *opts[1] = { NULL };
10810    char *parse;
10811    AST_DECLARE_APP_ARGS(args,
10812       AST_APP_ARG(timeout);
10813       AST_APP_ARG(options);
10814    );
10815 
10816    if (!ast_strlen_zero(data)) {
10817       parse = ast_strdupa(data);
10818       AST_STANDARD_APP_ARGS(args, parse);
10819    } else
10820       memset(&args, 0, sizeof(args));
10821 
10822    if (args.options)
10823       ast_app_parse_options(waitexten_opts, &flags, opts, args.options);
10824 
10825    if (ast_test_flag(&flags, WAITEXTEN_MOH) && !opts[0] ) {
10826       ast_log(LOG_WARNING, "The 'm' option has been specified for WaitExten without a class.\n");
10827    } else if (ast_test_flag(&flags, WAITEXTEN_MOH)) {
10828       ast_indicate_data(chan, AST_CONTROL_HOLD, S_OR(opts[0], NULL),
10829          !ast_strlen_zero(opts[0]) ? strlen(opts[0]) + 1 : 0);
10830    } else if (ast_test_flag(&flags, WAITEXTEN_DIALTONE)) {
10831       struct ast_tone_zone_sound *ts = ast_get_indication_tone(ast_channel_zone(chan), "dial");
10832       if (ts) {
10833          ast_playtones_start(chan, 0, ts->data, 0);
10834          ts = ast_tone_zone_sound_unref(ts);
10835       } else {
10836          ast_tonepair_start(chan, 350, 440, 0, 0);
10837       }
10838    }
10839    /* Wait for "n" seconds */
10840    if (!ast_app_parse_timelen(args.timeout, &ms, TIMELEN_SECONDS) && ms > 0) {
10841       /* Yay! */
10842    } else if (ast_channel_pbx(chan)) {
10843       ms = ast_channel_pbx(chan)->rtimeoutms;
10844    } else {
10845       ms = 10000;
10846    }
10847 
10848    res = ast_waitfordigit(chan, ms);
10849    if (!res) {
10850       if (ast_check_hangup(chan)) {
10851          /* Call is hungup for some reason. */
10852          res = -1;
10853       } else if (ast_exists_extension(chan, ast_channel_context(chan), ast_channel_exten(chan), ast_channel_priority(chan) + 1,
10854          S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL))) {
10855          ast_verb(3, "Timeout on %s, continuing...\n", ast_channel_name(chan));
10856       } else if (ast_exists_extension(chan, ast_channel_context(chan), "t", 1,
10857          S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL))) {
10858          ast_verb(3, "Timeout on %s, going to 't'\n", ast_channel_name(chan));
10859          set_ext_pri(chan, "t", 0); /* 0 will become 1, next time through the loop */
10860       } else if (ast_exists_extension(chan, ast_channel_context(chan), "e", 1,
10861          S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL))) {
10862          raise_exception(chan, "RESPONSETIMEOUT", 0); /* 0 will become 1, next time through the loop */
10863       } else {
10864          ast_log(LOG_WARNING, "Timeout but no rule 't' or 'e' in context '%s'\n",
10865             ast_channel_context(chan));
10866          res = -1;
10867       }
10868    }
10869 
10870    if (ast_test_flag(&flags, WAITEXTEN_MOH))
10871       ast_indicate(chan, AST_CONTROL_UNHOLD);
10872    else if (ast_test_flag(&flags, WAITEXTEN_DIALTONE))
10873       ast_playtones_stop(chan);
10874 
10875    return res;
10876 }


Generated on Thu Oct 11 06:37:43 2012 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6