Asterisk - The Open Source Telephony Project  18.5.0
Data Structures | Macros | Functions | Variables
features_config.c File Reference
#include "asterisk.h"
#include "asterisk/features_config.h"
#include "asterisk/config_options.h"
#include "asterisk/datastore.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/app.h"
#include "asterisk/cli.h"
#include "features_config.h"
Include dependency graph for features_config.c:

Go to the source code of this file.

Data Structures

struct  dummy_config
 
struct  featuregroup
 Featuregroup representation. More...
 
struct  featuregroup_item
 Entry in the container of featuregroups. More...
 
struct  features_config
 
struct  features_global_config
 Configuration from the "general" section of features.conf. More...
 

Macros

#define DEFAULT_ATXFER_ABORT   "*1"
 
#define DEFAULT_ATXFER_CALLBACK_RETRIES   2
 
#define DEFAULT_ATXFER_COMPLETE   "*2"
 
#define DEFAULT_ATXFER_DROP_CALL   0
 
#define DEFAULT_ATXFER_LOOP_DELAY   10
 
#define DEFAULT_ATXFER_SWAP   "*4"
 
#define DEFAULT_ATXFER_THREEWAY   "*3"
 
#define DEFAULT_COURTESY_TONE   ""
 
#define DEFAULT_FEATURE_DIGIT_TIMEOUT   1000
 
#define DEFAULT_FEATUREMAP_ATXFER   ""
 
#define DEFAULT_FEATUREMAP_AUTOMIXMON   ""
 
#define DEFAULT_FEATUREMAP_AUTOMON   ""
 
#define DEFAULT_FEATUREMAP_BLINDXFER   "#"
 
#define DEFAULT_FEATUREMAP_DISCONNECT   "*"
 
#define DEFAULT_FEATUREMAP_PARKCALL   ""
 
#define DEFAULT_NOANSWER_TIMEOUT_ATTENDED_TRANSFER   15
 
#define DEFAULT_PICKUPEXTEN   "*8"
 
#define DEFAULT_PICKUPFAILSOUND   ""
 
#define DEFAULT_PICKUPSOUND   ""
 
#define DEFAULT_RECORDING_FAIL_SOUND   ""
 
#define DEFAULT_TRANSFER_DIAL_ATTEMPTS   3
 
#define DEFAULT_TRANSFER_DIGIT_TIMEOUT   3
 
#define DEFAULT_TRANSFER_INVALID_SOUND   "privacy-incorrect"
 
#define DEFAULT_TRANSFER_RETRY_SOUND   "pbx-invalid"
 
#define DEFAULT_XFERFAILSOUND   "beeperr"
 
#define DEFAULT_XFERSOUND   "beep"
 
#define HFS_FORMAT   "%-25s %-7s %-7s\n"
 

Functions

static struct features_config__features_config_alloc (int allocate_applicationmap)
 
static int add_item (void *obj, void *arg, int flags)
 
 AO2_GLOBAL_OBJ_STATIC (globals)
 
static struct ao2_containerapplicationmap_alloc (int replace_duplicates)
 
static int applicationmap_handler (const struct aco_option *opt, struct ast_variable *var, void *obj)
 
static struct ast_applicationmap_itemapplicationmap_item_alloc (const char *name, const char *app, const char *app_data, const char *moh_class, const char *dtmf, unsigned int activate_on_self)
 
static int applicationmap_sort (const void *obj, const void *arg, int flags)
 
static void ast_applicationmap_item_destructor (void *obj)
 
int ast_get_builtin_feature (struct ast_channel *chan, const char *feature, char *buf, size_t len)
 Get the DTMF code for a builtin feature. More...
 
struct ao2_containerast_get_chan_applicationmap (struct ast_channel *chan)
 Get the applicationmap for a given channel. More...
 
struct ast_featuremap_configast_get_chan_featuremap_config (struct ast_channel *chan)
 Get the featuremap configuration options for a channel. More...
 
char * ast_get_chan_features_atxferabort (struct ast_channel *chan)
 Get the transfer configuration option atxferabort. More...
 
struct ast_features_general_configast_get_chan_features_general_config (struct ast_channel *chan)
 Get the general configuration options for a channel. More...
 
struct ast_features_pickup_configast_get_chan_features_pickup_config (struct ast_channel *chan)
 Get the pickup configuration options for a channel. More...
 
struct ast_features_xfer_configast_get_chan_features_xfer_config (struct ast_channel *chan)
 Get the transfer configuration options for a channel. More...
 
char * ast_get_chan_features_xferfailsound (struct ast_channel *chan)
 Get the transfer configuration option xferfailsound. More...
 
int ast_get_feature (struct ast_channel *chan, const char *feature, char *buf, size_t len)
 Get the DTMF code for a call feature. More...
 
static int check_featuregroup (void *obj, void *arg, void *data, int flags)
 
static int check_featuregroup_item (void *obj, void *arg, void *data, int flags)
 
 CONFIG_INFO_CORE ("features", cfg_info, globals, features_config_alloc,.files=ACO_FILES(&features_conf),.pre_apply_config=features_pre_apply_config,)
 
static void feature_ds_destroy (void *data)
 
static void * feature_ds_duplicate (void *data)
 
static int feature_read (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
 
static int feature_write (struct ast_channel *chan, const char *cmd, char *data, const char *value)
 
static void * featuregroup_alloc (const char *cat)
 
static int featuregroup_cmp (void *obj, void *arg, int flags)
 
static void featuregroup_destructor (void *obj)
 
static void * featuregroup_find (struct ao2_container *group_container, const char *category)
 
static int featuregroup_handler (const struct aco_option *opt, struct ast_variable *var, void *obj)
 
static int featuregroup_hash (const void *obj, int flags)
 
static void featuregroup_item_destructor (void *obj)
 
static void featuremap_config_destructor (void *obj)
 
static void featuremap_copy (struct ast_featuremap_config *dest, const struct ast_featuremap_config *src)
 
static int featuremap_get (struct ast_featuremap_config *featuremap, const char *field, char *buf, size_t len)
 
static int featuremap_handler (const struct aco_option *opt, struct ast_variable *var, void *obj)
 
static int featuremap_read (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
 
static int featuremap_set (struct ast_featuremap_config *featuremap, const char *name, const char *value)
 
static int featuremap_write (struct ast_channel *chan, const char *cmd, char *data, const char *value)
 
static void * features_config_alloc (void)
 
static void features_config_destructor (void *obj)
 
static struct features_configfeatures_config_dup (const struct features_config *orig)
 
static void features_copy (struct features_config *dest, const struct features_config *src)
 
static int features_pre_apply_config (void)
 
static void general_copy (struct ast_features_general_config *dest, const struct ast_features_general_config *src)
 
static void general_destructor (void *obj)
 
static int general_get (struct ast_features_general_config *general, const char *field, char *buf, size_t len)
 
static int general_handler (const struct aco_option *opt, struct ast_variable *var, void *obj)
 
static int general_set (struct ast_features_general_config *general, const char *name, const char *value)
 
static struct ast_datastoreget_feature_chan_ds (struct ast_channel *chan)
 
static struct features_configget_feature_ds (struct ast_channel *chan)
 
static struct features_global_configglobal_config_alloc (void)
 
static void global_config_destructor (void *obj)
 
static void global_copy (struct features_global_config *dest, const struct features_global_config *src)
 
static int group_item_sort (const void *obj, const void *arg, int flags)
 
static char * handle_feature_show (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 CLI command to list configured features. More...
 
static int internal_feature_read (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
 
static int internal_feature_write (struct ast_channel *chan, const char *cmd, char *data, const char *value)
 
static int internal_featuremap_read (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
 
static int internal_featuremap_write (struct ast_channel *chan, const char *cmd, char *data, const char *value)
 
static int load_config (void)
 
int load_features_config (void)
 
static void pickup_copy (struct ast_features_pickup_config *dest, const struct ast_features_pickup_config *src)
 
static void pickup_destructor (void *obj)
 
static int pickup_get (struct ast_features_pickup_config *pickup, const char *field, char *buf, size_t len)
 
static int pickup_handler (const struct aco_option *opt, struct ast_variable *var, void *obj)
 
static int pickup_set (struct ast_features_pickup_config *pickup, const char *name, const char *value)
 
static int print_applicationmap (void *obj, void *arg, int flags)
 
static int print_featuregroup (void *obj, void *arg, int flags)
 
static int print_featuregroups (void *obj, void *arg, int flags)
 
int reload_features_config (void)
 
void unload_features_config (void)
 
static int unsupported_handler (const struct aco_option *opt, struct ast_variable *var, void *obj)
 
static void xfer_copy (struct ast_features_xfer_config *dest, const struct ast_features_xfer_config *src)
 
static void xfer_destructor (void *obj)
 
static int xfer_get (struct ast_features_xfer_config *xfer, const char *field, char *buf, size_t len)
 
static int xfer_handler (const struct aco_option *opt, struct ast_variable *var, void *obj)
 
static int xfer_set (struct ast_features_xfer_config *xfer, const char *name, const char *value)
 

Variables

static struct aco_type applicationmap_option
 
static struct aco_typeapplicationmap_options [] = ACO_TYPES(&applicationmap_option)
 
static struct ast_cli_entry cli_features_config []
 
static const struct ast_datastore_info feature_ds_info
 
static struct ast_custom_function feature_function
 
static struct aco_type featuregroup_option
 
static struct aco_typefeaturegroup_options [] = ACO_TYPES(&featuregroup_option)
 
static struct ast_custom_function featuremap_function
 
static struct aco_type featuremap_option
 
static struct aco_typefeaturemap_options [] = ACO_TYPES(&featuremap_option)
 
static struct aco_file features_conf
 
static struct aco_type global_option
 
static struct aco_typeglobal_options [] = ACO_TYPES(&global_option)
 
static int parking_warning = 0
 
static struct aco_type parkinglot_option
 
static struct aco_typeparkinglot_options [] = ACO_TYPES(&parkinglot_option)
 

Macro Definition Documentation

◆ DEFAULT_ATXFER_ABORT

#define DEFAULT_ATXFER_ABORT   "*1"

Definition at line 379 of file features_config.c.

Referenced by load_config().

◆ DEFAULT_ATXFER_CALLBACK_RETRIES

#define DEFAULT_ATXFER_CALLBACK_RETRIES   2

Definition at line 376 of file features_config.c.

Referenced by load_config().

◆ DEFAULT_ATXFER_COMPLETE

#define DEFAULT_ATXFER_COMPLETE   "*2"

Definition at line 380 of file features_config.c.

Referenced by load_config().

◆ DEFAULT_ATXFER_DROP_CALL

#define DEFAULT_ATXFER_DROP_CALL   0

Definition at line 374 of file features_config.c.

Referenced by load_config().

◆ DEFAULT_ATXFER_LOOP_DELAY

#define DEFAULT_ATXFER_LOOP_DELAY   10

Definition at line 375 of file features_config.c.

Referenced by load_config().

◆ DEFAULT_ATXFER_SWAP

#define DEFAULT_ATXFER_SWAP   "*4"

Definition at line 382 of file features_config.c.

Referenced by load_config().

◆ DEFAULT_ATXFER_THREEWAY

#define DEFAULT_ATXFER_THREEWAY   "*3"

Definition at line 381 of file features_config.c.

Referenced by load_config().

◆ DEFAULT_COURTESY_TONE

#define DEFAULT_COURTESY_TONE   ""

Definition at line 368 of file features_config.c.

Referenced by load_config().

◆ DEFAULT_FEATURE_DIGIT_TIMEOUT

#define DEFAULT_FEATURE_DIGIT_TIMEOUT   1000

Default general options

Definition at line 367 of file features_config.c.

Referenced by load_config().

◆ DEFAULT_FEATUREMAP_ATXFER

#define DEFAULT_FEATUREMAP_ATXFER   ""

Definition at line 396 of file features_config.c.

Referenced by handle_feature_show(), and load_config().

◆ DEFAULT_FEATUREMAP_AUTOMIXMON

#define DEFAULT_FEATUREMAP_AUTOMIXMON   ""

Definition at line 398 of file features_config.c.

Referenced by handle_feature_show(), and load_config().

◆ DEFAULT_FEATUREMAP_AUTOMON

#define DEFAULT_FEATUREMAP_AUTOMON   ""

Definition at line 395 of file features_config.c.

Referenced by handle_feature_show(), and load_config().

◆ DEFAULT_FEATUREMAP_BLINDXFER

#define DEFAULT_FEATUREMAP_BLINDXFER   "#"

Default featuremap options

Definition at line 393 of file features_config.c.

Referenced by handle_feature_show(), and load_config().

◆ DEFAULT_FEATUREMAP_DISCONNECT

#define DEFAULT_FEATUREMAP_DISCONNECT   "*"

Definition at line 394 of file features_config.c.

Referenced by handle_feature_show(), and load_config().

◆ DEFAULT_FEATUREMAP_PARKCALL

#define DEFAULT_FEATUREMAP_PARKCALL   ""

Definition at line 397 of file features_config.c.

Referenced by handle_feature_show(), and load_config().

◆ DEFAULT_NOANSWER_TIMEOUT_ATTENDED_TRANSFER

#define DEFAULT_NOANSWER_TIMEOUT_ATTENDED_TRANSFER   15

Definition at line 373 of file features_config.c.

Referenced by load_config().

◆ DEFAULT_PICKUPEXTEN

#define DEFAULT_PICKUPEXTEN   "*8"

Default pickup options

Definition at line 388 of file features_config.c.

Referenced by handle_feature_show(), and load_config().

◆ DEFAULT_PICKUPFAILSOUND

#define DEFAULT_PICKUPFAILSOUND   ""

Definition at line 390 of file features_config.c.

Referenced by load_config().

◆ DEFAULT_PICKUPSOUND

#define DEFAULT_PICKUPSOUND   ""

Definition at line 389 of file features_config.c.

Referenced by load_config().

◆ DEFAULT_RECORDING_FAIL_SOUND

#define DEFAULT_RECORDING_FAIL_SOUND   ""

Definition at line 369 of file features_config.c.

Referenced by load_config().

◆ DEFAULT_TRANSFER_DIAL_ATTEMPTS

#define DEFAULT_TRANSFER_DIAL_ATTEMPTS   3

Definition at line 383 of file features_config.c.

Referenced by load_config().

◆ DEFAULT_TRANSFER_DIGIT_TIMEOUT

#define DEFAULT_TRANSFER_DIGIT_TIMEOUT   3

Default xfer options

Definition at line 372 of file features_config.c.

Referenced by load_config().

◆ DEFAULT_TRANSFER_INVALID_SOUND

#define DEFAULT_TRANSFER_INVALID_SOUND   "privacy-incorrect"

Definition at line 385 of file features_config.c.

Referenced by load_config().

◆ DEFAULT_TRANSFER_RETRY_SOUND

#define DEFAULT_TRANSFER_RETRY_SOUND   "pbx-invalid"

Definition at line 384 of file features_config.c.

Referenced by load_config().

◆ DEFAULT_XFERFAILSOUND

#define DEFAULT_XFERFAILSOUND   "beeperr"

Definition at line 378 of file features_config.c.

Referenced by load_config().

◆ DEFAULT_XFERSOUND

#define DEFAULT_XFERSOUND   "beep"

Definition at line 377 of file features_config.c.

Referenced by load_config().

◆ HFS_FORMAT

#define HFS_FORMAT   "%-25s %-7s %-7s\n"

Definition at line 1903 of file features_config.c.

Referenced by handle_feature_show(), and print_applicationmap().

Function Documentation

◆ __features_config_alloc()

static struct features_config* __features_config_alloc ( int  allocate_applicationmap)
static

Definition at line 732 of file features_config.c.

References ao2_alloc, AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_cleanup, ao2_container_alloc_hash, ao2_ref, applicationmap_alloc(), ast_string_field_init, featuregroup_cmp(), featuregroup_hash(), featuremap_config_destructor(), features_config_destructor(), global_config_alloc(), NULL, and RAII_VAR.

Referenced by features_config_alloc(), and features_config_dup().

733 {
734  RAII_VAR(struct features_config *, cfg, NULL, ao2_cleanup);
735 
736  cfg = ao2_alloc(sizeof(*cfg), features_config_destructor);
737  if (!cfg) {
738  return NULL;
739  }
740 
741  cfg->global = global_config_alloc();
742  if (!cfg->global) {
743  return NULL;
744  }
745 
746  cfg->featuremap = ao2_alloc(sizeof(*cfg->featuremap), featuremap_config_destructor);
747  if (!cfg->featuremap || ast_string_field_init(cfg->featuremap, 32)) {
748  return NULL;
749  }
750 
751  cfg->parkinglots = ao2_alloc(sizeof(*cfg->parkinglots), NULL);
752  if (!cfg->parkinglots) {
753  return NULL;
754  }
755 
756  if (allocate_applicationmap) {
757  cfg->applicationmap = applicationmap_alloc(1);
758  if (!cfg->applicationmap) {
759  return NULL;
760  }
761 
762  cfg->featuregroups = ao2_container_alloc_hash(AO2_ALLOC_OPT_LOCK_NOLOCK, 0, 11,
764  if (!cfg->featuregroups) {
765  return NULL;
766  }
767  }
768 
769  ao2_ref(cfg, +1);
770  return cfg;
771 
772 }
static void features_config_destructor(void *obj)
static int featuregroup_hash(const void *obj, int flags)
static struct ao2_container * applicationmap_alloc(int replace_duplicates)
static int featuregroup_cmp(void *obj, void *arg, int flags)
#define NULL
Definition: resample.c:96
static struct features_global_config * global_config_alloc(void)
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:911
#define ast_string_field_init(x, size)
Initialize a field pool and fields.
Definition: stringfields.h:353
#define ao2_ref(o, delta)
Definition: astobj2.h:464
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
Definition: astobj2.h:1310
#define ao2_alloc(data_size, destructor_fn)
Definition: astobj2.h:411
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
static void featuremap_config_destructor(void *obj)

◆ add_item()

static int add_item ( void *  obj,
void *  arg,
int  flags 
)
static

Definition at line 1296 of file features_config.c.

References ast_applicationmap_item::activate_on_self, ao2_cleanup, ao2_link, ao2_ref, ast_applicationmap_item::app, ast_applicationmap_item::app_data, applicationmap_item_alloc(), featuregroup_item::appmap_item, featuregroup_item::appmap_item_name, ast_strlen_zero, featuregroup_item::dtmf_override, ast_applicationmap_item::moh_class, NULL, and RAII_VAR.

Referenced by ast_get_chan_applicationmap().

1297 {
1298  struct featuregroup_item *fg_item = obj;
1299  struct ao2_container *applicationmap = arg;
1300  RAII_VAR(struct ast_applicationmap_item *, appmap_item, NULL, ao2_cleanup);
1301 
1302  /* If there's no DTMF override, then we can just link
1303  * the applicationmap item directly. Otherwise, we need
1304  * to create a copy with the DTMF override in place and
1305  * link that instead
1306  */
1307  if (ast_strlen_zero(fg_item->dtmf_override)) {
1308  ao2_ref(fg_item->appmap_item, +1);
1309  appmap_item = fg_item->appmap_item;
1310  } else {
1311  appmap_item = applicationmap_item_alloc(fg_item->appmap_item_name,
1312  fg_item->appmap_item->app, fg_item->appmap_item->app_data,
1313  fg_item->appmap_item->moh_class, fg_item->dtmf_override,
1314  fg_item->appmap_item->activate_on_self);
1315  }
1316 
1317  if (!appmap_item) {
1318  return 0;
1319  }
1320 
1321  ao2_link(applicationmap, appmap_item);
1322  return 0;
1323 }
An applicationmap configuration item.
const ast_string_field appmap_item_name
#define NULL
Definition: resample.c:96
struct ast_applicationmap_item * appmap_item
#define ast_strlen_zero(foo)
Definition: strings.h:52
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:911
static struct ast_applicationmap_item * applicationmap_item_alloc(const char *name, const char *app, const char *app_data, const char *moh_class, const char *dtmf, unsigned int activate_on_self)
#define ao2_ref(o, delta)
Definition: astobj2.h:464
const ast_string_field dtmf_override
Entry in the container of featuregroups.
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
Generic container type.
#define ao2_link(container, obj)
Definition: astobj2.h:1549

◆ AO2_GLOBAL_OBJ_STATIC()

AO2_GLOBAL_OBJ_STATIC ( globals  )

◆ applicationmap_alloc()

static struct ao2_container* applicationmap_alloc ( int  replace_duplicates)
static

Definition at line 712 of file features_config.c.

References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_container_alloc_list, AO2_CONTAINER_ALLOC_OPT_DUPS_ALLOW, AO2_CONTAINER_ALLOC_OPT_DUPS_REPLACE, applicationmap_sort(), and NULL.

Referenced by __features_config_alloc(), and ast_get_chan_applicationmap().

713 {
717 }
Allow objects with duplicate keys in container.
Definition: astobj2.h:1185
#define ao2_container_alloc_list(ao2_options, container_options, sort_fn, cmp_fn)
Definition: astobj2.h:1335
#define NULL
Definition: resample.c:96
static int applicationmap_sort(const void *obj, const void *arg, int flags)
Replace objects with duplicate keys in container.
Definition: astobj2.h:1215

◆ applicationmap_handler()

static int applicationmap_handler ( const struct aco_option opt,
struct ast_variable var,
void *  obj 
)
static

Definition at line 1382 of file features_config.c.

References ao2_cleanup, ao2_link, app, applicationmap_item_alloc(), args, AST_APP_ARG, ast_debug, AST_DECLARE_APP_ARGS, ast_log, AST_STANDARD_APP_ARGS, ast_strdupa, ast_strip_quoted(), ast_strlen_zero, item, LOG_WARNING, ast_variable::name, NULL, paren, parse(), RAII_VAR, and ast_variable::value.

Referenced by load_config().

1384 {
1386  struct ao2_container *applicationmap = obj;
1388  AST_APP_ARG(dtmf);
1389  AST_APP_ARG(activate_on);
1390  AST_APP_ARG(app);
1392  AST_APP_ARG(moh_class);
1393  );
1394  char *parse = ast_strdupa(var->value);
1395  char *slash;
1396  char *paren;
1397  unsigned int activate_on_self;
1398 
1399  AST_STANDARD_APP_ARGS(args, parse);
1400 
1401  if (ast_strlen_zero(args.dtmf) ||
1402  ast_strlen_zero(args.activate_on) ||
1403  ast_strlen_zero(args.app)) {
1404  ast_log(LOG_WARNING, "Invalid applicationmap syntax for '%s'. Missing required argument\n", var->name);
1405  return -1;
1406  }
1407 
1408  /* features.conf used to have an "activated_by" portion
1409  * in addition to activate_on. Get rid of whatever may be
1410  * there
1411  */
1412  slash = strchr(args.activate_on, '/');
1413  if (slash) {
1414  *slash = '\0';
1415  }
1416 
1417  /* Some applications do not require arguments. */
1418  if (!args.app_data) {
1419  args.app_data = "";
1420  }
1421 
1422  /* Two syntaxes allowed for applicationmap:
1423  * Old: foo = *1,self,NoOp,Boo!,default
1424  * New: foo = *1,self,NoOp(Boo!),default
1425  *
1426  * We need to handle both
1427  */
1428  paren = strchr(args.app, '(');
1429  if (paren) {
1430  /* New syntax */
1431  char *close_paren;
1432 
1433  args.moh_class = args.app_data;
1434  *paren++ = '\0';
1435  close_paren = strrchr(paren, ')');
1436  if (close_paren) {
1437  *close_paren = '\0';
1438  }
1439  args.app_data = paren;
1440 
1441  /* Re-check that the application is not empty */
1442  if (ast_strlen_zero(args.app)) {
1443  ast_log(LOG_WARNING, "Applicationmap item '%s' does not contain an application name.\n", var->name);
1444  return -1;
1445  }
1446  } else if (strchr(args.app_data, '"')) {
1447  args.app_data = ast_strip_quoted(args.app_data, "\"", "\"");
1448  }
1449 
1450  /* Allow caller and callee to be specified for backwards compatibility */
1451  if (!strcasecmp(args.activate_on, "self") || !strcasecmp(args.activate_on, "caller")) {
1452  activate_on_self = 1;
1453  } else if (!strcasecmp(args.activate_on, "peer") || !strcasecmp(args.activate_on, "callee")) {
1454  activate_on_self = 0;
1455  } else {
1456  ast_log(LOG_WARNING, "Invalid 'activate_on' value %s for applicationmap item %s\n",
1457  args.activate_on, var->name);
1458  return -1;
1459  }
1460 
1461  ast_debug(1, "Allocating applicationmap item: dtmf = %s, app = %s, app_data = %s, moh_class = %s\n",
1462  args.dtmf, args.app, args.app_data, args.moh_class);
1463 
1464  item = applicationmap_item_alloc(var->name, args.app, args.app_data,
1465  args.moh_class, args.dtmf, activate_on_self);
1466 
1467  if (!item) {
1468  return -1;
1469  }
1470 
1471  if (!ao2_link(applicationmap, item)) {
1472  return -1;
1473  }
1474 
1475  return 0;
1476 }
An applicationmap configuration item.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
#define LOG_WARNING
Definition: logger.h:274
static struct aco_type item
Definition: test_config.c:1463
const char * args
#define NULL
Definition: resample.c:96
#define ast_strlen_zero(foo)
Definition: strings.h:52
char * ast_strip_quoted(char *s, const char *beg_quotes, const char *end_quotes)
Strip leading/trailing whitespace and quotes from a string.
Definition: main/utils.c:1639
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define ast_log
Definition: astobj2.c:42
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:911
static struct ast_applicationmap_item * applicationmap_item_alloc(const char *name, const char *app, const char *app_data, const char *moh_class, const char *dtmf, unsigned int activate_on_self)
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
static void parse(struct mgcp_request *req)
Definition: chan_mgcp.c:1872
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
Generic container type.
static const char app[]
Definition: app_mysql.c:62
#define paren
Definition: ael_lex.c:973
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define AST_APP_ARG(name)
Define an application argument.
#define ao2_link(container, obj)
Definition: astobj2.h:1549

◆ applicationmap_item_alloc()

static struct ast_applicationmap_item* applicationmap_item_alloc ( const char *  name,
const char *  app,
const char *  app_data,
const char *  moh_class,
const char *  dtmf,
unsigned int  activate_on_self 
)
static

Definition at line 1274 of file features_config.c.

References ast_applicationmap_item::activate_on_self, ao2_alloc, ast_applicationmap_item_destructor(), ast_copy_string(), ast_string_field_init, ast_string_field_set, ast_applicationmap_item::dtmf, item, and NULL.

Referenced by add_item(), and applicationmap_handler().

1277 {
1278  struct ast_applicationmap_item *item;
1279 
1280  item = ao2_alloc(sizeof(*item), ast_applicationmap_item_destructor);
1281 
1282  if (!item || ast_string_field_init(item, 64)) {
1283  return NULL;
1284  }
1285 
1286  ast_string_field_set(item, name, name);
1287  ast_string_field_set(item, app, app);
1290  ast_copy_string(item->dtmf, dtmf, sizeof(item->dtmf));
1292 
1293  return item;
1294 }
An applicationmap configuration item.
static struct aco_type item
Definition: test_config.c:1463
#define NULL
Definition: resample.c:96
static void ast_applicationmap_item_destructor(void *obj)
#define ast_string_field_init(x, size)
Initialize a field pool and fields.
Definition: stringfields.h:353
#define ao2_alloc(data_size, destructor_fn)
Definition: astobj2.h:411
static const char name[]
Definition: cdr_mysql.c:74
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
static const char app[]
Definition: app_mysql.c:62
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
Definition: stringfields.h:514

◆ applicationmap_sort()

static int applicationmap_sort ( const void *  obj,
const void *  arg,
int  flags 
)
static

Definition at line 416 of file features_config.c.

References ast_applicationmap_item::name, OBJ_KEY, OBJ_PARTIAL_KEY, and OBJ_POINTER.

Referenced by applicationmap_alloc().

417 {
418  const struct ast_applicationmap_item *item1 = obj;
419  const struct ast_applicationmap_item *item2;
420  const char *key2;
421 
422  switch(flags & (OBJ_POINTER | OBJ_KEY | OBJ_PARTIAL_KEY)) {
423  case OBJ_KEY:
424  key2 = arg;
425  return strcasecmp(item1->name, key2);
426  case OBJ_PARTIAL_KEY:
427  key2 = arg;
428  return strncasecmp(item1->name, key2, strlen(key2));
429  default:
430  case OBJ_POINTER:
431  item2 = arg;
432  return strcasecmp(item1->name, item2->name);
433  }
434 }
#define OBJ_KEY
Definition: astobj2.h:1155
#define OBJ_POINTER
Definition: astobj2.h:1154
An applicationmap configuration item.
#define OBJ_PARTIAL_KEY
Definition: astobj2.h:1156

◆ ast_applicationmap_item_destructor()

static void ast_applicationmap_item_destructor ( void *  obj)
static

Definition at line 409 of file features_config.c.

References ast_string_field_free_memory, and item.

Referenced by applicationmap_item_alloc().

410 {
411  struct ast_applicationmap_item *item = obj;
412 
414 }
An applicationmap configuration item.
static struct aco_type item
Definition: test_config.c:1463
#define ast_string_field_free_memory(x)
free all memory - to be called before destroying the object
Definition: stringfields.h:368

◆ ast_get_builtin_feature()

int ast_get_builtin_feature ( struct ast_channel chan,
const char *  feature,
char *  buf,
size_t  len 
)

Get the DTMF code for a builtin feature.

Note
The channel should be locked before calling this function

If no channel is provided, then the global setting for the option is returned.

Parameters
chanThe channel to get the option from
featureThe short name of the feature (as it appears in features.conf)
[out]bufThe buffer to write the DTMF value into
sizeThe size of the buffer in bytes
Return values
0Success
non-zeroUnrecognized builtin feature name

Definition at line 1233 of file features_config.c.

References ao2_cleanup, ao2_global_obj_ref, featuremap_get(), get_feature_ds(), globals, NULL, and RAII_VAR.

Referenced by action_atxfer(), ast_get_feature(), attended_transfer_exec(), builtin_feature_get_exten(), detect_disconnect(), and internal_featuremap_read().

1234 {
1235  RAII_VAR(struct features_config *, cfg, NULL, ao2_cleanup);
1236 
1237  if (chan) {
1238  cfg = get_feature_ds(chan);
1239  } else {
1240  cfg = ao2_global_obj_ref(globals);
1241  }
1242 
1243  if (!cfg) {
1244  return -1;
1245  }
1246 
1247  return featuremap_get(cfg->featuremap, feature, buf, len);
1248 }
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
#define ao2_global_obj_ref(holder)
Definition: astobj2.h:925
#define NULL
Definition: resample.c:96
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:911
static struct console_pvt globals
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
static int featuremap_get(struct ast_featuremap_config *featuremap, const char *field, char *buf, size_t len)
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
static struct features_config * get_feature_ds(struct ast_channel *chan)

◆ ast_get_chan_applicationmap()

struct ao2_container* ast_get_chan_applicationmap ( struct ast_channel chan)

Get the applicationmap for a given channel.

Note
The channel should be locked before calling this function.

This uses the value of the DYNAMIC_FEATURES channel variable to build a custom applicationmap for this channel. The returned container has applicationmap_items inside.

Parameters
chanThe channel for which applicationmap is being retrieved.
Return values
NULLAn error occurred or the channel has no dynamic features.
non-NULLA container of applicationmap_items pertaining to the channel.

Definition at line 1325 of file features_config.c.

References add_item(), ao2_callback, ao2_cleanup, ao2_container_count(), ao2_find, ao2_global_obj_ref, ao2_link, ao2_ref, applicationmap_alloc(), ast_assert, ast_channel_name(), ast_log, ast_strdupa, ast_strlen_zero, globals, item, LOG_WARNING, name, NULL, OBJ_KEY, pbx_builtin_getvar_helper(), RAII_VAR, S_OR, and strsep().

Referenced by ast_get_feature(), set_config_flags(), and setup_bridge_features_dynamic().

1326 {
1328  struct ao2_container *applicationmap;
1329  char *group_names;
1330  char *name;
1331 
1332  if (!cfg) {
1333  return NULL;
1334  }
1335 
1336  if (!chan) {
1337  if (!cfg->applicationmap || ao2_container_count(cfg->applicationmap) == 0) {
1338  return NULL;
1339  }
1340  ao2_ref(cfg->applicationmap, +1);
1341  return cfg->applicationmap;
1342  }
1343 
1344  group_names = ast_strdupa(S_OR(pbx_builtin_getvar_helper(chan, "DYNAMIC_FEATURES"), ""));
1345  if (ast_strlen_zero(group_names)) {
1346  return NULL;
1347  }
1348 
1349  applicationmap = applicationmap_alloc(0);
1350  if (!applicationmap) {
1351  return NULL;
1352  }
1353 
1354  /* global config must be initialized */
1355  ast_assert(cfg->featuregroups != NULL);
1356  ast_assert(cfg->applicationmap != NULL);
1357  while ((name = strsep(&group_names, "#"))) {
1358  RAII_VAR(struct featuregroup *, group, ao2_find(cfg->featuregroups, name, OBJ_KEY), ao2_cleanup);
1359 
1360  if (!group) {
1361  RAII_VAR(struct ast_applicationmap_item *, item, ao2_find(cfg->applicationmap, name, OBJ_KEY), ao2_cleanup);
1362 
1363  if (item) {
1364  ao2_link(applicationmap, item);
1365  } else {
1366  ast_log(LOG_WARNING, "Unknown DYNAMIC_FEATURES item '%s' on channel %s.\n",
1367  name, ast_channel_name(chan));
1368  }
1369  } else {
1370  ao2_callback(group->items, 0, add_item, applicationmap);
1371  }
1372  }
1373 
1374  if (ao2_container_count(applicationmap) == 0) {
1375  ao2_cleanup(applicationmap);
1376  return NULL;
1377  }
1378 
1379  return applicationmap;
1380 }
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
Featuregroup representation.
#define OBJ_KEY
Definition: astobj2.h:1155
An applicationmap configuration item.
#define LOG_WARNING
Definition: logger.h:274
#define ao2_callback(c, flags, cb_fn, arg)
Definition: astobj2.h:1716
static struct ao2_container * applicationmap_alloc(int replace_duplicates)
static struct aco_type item
Definition: test_config.c:1463
#define ao2_global_obj_ref(holder)
Definition: astobj2.h:925
#define ast_assert(a)
Definition: utils.h:695
#define NULL
Definition: resample.c:96
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 RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:911
#define ao2_ref(o, delta)
Definition: astobj2.h:464
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
static int add_item(void *obj, void *arg, int flags)
static struct console_pvt globals
static const char name[]
Definition: cdr_mysql.c:74
#define ao2_find(container, arg, flags)
Definition: astobj2.h:1756
char * strsep(char **str, const char *delims)
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
Definition: strings.h:79
const char * ast_channel_name(const struct ast_channel *chan)
Generic container type.
#define ao2_link(container, obj)
Definition: astobj2.h:1549

◆ ast_get_chan_featuremap_config()

struct ast_featuremap_config* ast_get_chan_featuremap_config ( struct ast_channel chan)

Get the featuremap configuration options for a channel.

Note
The channel should be locked before calling this function.
The returned value has its reference count incremented.

If no channel is provided, then the global featuremap configuration is returned.

Parameters
chanThe channel to get configuration options for
Return values
NULLFailed to get configuration
non-NULLThe pickup features configuration

Definition at line 1213 of file features_config.c.

References ao2_cleanup, ao2_global_obj_ref, ao2_ref, ast_assert, get_feature_ds(), globals, NULL, and RAII_VAR.

Referenced by testsuite_notify_feature_success().

1214 {
1215  RAII_VAR(struct features_config *, cfg, NULL, ao2_cleanup);
1216 
1217  if (chan) {
1218  cfg = get_feature_ds(chan);
1219  } else {
1220  cfg = ao2_global_obj_ref(globals);
1221  }
1222 
1223  if (!cfg) {
1224  return NULL;
1225  }
1226 
1227  ast_assert(cfg->featuremap != NULL);
1228 
1229  ao2_ref(cfg->featuremap, +1);
1230  return cfg->featuremap;
1231 }
#define ao2_global_obj_ref(holder)
Definition: astobj2.h:925
#define ast_assert(a)
Definition: utils.h:695
#define NULL
Definition: resample.c:96
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:911
#define ao2_ref(o, delta)
Definition: astobj2.h:464
static struct console_pvt globals
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
static struct features_config * get_feature_ds(struct ast_channel *chan)

◆ ast_get_chan_features_atxferabort()

char* ast_get_chan_features_atxferabort ( struct ast_channel chan)

Get the transfer configuration option atxferabort.

Note
The channel should be locked before calling this function.
The returned value has to be freed.

If no channel is provided, then option is pulled from the global transfer configuration.

Parameters
chanThe channel to get configuration options for
Return values
NULLFailed to get configuration
non-NULLThe atxferabort

Definition at line 1178 of file features_config.c.

References ao2_ref, ast_get_chan_features_xfer_config(), ast_strdup, ast_features_xfer_config::atxferabort, and NULL.

Referenced by action_cancel_atxfer().

1179 {
1180  char *res;
1182 
1183  if (!cfg) {
1184  return NULL;
1185  }
1186 
1187  res = ast_strdup(cfg->atxferabort);
1188  ao2_ref(cfg, -1);
1189 
1190  return res;
1191 }
Feature configuration relating to transfers.
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
#define NULL
Definition: resample.c:96
#define ao2_ref(o, delta)
Definition: astobj2.h:464
struct ast_features_xfer_config * ast_get_chan_features_xfer_config(struct ast_channel *chan)
Get the transfer configuration options for a channel.

◆ ast_get_chan_features_general_config()

struct ast_features_general_config* ast_get_chan_features_general_config ( struct ast_channel chan)

Get the general configuration options for a channel.

Note
The channel should be locked before calling this function.
The returned value has its reference count incremented.

If no channel is provided, then the global features configuration is returned.

Parameters
chanThe channel to get configuration options for
Return values
NULLFailed to get configuration
non-NULLThe general features configuration

Definition at line 1123 of file features_config.c.

References ao2_cleanup, ao2_global_obj_ref, ao2_ref, ast_assert, get_feature_ds(), globals, NULL, and RAII_VAR.

Referenced by bridge_channel_feature_digit_timeout(), feature_automixmonitor(), and feature_automonitor().

1124 {
1125  RAII_VAR(struct features_config *, cfg, NULL, ao2_cleanup);
1126 
1127  if (chan) {
1128  cfg = get_feature_ds(chan);
1129  } else {
1130  cfg = ao2_global_obj_ref(globals);
1131  }
1132 
1133  if (!cfg) {
1134  return NULL;
1135  }
1136 
1137  ast_assert(cfg->global && cfg->global->general);
1138 
1139  ao2_ref(cfg->global->general, +1);
1140  return cfg->global->general;
1141 }
#define ao2_global_obj_ref(holder)
Definition: astobj2.h:925
#define ast_assert(a)
Definition: utils.h:695
#define NULL
Definition: resample.c:96
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:911
#define ao2_ref(o, delta)
Definition: astobj2.h:464
static struct console_pvt globals
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
static struct features_config * get_feature_ds(struct ast_channel *chan)

◆ ast_get_chan_features_pickup_config()

struct ast_features_pickup_config* ast_get_chan_features_pickup_config ( struct ast_channel chan)

Get the pickup configuration options for a channel.

Note
The channel should be locked before calling this function.
The returned value has its reference count incremented.

If no channel is provided, then the global pickup configuration is returned.

Parameters
chanThe channel to get configuration options for
Return values
NULLFailed to get configuration
non-NULLThe pickup features configuration

Definition at line 1193 of file features_config.c.

References ao2_cleanup, ao2_global_obj_ref, ao2_ref, ast_assert, get_feature_ds(), globals, NULL, and RAII_VAR.

Referenced by __analog_ss_thread(), analog_ss_thread(), ast_pickup_call(), call_pickup_incoming_request(), cb_events(), get_destination(), handle_call_outgoing(), handle_request_invite(), key_main_page(), and mgcp_ss().

1194 {
1195  RAII_VAR(struct features_config *, cfg, NULL, ao2_cleanup);
1196 
1197  if (chan) {
1198  cfg = get_feature_ds(chan);
1199  } else {
1200  cfg = ao2_global_obj_ref(globals);
1201  }
1202 
1203  if (!cfg) {
1204  return NULL;
1205  }
1206 
1207  ast_assert(cfg->global && cfg->global->pickup);
1208 
1209  ao2_ref(cfg->global->pickup, +1);
1210  return cfg->global->pickup;
1211 }
#define ao2_global_obj_ref(holder)
Definition: astobj2.h:925
#define ast_assert(a)
Definition: utils.h:695
#define NULL
Definition: resample.c:96
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:911
#define ao2_ref(o, delta)
Definition: astobj2.h:464
static struct console_pvt globals
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
static struct features_config * get_feature_ds(struct ast_channel *chan)

◆ ast_get_chan_features_xfer_config()

struct ast_features_xfer_config* ast_get_chan_features_xfer_config ( struct ast_channel chan)

Get the transfer configuration options for a channel.

Note
The channel should be locked before calling this function.
The returned value has its reference count incremented.

If no channel is provided, then the global transfer configuration is returned.

Parameters
chanThe channel to get configuration options for
Return values
NULLFailed to get configuration
non-NULLThe transfer features configuration

Definition at line 1143 of file features_config.c.

References ao2_cleanup, ao2_global_obj_ref, ao2_ref, ast_assert, get_feature_ds(), globals, NULL, and RAII_VAR.

Referenced by action_bridge(), add_transferer_role(), ast_get_chan_features_atxferabort(), ast_get_chan_features_xferfailsound(), attended_transfer_properties_alloc(), bridge_exec(), grab_transfer(), and testsuite_notify_feature_success().

1144 {
1145  RAII_VAR(struct features_config *, cfg, NULL, ao2_cleanup);
1146 
1147  if (chan) {
1148  cfg = get_feature_ds(chan);
1149  } else {
1150  cfg = ao2_global_obj_ref(globals);
1151  }
1152 
1153  if (!cfg) {
1154  return NULL;
1155  }
1156 
1157  ast_assert(cfg->global && cfg->global->xfer);
1158 
1159  ao2_ref(cfg->global->xfer, +1);
1160  return cfg->global->xfer;
1161 }
#define ao2_global_obj_ref(holder)
Definition: astobj2.h:925
#define ast_assert(a)
Definition: utils.h:695
#define NULL
Definition: resample.c:96
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:911
#define ao2_ref(o, delta)
Definition: astobj2.h:464
static struct console_pvt globals
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
static struct features_config * get_feature_ds(struct ast_channel *chan)

◆ ast_get_chan_features_xferfailsound()

char* ast_get_chan_features_xferfailsound ( struct ast_channel chan)

Get the transfer configuration option xferfailsound.

Note
The channel should be locked before calling this function.
The returned value has to be freed.

If no channel is provided, then option is pulled from the global transfer configuration.

Parameters
chanThe channel to get configuration options for
Return values
NULLFailed to get configuration
non-NULLThe xferfailsound

Definition at line 1163 of file features_config.c.

References ao2_ref, ast_get_chan_features_xfer_config(), ast_strdup, NULL, and ast_features_xfer_config::xferfailsound.

Referenced by play_failsound(), and stream_failsound().

1164 {
1165  char *res;
1167 
1168  if (!cfg) {
1169  return NULL;
1170  }
1171 
1172  res = ast_strdup(cfg->xferfailsound);
1173  ao2_ref(cfg, -1);
1174 
1175  return res;
1176 }
Feature configuration relating to transfers.
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
#define NULL
Definition: resample.c:96
#define ao2_ref(o, delta)
Definition: astobj2.h:464
struct ast_features_xfer_config * ast_get_chan_features_xfer_config(struct ast_channel *chan)
Get the transfer configuration options for a channel.

◆ ast_get_feature()

int ast_get_feature ( struct ast_channel chan,
const char *  feature,
char *  buf,
size_t  len 
)

Get the DTMF code for a call feature.

Note
The channel should be locked before calling this function

If no channel is provided, then the global setting for the option is returned.

This function is like ast_get_builtin_feature except that it will also check the applicationmap in addition to the builtin features.

Parameters
chanThe channel to get the option from
featureThe short name of the feature
[out]bufThe buffer to write the DTMF value into
sizeThe size of the buffer in bytes
Return values
0Success
non-zeroUnrecognized feature name

Definition at line 1250 of file features_config.c.

References ao2_cleanup, ao2_find, ast_copy_string(), ast_get_builtin_feature(), ast_get_chan_applicationmap(), item, NULL, OBJ_KEY, and RAII_VAR.

Referenced by handle_incoming_request(), and handle_request_info().

1251 {
1252  RAII_VAR(struct ao2_container *, applicationmap, NULL, ao2_cleanup);
1254 
1255  if (!ast_get_builtin_feature(chan, feature, buf, len)) {
1256  return 0;
1257  }
1258 
1259  /* Dang, must be in the application map */
1260  applicationmap = ast_get_chan_applicationmap(chan);
1261  if (!applicationmap) {
1262  return -1;
1263  }
1264 
1265  item = ao2_find(applicationmap, feature, OBJ_KEY);
1266  if (!item) {
1267  return -1;
1268  }
1269 
1270  ast_copy_string(buf, item->dtmf, len);
1271  return 0;
1272 }
#define OBJ_KEY
Definition: astobj2.h:1155
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
An applicationmap configuration item.
struct ao2_container * ast_get_chan_applicationmap(struct ast_channel *chan)
Get the applicationmap for a given channel.
static struct aco_type item
Definition: test_config.c:1463
#define NULL
Definition: resample.c:96
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:911
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
#define ao2_find(container, arg, flags)
Definition: astobj2.h:1756
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
Generic container type.
int ast_get_builtin_feature(struct ast_channel *chan, const char *feature, char *buf, size_t len)
Get the DTMF code for a builtin feature.

◆ check_featuregroup()

static int check_featuregroup ( void *  obj,
void *  arg,
void *  data,
int  flags 
)
static

Definition at line 1567 of file features_config.c.

References ACO_FILES, ao2_callback_data, ast_log, check_featuregroup_item(), CMP_STOP, CONFIG_INFO_CORE(), features_config_alloc(), features_pre_apply_config(), globals, featuregroup::items, LOG_WARNING, and featuregroup::name.

Referenced by features_pre_apply_config().

1568 {
1569  struct featuregroup *group = obj;
1570  int *err = arg;
1571 
1572  ao2_callback_data(group->items, 0, check_featuregroup_item, arg, data);
1573 
1574  if (*err) {
1575  ast_log(LOG_WARNING, "Featuregroup %s refers to non-existent applicationmap item\n",
1576  group->name);
1577  }
1578 
1579  return *err ? CMP_STOP : 0;
1580 }
Featuregroup representation.
#define LOG_WARNING
Definition: logger.h:274
struct ao2_container * items
static int check_featuregroup_item(void *obj, void *arg, void *data, int flags)
#define ast_log
Definition: astobj2.c:42
const char * name
#define ao2_callback_data(container, flags, cb_fn, arg, data)
Definition: astobj2.h:1743

◆ check_featuregroup_item()

static int check_featuregroup_item ( void *  obj,
void *  arg,
void *  data,
int  flags 
)
static

Definition at line 1549 of file features_config.c.

References ao2_find, featuregroup_item::appmap_item, featuregroup_item::appmap_item_name, CMP_STOP, and OBJ_KEY.

Referenced by check_featuregroup().

1550 {
1551  struct ast_applicationmap_item *appmap_item;
1552  struct featuregroup_item *fg_item = obj;
1553  int *err = arg;
1554  struct ao2_container *applicationmap = data;
1555 
1556  appmap_item = ao2_find(applicationmap, fg_item->appmap_item_name, OBJ_KEY);
1557  if (!appmap_item) {
1558  *err = 1;
1559  return CMP_STOP;
1560  }
1561 
1562  fg_item->appmap_item = appmap_item;
1563 
1564  return 0;
1565 }
#define OBJ_KEY
Definition: astobj2.h:1155
An applicationmap configuration item.
const ast_string_field appmap_item_name
struct ast_applicationmap_item * appmap_item
#define ao2_find(container, arg, flags)
Definition: astobj2.h:1756
Entry in the container of featuregroups.
Generic container type.

◆ CONFIG_INFO_CORE()

CONFIG_INFO_CORE ( "features"  ,
cfg_info  ,
globals  ,
features_config_alloc  ,
files = ACO_FILES(&features_conf),
pre_apply_config = features_pre_apply_config 
)

Referenced by check_featuregroup().

◆ feature_ds_destroy()

static void feature_ds_destroy ( void *  data)
static

Definition at line 1046 of file features_config.c.

References ao2_cleanup.

1047 {
1048  struct features_config *cfg = data;
1049  ao2_cleanup(cfg);
1050 }
#define ao2_cleanup(obj)
Definition: astobj2.h:1958

◆ feature_ds_duplicate()

static void* feature_ds_duplicate ( void *  data)
static

Definition at line 1052 of file features_config.c.

References features_config_dup().

1053 {
1054  struct features_config *old_cfg = data;
1055 
1056  return features_config_dup(old_cfg);
1057 }
static struct features_config * features_config_dup(const struct features_config *orig)

◆ feature_read()

static int feature_read ( struct ast_channel chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  len 
)
static

Definition at line 1702 of file features_config.c.

References ast_log, internal_feature_read(), and LOG_WARNING.

1704 {
1705  if (!chan) {
1706  ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
1707  return -1;
1708  }
1709 
1710  return internal_feature_read(chan, cmd, data, buf, len);
1711 }
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
#define LOG_WARNING
Definition: logger.h:274
#define ast_log
Definition: astobj2.c:42
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
static int internal_feature_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)

◆ feature_write()

static int feature_write ( struct ast_channel chan,
const char *  cmd,
char *  data,
const char *  value 
)
static

Definition at line 1713 of file features_config.c.

References ast_log, internal_feature_write(), and LOG_WARNING.

1715 {
1716  if (!chan) {
1717  ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
1718  return -1;
1719  }
1720 
1721  return internal_feature_write(chan, cmd, data, value);
1722 }
static int internal_feature_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
#define LOG_WARNING
Definition: logger.h:274
int value
Definition: syslog.c:37
#define ast_log
Definition: astobj2.c:42

◆ featuregroup_alloc()

static void* featuregroup_alloc ( const char *  cat)
static

Definition at line 542 of file features_config.c.

References ao2_alloc, AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_cleanup, ao2_container_alloc_list, AO2_CONTAINER_ALLOC_OPT_DUPS_REPLACE, ast_strdup, featuregroup_destructor(), group_item_sort(), featuregroup::items, featuregroup::name, and NULL.

543 {
544  struct featuregroup *group;
545 
546  group = ao2_alloc(sizeof(*group), featuregroup_destructor);
547  if (!group) {
548  return NULL;
549  }
550 
551  group->name = ast_strdup(cat);
552  if (!group->name) {
553  ao2_cleanup(group);
554  return NULL;
555  }
556 
559  if (!group->items) {
560  ao2_cleanup(group);
561  return NULL;
562  }
563 
564  return group;
565 }
Featuregroup representation.
#define ao2_container_alloc_list(ao2_options, container_options, sort_fn, cmp_fn)
Definition: astobj2.h:1335
static int group_item_sort(const void *obj, const void *arg, int flags)
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
#define NULL
Definition: resample.c:96
struct ao2_container * items
const char * name
#define ao2_alloc(data_size, destructor_fn)
Definition: astobj2.h:411
Replace objects with duplicate keys in container.
Definition: astobj2.h:1215
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
static void featuregroup_destructor(void *obj)

◆ featuregroup_cmp()

static int featuregroup_cmp ( void *  obj,
void *  arg,
int  flags 
)
static

Definition at line 508 of file features_config.c.

References CMP_MATCH, CMP_STOP, featuregroup::name, OBJ_KEY, OBJ_PARTIAL_KEY, and OBJ_POINTER.

Referenced by __features_config_alloc().

509 {
510  struct featuregroup *group1 = obj;
511  struct featuregroup *group2;
512  const char *key2;
513 
514  switch(flags & (OBJ_POINTER | OBJ_KEY | OBJ_PARTIAL_KEY)) {
515  case OBJ_KEY:
516  key2 = arg;
517  return strcasecmp(group1->name, key2) ? 0 : CMP_MATCH;
518  case OBJ_PARTIAL_KEY:
519  key2 = arg;
520  return strncasecmp(group1->name, key2, strlen(key2)) ? 0 : CMP_MATCH;
521  case OBJ_POINTER:
522  group2 = arg;
523  return strcasecmp(group1->name, group2->name) ? 0 : CMP_MATCH;
524  default:
525  return CMP_STOP;
526  }
527 }
Featuregroup representation.
#define OBJ_KEY
Definition: astobj2.h:1155
#define OBJ_POINTER
Definition: astobj2.h:1154
#define OBJ_PARTIAL_KEY
Definition: astobj2.h:1156
const char * name

◆ featuregroup_destructor()

static void featuregroup_destructor ( void *  obj)
static

Definition at line 534 of file features_config.c.

References ao2_cleanup, ast_free, featuregroup::items, and featuregroup::name.

Referenced by featuregroup_alloc().

535 {
536  struct featuregroup *group = obj;
537 
538  ast_free((char *) group->name);
539  ao2_cleanup(group->items);
540 }
Featuregroup representation.
struct ao2_container * items
const char * name
#define ast_free(a)
Definition: astmm.h:182
#define ao2_cleanup(obj)
Definition: astobj2.h:1958

◆ featuregroup_find()

static void* featuregroup_find ( struct ao2_container group_container,
const char *  category 
)
static

Definition at line 529 of file features_config.c.

References ao2_find, and OBJ_KEY.

530 {
531  return ao2_find(group_container, category, OBJ_KEY);
532 }
#define OBJ_KEY
Definition: astobj2.h:1155
#define ao2_find(container, arg, flags)
Definition: astobj2.h:1756

◆ featuregroup_handler()

static int featuregroup_handler ( const struct aco_option opt,
struct ast_variable var,
void *  obj 
)
static

Definition at line 1478 of file features_config.c.

References ao2_alloc, ao2_cleanup, ao2_link, ast_string_field_init, ast_string_field_set, featuregroup_item_destructor(), item, featuregroup::items, ast_variable::name, NULL, RAII_VAR, and ast_variable::value.

Referenced by load_config().

1480 {
1482  struct featuregroup *group = obj;
1483 
1485  if (!item || ast_string_field_init(item, 32)) {
1486  return -1;
1487  }
1488 
1489  ast_string_field_set(item, appmap_item_name, var->name);
1490  ast_string_field_set(item, dtmf_override, var->value);
1491 
1492  if (!ao2_link(group->items, item)) {
1493  return -1;
1494  }
1495 
1496  /* We wait to look up the application map item in the preapply callback */
1497 
1498  return 0;
1499 }
Featuregroup representation.
static void featuregroup_item_destructor(void *obj)
static struct aco_type item
Definition: test_config.c:1463
#define NULL
Definition: resample.c:96
struct ao2_container * items
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:911
#define ast_string_field_init(x, size)
Initialize a field pool and fields.
Definition: stringfields.h:353
#define ao2_alloc(data_size, destructor_fn)
Definition: astobj2.h:411
Entry in the container of featuregroups.
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
Definition: stringfields.h:514
#define ao2_link(container, obj)
Definition: astobj2.h:1549

◆ featuregroup_hash()

static int featuregroup_hash ( const void *  obj,
int  flags 
)
static

Definition at line 489 of file features_config.c.

References ast_assert, ast_str_case_hash(), featuregroup::name, OBJ_KEY, OBJ_PARTIAL_KEY, and OBJ_POINTER.

Referenced by __features_config_alloc().

490 {
491  const struct featuregroup *group;
492  const char *key;
493 
494  switch (flags & (OBJ_POINTER | OBJ_KEY | OBJ_PARTIAL_KEY)) {
495  case OBJ_KEY:
496  key = obj;
497  return ast_str_case_hash(key);
498  case OBJ_PARTIAL_KEY:
499  ast_assert(0);
500  return 0;
501  case OBJ_POINTER:
502  default:
503  group = obj;
504  return ast_str_case_hash(group->name);
505  }
506 }
Featuregroup representation.
#define OBJ_KEY
Definition: astobj2.h:1155
#define OBJ_POINTER
Definition: astobj2.h:1154
#define ast_assert(a)
Definition: utils.h:695
#define OBJ_PARTIAL_KEY
Definition: astobj2.h:1156
const char * name
static force_inline int attribute_pure ast_str_case_hash(const char *str)
Compute a hash value on a case-insensitive string.
Definition: strings.h:1250

◆ featuregroup_item_destructor()

static void featuregroup_item_destructor ( void *  obj)
static

Definition at line 450 of file features_config.c.

References ao2_cleanup, featuregroup_item::appmap_item, ast_string_field_free_memory, and item.

Referenced by featuregroup_handler().

451 {
452  struct featuregroup_item *item = obj;
453 
455  ao2_cleanup(item->appmap_item);
456 }
static struct aco_type item
Definition: test_config.c:1463
struct ast_applicationmap_item * appmap_item
Entry in the container of featuregroups.
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
#define ast_string_field_free_memory(x)
free all memory - to be called before destroying the object
Definition: stringfields.h:368

◆ featuremap_config_destructor()

static void featuremap_config_destructor ( void *  obj)
static

Definition at line 647 of file features_config.c.

References ast_string_field_free_memory.

Referenced by __features_config_alloc().

648 {
649  struct ast_featuremap_config *cfg = obj;
650 
652 }
Configuration for the builtin features.
#define ast_string_field_free_memory(x)
free all memory - to be called before destroying the object
Definition: stringfields.h:368

◆ featuremap_copy()

static void featuremap_copy ( struct ast_featuremap_config dest,
const struct ast_featuremap_config src 
)
static

Definition at line 808 of file features_config.c.

References ast_string_fields_copy.

Referenced by features_copy().

809 {
810  ast_string_fields_copy(dest, src);
811 }
#define ast_string_fields_copy(copy, orig)
Copy all string fields from one instance to another of the same structure.
Definition: stringfields.h:627

◆ featuremap_get()

static int featuremap_get ( struct ast_featuremap_config featuremap,
const char *  field,
char *  buf,
size_t  len 
)
static

Definition at line 1021 of file features_config.c.

References ast_copy_string(), ast_featuremap_config::atxfer, ast_featuremap_config::automixmon, ast_featuremap_config::automon, ast_featuremap_config::blindxfer, ast_featuremap_config::disconnect, and ast_featuremap_config::parkcall.

Referenced by ast_get_builtin_feature().

1023 {
1024  int res = 0;
1025 
1026  if (!strcasecmp(field, "blindxfer")) {
1027  ast_copy_string(buf, featuremap->blindxfer, len);
1028  } else if (!strcasecmp(field, "disconnect")) {
1029  ast_copy_string(buf, featuremap->disconnect, len);
1030  } else if (!strcasecmp(field, "automon")) {
1031  ast_copy_string(buf, featuremap->automon, len);
1032  } else if (!strcasecmp(field, "atxfer")) {
1033  ast_copy_string(buf, featuremap->atxfer, len);
1034  } else if (!strcasecmp(field, "automixmon")) {
1035  ast_copy_string(buf, featuremap->automixmon, len);
1036  } else if (!strcasecmp(field, "parkcall")) {
1037  ast_copy_string(buf, featuremap->parkcall, len);
1038  } else {
1039  /* Unrecognized option */
1040  res = -1;
1041  }
1042 
1043  return res;
1044 }
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401

◆ featuremap_handler()

static int featuremap_handler ( const struct aco_option opt,
struct ast_variable var,
void *  obj 
)
static

Definition at line 1541 of file features_config.c.

References featuremap_set(), ast_variable::name, and ast_variable::value.

Referenced by load_config().

1543 {
1544  struct ast_featuremap_config *featuremap = obj;
1545 
1546  return featuremap_set(featuremap, var->name, var->value);
1547 }
Configuration for the builtin features.
static int featuremap_set(struct ast_featuremap_config *featuremap, const char *name, const char *value)

◆ featuremap_read()

static int featuremap_read ( struct ast_channel chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  len 
)
static

Definition at line 1724 of file features_config.c.

References ast_log, internal_featuremap_read(), and LOG_WARNING.

1726 {
1727  if (!chan) {
1728  ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
1729  return -1;
1730  }
1731 
1732  return internal_featuremap_read(chan, cmd, data, buf, len);
1733 }
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
#define LOG_WARNING
Definition: logger.h:274
#define ast_log
Definition: astobj2.c:42
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
static int internal_featuremap_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)

◆ featuremap_set()

static int featuremap_set ( struct ast_featuremap_config featuremap,
const char *  name,
const char *  value 
)
static

Definition at line 996 of file features_config.c.

References ast_string_field_set.

Referenced by featuremap_handler(), and internal_featuremap_write().

998 {
999  int res = 0;
1000 
1001  if (!strcasecmp(name, "blindxfer")) {
1002  ast_string_field_set(featuremap, blindxfer, value);
1003  } else if (!strcasecmp(name, "disconnect")) {
1004  ast_string_field_set(featuremap, disconnect, value);
1005  } else if (!strcasecmp(name, "automon")) {
1006  ast_string_field_set(featuremap, automon, value);
1007  } else if (!strcasecmp(name, "atxfer")) {
1008  ast_string_field_set(featuremap, atxfer, value);
1009  } else if (!strcasecmp(name, "automixmon")) {
1010  ast_string_field_set(featuremap, automixmon, value);
1011  } else if (!strcasecmp(name, "parkcall")) {
1012  ast_string_field_set(featuremap, parkcall, value);
1013  } else {
1014  /* Unrecognized option */
1015  res = -1;
1016  }
1017 
1018  return res;
1019 }
int value
Definition: syslog.c:37
static const char name[]
Definition: cdr_mysql.c:74
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
Definition: stringfields.h:514

◆ featuremap_write()

static int featuremap_write ( struct ast_channel chan,
const char *  cmd,
char *  data,
const char *  value 
)
static

Definition at line 1735 of file features_config.c.

References ast_log, internal_featuremap_write(), and LOG_WARNING.

1737 {
1738  if (!chan) {
1739  ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
1740  return -1;
1741  }
1742 
1743  return internal_featuremap_write(chan, cmd, data, value);
1744 }
static int internal_featuremap_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
#define LOG_WARNING
Definition: logger.h:274
int value
Definition: syslog.c:37
#define ast_log
Definition: astobj2.c:42

◆ features_config_alloc()

static void* features_config_alloc ( void  )
static

Definition at line 774 of file features_config.c.

References __features_config_alloc().

Referenced by check_featuregroup(), and load_config().

775 {
776  return __features_config_alloc(1);
777 }
static struct features_config * __features_config_alloc(int allocate_applicationmap)

◆ features_config_destructor()

static void features_config_destructor ( void *  obj)
static

Definition at line 636 of file features_config.c.

References ao2_cleanup, features_config::applicationmap, features_config::featuregroups, features_config::featuremap, features_config::global, and features_config::parkinglots.

Referenced by __features_config_alloc().

637 {
638  struct features_config *cfg = obj;
639 
640  ao2_cleanup(cfg->global);
641  ao2_cleanup(cfg->featuremap);
642  ao2_cleanup(cfg->parkinglots);
645 }
struct features_global_config * global
struct ao2_container * featuregroups
struct ast_featuremap_config * featuremap
struct dummy_config * parkinglots
struct ao2_container * applicationmap
#define ao2_cleanup(obj)
Definition: astobj2.h:1958

◆ features_config_dup()

static struct features_config* features_config_dup ( const struct features_config orig)
static

Definition at line 824 of file features_config.c.

References __features_config_alloc(), features_copy(), and NULL.

Referenced by feature_ds_duplicate(), and get_feature_ds().

825 {
826  struct features_config *dup;
827 
828  dup = __features_config_alloc(0);
829  if (!dup) {
830  return NULL;
831  }
832 
833  features_copy(dup, orig);
834 
835  return dup;
836 }
static struct features_config * __features_config_alloc(int allocate_applicationmap)
#define NULL
Definition: resample.c:96
static void features_copy(struct features_config *dest, const struct features_config *src)

◆ features_copy()

static void features_copy ( struct features_config dest,
const struct features_config src 
)
static

Definition at line 813 of file features_config.c.

References features_config::featuremap, featuremap_copy(), features_config::global, and global_copy().

Referenced by features_config_dup().

814 {
815  global_copy(dest->global, src->global);
817 
818  /* applicationmap and featuregroups are purposely not copied. A channel's applicationmap
819  * is produced on the fly when ast_get_chan_applicationmap() is called
820  * NOTE: This does not apply to the global cfg->applicationmap and cfg->featuresgroups
821  */
822 }
struct features_global_config * global
struct ast_featuremap_config * featuremap
static void featuremap_copy(struct ast_featuremap_config *dest, const struct ast_featuremap_config *src)
static void global_copy(struct features_global_config *dest, const struct features_global_config *src)

◆ features_pre_apply_config()

static int features_pre_apply_config ( void  )
static

Definition at line 1589 of file features_config.c.

References aco_pending_config(), ao2_callback_data, features_config::applicationmap, ast_assert, check_featuregroup(), features_config::featuregroups, and NULL.

Referenced by check_featuregroup().

1590 {
1591  struct features_config *cfg = aco_pending_config(&cfg_info);
1592  int err = 0;
1593 
1594  /* Now that the entire config has been processed, we can check that the featuregroup
1595  * items refer to actual applicationmap items.
1596  */
1597 
1598  /* global config must be initialized */
1599  ast_assert(cfg->featuregroups != NULL);
1600  ast_assert(cfg->applicationmap != NULL);
1602 
1603  return err;
1604 }
struct ao2_container * featuregroups
#define ast_assert(a)
Definition: utils.h:695
#define NULL
Definition: resample.c:96
void * aco_pending_config(struct aco_info *info)
Get pending config changes.
struct ao2_container * applicationmap
#define ao2_callback_data(container, flags, cb_fn, arg, data)
Definition: astobj2.h:1743
static int check_featuregroup(void *obj, void *arg, void *data, int flags)

◆ general_copy()

static void general_copy ( struct ast_features_general_config dest,
const struct ast_features_general_config src 
)
static

Definition at line 779 of file features_config.c.

References ast_string_fields_copy, and ast_features_general_config::featuredigittimeout.

Referenced by global_copy().

780 {
781  ast_string_fields_copy(dest, src);
783 }
#define ast_string_fields_copy(copy, orig)
Copy all string fields from one instance to another of the same structure.
Definition: stringfields.h:627

◆ general_destructor()

static void general_destructor ( void *  obj)
static

Definition at line 663 of file features_config.c.

References ast_string_field_free_memory.

Referenced by global_config_alloc().

664 {
665  struct ast_features_general_config *cfg = obj;
666 
668 }
General features configuration items.
#define ast_string_field_free_memory(x)
free all memory - to be called before destroying the object
Definition: stringfields.h:368

◆ general_get()

static int general_get ( struct ast_features_general_config general,
const char *  field,
char *  buf,
size_t  len 
)
static

Definition at line 857 of file features_config.c.

References ast_copy_string(), ast_features_general_config::courtesytone, ast_features_general_config::featuredigittimeout, and ast_features_general_config::recordingfailsound.

Referenced by internal_feature_read().

859 {
860  int res = 0;
861 
862  if (!strcasecmp(field, "featuredigittimeout")) {
863  snprintf(buf, len, "%u", general->featuredigittimeout);
864  } else if (!strcasecmp(field, "courtesytone")) {
865  ast_copy_string(buf, general->courtesytone, len);
866  } else if (!strcasecmp(field, "recordingfailsound")) {
868  } else {
869  /* Unrecognized option */
870  res = -1;
871  }
872 
873  return res;
874 }
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401

◆ general_handler()

static int general_handler ( const struct aco_option opt,
struct ast_variable var,
void *  obj 
)
static

Definition at line 1501 of file features_config.c.

References features_global_config::general, general_set(), global, ast_variable::name, and ast_variable::value.

Referenced by load_config().

1503 {
1504  struct features_global_config *global = obj;
1505  struct ast_features_general_config *general = global->general;
1506 
1507  return general_set(general, var->name, var->value);
1508 }
static struct aco_type global
Definition: test_config.c:1445
General features configuration items.
struct ast_features_general_config * general
Configuration from the "general" section of features.conf.
static int general_set(struct ast_features_general_config *general, const char *name, const char *value)

◆ general_set()

static int general_set ( struct ast_features_general_config general,
const char *  name,
const char *  value 
)
static

Definition at line 838 of file features_config.c.

References ast_parse_arg(), ast_string_field_set, ast_features_general_config::featuredigittimeout, and PARSE_INT32.

Referenced by general_handler(), and internal_feature_write().

840 {
841  int res = 0;
842 
843  if (!strcasecmp(name, "featuredigittimeout")) {
845  } else if (!strcasecmp(name, "courtesytone")) {
847  } else if (!strcasecmp(name, "recordingfailsound")) {
849  } else {
850  /* Unrecognized option */
851  res = -1;
852  }
853 
854  return res;
855 }
int value
Definition: syslog.c:37
static const char name[]
Definition: cdr_mysql.c:74
int ast_parse_arg(const char *arg, enum ast_parse_flags flags, void *result,...)
The argument parsing routine.
Definition: main/config.c:3657
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
Definition: stringfields.h:514

◆ get_feature_chan_ds()

static struct ast_datastore* get_feature_chan_ds ( struct ast_channel chan)
static

Definition at line 1109 of file features_config.c.

References ao2_cleanup, ast_channel_datastore_find(), get_feature_ds(), and NULL.

Referenced by internal_feature_read(), and internal_feature_write().

1110 {
1111  struct ast_datastore *ds;
1112 
1113  if (!(ds = ast_channel_datastore_find(chan, &feature_ds_info, NULL))) {
1114  /* Hasn't been created yet. Trigger creation. */
1115  ao2_cleanup(get_feature_ds(chan));
1116 
1118  }
1119 
1120  return ds;
1121 }
static const struct ast_datastore_info feature_ds_info
Structure for a data store object.
Definition: datastore.h:68
struct ast_datastore * ast_channel_datastore_find(struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid)
Find a datastore on a channel.
Definition: channel.c:2404
#define NULL
Definition: resample.c:96
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
static struct features_config * get_feature_ds(struct ast_channel *chan)

◆ get_feature_ds()

static struct features_config* get_feature_ds ( struct ast_channel chan)
static

Definition at line 1073 of file features_config.c.

References ao2_cleanup, ao2_global_obj_ref, ao2_ref, ast_channel_datastore_add(), ast_channel_datastore_find(), ast_datastore_alloc, ast_datastore::data, features_config_dup(), globals, NULL, and RAII_VAR.

Referenced by ast_get_builtin_feature(), ast_get_chan_featuremap_config(), ast_get_chan_features_general_config(), ast_get_chan_features_pickup_config(), ast_get_chan_features_xfer_config(), get_feature_chan_ds(), internal_feature_read(), internal_feature_write(), and internal_featuremap_write().

1074 {
1075  RAII_VAR(struct features_config *, orig, NULL, ao2_cleanup);
1076  struct features_config *cfg;
1077  struct ast_datastore *ds;
1078 
1079  if ((ds = ast_channel_datastore_find(chan, &feature_ds_info, NULL))) {
1080  cfg = ds->data;
1081  ao2_ref(cfg, +1);
1082  return cfg;
1083  }
1084 
1085  orig = ao2_global_obj_ref(globals);
1086  if (!orig) {
1087  return NULL;
1088  }
1089 
1090  cfg = features_config_dup(orig);
1091  if (!cfg) {
1092  return NULL;
1093  }
1094 
1095  if (!(ds = ast_datastore_alloc(&feature_ds_info, NULL))) {
1096  ao2_cleanup(cfg);
1097  return NULL;
1098  }
1099 
1100  /* Give the datastore a reference to the config */
1101  ao2_ref(cfg, +1);
1102  ds->data = cfg;
1103 
1104  ast_channel_datastore_add(chan, ds);
1105 
1106  return cfg;
1107 }
static const struct ast_datastore_info feature_ds_info
#define ao2_global_obj_ref(holder)
Definition: astobj2.h:925
Structure for a data store object.
Definition: datastore.h:68
struct ast_datastore * ast_channel_datastore_find(struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid)
Find a datastore on a channel.
Definition: channel.c:2404
#define NULL
Definition: resample.c:96
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:911
#define ao2_ref(o, delta)
Definition: astobj2.h:464
static struct console_pvt globals
static struct features_config * features_config_dup(const struct features_config *orig)
void * data
Definition: datastore.h:70
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
#define ast_datastore_alloc(info, uid)
Definition: datastore.h:89
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
Definition: channel.c:2390

◆ global_config_alloc()

static struct features_global_config* global_config_alloc ( void  )
static

Definition at line 684 of file features_config.c.

References ao2_alloc, ao2_cleanup, ao2_ref, ast_string_field_init, general_destructor(), global_config_destructor(), NULL, pickup_destructor(), RAII_VAR, and xfer_destructor().

Referenced by __features_config_alloc().

685 {
687 
688  cfg = ao2_alloc(sizeof(*cfg), global_config_destructor);
689  if (!cfg) {
690  return NULL;
691  }
692 
693  cfg->general = ao2_alloc(sizeof(*cfg->general), general_destructor);
694  if (!cfg->general || ast_string_field_init(cfg->general, 32)) {
695  return NULL;
696  }
697 
698  cfg->xfer = ao2_alloc(sizeof(*cfg->xfer), xfer_destructor);
699  if (!cfg->xfer || ast_string_field_init(cfg->xfer, 32)) {
700  return NULL;
701  }
702 
703  cfg->pickup = ao2_alloc(sizeof(*cfg->pickup), pickup_destructor);
704  if (!cfg->pickup || ast_string_field_init(cfg->pickup, 32)) {
705  return NULL;
706  }
707 
708  ao2_ref(cfg, +1);
709  return cfg;
710 }
static void global_config_destructor(void *obj)
#define NULL
Definition: resample.c:96
Configuration from the "general" section of features.conf.
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:911
#define ast_string_field_init(x, size)
Initialize a field pool and fields.
Definition: stringfields.h:353
#define ao2_ref(o, delta)
Definition: astobj2.h:464
static void general_destructor(void *obj)
static void xfer_destructor(void *obj)
#define ao2_alloc(data_size, destructor_fn)
Definition: astobj2.h:411
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
static void pickup_destructor(void *obj)

◆ global_config_destructor()

static void global_config_destructor ( void *  obj)
static

Definition at line 654 of file features_config.c.

References ao2_cleanup, features_global_config::general, features_global_config::pickup, and features_global_config::xfer.

Referenced by global_config_alloc().

655 {
656  struct features_global_config *cfg = obj;
657 
658  ao2_cleanup(cfg->general);
659  ao2_cleanup(cfg->xfer);
660  ao2_cleanup(cfg->pickup);
661 }
struct ast_features_xfer_config * xfer
struct ast_features_general_config * general
Configuration from the "general" section of features.conf.
struct ast_features_pickup_config * pickup
#define ao2_cleanup(obj)
Definition: astobj2.h:1958

◆ global_copy()

static void global_copy ( struct features_global_config dest,
const struct features_global_config src 
)
static

Definition at line 801 of file features_config.c.

References features_global_config::general, general_copy(), features_global_config::pickup, pickup_copy(), features_global_config::xfer, and xfer_copy().

Referenced by features_copy().

802 {
803  general_copy(dest->general, src->general);
804  xfer_copy(dest->xfer, src->xfer);
805  pickup_copy(dest->pickup, src->pickup);
806 }
static void general_copy(struct ast_features_general_config *dest, const struct ast_features_general_config *src)
struct ast_features_xfer_config * xfer
struct ast_features_general_config * general
struct ast_features_pickup_config * pickup
static void xfer_copy(struct ast_features_xfer_config *dest, const struct ast_features_xfer_config *src)
static void pickup_copy(struct ast_features_pickup_config *dest, const struct ast_features_pickup_config *src)

◆ group_item_sort()

static int group_item_sort ( const void *  obj,
const void *  arg,
int  flags 
)
static

Definition at line 458 of file features_config.c.

References featuregroup_item::appmap_item_name, CMP_STOP, OBJ_KEY, OBJ_PARTIAL_KEY, and OBJ_POINTER.

Referenced by featuregroup_alloc().

459 {
460  const struct featuregroup_item *item1 = obj;
461  const struct featuregroup_item *item2;
462  const char *key2;
463 
464  switch(flags & (OBJ_POINTER | OBJ_KEY | OBJ_PARTIAL_KEY)) {
465  case OBJ_KEY:
466  key2 = arg;
467  return strcasecmp(item1->appmap_item_name, key2);
468  case OBJ_PARTIAL_KEY:
469  key2 = arg;
470  return strncasecmp(item1->appmap_item_name, key2, strlen(key2));
471  case OBJ_POINTER:
472  item2 = arg;
473  return strcasecmp(item1->appmap_item_name, item2->appmap_item_name);
474  default:
475  return CMP_STOP;
476  }
477 }
#define OBJ_KEY
Definition: astobj2.h:1155
#define OBJ_POINTER
Definition: astobj2.h:1154
const ast_string_field appmap_item_name
#define OBJ_PARTIAL_KEY
Definition: astobj2.h:1156
Entry in the container of featuregroups.

◆ handle_feature_show()

static char* handle_feature_show ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
)
static

CLI command to list configured features.

Parameters
e
cmd
a
Return values
CLI_SUCCESSon success.
NULLwhen tab completion is used.

Definition at line 1923 of file features_config.c.

References ao2_callback, ao2_cleanup, ao2_container_count(), ao2_global_obj_ref, ast_cli(), CLI_GENERATE, CLI_INIT, CLI_SUCCESS, ast_cli_entry::command, DEFAULT_FEATUREMAP_ATXFER, DEFAULT_FEATUREMAP_AUTOMIXMON, DEFAULT_FEATUREMAP_AUTOMON, DEFAULT_FEATUREMAP_BLINDXFER, DEFAULT_FEATUREMAP_DISCONNECT, DEFAULT_FEATUREMAP_PARKCALL, DEFAULT_PICKUPEXTEN, ast_cli_args::fd, globals, HFS_FORMAT, NULL, print_applicationmap(), print_featuregroups(), RAII_VAR, and ast_cli_entry::usage.

1924 {
1925  RAII_VAR(struct features_config *, cfg, NULL, ao2_cleanup);
1926 
1927  switch (cmd) {
1928 
1929  case CLI_INIT:
1930  e->command = "features show";
1931  e->usage =
1932  "Usage: features show\n"
1933  " Lists configured features\n";
1934  return NULL;
1935  case CLI_GENERATE:
1936  return NULL;
1937  }
1938 
1939  cfg = ao2_global_obj_ref(globals);
1940 
1941  ast_cli(a->fd, HFS_FORMAT, "Builtin Feature", "Default", "Current");
1942  ast_cli(a->fd, HFS_FORMAT, "---------------", "-------", "-------");
1943 
1944  ast_cli(a->fd, HFS_FORMAT, "Pickup", DEFAULT_PICKUPEXTEN, cfg->global->pickup->pickupexten);
1945  ast_cli(a->fd, HFS_FORMAT, "Blind Transfer", DEFAULT_FEATUREMAP_BLINDXFER, cfg->featuremap->blindxfer);
1946  ast_cli(a->fd, HFS_FORMAT, "Attended Transfer", DEFAULT_FEATUREMAP_ATXFER, cfg->featuremap->atxfer);
1947  ast_cli(a->fd, HFS_FORMAT, "One Touch Monitor", DEFAULT_FEATUREMAP_AUTOMON, cfg->featuremap->automon);
1948  ast_cli(a->fd, HFS_FORMAT, "Disconnect Call", DEFAULT_FEATUREMAP_DISCONNECT, cfg->featuremap->disconnect);
1949  ast_cli(a->fd, HFS_FORMAT, "Park Call", DEFAULT_FEATUREMAP_PARKCALL, cfg->featuremap->parkcall);
1950  ast_cli(a->fd, HFS_FORMAT, "One Touch MixMonitor", DEFAULT_FEATUREMAP_AUTOMIXMON, cfg->featuremap->automixmon);
1951 
1952  ast_cli(a->fd, "\n");
1953  ast_cli(a->fd, HFS_FORMAT, "Dynamic Feature", "Default", "Current");
1954  ast_cli(a->fd, HFS_FORMAT, "---------------", "-------", "-------");
1955  if (!cfg->applicationmap || ao2_container_count(cfg->applicationmap) == 0) {
1956  ast_cli(a->fd, "(none)\n");
1957  } else {
1958  ao2_callback(cfg->applicationmap, 0, print_applicationmap, a);
1959  }
1960 
1961  ast_cli(a->fd, "\nFeature Groups:\n");
1962  ast_cli(a->fd, "---------------\n");
1963  if (!cfg->featuregroups || ao2_container_count(cfg->featuregroups) == 0) {
1964  ast_cli(a->fd, "(none)\n");
1965  } else {
1966  ao2_callback(cfg->featuregroups, 0, print_featuregroups, a);
1967  }
1968 
1969  return CLI_SUCCESS;
1970 }
#define DEFAULT_FEATUREMAP_BLINDXFER
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
static int print_applicationmap(void *obj, void *arg, int flags)
#define DEFAULT_FEATUREMAP_ATXFER
#define ao2_callback(c, flags, cb_fn, arg)
Definition: astobj2.h:1716
Definition: cli.h:152
#define ao2_global_obj_ref(holder)
Definition: astobj2.h:925
#define NULL
Definition: resample.c:96
void ast_cli(int fd, const char *fmt,...)
Definition: clicompat.c:6
#define DEFAULT_FEATUREMAP_DISCONNECT
#define DEFAULT_PICKUPEXTEN
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:911
const int fd
Definition: cli.h:159
#define DEFAULT_FEATUREMAP_AUTOMIXMON
static struct console_pvt globals
#define DEFAULT_FEATUREMAP_PARKCALL
#define HFS_FORMAT
char * command
Definition: cli.h:186
const char * usage
Definition: cli.h:177
static int print_featuregroups(void *obj, void *arg, int flags)
#define CLI_SUCCESS
Definition: cli.h:44
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
#define DEFAULT_FEATUREMAP_AUTOMON

◆ internal_feature_read()

static int internal_feature_read ( struct ast_channel chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  len 
)
static

Definition at line 1606 of file features_config.c.

References ao2_cleanup, ast_log, general_get(), get_feature_chan_ds(), get_feature_ds(), ast_datastore::inheritance, lock, LOG_WARNING, NULL, pickup_get(), RAII_VAR, SCOPED_CHANNELLOCK, and xfer_get().

Referenced by feature_read().

1608 {
1609  int res;
1610  RAII_VAR(struct features_config *, cfg, NULL, ao2_cleanup);
1611  SCOPED_CHANNELLOCK(lock, chan);
1612 
1613  if (!strcasecmp(data, "inherit")) {
1614  struct ast_datastore *ds = get_feature_chan_ds(chan);
1615  unsigned int inherit = ds ? ds->inheritance : 0;
1616 
1617  snprintf(buf, len, "%s", inherit ? "yes" : "no");
1618  return 0;
1619  }
1620 
1621  cfg = get_feature_ds(chan);
1622  if (!cfg) {
1623  return -1;
1624  }
1625 
1626  res = general_get(cfg->global->general, data, buf, len) &&
1627  xfer_get(cfg->global->xfer, data, buf, len) &&
1628  pickup_get(cfg->global->pickup, data, buf, len);
1629 
1630  if (res) {
1631  ast_log(LOG_WARNING, "Invalid argument '%s' to FEATURE()\n", data);
1632  }
1633 
1634  return res;
1635 }
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
static struct ast_datastore * get_feature_chan_ds(struct ast_channel *chan)
#define LOG_WARNING
Definition: logger.h:274
Structure for a data store object.
Definition: datastore.h:68
#define NULL
Definition: resample.c:96
#define ast_log
Definition: astobj2.c:42
static int general_get(struct ast_features_general_config *general, const char *field, char *buf, size_t len)
#define SCOPED_CHANNELLOCK(varname, chan)
scoped lock specialization for channels.
Definition: lock.h:617
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:911
ast_mutex_t lock
Definition: app_meetme.c:1091
static int xfer_get(struct ast_features_xfer_config *xfer, const char *field, char *buf, size_t len)
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
static int pickup_get(struct ast_features_pickup_config *pickup, const char *field, char *buf, size_t len)
unsigned int inheritance
Definition: datastore.h:73
void * data
Definition: datastore.h:70
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
static struct features_config * get_feature_ds(struct ast_channel *chan)

◆ internal_feature_write()

static int internal_feature_write ( struct ast_channel chan,
const char *  cmd,
char *  data,
const char *  value 
)
static

Definition at line 1637 of file features_config.c.

References ao2_cleanup, ast_log, ast_true(), DATASTORE_INHERIT_FOREVER, general_set(), get_feature_chan_ds(), get_feature_ds(), ast_datastore::inheritance, lock, LOG_WARNING, NULL, pickup_set(), RAII_VAR, SCOPED_CHANNELLOCK, and xfer_set().

Referenced by feature_write().

1639 {
1640  int res;
1641  RAII_VAR(struct features_config *, cfg, NULL, ao2_cleanup);
1642  SCOPED_CHANNELLOCK(lock, chan);
1643 
1644  if (!strcasecmp(data, "inherit")) {
1645  struct ast_datastore *ds = get_feature_chan_ds(chan);
1646  if (ds) {
1648  }
1649  return 0;
1650  }
1651 
1652  if (!(cfg = get_feature_ds(chan))) {
1653  return -1;
1654  }
1655 
1656  res = general_set(cfg->global->general, data, value) &&
1657  xfer_set(cfg->global->xfer, data, value) &&
1658  pickup_set(cfg->global->pickup, data, value);
1659 
1660  if (res) {
1661  ast_log(LOG_WARNING, "Invalid argument '%s' to FEATURE()\n", data);
1662  }
1663 
1664  return res;
1665 }
static struct ast_datastore * get_feature_chan_ds(struct ast_channel *chan)
#define LOG_WARNING
Definition: logger.h:274
Structure for a data store object.
Definition: datastore.h:68
#define NULL
Definition: resample.c:96
int value
Definition: syslog.c:37
#define ast_log
Definition: astobj2.c:42
#define SCOPED_CHANNELLOCK(varname, chan)
scoped lock specialization for channels.
Definition: lock.h:617
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:911
ast_mutex_t lock
Definition: app_meetme.c:1091
static int pickup_set(struct ast_features_pickup_config *pickup, const char *name, const char *value)
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
static int general_set(struct ast_features_general_config *general, const char *name, const char *value)
#define DATASTORE_INHERIT_FOREVER
Definition: channel.h:193
unsigned int inheritance
Definition: datastore.h:73
void * data
Definition: datastore.h:70
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
static struct features_config * get_feature_ds(struct ast_channel *chan)
static int xfer_set(struct ast_features_xfer_config *xfer, const char *name, const char *value)

◆ internal_featuremap_read()

static int internal_featuremap_read ( struct ast_channel chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  len 
)
static

Definition at line 1667 of file features_config.c.

References ast_get_builtin_feature(), ast_log, lock, LOG_WARNING, and SCOPED_CHANNELLOCK.

Referenced by featuremap_read().

1669 {
1670  int res;
1671  SCOPED_CHANNELLOCK(lock, chan);
1672 
1673  res = ast_get_builtin_feature(chan, data, buf, len);
1674 
1675  if (res) {
1676  ast_log(LOG_WARNING, "Invalid argument '%s' to FEATUREMAP()\n", data);
1677  }
1678 
1679  return res;
1680 }
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
#define LOG_WARNING
Definition: logger.h:274
#define ast_log
Definition: astobj2.c:42
#define SCOPED_CHANNELLOCK(varname, chan)
scoped lock specialization for channels.
Definition: lock.h:617
ast_mutex_t lock
Definition: app_meetme.c:1091
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
void * data
Definition: datastore.h:70
int ast_get_builtin_feature(struct ast_channel *chan, const char *feature, char *buf, size_t len)
Get the DTMF code for a builtin feature.

◆ internal_featuremap_write()

static int internal_featuremap_write ( struct ast_channel chan,
const char *  cmd,
char *  data,
const char *  value 
)
static

Definition at line 1682 of file features_config.c.

References ao2_cleanup, ast_log, featuremap_set(), get_feature_ds(), lock, LOG_WARNING, NULL, RAII_VAR, and SCOPED_CHANNELLOCK.

Referenced by featuremap_write().

1684 {
1685  int res;
1686  RAII_VAR(struct features_config *, cfg, NULL, ao2_cleanup);
1687  SCOPED_CHANNELLOCK(lock, chan);
1688 
1689  if (!(cfg = get_feature_ds(chan))) {
1690  return -1;
1691  }
1692 
1693  res = featuremap_set(cfg->featuremap, data, value);
1694  if (res) {
1695  ast_log(LOG_WARNING, "Invalid argument '%s' to FEATUREMAP()\n", data);
1696  return -1;
1697  }
1698 
1699  return 0;
1700 }
#define LOG_WARNING
Definition: logger.h:274
#define NULL
Definition: resample.c:96
int value
Definition: syslog.c:37
#define ast_log
Definition: astobj2.c:42
#define SCOPED_CHANNELLOCK(varname, chan)
scoped lock specialization for channels.
Definition: lock.h:617
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:911
ast_mutex_t lock
Definition: app_meetme.c:1091
void * data
Definition: datastore.h:70
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
static struct features_config * get_feature_ds(struct ast_channel *chan)
static int featuremap_set(struct ast_featuremap_config *featuremap, const char *name, const char *value)

◆ load_config()

static int load_config ( void  )
static

Definition at line 1758 of file features_config.c.

References __stringify, ACO_EXACT, aco_info_init(), aco_option_register_custom, aco_option_register_custom_nodoc, ACO_PREFIX, aco_process_config(), ACO_PROCESS_ERROR, aco_set_defaults(), ao2_cleanup, ao2_global_obj_replace_unref, applicationmap_handler(), ast_log, DEFAULT_ATXFER_ABORT, DEFAULT_ATXFER_CALLBACK_RETRIES, DEFAULT_ATXFER_COMPLETE, DEFAULT_ATXFER_DROP_CALL, DEFAULT_ATXFER_LOOP_DELAY, DEFAULT_ATXFER_SWAP, DEFAULT_ATXFER_THREEWAY, DEFAULT_COURTESY_TONE, DEFAULT_FEATURE_DIGIT_TIMEOUT, DEFAULT_FEATUREMAP_ATXFER, DEFAULT_FEATUREMAP_AUTOMIXMON, DEFAULT_FEATUREMAP_AUTOMON, DEFAULT_FEATUREMAP_BLINDXFER, DEFAULT_FEATUREMAP_DISCONNECT, DEFAULT_FEATUREMAP_PARKCALL, DEFAULT_NOANSWER_TIMEOUT_ATTENDED_TRANSFER, DEFAULT_PICKUPEXTEN, DEFAULT_PICKUPFAILSOUND, DEFAULT_PICKUPSOUND, DEFAULT_RECORDING_FAIL_SOUND, DEFAULT_TRANSFER_DIAL_ATTEMPTS, DEFAULT_TRANSFER_DIGIT_TIMEOUT, DEFAULT_TRANSFER_INVALID_SOUND, DEFAULT_TRANSFER_RETRY_SOUND, DEFAULT_XFERFAILSOUND, DEFAULT_XFERSOUND, featuregroup_handler(), featuremap_handler(), features_config_alloc(), general_handler(), globals, LOG_ERROR, LOG_NOTICE, pickup_handler(), RAII_VAR, unsupported_handler(), and xfer_handler().

Referenced by load_features_config().

1759 {
1760  if (aco_info_init(&cfg_info)) {
1761  ast_log(LOG_ERROR, "Unable to initialize configuration info for features\n");
1762  return -1;
1763  }
1764 
1765  aco_option_register_custom(&cfg_info, "featuredigittimeout", ACO_EXACT, global_options,
1767  aco_option_register_custom(&cfg_info, "recordingfailsound", ACO_EXACT, global_options,
1769  aco_option_register_custom(&cfg_info, "courtesytone", ACO_EXACT, global_options,
1771 
1772  aco_option_register_custom(&cfg_info, "transferdigittimeout", ACO_EXACT, global_options,
1774  aco_option_register_custom(&cfg_info, "atxfernoanswertimeout", ACO_EXACT, global_options,
1776  aco_option_register_custom(&cfg_info, "atxferdropcall", ACO_EXACT, global_options,
1777  __stringify(DEFAULT_ATXFER_DROP_CALL), xfer_handler, 0);
1778  aco_option_register_custom(&cfg_info, "atxferloopdelay", ACO_EXACT, global_options,
1779  __stringify(DEFAULT_ATXFER_LOOP_DELAY), xfer_handler, 0);
1780  aco_option_register_custom(&cfg_info, "atxfercallbackretries", ACO_EXACT, global_options,
1781  __stringify(DEFAULT_ATXFER_CALLBACK_RETRIES), xfer_handler, 0);
1782  aco_option_register_custom(&cfg_info, "xfersound", ACO_EXACT, global_options,
1783  DEFAULT_XFERSOUND, xfer_handler, 0);
1784  aco_option_register_custom(&cfg_info, "xferfailsound", ACO_EXACT, global_options,
1785  DEFAULT_XFERFAILSOUND, xfer_handler, 0);
1786  aco_option_register_custom(&cfg_info, "atxferabort", ACO_EXACT, global_options,
1787  DEFAULT_ATXFER_ABORT, xfer_handler, 0);
1788  aco_option_register_custom(&cfg_info, "atxfercomplete", ACO_EXACT, global_options,
1789  DEFAULT_ATXFER_COMPLETE, xfer_handler, 0);
1790  aco_option_register_custom(&cfg_info, "atxferthreeway", ACO_EXACT, global_options,
1791  DEFAULT_ATXFER_THREEWAY, xfer_handler, 0);
1792  aco_option_register_custom(&cfg_info, "atxferswap", ACO_EXACT, global_options,
1793  DEFAULT_ATXFER_SWAP, xfer_handler, 0);
1794  aco_option_register_custom(&cfg_info, "transferdialattempts", ACO_EXACT, global_options,
1795  __stringify(DEFAULT_TRANSFER_DIAL_ATTEMPTS), xfer_handler, 0);
1796  aco_option_register_custom(&cfg_info, "transferretrysound", ACO_EXACT, global_options,
1797  DEFAULT_TRANSFER_RETRY_SOUND, xfer_handler, 0);
1798  aco_option_register_custom(&cfg_info, "transferinvalidsound", ACO_EXACT, global_options,
1799  DEFAULT_TRANSFER_INVALID_SOUND, xfer_handler, 0);
1800 
1801  aco_option_register_custom(&cfg_info, "pickupexten", ACO_EXACT, global_options,
1803  aco_option_register_custom(&cfg_info, "pickupsound", ACO_EXACT, global_options,
1804  DEFAULT_PICKUPSOUND, pickup_handler, 0);
1805  aco_option_register_custom(&cfg_info, "pickupfailsound", ACO_EXACT, global_options,
1806  DEFAULT_PICKUPFAILSOUND, pickup_handler, 0);
1807 
1808  aco_option_register_custom_nodoc(&cfg_info, "context", ACO_EXACT, global_options,
1809  "", unsupported_handler, 0);
1810  aco_option_register_custom_nodoc(&cfg_info, "parkext", ACO_EXACT, global_options,
1811  "", unsupported_handler, 0);
1812  aco_option_register_custom_nodoc(&cfg_info, "parkext_exclusive", ACO_EXACT, global_options,
1813  "", unsupported_handler, 0);
1814  aco_option_register_custom_nodoc(&cfg_info, "parkinghints", ACO_EXACT, global_options,
1815  "", unsupported_handler, 0);
1816  aco_option_register_custom_nodoc(&cfg_info, "parkedmusicclass", ACO_EXACT, global_options,
1817  "", unsupported_handler, 0);
1818  aco_option_register_custom_nodoc(&cfg_info, "parkingtime", ACO_EXACT, global_options,
1819  "", unsupported_handler, 0);
1820  aco_option_register_custom_nodoc(&cfg_info, "parkpos", ACO_EXACT, global_options,
1821  "", unsupported_handler, 0);
1822  aco_option_register_custom_nodoc(&cfg_info, "findslot", ACO_EXACT, global_options,
1823  "", unsupported_handler, 0);
1824  aco_option_register_custom_nodoc(&cfg_info, "parkedcalltransfers", ACO_EXACT, global_options,
1825  "", unsupported_handler, 0);
1826  aco_option_register_custom_nodoc(&cfg_info, "parkedcallreparking", ACO_EXACT, global_options,
1827  "", unsupported_handler, 0);
1828  aco_option_register_custom_nodoc(&cfg_info, "parkedcallhangup", ACO_EXACT, global_options,
1829  "", unsupported_handler, 0);
1830  aco_option_register_custom_nodoc(&cfg_info, "parkedcallrecording", ACO_EXACT, global_options,
1831  "", unsupported_handler, 0);
1832  aco_option_register_custom_nodoc(&cfg_info, "comebackcontext", ACO_EXACT, global_options,
1833  "", unsupported_handler, 0);
1834  aco_option_register_custom_nodoc(&cfg_info, "comebacktoorigin", ACO_EXACT, global_options,
1835  "", unsupported_handler, 0);
1836  aco_option_register_custom_nodoc(&cfg_info, "comebackdialtime", ACO_EXACT, global_options,
1837  "", unsupported_handler, 0);
1838  aco_option_register_custom_nodoc(&cfg_info, "parkeddynamic", ACO_EXACT, global_options,
1839  "", unsupported_handler, 0);
1840  aco_option_register_custom_nodoc(&cfg_info, "adsipark", ACO_EXACT, global_options,
1841  "", unsupported_handler, 0);
1842 
1843  aco_option_register_custom(&cfg_info, "blindxfer", ACO_EXACT, featuremap_options,
1845  aco_option_register_custom(&cfg_info, "disconnect", ACO_EXACT, featuremap_options,
1846  DEFAULT_FEATUREMAP_DISCONNECT, featuremap_handler, 0);
1847  aco_option_register_custom(&cfg_info, "automon", ACO_EXACT, featuremap_options,
1848  DEFAULT_FEATUREMAP_AUTOMON, featuremap_handler, 0);
1849  aco_option_register_custom(&cfg_info, "atxfer", ACO_EXACT, featuremap_options,
1850  DEFAULT_FEATUREMAP_ATXFER, featuremap_handler, 0);
1851  aco_option_register_custom(&cfg_info, "parkcall", ACO_EXACT, featuremap_options,
1852  DEFAULT_FEATUREMAP_PARKCALL, featuremap_handler, 0);
1853  aco_option_register_custom(&cfg_info, "automixmon", ACO_EXACT, featuremap_options,
1854  DEFAULT_FEATUREMAP_AUTOMIXMON, featuremap_handler, 0);
1855 
1857  "", applicationmap_handler, 0);
1858 
1859  aco_option_register_custom(&cfg_info, "", ACO_PREFIX, featuregroup_options,
1860  "", featuregroup_handler, 0);
1861 
1862  aco_option_register_custom_nodoc(&cfg_info, "", ACO_PREFIX, parkinglot_options,
1863  "", unsupported_handler, 0);
1864 
1865  if (aco_process_config(&cfg_info, 0) == ACO_PROCESS_ERROR) {
1866  RAII_VAR(struct features_config *, features_cfg, features_config_alloc(), ao2_cleanup);
1867 
1868  if (aco_set_defaults(&global_option, "general", features_cfg->global) ||
1869  aco_set_defaults(&featuremap_option, "featuremap", features_cfg->featuremap)) {
1870  ast_log(LOG_ERROR, "Failed to load features.conf and failed to initialize defaults.\n");
1871  return -1;
1872  }
1873 
1874  ast_log(LOG_NOTICE, "Could not load features config; using defaults\n");
1875  ao2_global_obj_replace_unref(globals, features_cfg);
1876  }
1877 
1878  return 0;
1879 }
#define DEFAULT_XFERFAILSOUND
#define DEFAULT_FEATUREMAP_BLINDXFER
#define DEFAULT_ATXFER_CALLBACK_RETRIES
static struct aco_type global_option
static int pickup_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
static struct aco_type * applicationmap_options[]
static struct aco_type featuremap_option
#define DEFAULT_ATXFER_LOOP_DELAY
#define aco_option_register_custom(info, name, matchtype, types, default_val, handler, flags)
Register a config option.
#define DEFAULT_FEATUREMAP_ATXFER
#define DEFAULT_ATXFER_COMPLETE
if(!yyg->yy_init)
Definition: ast_expr2f.c:868
enum aco_process_status aco_process_config(struct aco_info *info, int reload)
Process a config info via the options registered with an aco_info.
#define DEFAULT_FEATUREMAP_DISCONNECT
#define DEFAULT_RECORDING_FAIL_SOUND
#define DEFAULT_PICKUPEXTEN
static int general_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
static int unsupported_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
#define ast_log
Definition: astobj2.c:42
#define __stringify(x)
Definition: asterisk.h:214
#define DEFAULT_ATXFER_DROP_CALL
static int xfer_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
#define DEFAULT_TRANSFER_INVALID_SOUND
int aco_info_init(struct aco_info *info)
Initialize an aco_info structure.
static struct aco_type * featuremap_options[]
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:911
static int applicationmap_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
#define DEFAULT_FEATUREMAP_AUTOMIXMON
static struct console_pvt globals
Their was an error and no changes were applied.
#define DEFAULT_FEATUREMAP_PARKCALL
#define LOG_ERROR
Definition: logger.h:285
#define LOG_NOTICE
Definition: logger.h:263
static struct aco_type * featuregroup_options[]
#define DEFAULT_NOANSWER_TIMEOUT_ATTENDED_TRANSFER
static int featuregroup_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
int aco_set_defaults(struct aco_type *type, const char *category, void *obj)
Set all default options of obj.
static struct aco_type * parkinglot_options[]
#define DEFAULT_TRANSFER_DIAL_ATTEMPTS
#define DEFAULT_ATXFER_ABORT
#define DEFAULT_XFERSOUND
#define ao2_global_obj_replace_unref(holder, obj)
Definition: astobj2.h:908
#define DEFAULT_FEATURE_DIGIT_TIMEOUT
#define DEFAULT_COURTESY_TONE
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
#define DEFAULT_TRANSFER_DIGIT_TIMEOUT
#define DEFAULT_PICKUPFAILSOUND
static struct aco_type * global_options[]
static void * features_config_alloc(void)
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:116
#define DEFAULT_FEATUREMAP_AUTOMON
#define DEFAULT_PICKUPSOUND
#define DEFAULT_ATXFER_THREEWAY
#define DEFAULT_ATXFER_SWAP
#define DEFAULT_TRANSFER_RETRY_SOUND
#define aco_option_register_custom_nodoc(info, name, matchtype, types, default_val, handler, flags)
Register a config option with no expected documentation.
static int featuremap_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)

◆ load_features_config()

int load_features_config ( void  )

Definition at line 1996 of file features_config.c.

References __ast_custom_function_register(), ARRAY_LEN, ast_cli_register_multiple, load_config(), and NULL.

Referenced by load_module().

1997 {
1998  int res;
1999 
2000  res = load_config();
2004 
2005  return res;
2006 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
#define NULL
Definition: resample.c:96
static struct ast_cli_entry cli_features_config[]
static int load_config(void)
static struct ast_custom_function feature_function
static struct ast_custom_function featuremap_function
int __ast_custom_function_register(struct ast_custom_function *acf, struct ast_module *mod)
Register a custom function.

◆ pickup_copy()

static void pickup_copy ( struct ast_features_pickup_config dest,
const struct ast_features_pickup_config src 
)
static

Definition at line 796 of file features_config.c.

References ast_string_fields_copy.

Referenced by global_copy().

797 {
798  ast_string_fields_copy(dest, src);
799 }
#define ast_string_fields_copy(copy, orig)
Copy all string fields from one instance to another of the same structure.
Definition: stringfields.h:627

◆ pickup_destructor()

static void pickup_destructor ( void *  obj)
static

Definition at line 677 of file features_config.c.

References ast_string_field_free_memory.

Referenced by global_config_alloc().

678 {
679  struct ast_features_pickup_config *cfg = obj;
680 
682 }
#define ast_string_field_free_memory(x)
free all memory - to be called before destroying the object
Definition: stringfields.h:368
Configuration relating to call pickup.

◆ pickup_get()

static int pickup_get ( struct ast_features_pickup_config pickup,
const char *  field,
char *  buf,
size_t  len 
)
static

Definition at line 977 of file features_config.c.

References ast_copy_string(), ast_features_pickup_config::pickupexten, ast_features_pickup_config::pickupfailsound, and ast_features_pickup_config::pickupsound.

Referenced by internal_feature_read().

979 {
980  int res = 0;
981 
982  if (!strcasecmp(field, "pickupsound")) {
983  ast_copy_string(buf, pickup->pickupsound, len);
984  } else if (!strcasecmp(field, "pickupfailsound")) {
986  } else if (!strcasecmp(field, "pickupexten")) {
987  ast_copy_string(buf, pickup->pickupexten, len);
988  } else {
989  /* Unrecognized option */
990  res = -1;
991  }
992 
993  return res;
994 }
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401

◆ pickup_handler()

static int pickup_handler ( const struct aco_option opt,
struct ast_variable var,
void *  obj 
)
static

Definition at line 1519 of file features_config.c.

References global, ast_variable::name, features_global_config::pickup, pickup_set(), and ast_variable::value.

Referenced by load_config().

1521 {
1522  struct features_global_config *global = obj;
1523  struct ast_features_pickup_config *pickup = global->pickup;
1524 
1525  return pickup_set(pickup, var->name, var->value);
1526 }
static struct aco_type global
Definition: test_config.c:1445
Configuration from the "general" section of features.conf.
struct ast_features_pickup_config * pickup
static int pickup_set(struct ast_features_pickup_config *pickup, const char *name, const char *value)
Configuration relating to call pickup.

◆ pickup_set()

static int pickup_set ( struct ast_features_pickup_config pickup,
const char *  name,
const char *  value 
)
static

Definition at line 958 of file features_config.c.

References ast_string_field_set.

Referenced by internal_feature_write(), and pickup_handler().

960 {
961  int res = 0;
962 
963  if (!strcasecmp(name, "pickupsound")) {
965  } else if (!strcasecmp(name, "pickupfailsound")) {
967  } else if (!strcasecmp(name, "pickupexten")) {
969  } else {
970  /* Unrecognized option */
971  res = -1;
972  }
973 
974  return res;
975 }
int value
Definition: syslog.c:37
static const char name[]
Definition: cdr_mysql.c:74
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
Definition: stringfields.h:514

◆ print_applicationmap()

static int print_applicationmap ( void *  obj,
void *  arg,
int  flags 
)
static

Definition at line 1905 of file features_config.c.

References a, ast_cli(), ast_applicationmap_item::dtmf, ast_cli_args::fd, HFS_FORMAT, item, and ast_applicationmap_item::name.

Referenced by handle_feature_show().

1906 {
1907  struct ast_applicationmap_item *item = obj;
1908  struct ast_cli_args *a = arg;
1909 
1910  ast_cli(a->fd, HFS_FORMAT, item->name, "no def", item->dtmf);
1911  return 0;
1912 }
An applicationmap configuration item.
static struct aco_type item
Definition: test_config.c:1463
void ast_cli(int fd, const char *fmt,...)
Definition: clicompat.c:6
const int fd
Definition: cli.h:159
#define HFS_FORMAT
static struct test_val a

◆ print_featuregroup()

static int print_featuregroup ( void *  obj,
void *  arg,
int  flags 
)
static

Definition at line 1881 of file features_config.c.

References a, featuregroup_item::appmap_item, featuregroup_item::appmap_item_name, ast_cli(), ast_applicationmap_item::dtmf, featuregroup_item::dtmf_override, ast_cli_args::fd, item, and S_OR.

Referenced by print_featuregroups().

1882 {
1883  struct featuregroup_item *item = obj;
1884  struct ast_cli_args *a = arg;
1885 
1886  ast_cli(a->fd, "===> --> %s (%s)\n", item->appmap_item_name,
1887  S_OR(item->dtmf_override, item->appmap_item->dtmf));
1888 
1889  return 0;
1890 }
const ast_string_field appmap_item_name
static struct aco_type item
Definition: test_config.c:1463
void ast_cli(int fd, const char *fmt,...)
Definition: clicompat.c:6
struct ast_applicationmap_item * appmap_item
const int fd
Definition: cli.h:159
const ast_string_field dtmf_override
Entry in the container of featuregroups.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
Definition: strings.h:79
static struct test_val a

◆ print_featuregroups()

static int print_featuregroups ( void *  obj,
void *  arg,
int  flags 
)
static

Definition at line 1892 of file features_config.c.

References a, ao2_callback, ast_cli(), ast_cli_args::fd, featuregroup::items, featuregroup::name, and print_featuregroup().

Referenced by handle_feature_show().

1893 {
1894  struct featuregroup *group = obj;
1895  struct ast_cli_args *a = arg;
1896 
1897  ast_cli(a->fd, "===> Group: %s\n", group->name);
1898 
1899  ao2_callback(group->items, 0, print_featuregroup, a);
1900  return 0;
1901 }
Featuregroup representation.
#define ao2_callback(c, flags, cb_fn, arg)
Definition: astobj2.h:1716
void ast_cli(int fd, const char *fmt,...)
Definition: clicompat.c:6
struct ao2_container * items
const char * name
const int fd
Definition: cli.h:159
static int print_featuregroup(void *obj, void *arg, int flags)
static struct test_val a

◆ reload_features_config()

int reload_features_config ( void  )

Definition at line 1985 of file features_config.c.

References aco_process_config(), ACO_PROCESS_ERROR, and parking_warning.

Referenced by load_module().

1986 {
1987  /* Rearm the parking config options have moved warning. */
1988  parking_warning = 0;
1989 
1990  if (aco_process_config(&cfg_info, 1) == ACO_PROCESS_ERROR) {
1991  return -1;
1992  }
1993  return 0;
1994 }
enum aco_process_status aco_process_config(struct aco_info *info, int reload)
Process a config info via the options registered with an aco_info.
Their was an error and no changes were applied.
static int parking_warning

◆ unload_features_config()

void unload_features_config ( void  )

Definition at line 1976 of file features_config.c.

References aco_info_destroy(), ao2_global_obj_release, ARRAY_LEN, ast_cli_unregister_multiple(), ast_custom_function_unregister(), and globals.

Referenced by unload_module().

1977 {
1981  aco_info_destroy(&cfg_info);
1983 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
Definition: clicompat.c:30
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
static struct console_pvt globals
static struct ast_cli_entry cli_features_config[]
void aco_info_destroy(struct aco_info *info)
Destroy an initialized aco_info struct.
#define ao2_global_obj_release(holder)
Definition: astobj2.h:865
static struct ast_custom_function feature_function
static struct ast_custom_function featuremap_function

◆ unsupported_handler()

static int unsupported_handler ( const struct aco_option opt,
struct ast_variable var,
void *  obj 
)
static

Definition at line 1529 of file features_config.c.

References ast_log, LOG_WARNING, ast_variable::name, and parking_warning.

Referenced by load_config().

1531 {
1532  if (!parking_warning) {
1533  ast_log(LOG_WARNING, "Parkinglots are no longer configurable in features.conf; "
1534  "parking is now handled by res_parking.conf\n");
1535  parking_warning = 1;
1536  }
1537  ast_log(LOG_WARNING, "The option '%s' is no longer configurable in features.conf.\n", var->name);
1538  return 0;
1539 }
#define LOG_WARNING
Definition: logger.h:274
#define ast_log
Definition: astobj2.c:42
static int parking_warning

◆ xfer_copy()

static void xfer_copy ( struct ast_features_xfer_config dest,
const struct ast_features_xfer_config src 
)
static

Definition at line 785 of file features_config.c.

References ast_string_fields_copy, ast_features_xfer_config::atxfercallbackretries, ast_features_xfer_config::atxferdropcall, ast_features_xfer_config::atxferloopdelay, ast_features_xfer_config::atxfernoanswertimeout, ast_features_xfer_config::transferdialattempts, and ast_features_xfer_config::transferdigittimeout.

Referenced by global_copy().

786 {
787  ast_string_fields_copy(dest, src);
790  dest->atxferloopdelay = src->atxferloopdelay;
792  dest->atxferdropcall = src->atxferdropcall;
794 }
#define ast_string_fields_copy(copy, orig)
Copy all string fields from one instance to another of the same structure.
Definition: stringfields.h:627

◆ xfer_destructor()

static void xfer_destructor ( void *  obj)
static

Definition at line 670 of file features_config.c.

References ast_string_field_free_memory.

Referenced by global_config_alloc().

671 {
672  struct ast_features_xfer_config *cfg = obj;
673 
675 }
Feature configuration relating to transfers.
#define ast_string_field_free_memory(x)
free all memory - to be called before destroying the object
Definition: stringfields.h:368

◆ xfer_get()

static int xfer_get ( struct ast_features_xfer_config xfer,
const char *  field,
char *  buf,
size_t  len 
)
static

Definition at line 917 of file features_config.c.

References ast_copy_string(), ast_features_xfer_config::atxferabort, ast_features_xfer_config::atxfercallbackretries, ast_features_xfer_config::atxfercomplete, ast_features_xfer_config::atxferdropcall, ast_features_xfer_config::atxferloopdelay, ast_features_xfer_config::atxfernoanswertimeout, ast_features_xfer_config::atxferswap, ast_features_xfer_config::atxferthreeway, ast_features_xfer_config::transferdialattempts, ast_features_xfer_config::transferdigittimeout, ast_features_xfer_config::transferinvalidsound, ast_features_xfer_config::transferretrysound, ast_features_xfer_config::xferfailsound, and ast_features_xfer_config::xfersound.

Referenced by internal_feature_read().

919 {
920  int res = 0;
921 
922  if (!strcasecmp(field, "transferdigittimeout")) {
923  snprintf(buf, len, "%u", xfer->transferdigittimeout);
924  } else if (!strcasecmp(field, "atxfernoanswertimeout")) {
925  snprintf(buf, len, "%u", xfer->atxfernoanswertimeout);
926  } else if (!strcasecmp(field, "atxferloopdelay")) {
927  snprintf(buf, len, "%u", xfer->atxferloopdelay);
928  } else if (!strcasecmp(field, "atxfercallbackretries")) {
929  snprintf(buf, len, "%u", xfer->atxfercallbackretries);
930  } else if (!strcasecmp(field, "atxferdropcall")) {
931  snprintf(buf, len, "%u", xfer->atxferdropcall);
932  } else if (!strcasecmp(field, "xfersound")) {
933  ast_copy_string(buf, xfer->xfersound, len);
934  } else if (!strcasecmp(field, "xferfailsound")) {
936  } else if (!strcasecmp(field, "atxferabort")) {
938  } else if (!strcasecmp(field, "atxfercomplete")) {
940  } else if (!strcasecmp(field, "atxferthreeway")) {
942  } else if (!strcasecmp(field, "atxferswap")) {
944  } else if (!strcasecmp(field, "transferdialattempts")) {
945  snprintf(buf, len, "%u", xfer->transferdialattempts);
946  } else if (!strcasecmp(field, "transferretrysound")) {
948  } else if (!strcasecmp(field, "transferinvalidsound")) {
950  } else {
951  /* Unrecognized option */
952  res = -1;
953  }
954 
955  return res;
956 }
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401

◆ xfer_handler()

static int xfer_handler ( const struct aco_option opt,
struct ast_variable var,
void *  obj 
)
static

Definition at line 1510 of file features_config.c.

References global, ast_variable::name, ast_variable::value, features_global_config::xfer, and xfer_set().

Referenced by load_config().

1512 {
1513  struct features_global_config *global = obj;
1514  struct ast_features_xfer_config *xfer = global->xfer;
1515 
1516  return xfer_set(xfer, var->name, var->value);
1517 }
Feature configuration relating to transfers.
static struct aco_type global
Definition: test_config.c:1445
struct ast_features_xfer_config * xfer
Configuration from the "general" section of features.conf.
static int xfer_set(struct ast_features_xfer_config *xfer, const char *name, const char *value)

◆ xfer_set()

static int xfer_set ( struct ast_features_xfer_config xfer,
const char *  name,
const char *  value 
)
static

Definition at line 876 of file features_config.c.

References ast_parse_arg(), ast_string_field_set, ast_true(), ast_features_xfer_config::atxfercallbackretries, ast_features_xfer_config::atxferdropcall, ast_features_xfer_config::atxferloopdelay, ast_features_xfer_config::atxfernoanswertimeout, PARSE_INT32, ast_features_xfer_config::transferdialattempts, and ast_features_xfer_config::transferdigittimeout.

Referenced by internal_feature_write(), and xfer_handler().

878 {
879  int res = 0;
880 
881  if (!strcasecmp(name, "transferdigittimeout")) {
883  } else if (!strcasecmp(name, "atxfernoanswertimeout")) {
885  } else if (!strcasecmp(name, "atxferloopdelay")) {
887  } else if (!strcasecmp(name, "atxfercallbackretries")) {
889  } else if (!strcasecmp(name, "atxferdropcall")) {
890  xfer->atxferdropcall = ast_true(value);
891  } else if (!strcasecmp(name, "xfersound")) {
893  } else if (!strcasecmp(name, "xferfailsound")) {
895  } else if (!strcasecmp(name, "atxferabort")) {
897  } else if (!strcasecmp(name, "atxfercomplete")) {
899  } else if (!strcasecmp(name, "atxferthreeway")) {
901  } else if (!strcasecmp(name, "atxferswap")) {
903  } else if (!strcasecmp(name, "transferdialattempts")) {
905  } else if (!strcasecmp(name, "transferretrysound")) {
907  } else if (!strcasecmp(name, "transferinvalidsound")) {
909  } else {
910  /* Unrecognized option */
911  res = -1;
912  }
913 
914  return res;
915 }
int value
Definition: syslog.c:37
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
static const char name[]
Definition: cdr_mysql.c:74
int ast_parse_arg(const char *arg, enum ast_parse_flags flags, void *result,...)
The argument parsing routine.
Definition: main/config.c:3657
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
Definition: stringfields.h:514

Variable Documentation

◆ applicationmap_option

struct aco_type applicationmap_option
static

Definition at line 596 of file features_config.c.

◆ applicationmap_options

struct aco_type* applicationmap_options[] = ACO_TYPES(&applicationmap_option)
static

Definition at line 625 of file features_config.c.

◆ cli_features_config

struct ast_cli_entry cli_features_config[]
static
Initial value:
= {
{ .handler = handle_feature_show , .summary = "Lists configured features" ,},
}
static char * handle_feature_show(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
CLI command to list configured features.

Definition at line 1972 of file features_config.c.

◆ feature_ds_info

const struct ast_datastore_info feature_ds_info
static
Initial value:
= {
.type = "FEATURE",
.destroy = feature_ds_destroy,
.duplicate = feature_ds_duplicate,
}
static void * feature_ds_duplicate(void *data)
static void feature_ds_destroy(void *data)

Definition at line 1059 of file features_config.c.

◆ feature_function

struct ast_custom_function feature_function
static
Initial value:
= {
.name = "FEATURE",
.read = feature_read,
.write = feature_write
}
static int feature_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
static int feature_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)

Definition at line 1746 of file features_config.c.

◆ featuregroup_option

struct aco_type featuregroup_option
static

Definition at line 604 of file features_config.c.

◆ featuregroup_options

struct aco_type* featuregroup_options[] = ACO_TYPES(&featuregroup_option)
static

Definition at line 626 of file features_config.c.

◆ featuremap_function

struct ast_custom_function featuremap_function
static
Initial value:
= {
.name = "FEATUREMAP",
.read = featuremap_read,
}
static int featuremap_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
static int featuremap_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)

Definition at line 1752 of file features_config.c.

◆ featuremap_option

struct aco_type featuremap_option
static

Definition at line 588 of file features_config.c.

◆ featuremap_options

struct aco_type* featuremap_options[] = ACO_TYPES(&featuremap_option)
static

Definition at line 624 of file features_config.c.

◆ features_conf

struct aco_file features_conf
static
Initial value:
= {
.filename = "features.conf",
}
static struct aco_type featuregroup_option
static struct aco_type global_option
static struct aco_type featuremap_option
static struct aco_type applicationmap_option
#define ACO_TYPES(...)
A helper macro to ensure that aco_info types always have a sentinel.
static struct aco_type parkinglot_option

Definition at line 629 of file features_config.c.

◆ global_option

struct aco_type global_option
static

Definition at line 580 of file features_config.c.

◆ global_options

struct aco_type* global_options[] = ACO_TYPES(&global_option)
static

Definition at line 623 of file features_config.c.

◆ parking_warning

int parking_warning = 0
static

Definition at line 1528 of file features_config.c.

Referenced by reload_features_config(), and unsupported_handler().

◆ parkinglot_option

struct aco_type parkinglot_option
static

Definition at line 614 of file features_config.c.

◆ parkinglot_options

struct aco_type* parkinglot_options[] = ACO_TYPES(&parkinglot_option)
static

Definition at line 627 of file features_config.c.