Asterisk - The Open Source Telephony Project  18.5.0
Data Structures | Macros | Functions | Variables
pbx_builtins.c File Reference

Core PBX builtin routines. More...

#include "asterisk.h"
#include "asterisk/_private.h"
#include "asterisk/pbx.h"
#include "asterisk/causes.h"
#include "asterisk/indications.h"
#include "asterisk/stasis_channels.h"
#include "asterisk/say.h"
#include "asterisk/app.h"
#include "asterisk/module.h"
#include "pbx_private.h"
Include dependency graph for pbx_builtins.c:

Go to the source code of this file.

Data Structures

struct  pbx_builtin
 Declaration of builtin applications. More...
 

Macros

#define BACKGROUND_MATCHEXTEN   (1 << 2)
 
#define BACKGROUND_NOANSWER   (1 << 1)
 
#define BACKGROUND_PLAYBACK   (1 << 3)
 
#define BACKGROUND_SKIP   (1 << 0)
 
#define WAITEXTEN_DIALTONE   (1 << 1)
 
#define WAITEXTEN_MOH   (1 << 0)
 

Functions

int indicate_busy (struct ast_channel *chan, const char *data)
 
int indicate_congestion (struct ast_channel *chan, const char *data)
 
int load_pbx_builtins (void)
 
static int pbx_builtin_answer (struct ast_channel *chan, const char *data)
 
static int pbx_builtin_background (struct ast_channel *chan, const char *data)
 
static int pbx_builtin_execiftime (struct ast_channel *chan, const char *data)
 
static int pbx_builtin_goto (struct ast_channel *chan, const char *data)
 
static int pbx_builtin_gotoif (struct ast_channel *chan, const char *data)
 
static int pbx_builtin_gotoiftime (struct ast_channel *chan, const char *data)
 
static int pbx_builtin_hangup (struct ast_channel *chan, const char *data)
 
static int pbx_builtin_importvar (struct ast_channel *chan, const char *data)
 
static int pbx_builtin_incomplete (struct ast_channel *chan, const char *data)
 
static int pbx_builtin_noop (struct ast_channel *chan, const char *data)
 
static int pbx_builtin_proceeding (struct ast_channel *chan, const char *data)
 
static int pbx_builtin_progress (struct ast_channel *chan, const char *data)
 
int pbx_builtin_raise_exception (struct ast_channel *chan, const char *reason)
 
static int pbx_builtin_ringing (struct ast_channel *chan, const char *data)
 
static int pbx_builtin_saycharacters (struct ast_channel *chan, const char *data)
 
static int pbx_builtin_saycharacters_case (struct ast_channel *chan, const char *data)
 
static int pbx_builtin_saydigits (struct ast_channel *chan, const char *data)
 
static int pbx_builtin_saymoney (struct ast_channel *chan, const char *data)
 
static int pbx_builtin_saynumber (struct ast_channel *chan, const char *data)
 
static int pbx_builtin_sayphonetic (struct ast_channel *chan, const char *data)
 
static int pbx_builtin_setamaflags (struct ast_channel *chan, const char *data)
 
static int pbx_builtin_wait (struct ast_channel *chan, const char *data)
 
static int pbx_builtin_waitdigit (struct ast_channel *chan, const char *data)
 
static int pbx_builtin_waitexten (struct ast_channel *chan, const char *data)
 
static void unload_pbx_builtins (void)
 

Variables

static const struct ast_app_option background_opts [128] = { [ 's' ] = { .flag = (1 << 0) }, [ 'n' ] = { .flag = (1 << 1) }, [ 'm' ] = { .flag = (1 << 2) }, [ 'p' ] = { .flag = (1 << 3) }, }
 
struct pbx_builtin builtins []
 
static const struct ast_app_option waitexten_opts [128] = { [ 'm' ] = { .flag = (1 << 0) , .arg_index = 0 + 1 }, [ 'd' ] = { .flag = (1 << 1) , .arg_index = 0 + 1 }, }
 

Detailed Description

Core PBX builtin routines.

Author
George Joseph georg.nosp@m.e.jo.nosp@m.seph@.nosp@m.fair.nosp@m.view5.nosp@m..com

Definition in file pbx_builtins.c.

Macro Definition Documentation

◆ BACKGROUND_MATCHEXTEN

#define BACKGROUND_MATCHEXTEN   (1 << 2)

Definition at line 685 of file pbx_builtins.c.

Referenced by pbx_builtin_background().

◆ BACKGROUND_NOANSWER

#define BACKGROUND_NOANSWER   (1 << 1)

Definition at line 684 of file pbx_builtins.c.

Referenced by pbx_builtin_background().

◆ BACKGROUND_PLAYBACK

#define BACKGROUND_PLAYBACK   (1 << 3)

Definition at line 686 of file pbx_builtins.c.

Referenced by pbx_builtin_background().

◆ BACKGROUND_SKIP

#define BACKGROUND_SKIP   (1 << 0)

Definition at line 683 of file pbx_builtins.c.

Referenced by pbx_builtin_background().

◆ WAITEXTEN_DIALTONE

#define WAITEXTEN_DIALTONE   (1 << 1)

Definition at line 696 of file pbx_builtins.c.

Referenced by pbx_builtin_waitexten().

◆ WAITEXTEN_MOH

#define WAITEXTEN_MOH   (1 << 0)

Definition at line 695 of file pbx_builtins.c.

Referenced by pbx_builtin_waitexten().

Function Documentation

◆ load_pbx_builtins()

int load_pbx_builtins ( void  )

Provided by pbx_builtins.c

Definition at line 1556 of file pbx_builtins.c.

References ARRAY_LEN, ast_log, ast_register_application2(), ast_register_cleanup(), builtins, pbx_builtin::execute, LOG_ERROR, pbx_builtin::name, NULL, unload_pbx_builtins(), and ast_channel::x.

Referenced by asterisk_daemon().

1557 {
1558  int x;
1559 
1560  /* Register builtin applications */
1561  for (x = 0; x < ARRAY_LEN(builtins); x++) {
1563  ast_log(LOG_ERROR, "Unable to register builtin application '%s'\n", builtins[x].name);
1564  return -1;
1565  }
1566  }
1567 
1569 
1570  return 0;
1571 }
static SQLHSTMT execute(struct odbc_obj *obj, void *data, int silent)
Common execution function for SQL queries.
Definition: func_odbc.c:454
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
#define NULL
Definition: resample.c:96
#define ast_log
Definition: astobj2.c:42
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
struct pbx_builtin builtins[]
#define LOG_ERROR
Definition: logger.h:285
static void unload_pbx_builtins(void)
static const char name[]
Definition: cdr_mysql.c:74
int ast_register_application2(const char *app, int(*execute)(struct ast_channel *, const char *), const char *synopsis, const char *description, void *mod)
Register an application.
Definition: pbx_app.c:103

◆ pbx_builtin_gotoif()

static int pbx_builtin_gotoif ( struct ast_channel chan,
const char *  data 
)
static

Definition at line 1269 of file pbx_builtins.c.

References ast_debug, ast_log, ast_strdupa, ast_strlen_zero, LOG_WARNING, pbx_builtin_goto(), pbx_checkcondition(), and strsep().

1270 {
1271  char *condition, *branch1, *branch2, *branch;
1272  char *stringp;
1273 
1274  if (ast_strlen_zero(data)) {
1275  ast_log(LOG_WARNING, "Ignoring, since there is no variable to check\n");
1276  return 0;
1277  }
1278 
1279  stringp = ast_strdupa(data);
1280  condition = strsep(&stringp,"?");
1281  branch1 = strsep(&stringp,":");
1282  branch2 = strsep(&stringp,"");
1283  branch = pbx_checkcondition(condition) ? branch1 : branch2;
1284 
1285  if (ast_strlen_zero(branch)) {
1286  ast_debug(1, "Not taking any branch\n");
1287  return 0;
1288  }
1289 
1290  return pbx_builtin_goto(chan, branch);
1291 }
#define LOG_WARNING
Definition: logger.h:274
int pbx_checkcondition(const char *condition)
Evaluate a condition.
Definition: pbx.c:8321
#define ast_strlen_zero(foo)
Definition: strings.h:52
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define ast_log
Definition: astobj2.c:42
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
char * strsep(char **str, const char *delims)
static int pbx_builtin_goto(struct ast_channel *chan, const char *data)
Definition: pbx_builtins.c:894

◆ pbx_builtin_importvar()

static int pbx_builtin_importvar ( struct ast_channel chan,
const char *  data 
)
static
Todo:
XXX should do !ast_strlen_zero(..) of the args ?

Definition at line 1474 of file pbx_builtins.c.

References ast_alloca, ast_channel_get_by_name(), ast_channel_unref, ast_log, ast_strdupa, ast_strlen_zero, LOG_WARNING, name, pbx_builtin_setvar_helper(), pbx_substitute_variables_helper(), strsep(), tmp(), value, and VAR_BUF_SIZE.

1475 {
1476  char *name;
1477  char *value;
1478  char *channel;
1479  char tmp[VAR_BUF_SIZE];
1480  static int deprecation_warning = 0;
1481 
1482  if (ast_strlen_zero(data)) {
1483  ast_log(LOG_WARNING, "Ignoring, since there is no variable to set\n");
1484  return 0;
1485  }
1486  tmp[0] = 0;
1487  if (!deprecation_warning) {
1488  ast_log(LOG_WARNING, "ImportVar is deprecated. Please use Set(varname=${IMPORT(channel,variable)}) instead.\n");
1489  deprecation_warning = 1;
1490  }
1491 
1492  value = ast_strdupa(data);
1493  name = strsep(&value,"=");
1494  channel = strsep(&value,",");
1495  if (channel && value && name) { /*! \todo XXX should do !ast_strlen_zero(..) of the args ? */
1496  struct ast_channel *chan2 = ast_channel_get_by_name(channel);
1497  if (chan2) {
1498  char *s = ast_alloca(strlen(value) + 4);
1499  sprintf(s, "${%s}", value);
1500  pbx_substitute_variables_helper(chan2, s, tmp, sizeof(tmp) - 1);
1501  chan2 = ast_channel_unref(chan2);
1502  }
1503  pbx_builtin_setvar_helper(chan, name, tmp);
1504  }
1505 
1506  return(0);
1507 }
Main Channel structure associated with a channel.
#define ast_channel_unref(c)
Decrease channel reference count.
Definition: channel.h:2981
#define LOG_WARNING
Definition: logger.h:274
static int tmp()
Definition: bt_open.c:389
Definition: muted.c:95
int value
Definition: syslog.c:37
#define ast_strlen_zero(foo)
Definition: strings.h:52
#define ast_log
Definition: astobj2.c:42
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
Definition: astmm.h:290
#define VAR_BUF_SIZE
Definition: pbx_private.h:68
static const char name[]
Definition: cdr_mysql.c:74
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name...
char * strsep(char **str, const char *delims)
void pbx_substitute_variables_helper(struct ast_channel *c, const char *cp1, char *cp2, int count)
Definition: ael_main.c:211
struct ast_channel * ast_channel_get_by_name(const char *name)
Find a channel by name.
Definition: channel.c:1454

◆ pbx_builtin_incomplete()

static int pbx_builtin_incomplete ( struct ast_channel chan,
const char *  data 
)
static

Definition at line 806 of file pbx_builtins.c.

References __ast_answer(), answer(), ast_check_hangup(), AST_CONTROL_INCOMPLETE, ast_indicate(), AST_PBX_INCOMPLETE, AST_STATE_UP, ast_strlen_zero, and options.

807 {
808  const char *options = data;
809  int answer = 1;
810 
811  /* Some channels can receive DTMF in unanswered state; some cannot */
812  if (!ast_strlen_zero(options) && strchr(options, 'n')) {
813  answer = 0;
814  }
815 
816  /* If the channel is hungup, stop waiting */
817  if (ast_check_hangup(chan)) {
818  return -1;
819  } else if (ast_channel_state(chan) != AST_STATE_UP && answer) {
820  __ast_answer(chan, 0);
821  }
822 
824 
825  return AST_PBX_INCOMPLETE;
826 }
int ast_indicate(struct ast_channel *chan, int condition)
Indicates condition of channel.
Definition: channel.c:4322
ast_channel_state
ast_channel states
Definition: channelstate.h:35
const char * data
#define ast_strlen_zero(foo)
Definition: strings.h:52
static int answer(void *data)
Definition: chan_pjsip.c:682
int ast_check_hangup(struct ast_channel *chan)
Check to see if a channel is needing hang up.
Definition: channel.c:445
#define AST_PBX_INCOMPLETE
Definition: pbx.h:51
int __ast_answer(struct ast_channel *chan, unsigned int delay)
Answer a channel, with a selectable delay before returning.
Definition: channel.c:2704
static struct test_options options

◆ pbx_builtin_noop()

static int pbx_builtin_noop ( struct ast_channel chan,
const char *  data 
)
static

Definition at line 1264 of file pbx_builtins.c.

1265 {
1266  return 0;
1267 }

◆ pbx_builtin_raise_exception()

int pbx_builtin_raise_exception ( struct ast_channel chan,
const char *  reason 
)

Definition at line 703 of file pbx_builtins.c.

References raise_exception().

704 {
705  /* Priority will become 1, next time through the AUTOLOOP */
706  return raise_exception(chan, reason, 0);
707 }
int raise_exception(struct ast_channel *chan, const char *reason, int priority)
Definition: pbx.c:2806

◆ pbx_builtin_saycharacters()

static int pbx_builtin_saycharacters ( struct ast_channel chan,
const char *  data 
)
static

Definition at line 1436 of file pbx_builtins.c.

References ast_channel_language(), ast_channel_lock, ast_channel_unlock, AST_DIGIT_ANY, AST_SAY_CASE_NONE, ast_say_character_str(), ast_true(), and pbx_builtin_getvar_helper().

1437 {
1438  int res = 0;
1439  int interrupt = 0;
1440  const char *interrupt_string;
1441 
1442  ast_channel_lock(chan);
1443  interrupt_string = pbx_builtin_getvar_helper(chan, "SAY_DTMF_INTERRUPT");
1444  if (ast_true(interrupt_string)) {
1445  interrupt = 1;
1446  }
1447  ast_channel_unlock(chan);
1448 
1449  if (data) {
1450  res = ast_say_character_str(chan, data, interrupt ? AST_DIGIT_ANY : "", ast_channel_language(chan), AST_SAY_CASE_NONE);
1451  }
1452 
1453  return res;
1454 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
#define AST_DIGIT_ANY
Definition: file.h:48
const char * data
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
int ast_say_character_str(struct ast_channel *chan, const char *num, const char *ints, const char *lang, enum ast_say_case_sensitivity sensitivity)
function to pronounce character and phonetic strings
Definition: channel.c:8367
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true". This function checks to see whether a string passed to it is an indication of an "true" value. It checks to see if the string is "yes", "true", "y", "t", "on" or "1".
Definition: main/utils.c:1951
#define ast_channel_unlock(chan)
Definition: channel.h:2946
const char * ast_channel_language(const struct ast_channel *chan)

◆ pbx_builtin_saycharacters_case()

static int pbx_builtin_saycharacters_case ( struct ast_channel chan,
const char *  data 
)
static

Definition at line 1380 of file pbx_builtins.c.

References args, AST_APP_ARG, ast_channel_language(), ast_channel_lock, ast_channel_unlock, AST_DECLARE_APP_ARGS, AST_DIGIT_ANY, ast_log, AST_SAY_CASE_ALL, AST_SAY_CASE_LOWER, AST_SAY_CASE_NONE, AST_SAY_CASE_UPPER, ast_say_character_str(), AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero, ast_true(), LOG_WARNING, options, parse(), and pbx_builtin_getvar_helper().

1381 {
1382  int res = 0;
1383  int sensitivity = 0;
1384  char *parse;
1385  int interrupt = 0;
1386  const char *interrupt_string;
1387 
1390  AST_APP_ARG(characters);
1391  );
1392 
1393  ast_channel_lock(chan);
1394  interrupt_string = pbx_builtin_getvar_helper(chan, "SAY_DTMF_INTERRUPT");
1395  if (ast_true(interrupt_string)) {
1396  interrupt = 1;
1397  }
1398  ast_channel_unlock(chan);
1399 
1400  if (ast_strlen_zero(data)) {
1401  ast_log(LOG_WARNING, "SayAlphaCase requires two arguments (options, characters)\n");
1402  return 0;
1403  }
1404 
1405  parse = ast_strdupa(data);
1406  AST_STANDARD_APP_ARGS(args, parse);
1407 
1408  if (!args.options || strlen(args.options) != 1) {
1409  ast_log(LOG_WARNING, "SayAlphaCase options are mutually exclusive and required\n");
1410  return 0;
1411  }
1412 
1413  switch (args.options[0]) {
1414  case 'a':
1415  sensitivity = AST_SAY_CASE_ALL;
1416  break;
1417  case 'l':
1418  sensitivity = AST_SAY_CASE_LOWER;
1419  break;
1420  case 'n':
1421  sensitivity = AST_SAY_CASE_NONE;
1422  break;
1423  case 'u':
1424  sensitivity = AST_SAY_CASE_UPPER;
1425  break;
1426  default:
1427  ast_log(LOG_WARNING, "Invalid option: '%s'\n", args.options);
1428  return 0;
1429  }
1430 
1431  res = ast_say_character_str(chan, args.characters, interrupt ? AST_DIGIT_ANY : "", ast_channel_language(chan), sensitivity);
1432 
1433  return res;
1434 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
#define AST_DIGIT_ANY
Definition: file.h:48
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the &#39;standard&#39; argument separation process for an application.
#define LOG_WARNING
Definition: logger.h:274
const char * args
const char * data
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
#define ast_strlen_zero(foo)
Definition: strings.h:52
#define ast_log
Definition: astobj2.c:42
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
int ast_say_character_str(struct ast_channel *chan, const char *num, const char *ints, const char *lang, enum ast_say_case_sensitivity sensitivity)
function to pronounce character and phonetic strings
Definition: channel.c:8367
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true". This function checks to see whether a string passed to it is an indication of an "true" value. It checks to see if the string is "yes", "true", "y", "t", "on" or "1".
Definition: main/utils.c:1951
#define ast_channel_unlock(chan)
Definition: channel.h:2946
static void parse(struct mgcp_request *req)
Definition: chan_mgcp.c:1872
const char * ast_channel_language(const struct ast_channel *chan)
static struct test_options options
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application&#39;s arguments.
#define AST_APP_ARG(name)
Define an application argument.

◆ pbx_builtin_saydigits()

static int pbx_builtin_saydigits ( struct ast_channel chan,
const char *  data 
)
static

Definition at line 1340 of file pbx_builtins.c.

References ast_channel_language(), ast_channel_lock, ast_channel_unlock, AST_DIGIT_ANY, ast_say_digit_str(), ast_true(), and pbx_builtin_getvar_helper().

1341 {
1342  int res = 0;
1343  int interrupt = 0;
1344  const char *interrupt_string;
1345 
1346  ast_channel_lock(chan);
1347  interrupt_string = pbx_builtin_getvar_helper(chan, "SAY_DTMF_INTERRUPT");
1348  if (ast_true(interrupt_string)) {
1349  interrupt = 1;
1350  }
1351  ast_channel_unlock(chan);
1352 
1353  if (data) {
1354  res = ast_say_digit_str(chan, data, interrupt ? AST_DIGIT_ANY : "", ast_channel_language(chan));
1355  }
1356 
1357  return res;
1358 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
#define AST_DIGIT_ANY
Definition: file.h:48
int ast_say_digit_str(struct ast_channel *chan, const char *num, const char *ints, const char *lang)
says digits of a string
Definition: channel.c:8355
const char * data
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true". This function checks to see whether a string passed to it is an indication of an "true" value. It checks to see if the string is "yes", "true", "y", "t", "on" or "1".
Definition: main/utils.c:1951
#define ast_channel_unlock(chan)
Definition: channel.h:2946
const char * ast_channel_language(const struct ast_channel *chan)

◆ pbx_builtin_saymoney()

static int pbx_builtin_saymoney ( struct ast_channel chan,
const char *  data 
)
static

Definition at line 1360 of file pbx_builtins.c.

References ast_channel_language(), ast_channel_lock, ast_channel_unlock, AST_DIGIT_ANY, ast_say_money_str(), ast_true(), and pbx_builtin_getvar_helper().

1361 {
1362  int res = 0;
1363  int interrupt = 0;
1364  const char *interrupt_string;
1365 
1366  ast_channel_lock(chan);
1367  interrupt_string = pbx_builtin_getvar_helper(chan, "SAY_DTMF_INTERRUPT");
1368  if (ast_true(interrupt_string)) {
1369  interrupt = 1;
1370  }
1371  ast_channel_unlock(chan);
1372 
1373  if (data) {
1374  res = ast_say_money_str(chan, data, interrupt ? AST_DIGIT_ANY : "", ast_channel_language(chan));
1375  }
1376 
1377  return res;
1378 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
#define AST_DIGIT_ANY
Definition: file.h:48
int ast_say_money_str(struct ast_channel *chan, const char *num, const char *ints, const char *lang)
function to pronounce monetary amounts
Definition: channel.c:8361
const char * data
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true". This function checks to see whether a string passed to it is an indication of an "true" value. It checks to see if the string is "yes", "true", "y", "t", "on" or "1".
Definition: main/utils.c:1951
#define ast_channel_unlock(chan)
Definition: channel.h:2946
const char * ast_channel_language(const struct ast_channel *chan)

◆ pbx_builtin_saynumber()

static int pbx_builtin_saynumber ( struct ast_channel chan,
const char *  data 
)
static

Definition at line 1293 of file pbx_builtins.c.

References ast_channel_language(), ast_channel_lock, ast_channel_unlock, ast_check_hangup_locked(), ast_copy_string(), AST_DIGIT_ANY, ast_log, ast_say_number(), ast_strlen_zero, ast_true(), LOG_WARNING, options, pbx_builtin_getvar_helper(), strsep(), and tmp().

1294 {
1295  char tmp[256];
1296  char *number = tmp;
1297  int number_val;
1298  char *options;
1299  int res;
1300  int interrupt = 0;
1301  const char *interrupt_string;
1302 
1303  ast_channel_lock(chan);
1304  interrupt_string = pbx_builtin_getvar_helper(chan, "SAY_DTMF_INTERRUPT");
1305  if (ast_true(interrupt_string)) {
1306  interrupt = 1;
1307  }
1308  ast_channel_unlock(chan);
1309 
1310  if (ast_strlen_zero(data)) {
1311  ast_log(LOG_WARNING, "SayNumber requires an argument (number)\n");
1312  return -1;
1313  }
1314  ast_copy_string(tmp, data, sizeof(tmp));
1315  strsep(&number, ",");
1316 
1317  if (sscanf(tmp, "%d", &number_val) != 1) {
1318  ast_log(LOG_WARNING, "argument '%s' to SayNumber could not be parsed as a number.\n", tmp);
1319  return 0;
1320  }
1321 
1322  options = strsep(&number, ",");
1323  if (options) {
1324  if ( strcasecmp(options, "f") && strcasecmp(options, "m") &&
1325  strcasecmp(options, "c") && strcasecmp(options, "n") ) {
1326  ast_log(LOG_WARNING, "SayNumber gender option is either 'f', 'm', 'c' or 'n'\n");
1327  return -1;
1328  }
1329  }
1330 
1331  res = ast_say_number(chan, number_val, interrupt ? AST_DIGIT_ANY : "", ast_channel_language(chan), options);
1332 
1333  if (res < 0 && !ast_check_hangup_locked(chan)) {
1334  ast_log(LOG_WARNING, "We were unable to say the number %s, is it too large?\n", tmp);
1335  }
1336 
1337  return interrupt ? res : 0;
1338 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
#define AST_DIGIT_ANY
Definition: file.h:48
int ast_check_hangup_locked(struct ast_channel *chan)
Definition: channel.c:459
#define LOG_WARNING
Definition: logger.h:274
static int tmp()
Definition: bt_open.c:389
const char * data
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
#define ast_strlen_zero(foo)
Definition: strings.h:52
Number structure.
Definition: app_followme.c:154
#define ast_log
Definition: astobj2.c:42
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true". This function checks to see whether a string passed to it is an indication of an "true" value. It checks to see if the string is "yes", "true", "y", "t", "on" or "1".
Definition: main/utils.c:1951
#define ast_channel_unlock(chan)
Definition: channel.h:2946
char * strsep(char **str, const char *delims)
int ast_say_number(struct ast_channel *chan, int num, const char *ints, const char *lang, const char *options)
says a number
Definition: channel.c:8337
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
const char * ast_channel_language(const struct ast_channel *chan)
static struct test_options options

◆ pbx_builtin_sayphonetic()

static int pbx_builtin_sayphonetic ( struct ast_channel chan,
const char *  data 
)
static

Definition at line 1456 of file pbx_builtins.c.

References ast_channel_language(), ast_channel_lock, ast_channel_unlock, AST_DIGIT_ANY, ast_say_phonetic_str(), ast_true(), and pbx_builtin_getvar_helper().

1457 {
1458  int res = 0;
1459  int interrupt = 0;
1460  const char *interrupt_string;
1461 
1462  ast_channel_lock(chan);
1463  interrupt_string = pbx_builtin_getvar_helper(chan, "SAY_DTMF_INTERRUPT");
1464  if (ast_true(interrupt_string)) {
1465  interrupt = 1;
1466  }
1467  ast_channel_unlock(chan);
1468 
1469  if (data)
1470  res = ast_say_phonetic_str(chan, data, interrupt ? AST_DIGIT_ANY : "", ast_channel_language(chan));
1471  return res;
1472 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
#define AST_DIGIT_ANY
Definition: file.h:48
const char * data
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true". This function checks to see whether a string passed to it is an indication of an "true" value. It checks to see if the string is "yes", "true", "y", "t", "on" or "1".
Definition: main/utils.c:1951
#define ast_channel_unlock(chan)
Definition: channel.h:2946
int ast_say_phonetic_str(struct ast_channel *chan, const char *num, const char *ints, const char *lang)
Definition: channel.c:8373
const char * ast_channel_language(const struct ast_channel *chan)

◆ unload_pbx_builtins()

static void unload_pbx_builtins ( void  )
static

Definition at line 1546 of file pbx_builtins.c.

References ARRAY_LEN, ast_unregister_application(), builtins, pbx_builtin::name, and ast_channel::x.

Referenced by load_pbx_builtins().

1547 {
1548  int x;
1549 
1550  /* Unregister builtin applications */
1551  for (x = 0; x < ARRAY_LEN(builtins); x++) {
1553  }
1554 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
int ast_unregister_application(const char *app)
Unregister an application.
Definition: pbx_app.c:392
struct pbx_builtin builtins[]
static const char name[]
Definition: cdr_mysql.c:74
char x
Definition: extconf.c:81

Variable Documentation

◆ background_opts

const struct ast_app_option background_opts[128] = { [ 's' ] = { .flag = (1 << 0) }, [ 'n' ] = { .flag = (1 << 1) }, [ 'm' ] = { .flag = (1 << 2) }, [ 'p' ] = { .flag = (1 << 3) }, }
static

Definition at line 693 of file pbx_builtins.c.

Referenced by pbx_builtin_background().

◆ builtins

struct pbx_builtin builtins[]

◆ waitexten_opts

const struct ast_app_option waitexten_opts[128] = { [ 'm' ] = { .flag = (1 << 0) , .arg_index = 0 + 1 }, [ 'd' ] = { .flag = (1 << 1) , .arg_index = 0 + 1 }, }
static

Definition at line 701 of file pbx_builtins.c.

Referenced by pbx_builtin_waitexten().