![]() |
Home page |
Mailing list |
Docs
Asterisk developer's documentation :: Codename Pineapple
Module: Dial plan applications
Files | |
| file | res_realtime.c |
| RealTime CLI. | |
Functions | |
| static int | iax2_prov_app (struct ast_channel *chan, void *data) |
| static int | pbx_builtin_answer (struct ast_channel *, void *) |
| static int | pbx_builtin_background (struct ast_channel *, void *) |
| static int | pbx_builtin_busy (struct ast_channel *, void *) |
| static int | pbx_builtin_congestion (struct ast_channel *, void *) |
| static int | pbx_builtin_execiftime (struct ast_channel *, void *) |
| static int | pbx_builtin_goto (struct ast_channel *, void *) |
| static int | pbx_builtin_gotoiftime (struct ast_channel *, void *) |
| static int | pbx_builtin_hangup (struct ast_channel *, void *) |
| static int | pbx_builtin_progress (struct ast_channel *, void *) |
| static int | pbx_builtin_resetcdr (struct ast_channel *, void *) |
| static int | pbx_builtin_ringing (struct ast_channel *, void *) |
| static int | pbx_builtin_setamaflags (struct ast_channel *, void *) |
| static int | pbx_builtin_wait (struct ast_channel *, void *) |
| static int | pbx_builtin_waitexten (struct ast_channel *, void *) |
|
||||||||||||
|
iax2provision Definition at line 7952 of file chan_iax2.c. References ast_inet_ntoa(), ast_log(), ast_strdupa, ast_strlen_zero(), ast_verbose(), iax2_provision(), iax2_tech, iaxs, option_verbose, PTR_TO_CALLNO, ast_channel::tech, ast_channel::tech_pvt, and VERBOSE_PREFIX_3. Referenced by load_module(). 07953 { 07954 int res; 07955 char *sdata; 07956 char *opts; 07957 int force =0; 07958 unsigned short callno = PTR_TO_CALLNO(chan->tech_pvt); 07959 if (ast_strlen_zero(data)) 07960 data = "default"; 07961 sdata = ast_strdupa(data); 07962 opts = strchr(sdata, '|'); 07963 if (opts) 07964 *opts='\0'; 07965 07966 if (chan->tech != &iax2_tech) { 07967 ast_log(LOG_NOTICE, "Can't provision a non-IAX device!\n"); 07968 return -1; 07969 } 07970 if (!callno || !iaxs[callno] || !iaxs[callno]->addr.sin_addr.s_addr) { 07971 ast_log(LOG_NOTICE, "Can't provision something with no IP?\n"); 07972 return -1; 07973 } 07974 res = iax2_provision(&iaxs[callno]->addr, iaxs[callno]->sockfd, NULL, sdata, force); 07975 if (option_verbose > 2) 07976 ast_verbose(VERBOSE_PREFIX_3 "Provisioned IAXY at '%s' with '%s'= %d\n", 07977 ast_inet_ntoa(iaxs[callno]->addr.sin_addr), 07978 sdata, res); 07979 return res; 07980 }
|
|
||||||||||||
|
Definition at line 5335 of file pbx.c. References __ast_answer(), ast_channel::_state, AST_STATE_UP, and ast_strlen_zero(). 05336 { 05337 int delay = 0; 05338 05339 if ((chan->_state != AST_STATE_UP) && !ast_strlen_zero(data)) 05340 delay = atoi(data); 05341 05342 return __ast_answer(chan, delay); 05343 }
|
|
||||||||||||
|
Definition at line 5555 of file pbx.c. References ast_channel::_state, ast_answer(), AST_APP_ARG, ast_app_parse_options(), AST_DECLARE_APP_ARGS, AST_DIGIT_ANY, ast_log(), AST_STANDARD_APP_ARGS, AST_STATE_UP, ast_stopstream(), ast_strdupa, ast_streamfile(), ast_strlen_zero(), ast_test_flag, ast_waitstream(), ast_waitstream_exten(), BACKGROUND_MATCHEXTEN, BACKGROUND_NOANSWER, BACKGROUND_PLAYBACK, BACKGROUND_SKIP, ast_channel::context, ast_channel::exten, parse(), pbx_builtin_setvar_helper(), ast_channel::priority, and strsep(). 05556 { 05557 int res = 0; 05558 int mres = 0; 05559 struct ast_flags flags = {0}; 05560 char *parse; 05561 AST_DECLARE_APP_ARGS(args, 05562 AST_APP_ARG(filename); 05563 AST_APP_ARG(options); 05564 AST_APP_ARG(lang); 05565 AST_APP_ARG(context); 05566 ); 05567 05568 if (ast_strlen_zero(data)) { 05569 ast_log(LOG_WARNING, "Background requires an argument (filename)\n"); 05570 return -1; 05571 } 05572 05573 parse = ast_strdupa(data); 05574 05575 AST_STANDARD_APP_ARGS(args, parse); 05576 05577 if (!args.lang) 05578 args.lang = (char *)chan->language; /* XXX this is const */ 05579 05580 if (!args.context) 05581 args.context = chan->context; 05582 05583 if (args.options) { 05584 if (!strcasecmp(args.options, "skip")) 05585 flags.flags = BACKGROUND_SKIP; 05586 else if (!strcasecmp(args.options, "noanswer")) 05587 flags.flags = BACKGROUND_NOANSWER; 05588 else 05589 ast_app_parse_options(background_opts, &flags, NULL, args.options); 05590 } 05591 05592 /* Answer if need be */ 05593 if (chan->_state != AST_STATE_UP) { 05594 if (ast_test_flag(&flags, BACKGROUND_SKIP)) { 05595 goto done; 05596 } else if (!ast_test_flag(&flags, BACKGROUND_NOANSWER)) { 05597 res = ast_answer(chan); 05598 } 05599 } 05600 05601 if (!res) { 05602 char *back = args.filename; 05603 char *front; 05604 05605 ast_stopstream(chan); /* Stop anything playing */ 05606 /* Stream the list of files */ 05607 while (!res && (front = strsep(&back, "&")) ) { 05608 if ( (res = ast_streamfile(chan, front, args.lang)) ) { 05609 ast_log(LOG_WARNING, "ast_streamfile failed on %s for %s\n", chan->name, (char*)data); 05610 res = 0; 05611 mres = 1; 05612 break; 05613 } 05614 if (ast_test_flag(&flags, BACKGROUND_PLAYBACK)) { 05615 res = ast_waitstream(chan, ""); 05616 } else if (ast_test_flag(&flags, BACKGROUND_MATCHEXTEN)) { 05617 res = ast_waitstream_exten(chan, args.context); 05618 } else { 05619 res = ast_waitstream(chan, AST_DIGIT_ANY); 05620 } 05621 ast_stopstream(chan); 05622 } 05623 } 05624 if (args.context != chan->context && res) { 05625 snprintf(chan->exten, sizeof(chan->exten), "%c", res); 05626 ast_copy_string(chan->context, args.context, sizeof(chan->context)); 05627 chan->priority = 0; 05628 res = 0; 05629 } 05630 done: 05631 pbx_builtin_setvar_helper(chan, "BACKGROUNDSTATUS", mres ? "FAILED" : "SUCCESS"); 05632 return res; 05633 }
|
|
||||||||||||
|
Definition at line 5307 of file pbx.c. References ast_channel::_state, AST_CONTROL_BUSY, ast_indicate(), ast_setstate(), AST_STATE_BUSY, AST_STATE_UP, and wait_for_hangup(). 05308 { 05309 ast_indicate(chan, AST_CONTROL_BUSY); 05310 /* Don't change state of an UP channel, just indicate 05311 busy in audio */ 05312 if (chan->_state != AST_STATE_UP) 05313 ast_setstate(chan, AST_STATE_BUSY); 05314 wait_for_hangup(chan, data); 05315 return -1; 05316 }
|
|
||||||||||||
|
Definition at line 5321 of file pbx.c. References ast_channel::_state, AST_CONTROL_CONGESTION, ast_indicate(), ast_setstate(), AST_STATE_BUSY, AST_STATE_UP, and wait_for_hangup(). 05322 { 05323 ast_indicate(chan, AST_CONTROL_CONGESTION); 05324 /* Don't change state of an UP channel, just indicate 05325 congestion in audio */ 05326 if (chan->_state != AST_STATE_UP) 05327 ast_setstate(chan, AST_STATE_BUSY); 05328 wait_for_hangup(chan, data); 05329 return -1; 05330 }
|
|
||||||||||||
|
Definition at line 5438 of file pbx.c. References app, ast_build_timing(), ast_check_timing(), ast_log(), ast_strdupa, ast_strlen_zero(), pbx_exec(), pbx_findapp(), s, S_OR, and strsep(). 05439 { 05440 char *s, *appname; 05441 struct ast_timing timing; 05442 struct ast_app *app; 05443 static const char *usage = "ExecIfTime requires an argument:\n <time range>|<days of week>|<days of month>|<months>?<appname>[|<appargs>]"; 05444 05445 if (ast_strlen_zero(data)) { 05446 ast_log(LOG_WARNING, "%s\n", usage); 05447 return -1; 05448 } 05449 05450 appname = ast_strdupa(data); 05451 05452 s = strsep(&appname,"?"); /* Separate the timerange and application name/data */ 05453 if (!appname) { /* missing application */ 05454 ast_log(LOG_WARNING, "%s\n", usage); 05455 return -1; 05456 } 05457 05458 if (!ast_build_timing(&timing, s)) { 05459 ast_log(LOG_WARNING, "Invalid Time Spec: %s\nCorrect usage: %s\n", s, usage); 05460 return -1; 05461 } 05462 05463 if (!ast_check_timing(&timing)) /* outside the valid time window, just return */ 05464 return 0; 05465 05466 /* now split appname|appargs */ 05467 if ((s = strchr(appname, '|'))) 05468 *s++ = '\0'; 05469 05470 if ((app = pbx_findapp(appname))) { 05471 return pbx_exec(chan, app, S_OR(s, "")); 05472 } else { 05473 ast_log(LOG_WARNING, "Cannot locate application %s\n", appname); 05474 return -1; 05475 } 05476 }
|
|
||||||||||||
|
Goto Definition at line 5638 of file pbx.c. References ast_parseable_goto(), ast_verbose(), ast_channel::context, ast_channel::exten, option_verbose, ast_channel::priority, and VERBOSE_PREFIX_3. Referenced by pbx_builtin_gotoif(), and pbx_builtin_gotoiftime(). 05639 { 05640 int res = ast_parseable_goto(chan, data); 05641 if (!res && (option_verbose > 2)) 05642 ast_verbose( VERBOSE_PREFIX_3 "Goto (%s,%s,%d)\n", chan->context,chan->exten, chan->priority+1); 05643 return res; 05644 }
|
|
||||||||||||
|
Definition at line 5412 of file pbx.c. References ast_build_timing(), ast_check_timing(), ast_log(), ast_strdupa, ast_strlen_zero(), pbx_builtin_goto(), s, and strsep(). 05413 { 05414 int res=0; 05415 char *s, *ts; 05416 struct ast_timing timing; 05417 05418 if (ast_strlen_zero(data)) { 05419 ast_log(LOG_WARNING, "GotoIfTime requires an argument:\n <time range>|<days of week>|<days of month>|<months>?[[context|]extension|]priority\n"); 05420 return -1; 05421 } 05422 05423 ts = s = ast_strdupa(data); 05424 05425 /* Separate the Goto path */ 05426 strsep(&ts,"?"); 05427 05428 /* struct ast_include include contained garbage here, fixed by zeroing it on get_timerange */ 05429 if (ast_build_timing(&timing, s) && ast_check_timing(&timing)) 05430 res = pbx_builtin_goto(chan, ts); 05431 05432 return res; 05433 }
|
|
||||||||||||
|
Definition at line 5382 of file pbx.c. References AST_CAUSE_NORMAL_CLEARING, ast_log(), ast_str2cause(), ast_strlen_zero(), ast_channel::hangupcause, and LOG_NOTICE. 05383 { 05384 if (!ast_strlen_zero(data)) { 05385 int cause; 05386 char *endptr; 05387 05388 if ((cause = ast_str2cause(data)) > -1) { 05389 chan->hangupcause = cause; 05390 return -1; 05391 } 05392 05393 cause = strtol((const char *) data, &endptr, 10); 05394 if (cause != 0 || (data != endptr)) { 05395 chan->hangupcause = cause; 05396 return -1; 05397 } 05398 05399 ast_log(LOG_NOTICE, "Invalid cause given to Hangup(): \"%s\"\n", (char *) data); 05400 } 05401 05402 if (!chan->hangupcause) { 05403 chan->hangupcause = AST_CAUSE_NORMAL_CLEARING; 05404 } 05405 05406 return -1; 05407 }
|
|
||||||||||||
|
Definition at line 5289 of file pbx.c. References AST_CONTROL_PROGRESS, and ast_indicate(). 05290 { 05291 ast_indicate(chan, AST_CONTROL_PROGRESS); 05292 return 0; 05293 }
|
|
||||||||||||
|
Definition at line 5354 of file pbx.c. References ast_app_parse_options(), ast_cdr_reset(), ast_strdupa, ast_strlen_zero(), and ast_channel::cdr. 05355 { 05356 char *args; 05357 struct ast_flags flags = { 0 }; 05358 05359 if (!ast_strlen_zero(data)) { 05360 args = ast_strdupa(data); 05361 ast_app_parse_options(resetcdr_opts, &flags, NULL, args); 05362 } 05363 05364 ast_cdr_reset(chan->cdr, &flags); 05365 05366 return 0; 05367 }
|
|
||||||||||||
|
Definition at line 5298 of file pbx.c. References AST_CONTROL_RINGING, and ast_indicate(). 05299 { 05300 ast_indicate(chan, AST_CONTROL_RINGING); 05301 return 0; 05302 }
|
|
||||||||||||
|
Definition at line 5372 of file pbx.c. References ast_cdr_setamaflags(). 05373 { 05374 /* Copy the AMA Flags as specified */ 05375 ast_cdr_setamaflags(chan, data ? data : ""); 05376 return 0; 05377 }
|
|
||||||||||||
|
Definition at line 5481 of file pbx.c. References ast_safe_sleep(), and s. 05482 { 05483 double s; 05484 int ms; 05485 05486 /* Wait for "n" seconds */ 05487 if (data && (s = atof(data)) > 0.0) { 05488 ms = s*1000.0; 05489 return ast_safe_sleep(chan, ms); 05490 } 05491 return 0; 05492 }
|
|
||||||||||||
|
Definition at line 5497 of file pbx.c. References AST_APP_ARG, ast_app_parse_options(), AST_CONTROL_HOLD, AST_CONTROL_UNHOLD, AST_DECLARE_APP_ARGS, ast_exists_extension(), ast_indicate(), ast_indicate_data(), ast_log(), AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), ast_test_flag, ast_verbose(), ast_waitfordigit(), option_verbose, parse(), s, set_ext_pri(), VERBOSE_PREFIX_3, and WAITEXTEN_MOH. 05498 { 05499 int ms, res; 05500 double s; 05501 struct ast_flags flags = {0}; 05502 char *opts[1] = { NULL }; 05503 char *parse; 05504 AST_DECLARE_APP_ARGS(args, 05505 AST_APP_ARG(timeout); 05506 AST_APP_ARG(options); 05507 ); 05508 05509 if (!ast_strlen_zero(data)) { 05510 parse = ast_strdupa(data); 05511 AST_STANDARD_APP_ARGS(args, parse); 05512 } else 05513 memset(&args, 0, sizeof(args)); 05514 05515 if (args.options) 05516 ast_app_parse_options(waitexten_opts, &flags, opts, args.options); 05517 05518 if (ast_test_flag(&flags, WAITEXTEN_MOH) && !opts[0] ) { 05519 ast_log(LOG_WARNING, "The 'm' option has been specified for WaitExten without a class.\n"); 05520 } else if (ast_test_flag(&flags, WAITEXTEN_MOH)) 05521 ast_indicate_data(chan, AST_CONTROL_HOLD, opts[0], strlen(opts[0])); 05522 05523 /* Wait for "n" seconds */ 05524 if (args.timeout && (s = atof(args.timeout)) > 0) 05525 ms = s * 1000.0; 05526 else if (chan->pbx) 05527 ms = chan->pbx->rtimeout * 1000; 05528 else 05529 ms = 10000; 05530 05531 res = ast_waitfordigit(chan, ms); 05532 if (!res) { 05533 if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 1, chan->cid.cid_num)) { 05534 if (option_verbose > 2) 05535 ast_verbose(VERBOSE_PREFIX_3 "Timeout on %s, continuing...\n", chan->name); 05536 } else if (ast_exists_extension(chan, chan->context, "t", 1, chan->cid.cid_num)) { 05537 if (option_verbose > 2) 05538 ast_verbose(VERBOSE_PREFIX_3 "Timeout on %s, going to 't'\n", chan->name); 05539 set_ext_pri(chan, "t", 0); /* XXX is the 0 correct ? */ 05540 } else { 05541 ast_log(LOG_WARNING, "Timeout but no rule 't' in context '%s'\n", chan->context); 05542 res = -1; 05543 } 05544 } 05545 05546 if (ast_test_flag(&flags, WAITEXTEN_MOH)) 05547 ast_indicate(chan, AST_CONTROL_UNHOLD); 05548 05549 return res; 05550 }
|