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 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...

Defines

#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_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 int applicationmap_sort (const void *obj, const void *arg, int flags)
static void ast_applicationmap_item_destructor (void *obj)
int ast_features_config_init (void)
int ast_features_config_reload (void)
void ast_features_config_shutdown (void)
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.
struct ao2_containerast_get_chan_applicationmap (struct ast_channel *chan)
 Get the applicationmap for a given channel.
struct ast_featuremap_configast_get_chan_featuremap_config (struct ast_channel *chan)
 Get the featuremap configuration options for a channel.
struct
ast_features_general_config
ast_get_chan_features_general_config (struct ast_channel *chan)
 Get the general configuration options for a channel.
struct ast_features_pickup_configast_get_chan_features_pickup_config (struct ast_channel *chan)
 Get the pickup configuration options for a channel.
struct ast_features_xfer_configast_get_chan_features_xfer_config (struct ast_channel *chan)
 Get the transfer configuration options for a channel.
int ast_get_feature (struct ast_channel *chan, const char *feature, char *buf, size_t len)
 Get the DTMF code for a call feature.
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_config
global_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.
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)
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)
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 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)


Define Documentation

#define DEFAULT_ATXFER_ABORT   "*1"

Definition at line 377 of file features_config.c.

Referenced by load_config().

#define DEFAULT_ATXFER_CALLBACK_RETRIES   2

Definition at line 374 of file features_config.c.

Referenced by load_config().

#define DEFAULT_ATXFER_COMPLETE   "*2"

Definition at line 378 of file features_config.c.

Referenced by load_config().

#define DEFAULT_ATXFER_DROP_CALL   0

Definition at line 372 of file features_config.c.

Referenced by load_config().

#define DEFAULT_ATXFER_LOOP_DELAY   10

Definition at line 373 of file features_config.c.

Referenced by load_config().

#define DEFAULT_ATXFER_SWAP   "*4"

Definition at line 380 of file features_config.c.

Referenced by load_config().

#define DEFAULT_ATXFER_THREEWAY   "*3"

Definition at line 379 of file features_config.c.

Referenced by load_config().

#define DEFAULT_COURTESY_TONE   ""

Definition at line 366 of file features_config.c.

Referenced by load_config().

#define DEFAULT_FEATURE_DIGIT_TIMEOUT   1000

Default general options

Definition at line 365 of file features_config.c.

Referenced by load_config().

#define DEFAULT_FEATUREMAP_ATXFER   ""

Definition at line 394 of file features_config.c.

Referenced by handle_feature_show(), and load_config().

#define DEFAULT_FEATUREMAP_AUTOMIXMON   ""

Definition at line 396 of file features_config.c.

Referenced by handle_feature_show(), and load_config().

#define DEFAULT_FEATUREMAP_AUTOMON   ""

Definition at line 393 of file features_config.c.

Referenced by handle_feature_show(), and load_config().

#define DEFAULT_FEATUREMAP_BLINDXFER   "#"

Default featuremap options

Definition at line 391 of file features_config.c.

Referenced by handle_feature_show(), and load_config().

#define DEFAULT_FEATUREMAP_DISCONNECT   "*"

Definition at line 392 of file features_config.c.

Referenced by handle_feature_show(), and load_config().

#define DEFAULT_FEATUREMAP_PARKCALL   ""

Definition at line 395 of file features_config.c.

Referenced by handle_feature_show(), and load_config().

#define DEFAULT_NOANSWER_TIMEOUT_ATTENDED_TRANSFER   15

Definition at line 371 of file features_config.c.

Referenced by load_config().

#define DEFAULT_PICKUPEXTEN   "*8"

Default pickup options

Definition at line 386 of file features_config.c.

Referenced by handle_feature_show(), and load_config().

#define DEFAULT_PICKUPFAILSOUND   ""

Definition at line 388 of file features_config.c.

Referenced by load_config().

#define DEFAULT_PICKUPSOUND   ""

Definition at line 387 of file features_config.c.

Referenced by load_config().

#define DEFAULT_RECORDING_FAIL_SOUND   ""

Definition at line 367 of file features_config.c.

Referenced by load_config().

#define DEFAULT_TRANSFER_DIAL_ATTEMPTS   3

Definition at line 381 of file features_config.c.

Referenced by load_config().

#define DEFAULT_TRANSFER_DIGIT_TIMEOUT   3

Default xfer options

Definition at line 370 of file features_config.c.

Referenced by load_config().

#define DEFAULT_TRANSFER_INVALID_SOUND   "privacy-incorrect"

Definition at line 383 of file features_config.c.

Referenced by load_config().

#define DEFAULT_TRANSFER_RETRY_SOUND   "pbx-invalid"

Definition at line 382 of file features_config.c.

Referenced by load_config().

#define DEFAULT_XFERFAILSOUND   "beeperr"

Definition at line 376 of file features_config.c.

Referenced by load_config().

#define DEFAULT_XFERSOUND   "beep"

Definition at line 375 of file features_config.c.

Referenced by load_config().

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

Definition at line 1871 of file features_config.c.

Referenced by handle_feature_show(), and print_applicationmap().


Function Documentation

static struct features_config* __features_config_alloc ( int  allocate_applicationmap  )  [static, read]

Definition at line 730 of file features_config.c.

References ao2_alloc, AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_cleanup, ao2_container_alloc_options, 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().

00731 {
00732    RAII_VAR(struct features_config *, cfg, NULL, ao2_cleanup);
00733 
00734    cfg = ao2_alloc(sizeof(*cfg), features_config_destructor);
00735    if (!cfg) {
00736       return NULL;
00737    }
00738 
00739    cfg->global = global_config_alloc();
00740    if (!cfg->global) {
00741       return NULL;
00742    }
00743 
00744    cfg->featuremap = ao2_alloc(sizeof(*cfg->featuremap), featuremap_config_destructor);
00745    if (!cfg->featuremap || ast_string_field_init(cfg->featuremap, 32)) {
00746       return NULL;
00747    }
00748 
00749    cfg->parkinglots = ao2_alloc(sizeof(*cfg->parkinglots), NULL);
00750    if (!cfg->parkinglots) {
00751       return NULL;
00752    }
00753 
00754    if (allocate_applicationmap) {
00755       cfg->applicationmap = applicationmap_alloc(1);
00756       if (!cfg->applicationmap) {
00757          return NULL;
00758       }
00759 
00760       cfg->featuregroups = ao2_container_alloc_options(AO2_ALLOC_OPT_LOCK_NOLOCK, 11, featuregroup_hash,
00761          featuregroup_cmp);
00762       if (!cfg->featuregroups) {
00763          return NULL;
00764       }
00765    }
00766 
00767    ao2_ref(cfg, +1);
00768    return cfg;
00769 
00770 }

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

Definition at line 1264 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().

01265 {
01266    struct featuregroup_item *fg_item = obj;
01267    struct ao2_container *applicationmap = arg;
01268    RAII_VAR(struct ast_applicationmap_item *, appmap_item, NULL, ao2_cleanup);
01269 
01270    /* If there's no DTMF override, then we can just link
01271     * the applicationmap item directly. Otherwise, we need
01272     * to create a copy with the DTMF override in place and
01273     * link that instead
01274     */
01275    if (ast_strlen_zero(fg_item->dtmf_override)) {
01276       ao2_ref(fg_item->appmap_item, +1);
01277       appmap_item = fg_item->appmap_item;
01278    } else {
01279       appmap_item = applicationmap_item_alloc(fg_item->appmap_item_name,
01280             fg_item->appmap_item->app, fg_item->appmap_item->app_data,
01281             fg_item->appmap_item->moh_class, fg_item->dtmf_override,
01282             fg_item->appmap_item->activate_on_self);
01283    }
01284 
01285    if (!appmap_item) {
01286       return 0;
01287    }
01288 
01289    ao2_link(applicationmap, appmap_item);
01290    return 0;
01291 }

AO2_GLOBAL_OBJ_STATIC ( globals   ) 

static struct ao2_container* applicationmap_alloc ( int  replace_duplicates  )  [static, read]

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

Definition at line 1350 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().

01352 {
01353    RAII_VAR(struct ast_applicationmap_item *, item, NULL, ao2_cleanup);
01354    struct ao2_container *applicationmap = obj;
01355    AST_DECLARE_APP_ARGS(args,
01356       AST_APP_ARG(dtmf);
01357       AST_APP_ARG(activate_on);
01358       AST_APP_ARG(app);
01359       AST_APP_ARG(app_data);
01360       AST_APP_ARG(moh_class);
01361    );
01362    char *parse = ast_strdupa(var->value);
01363    char *slash;
01364    char *paren;
01365    unsigned int activate_on_self;
01366 
01367    AST_STANDARD_APP_ARGS(args, parse);
01368 
01369    if (ast_strlen_zero(args.dtmf) ||
01370          ast_strlen_zero(args.activate_on) ||
01371          ast_strlen_zero(args.app)) {
01372       ast_log(LOG_WARNING, "Invalid applicationmap syntax for '%s'. Missing required argument\n", var->name);
01373       return -1;
01374    }
01375 
01376    /* features.conf used to have an "activated_by" portion
01377     * in addition to activate_on. Get rid of whatever may be
01378     * there
01379     */
01380    slash = strchr(args.activate_on, '/');
01381    if (slash) {
01382       *slash = '\0';
01383    }
01384 
01385    /* Some applications do not require arguments. */
01386    if (!args.app_data) {
01387       args.app_data = "";
01388    }
01389 
01390    /* Two syntaxes allowed for applicationmap:
01391     * Old: foo = *1,self,NoOp,Boo!,default
01392     * New: foo = *1,self,NoOp(Boo!),default
01393     *
01394     * We need to handle both
01395     */
01396    paren = strchr(args.app, '(');
01397    if (paren) {
01398       /* New syntax */
01399       char *close_paren;
01400 
01401       args.moh_class = args.app_data;
01402       *paren++ = '\0';
01403       close_paren = strrchr(paren, ')');
01404       if (close_paren) {
01405          *close_paren = '\0';
01406       }
01407       args.app_data = paren;
01408 
01409       /* Re-check that the application is not empty */
01410       if (ast_strlen_zero(args.app)) {
01411          ast_log(LOG_WARNING, "Applicationmap item '%s' does not contain an application name.\n", var->name);
01412          return -1;
01413       }
01414    } else if (strchr(args.app_data, '"')) {
01415       args.app_data = ast_strip_quoted(args.app_data, "\"", "\"");
01416    }
01417 
01418    /* Allow caller and callee to be specified for backwards compatibility */
01419    if (!strcasecmp(args.activate_on, "self") || !strcasecmp(args.activate_on, "caller")) {
01420       activate_on_self = 1;
01421    } else if (!strcasecmp(args.activate_on, "peer") || !strcasecmp(args.activate_on, "callee")) {
01422       activate_on_self = 0;
01423    } else {
01424       ast_log(LOG_WARNING, "Invalid 'activate_on' value %s for applicationmap item %s\n",
01425          args.activate_on, var->name);
01426       return -1;
01427    }
01428 
01429    ast_debug(1, "Allocating applicationmap item: dtmf = %s, app = %s, app_data = %s, moh_class = %s\n",
01430          args.dtmf, args.app, args.app_data, args.moh_class);
01431 
01432    item = applicationmap_item_alloc(var->name, args.app, args.app_data,
01433          args.moh_class, args.dtmf, activate_on_self);
01434 
01435    if (!item) {
01436       return -1;
01437    }
01438 
01439    if (!ao2_link(applicationmap, item)) {
01440       return -1;
01441    }
01442 
01443    return 0;
01444 }

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, read]

Definition at line 1242 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().

01245 {
01246    struct ast_applicationmap_item *item;
01247 
01248    item = ao2_alloc(sizeof(*item), ast_applicationmap_item_destructor);
01249 
01250    if (!item || ast_string_field_init(item, 64)) {
01251       return NULL;
01252    }
01253 
01254    ast_string_field_set(item, name, name);
01255    ast_string_field_set(item, app, app);
01256    ast_string_field_set(item, app_data, app_data);
01257    ast_string_field_set(item, moh_class, moh_class);
01258    ast_copy_string(item->dtmf, dtmf, sizeof(item->dtmf));
01259    item->activate_on_self = activate_on_self;
01260 
01261    return item;
01262 }

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

Definition at line 414 of file features_config.c.

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

Referenced by applicationmap_alloc().

00415 {
00416    const struct ast_applicationmap_item *item1 = obj;
00417    const struct ast_applicationmap_item *item2;
00418    const char *key2;
00419 
00420    switch(flags & (OBJ_POINTER | OBJ_KEY | OBJ_PARTIAL_KEY)) {
00421    case OBJ_KEY:
00422       key2 = arg;
00423       return strcasecmp(item1->name, key2);
00424    case OBJ_PARTIAL_KEY:
00425       key2 = arg;
00426       return strncasecmp(item1->name, key2, strlen(key2));
00427    default:
00428    case OBJ_POINTER:
00429       item2 = arg;
00430       return strcasecmp(item1->name, item2->name);
00431    }
00432 }

static void ast_applicationmap_item_destructor ( void *  obj  )  [static]

Definition at line 407 of file features_config.c.

References ast_string_field_free_memory, and item.

Referenced by applicationmap_item_alloc().

00408 {
00409    struct ast_applicationmap_item *item = obj;
00410 
00411    ast_string_field_free_memory(item);
00412 }

int ast_features_config_init ( void   ) 

Definition at line 1966 of file features_config.c.

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

Referenced by ast_features_init().

01967 {
01968    int res;
01969 
01970    res = load_config();
01971    res |= __ast_custom_function_register(&feature_function, NULL);
01972    res |= __ast_custom_function_register(&featuremap_function, NULL);
01973    res |= ast_cli_register_multiple(cli_features_config, ARRAY_LEN(cli_features_config));
01974 
01975    if (res) {
01976       ast_features_config_shutdown();
01977    }
01978 
01979    return res;
01980 }

int ast_features_config_reload ( void   ) 

Definition at line 1955 of file features_config.c.

References aco_process_config(), ACO_PROCESS_ERROR, and parking_warning.

01956 {
01957    /* Rearm the parking config options have moved warning. */
01958    parking_warning = 0;
01959 
01960    if (aco_process_config(&cfg_info, 1) == ACO_PROCESS_ERROR) {
01961       return -1;
01962    }
01963    return 0;
01964 }

void ast_features_config_shutdown ( void   ) 

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:
chan The channel to get the option from
feature The short name of the feature (as it appears in features.conf)
[out] buf The buffer to write the DTMF value into
size The size of the buffer in bytes
Return values:
0 Success
non-zero Unrecognized builtin feature name

Definition at line 1201 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(), builtin_feature_get_exten(), detect_disconnect(), and internal_featuremap_read().

01202 {
01203    RAII_VAR(struct features_config *, cfg, NULL, ao2_cleanup);
01204 
01205    if (chan) {
01206       cfg = get_feature_ds(chan);
01207    } else {
01208       cfg = ao2_global_obj_ref(globals);
01209    }
01210 
01211    if (!cfg) {
01212       return -1;
01213    }
01214 
01215    return featuremap_get(cfg->featuremap, feature, buf, len);
01216 }

struct ao2_container* ast_get_chan_applicationmap ( struct ast_channel chan  )  [read]

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:
chan The channel for which applicationmap is being retrieved.
Return values:
NULL An error occurred or the channel has no dynamic features.
non-NULL A container of applicationmap_items pertaining to the channel.

Definition at line 1293 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().

01294 {
01295    RAII_VAR(struct features_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
01296    struct ao2_container *applicationmap;
01297    char *group_names;
01298    char *name;
01299 
01300    if (!cfg) {
01301       return NULL;
01302    }
01303 
01304    if (!chan) {
01305       if (!cfg->applicationmap || ao2_container_count(cfg->applicationmap) == 0) {
01306          return NULL;
01307       }
01308       ao2_ref(cfg->applicationmap, +1);
01309       return cfg->applicationmap;
01310    }
01311 
01312    group_names = ast_strdupa(S_OR(pbx_builtin_getvar_helper(chan, "DYNAMIC_FEATURES"), ""));
01313    if (ast_strlen_zero(group_names)) {
01314       return NULL;
01315    }
01316 
01317    applicationmap = applicationmap_alloc(0);
01318    if (!applicationmap) {
01319       return NULL;
01320    }
01321 
01322    /* global config must be initialized */
01323    ast_assert(cfg->featuregroups != NULL);
01324    ast_assert(cfg->applicationmap != NULL);
01325    while ((name = strsep(&group_names, "#"))) {
01326       RAII_VAR(struct featuregroup *, group, ao2_find(cfg->featuregroups, name, OBJ_KEY), ao2_cleanup);
01327 
01328       if (!group) {
01329          RAII_VAR(struct ast_applicationmap_item *, item, ao2_find(cfg->applicationmap, name, OBJ_KEY), ao2_cleanup);
01330 
01331          if (item) {
01332             ao2_link(applicationmap, item);
01333          } else {
01334             ast_log(LOG_WARNING, "Unknown DYNAMIC_FEATURES item '%s' on channel %s.\n",
01335                name, ast_channel_name(chan));
01336          }
01337       } else {
01338          ao2_callback(group->items, 0, add_item, applicationmap);
01339       }
01340    }
01341 
01342    if (ao2_container_count(applicationmap) == 0) {
01343       ao2_cleanup(applicationmap);
01344       return NULL;
01345    }
01346 
01347    return applicationmap;
01348 }

struct ast_featuremap_config* ast_get_chan_featuremap_config ( struct ast_channel chan  )  [read]

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:
chan The channel to get configuration options for
Return values:
NULL Failed to get configuration
non-NULL The pickup features configuration

Definition at line 1181 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().

01182 {
01183    RAII_VAR(struct features_config *, cfg, NULL, ao2_cleanup);
01184 
01185    if (chan) {
01186       cfg = get_feature_ds(chan);
01187    } else {
01188       cfg = ao2_global_obj_ref(globals);
01189    }
01190 
01191    if (!cfg) {
01192       return NULL;
01193    }
01194 
01195    ast_assert(cfg->featuremap != NULL);
01196 
01197    ao2_ref(cfg->featuremap, +1);
01198    return cfg->featuremap;
01199 }

struct ast_features_general_config* ast_get_chan_features_general_config ( struct ast_channel chan  )  [read]

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:
chan The channel to get configuration options for
Return values:
NULL Failed to get configuration
non-NULL The general features configuration

Definition at line 1121 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().

01122 {
01123    RAII_VAR(struct features_config *, cfg, NULL, ao2_cleanup);
01124 
01125    if (chan) {
01126       cfg = get_feature_ds(chan);
01127    } else {
01128       cfg = ao2_global_obj_ref(globals);
01129    }
01130 
01131    if (!cfg) {
01132       return NULL;
01133    }
01134 
01135    ast_assert(cfg->global && cfg->global->general);
01136 
01137    ao2_ref(cfg->global->general, +1);
01138    return cfg->global->general;
01139 }

struct ast_features_pickup_config* ast_get_chan_features_pickup_config ( struct ast_channel chan  )  [read]

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:
chan The channel to get configuration options for
Return values:
NULL Failed to get configuration
non-NULL The pickup features configuration

Definition at line 1161 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().

01162 {
01163    RAII_VAR(struct features_config *, cfg, NULL, ao2_cleanup);
01164 
01165    if (chan) {
01166       cfg = get_feature_ds(chan);
01167    } else {
01168       cfg = ao2_global_obj_ref(globals);
01169    }
01170 
01171    if (!cfg) {
01172       return NULL;
01173    }
01174 
01175    ast_assert(cfg->global && cfg->global->pickup);
01176 
01177    ao2_ref(cfg->global->pickup, +1);
01178    return cfg->global->pickup;
01179 }

struct ast_features_xfer_config* ast_get_chan_features_xfer_config ( struct ast_channel chan  )  [read]

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:
chan The channel to get configuration options for
Return values:
NULL Failed to get configuration
non-NULL The transfer features configuration

Definition at line 1141 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(), attended_transfer_properties_alloc(), bridge_exec(), grab_transfer(), and testsuite_notify_feature_success().

01142 {
01143    RAII_VAR(struct features_config *, cfg, NULL, ao2_cleanup);
01144 
01145    if (chan) {
01146       cfg = get_feature_ds(chan);
01147    } else {
01148       cfg = ao2_global_obj_ref(globals);
01149    }
01150 
01151    if (!cfg) {
01152       return NULL;
01153    }
01154 
01155    ast_assert(cfg->global && cfg->global->xfer);
01156 
01157    ao2_ref(cfg->global->xfer, +1);
01158    return cfg->global->xfer;
01159 }

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:
chan The channel to get the option from
feature The short name of the feature
[out] buf The buffer to write the DTMF value into
size The size of the buffer in bytes
Return values:
0 Success
non-zero Unrecognized feature name

Definition at line 1218 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().

01219 {
01220    RAII_VAR(struct ao2_container *, applicationmap, NULL, ao2_cleanup);
01221    RAII_VAR(struct ast_applicationmap_item *, item, NULL, ao2_cleanup);
01222 
01223    if (!ast_get_builtin_feature(chan, feature, buf, len)) {
01224       return 0;
01225    }
01226 
01227    /* Dang, must be in the application map */
01228    applicationmap = ast_get_chan_applicationmap(chan);
01229    if (!applicationmap) {
01230       return -1;
01231    }
01232 
01233    item = ao2_find(applicationmap, feature, OBJ_KEY);
01234    if (!item) {
01235       return -1;
01236    }
01237 
01238    ast_copy_string(buf, item->dtmf, len);
01239    return 0;
01240 }

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

Definition at line 1535 of file features_config.c.

References ao2_callback_data, ast_log, check_featuregroup_item(), CMP_STOP, featuregroup::items, LOG_WARNING, and featuregroup::name.

Referenced by features_pre_apply_config().

01536 {
01537    struct featuregroup *group = obj;
01538    int *err = arg;
01539 
01540    ao2_callback_data(group->items, 0, check_featuregroup_item, arg, data);
01541 
01542    if (*err) {
01543       ast_log(LOG_WARNING, "Featuregroup %s refers to non-existent applicationmap item\n",
01544             group->name);
01545    }
01546 
01547    return *err ? CMP_STOP : 0;
01548 }

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

Definition at line 1517 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().

01518 {
01519    struct ast_applicationmap_item *appmap_item;
01520    struct featuregroup_item *fg_item = obj;
01521    int *err = arg;
01522    struct ao2_container *applicationmap = data;
01523 
01524    appmap_item = ao2_find(applicationmap, fg_item->appmap_item_name, OBJ_KEY);
01525    if (!appmap_item) {
01526       *err = 1;
01527       return CMP_STOP;
01528    }
01529 
01530    fg_item->appmap_item = appmap_item;
01531 
01532    return 0;
01533 }

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]

Definition at line 1044 of file features_config.c.

References ao2_cleanup.

01045 {
01046    struct features_config *cfg = data;
01047    ao2_cleanup(cfg);
01048 }

static void* feature_ds_duplicate ( void *  data  )  [static]

Definition at line 1050 of file features_config.c.

References features_config_dup().

01051 {
01052    struct features_config *old_cfg = data;
01053 
01054    return features_config_dup(old_cfg);
01055 }

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

Definition at line 1670 of file features_config.c.

References ast_log, internal_feature_read(), and LOG_WARNING.

01672 {
01673    if (!chan) {
01674       ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
01675       return -1;
01676    }
01677 
01678    return internal_feature_read(chan, cmd, data, buf, len);
01679 }

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

Definition at line 1681 of file features_config.c.

References ast_log, internal_feature_write(), and LOG_WARNING.

01683 {
01684    if (!chan) {
01685       ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
01686       return -1;
01687    }
01688 
01689    return internal_feature_write(chan, cmd, data, value);
01690 }

static void* featuregroup_alloc ( const char *  cat  )  [static]

Definition at line 540 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.

00541 {
00542    struct featuregroup *group;
00543 
00544    group = ao2_alloc(sizeof(*group), featuregroup_destructor);
00545    if (!group) {
00546       return NULL;
00547    }
00548 
00549    group->name = ast_strdup(cat);
00550    if (!group->name) {
00551       ao2_cleanup(group);
00552       return NULL;
00553    }
00554 
00555    group->items = ao2_container_alloc_list(AO2_ALLOC_OPT_LOCK_NOLOCK,
00556       AO2_CONTAINER_ALLOC_OPT_DUPS_REPLACE, group_item_sort, NULL);
00557    if (!group->items) {
00558       ao2_cleanup(group);
00559       return NULL;
00560    }
00561 
00562    return group;
00563 }

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

Definition at line 506 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().

00507 {
00508    struct featuregroup *group1 = obj;
00509    struct featuregroup *group2;
00510    const char *key2;
00511 
00512    switch(flags & (OBJ_POINTER | OBJ_KEY | OBJ_PARTIAL_KEY)) {
00513    case OBJ_KEY:
00514       key2 = arg;
00515       return strcasecmp(group1->name, key2) ? 0 : CMP_MATCH;
00516    case OBJ_PARTIAL_KEY:
00517       key2 = arg;
00518       return strncasecmp(group1->name, key2, strlen(key2)) ? 0 : CMP_MATCH;
00519    case OBJ_POINTER:
00520       group2 = arg;
00521       return strcasecmp(group1->name, group2->name) ? 0 : CMP_MATCH;
00522    default:
00523       return CMP_STOP;
00524    }
00525 }

static void featuregroup_destructor ( void *  obj  )  [static]

Definition at line 532 of file features_config.c.

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

Referenced by featuregroup_alloc().

00533 {
00534    struct featuregroup *group = obj;
00535 
00536    ast_free((char *) group->name);
00537    ao2_cleanup(group->items);
00538 }

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

Definition at line 527 of file features_config.c.

References ao2_find, and OBJ_KEY.

00528 {
00529    return ao2_find(group_container, category, OBJ_KEY);
00530 }

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

Definition at line 1446 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().

01448 {
01449    RAII_VAR(struct featuregroup_item *, item, NULL, ao2_cleanup);
01450    struct featuregroup *group = obj;
01451 
01452    item = ao2_alloc(sizeof(*item), featuregroup_item_destructor);
01453    if (!item || ast_string_field_init(item, 32)) {
01454       return -1;
01455    }
01456 
01457    ast_string_field_set(item, appmap_item_name, var->name);
01458    ast_string_field_set(item, dtmf_override, var->value);
01459 
01460    if (!ao2_link(group->items, item)) {
01461       return -1;
01462    }
01463 
01464    /* We wait to look up the application map item in the preapply callback */
01465 
01466    return 0;
01467 }

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

Definition at line 487 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().

00488 {
00489    const struct featuregroup *group;
00490    const char *key;
00491 
00492    switch (flags & (OBJ_POINTER | OBJ_KEY | OBJ_PARTIAL_KEY)) {
00493    case OBJ_KEY:
00494       key = obj;
00495       return ast_str_case_hash(key);
00496    case OBJ_PARTIAL_KEY:
00497       ast_assert(0);
00498       return 0;
00499    case OBJ_POINTER:
00500    default:
00501       group = obj;
00502       return ast_str_case_hash(group->name);
00503    }
00504 }

static void featuregroup_item_destructor ( void *  obj  )  [static]

Definition at line 448 of file features_config.c.

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

Referenced by featuregroup_handler().

00449 {
00450    struct featuregroup_item *item = obj;
00451 
00452    ast_string_field_free_memory(item);
00453    ao2_cleanup(item->appmap_item);
00454 }

static void featuremap_config_destructor ( void *  obj  )  [static]

Definition at line 645 of file features_config.c.

References ast_string_field_free_memory.

Referenced by __features_config_alloc().

00646 {
00647    struct ast_featuremap_config *cfg = obj;
00648 
00649    ast_string_field_free_memory(cfg);
00650 }

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

Definition at line 806 of file features_config.c.

References ast_string_fields_copy.

Referenced by features_copy().

00807 {
00808    ast_string_fields_copy(dest, src);
00809 }

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

Definition at line 1019 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().

01021 {
01022    int res = 0;
01023 
01024    if (!strcasecmp(field, "blindxfer")) {
01025       ast_copy_string(buf, featuremap->blindxfer, len);
01026    } else if (!strcasecmp(field, "disconnect")) {
01027       ast_copy_string(buf, featuremap->disconnect, len);
01028    } else if (!strcasecmp(field, "automon")) {
01029       ast_copy_string(buf, featuremap->automon, len);
01030    } else if (!strcasecmp(field, "atxfer")) {
01031       ast_copy_string(buf, featuremap->atxfer, len);
01032    } else if (!strcasecmp(field, "automixmon")) {
01033       ast_copy_string(buf, featuremap->automixmon, len);
01034    } else if (!strcasecmp(field, "parkcall")) {
01035       ast_copy_string(buf, featuremap->parkcall, len);
01036    } else {
01037       /* Unrecognized option */
01038       res = -1;
01039    }
01040 
01041    return res;
01042 }

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

Definition at line 1509 of file features_config.c.

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

Referenced by load_config().

01511 {
01512    struct ast_featuremap_config *featuremap = obj;
01513 
01514    return featuremap_set(featuremap, var->name, var->value);
01515 }

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

Definition at line 1692 of file features_config.c.

References ast_log, internal_featuremap_read(), and LOG_WARNING.

01694 {
01695    if (!chan) {
01696       ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
01697       return -1;
01698    }
01699 
01700    return internal_featuremap_read(chan, cmd, data, buf, len);
01701 }

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

Definition at line 994 of file features_config.c.

References ast_string_field_set.

Referenced by featuremap_handler(), and internal_featuremap_write().

00996 {
00997    int res = 0;
00998 
00999    if (!strcasecmp(name, "blindxfer")) {
01000       ast_string_field_set(featuremap, blindxfer, value);
01001    } else if (!strcasecmp(name, "disconnect")) {
01002       ast_string_field_set(featuremap, disconnect, value);
01003    } else if (!strcasecmp(name, "automon")) {
01004       ast_string_field_set(featuremap, automon, value);
01005    } else if (!strcasecmp(name, "atxfer")) {
01006       ast_string_field_set(featuremap, atxfer, value);
01007    } else if (!strcasecmp(name, "automixmon")) {
01008       ast_string_field_set(featuremap, automixmon, value);
01009    } else if (!strcasecmp(name, "parkcall")) {
01010       ast_string_field_set(featuremap, parkcall, value);
01011    } else {
01012       /* Unrecognized option */
01013       res = -1;
01014    }
01015 
01016    return res;
01017 }

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

Definition at line 1703 of file features_config.c.

References ast_log, internal_featuremap_write(), and LOG_WARNING.

01705 {
01706    if (!chan) {
01707       ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
01708       return -1;
01709    }
01710 
01711    return internal_featuremap_write(chan, cmd, data, value);
01712 }

static void* features_config_alloc ( void   )  [static]

Definition at line 772 of file features_config.c.

References __features_config_alloc().

Referenced by load_config().

00773 {
00774    return __features_config_alloc(1);
00775 }

static void features_config_destructor ( void *  obj  )  [static]

static struct features_config* features_config_dup ( const struct features_config orig  )  [static, read]

Definition at line 822 of file features_config.c.

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

Referenced by feature_ds_duplicate(), and get_feature_ds().

00823 {
00824    struct features_config *dup;
00825 
00826    dup = __features_config_alloc(0);
00827    if (!dup) {
00828       return NULL;
00829    }
00830 
00831    features_copy(dup, orig);
00832 
00833    return dup;
00834 }

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

Definition at line 811 of file features_config.c.

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

Referenced by features_config_dup().

00812 {
00813    global_copy(dest->global, src->global);
00814    featuremap_copy(dest->featuremap, src->featuremap);
00815 
00816    /* applicationmap and featuregroups are purposely not copied. A channel's applicationmap
00817     * is produced on the fly when ast_get_chan_applicationmap() is called
00818     * NOTE: This does not apply to the global cfg->applicationmap and cfg->featuresgroups
00819     */
00820 }

static int features_pre_apply_config ( void   )  [static]

Definition at line 1557 of file features_config.c.

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

01558 {
01559    struct features_config *cfg = aco_pending_config(&cfg_info);
01560    int err = 0;
01561 
01562    /* Now that the entire config has been processed, we can check that the featuregroup
01563     * items refer to actual applicationmap items.
01564     */
01565 
01566    /* global config must be initialized */
01567    ast_assert(cfg->featuregroups != NULL);
01568    ast_assert(cfg->applicationmap != NULL);
01569    ao2_callback_data(cfg->featuregroups, 0, check_featuregroup, &err, cfg->applicationmap);
01570 
01571    return err;
01572 }

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

Definition at line 777 of file features_config.c.

References ast_string_fields_copy, and ast_features_general_config::featuredigittimeout.

Referenced by global_copy().

00778 {
00779    ast_string_fields_copy(dest, src);
00780    dest->featuredigittimeout = src->featuredigittimeout;
00781 }

static void general_destructor ( void *  obj  )  [static]

Definition at line 661 of file features_config.c.

References ast_string_field_free_memory.

Referenced by global_config_alloc().

00662 {
00663    struct ast_features_general_config *cfg = obj;
00664 
00665    ast_string_field_free_memory(cfg);
00666 }

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

Definition at line 855 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().

00857 {
00858    int res = 0;
00859 
00860    if (!strcasecmp(field, "featuredigittimeout")) {
00861       snprintf(buf, len, "%u", general->featuredigittimeout);
00862    } else if (!strcasecmp(field, "courtesytone")) {
00863       ast_copy_string(buf, general->courtesytone, len);
00864    } else if (!strcasecmp(field, "recordingfailsound")) {
00865       ast_copy_string(buf, general->recordingfailsound, len);
00866    } else {
00867       /* Unrecognized option */
00868       res = -1;
00869    }
00870 
00871    return res;
00872 }

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

Definition at line 1469 of file features_config.c.

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

Referenced by load_config().

01471 {
01472    struct features_global_config *global = obj;
01473    struct ast_features_general_config *general = global->general;
01474 
01475    return general_set(general, var->name, var->value);
01476 }

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

Definition at line 836 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().

00838 {
00839    int res = 0;
00840 
00841    if (!strcasecmp(name, "featuredigittimeout")) {
00842       res = ast_parse_arg(value, PARSE_INT32, &general->featuredigittimeout);
00843    } else if (!strcasecmp(name, "courtesytone")) {
00844       ast_string_field_set(general, courtesytone, value);
00845    } else if (!strcasecmp(name, "recordingfailsound")) {
00846       ast_string_field_set(general, recordingfailsound, value);
00847    } else {
00848       /* Unrecognized option */
00849       res = -1;
00850    }
00851 
00852    return res;
00853 }

static struct ast_datastore* get_feature_chan_ds ( struct ast_channel chan  )  [static, read]

Definition at line 1107 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().

01108 {
01109    struct ast_datastore *ds;
01110 
01111    if (!(ds = ast_channel_datastore_find(chan, &feature_ds_info, NULL))) {
01112       /* Hasn't been created yet.  Trigger creation. */
01113       ao2_cleanup(get_feature_ds(chan));
01114 
01115       ds = ast_channel_datastore_find(chan, &feature_ds_info, NULL);
01116    }
01117 
01118    return ds;
01119 }

static struct features_config* get_feature_ds ( struct ast_channel chan  )  [static, read]

Definition at line 1071 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().

01072 {
01073    RAII_VAR(struct features_config *, orig, NULL, ao2_cleanup);
01074    struct features_config *cfg;
01075    struct ast_datastore *ds;
01076 
01077    if ((ds = ast_channel_datastore_find(chan, &feature_ds_info, NULL))) {
01078       cfg = ds->data;
01079       ao2_ref(cfg, +1);
01080       return cfg;
01081    }
01082 
01083    orig = ao2_global_obj_ref(globals);
01084    if (!orig) {
01085       return NULL;
01086    }
01087 
01088    cfg = features_config_dup(orig);
01089    if (!cfg) {
01090       return NULL;
01091    }
01092 
01093    if (!(ds = ast_datastore_alloc(&feature_ds_info, NULL))) {
01094       ao2_cleanup(cfg);
01095       return NULL;
01096    }
01097 
01098    /* Give the datastore a reference to the config */
01099    ao2_ref(cfg, +1);
01100    ds->data = cfg;
01101 
01102    ast_channel_datastore_add(chan, ds);
01103 
01104    return cfg;
01105 }

static struct features_global_config* global_config_alloc ( void   )  [static, read]

Definition at line 682 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().

00683 {
00684    RAII_VAR(struct features_global_config *, cfg, NULL, ao2_cleanup);
00685 
00686    cfg = ao2_alloc(sizeof(*cfg), global_config_destructor);
00687    if (!cfg) {
00688       return NULL;
00689    }
00690 
00691    cfg->general = ao2_alloc(sizeof(*cfg->general), general_destructor);
00692    if (!cfg->general || ast_string_field_init(cfg->general, 32)) {
00693       return NULL;
00694    }
00695 
00696    cfg->xfer = ao2_alloc(sizeof(*cfg->xfer), xfer_destructor);
00697    if (!cfg->xfer || ast_string_field_init(cfg->xfer, 32)) {
00698       return NULL;
00699    }
00700 
00701    cfg->pickup = ao2_alloc(sizeof(*cfg->pickup), pickup_destructor);
00702    if (!cfg->pickup || ast_string_field_init(cfg->pickup, 32)) {
00703       return NULL;
00704    }
00705 
00706    ao2_ref(cfg, +1);
00707    return cfg;
00708 }

static void global_config_destructor ( void *  obj  )  [static]

Definition at line 652 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().

00653 {
00654    struct features_global_config *cfg = obj;
00655 
00656    ao2_cleanup(cfg->general);
00657    ao2_cleanup(cfg->xfer);
00658    ao2_cleanup(cfg->pickup);
00659 }

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

Definition at line 799 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().

00800 {
00801    general_copy(dest->general, src->general);
00802    xfer_copy(dest->xfer, src->xfer);
00803    pickup_copy(dest->pickup, src->pickup);
00804 }

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

Definition at line 456 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().

00457 {
00458    const struct featuregroup_item *item1 = obj;
00459    const struct featuregroup_item *item2;
00460    const char *key2;
00461 
00462    switch(flags & (OBJ_POINTER | OBJ_KEY | OBJ_PARTIAL_KEY)) {
00463    case OBJ_KEY:
00464       key2 = arg;
00465       return strcasecmp(item1->appmap_item_name, key2);
00466    case OBJ_PARTIAL_KEY:
00467       key2 = arg;
00468       return strncasecmp(item1->appmap_item_name, key2, strlen(key2));
00469    case OBJ_POINTER:
00470       item2 = arg;
00471       return strcasecmp(item1->appmap_item_name, item2->appmap_item_name);
00472    default:
00473       return CMP_STOP;
00474    }
00475 }

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_SUCCESS on success.
NULL when tab completion is used.

Definition at line 1891 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.

01892 {
01893    RAII_VAR(struct features_config *, cfg, NULL, ao2_cleanup);
01894 
01895    switch (cmd) {
01896 
01897    case CLI_INIT:
01898       e->command = "features show";
01899       e->usage =
01900          "Usage: features show\n"
01901          "       Lists configured features\n";
01902       return NULL;
01903    case CLI_GENERATE:
01904       return NULL;
01905    }
01906 
01907    cfg = ao2_global_obj_ref(globals);
01908 
01909    ast_cli(a->fd, HFS_FORMAT, "Builtin Feature", "Default", "Current");
01910    ast_cli(a->fd, HFS_FORMAT, "---------------", "-------", "-------");
01911 
01912    ast_cli(a->fd, HFS_FORMAT, "Pickup", DEFAULT_PICKUPEXTEN, cfg->global->pickup->pickupexten);
01913    ast_cli(a->fd, HFS_FORMAT, "Blind Transfer", DEFAULT_FEATUREMAP_BLINDXFER, cfg->featuremap->blindxfer);
01914    ast_cli(a->fd, HFS_FORMAT, "Attended Transfer", DEFAULT_FEATUREMAP_ATXFER, cfg->featuremap->atxfer);
01915    ast_cli(a->fd, HFS_FORMAT, "One Touch Monitor", DEFAULT_FEATUREMAP_AUTOMON, cfg->featuremap->automon);
01916    ast_cli(a->fd, HFS_FORMAT, "Disconnect Call", DEFAULT_FEATUREMAP_DISCONNECT, cfg->featuremap->disconnect);
01917    ast_cli(a->fd, HFS_FORMAT, "Park Call", DEFAULT_FEATUREMAP_PARKCALL, cfg->featuremap->parkcall);
01918    ast_cli(a->fd, HFS_FORMAT, "One Touch MixMonitor", DEFAULT_FEATUREMAP_AUTOMIXMON, cfg->featuremap->automixmon);
01919 
01920    ast_cli(a->fd, "\n");
01921    ast_cli(a->fd, HFS_FORMAT, "Dynamic Feature", "Default", "Current");
01922    ast_cli(a->fd, HFS_FORMAT, "---------------", "-------", "-------");
01923    if (!cfg->applicationmap || ao2_container_count(cfg->applicationmap) == 0) {
01924       ast_cli(a->fd, "(none)\n");
01925    } else {
01926       ao2_callback(cfg->applicationmap, 0, print_applicationmap, a);
01927    }
01928 
01929    ast_cli(a->fd, "\nFeature Groups:\n");
01930    ast_cli(a->fd, "---------------\n");
01931    if (!cfg->featuregroups || ao2_container_count(cfg->featuregroups) == 0) {
01932       ast_cli(a->fd, "(none)\n");
01933    } else {
01934       ao2_callback(cfg->featuregroups, 0, print_featuregroups, a);
01935    }
01936 
01937    ast_cli(a->fd, "\n");
01938 
01939    return CLI_SUCCESS;
01940 }

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

Definition at line 1574 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().

01576 {
01577    int res;
01578    RAII_VAR(struct features_config *, cfg, NULL, ao2_cleanup);
01579    SCOPED_CHANNELLOCK(lock, chan);
01580 
01581    if (!strcasecmp(data, "inherit")) {
01582       struct ast_datastore *ds = get_feature_chan_ds(chan);
01583       unsigned int inherit = ds ? ds->inheritance : 0;
01584 
01585       snprintf(buf, len, "%s", inherit ? "yes" : "no");
01586       return 0;
01587    }
01588 
01589    cfg = get_feature_ds(chan);
01590    if (!cfg) {
01591       return -1;
01592    }
01593 
01594    res = general_get(cfg->global->general, data, buf, len) &&
01595       xfer_get(cfg->global->xfer, data, buf, len) &&
01596       pickup_get(cfg->global->pickup, data, buf, len);
01597 
01598    if (res) {
01599       ast_log(LOG_WARNING, "Invalid argument '%s' to FEATURE()\n", data);
01600    }
01601 
01602    return res;
01603 }

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

Definition at line 1605 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().

01607 {
01608    int res;
01609    RAII_VAR(struct features_config *, cfg, NULL, ao2_cleanup);
01610    SCOPED_CHANNELLOCK(lock, chan);
01611 
01612    if (!strcasecmp(data, "inherit")) {
01613       struct ast_datastore *ds = get_feature_chan_ds(chan);
01614       if (ds) {
01615          ds->inheritance = ast_true(value) ? DATASTORE_INHERIT_FOREVER : 0;
01616       }
01617       return 0;
01618    }
01619 
01620    if (!(cfg = get_feature_ds(chan))) {
01621       return -1;
01622    }
01623 
01624    res = general_set(cfg->global->general, data, value) &&
01625       xfer_set(cfg->global->xfer, data, value) &&
01626       pickup_set(cfg->global->pickup, data, value);
01627 
01628    if (res) {
01629       ast_log(LOG_WARNING, "Invalid argument '%s' to FEATURE()\n", data);
01630    }
01631 
01632    return res;
01633 }

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

Definition at line 1635 of file features_config.c.

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

Referenced by featuremap_read().

01637 {
01638    int res;
01639    SCOPED_CHANNELLOCK(lock, chan);
01640 
01641    res = ast_get_builtin_feature(chan, data, buf, len);
01642 
01643    if (res) {
01644       ast_log(LOG_WARNING, "Invalid argument '%s' to FEATUREMAP()\n", data);
01645    }
01646 
01647    return res;
01648 }

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

Definition at line 1650 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().

01652 {
01653    int res;
01654    RAII_VAR(struct features_config *, cfg, NULL, ao2_cleanup);
01655    SCOPED_CHANNELLOCK(lock, chan);
01656 
01657    if (!(cfg = get_feature_ds(chan))) {
01658       return -1;
01659    }
01660 
01661    res = featuremap_set(cfg->featuremap, data, value);
01662    if (res) {
01663       ast_log(LOG_WARNING, "Invalid argument '%s' to FEATUREMAP()\n", data);
01664       return -1;
01665    }
01666 
01667    return 0;
01668 }

static int load_config ( void   )  [static]

Definition at line 1726 of file features_config.c.

References __stringify, ACO_EXACT, aco_info_init(), aco_option_register_custom, aco_option_register_custom_nodoc, aco_process_config(), ACO_PROCESS_ERROR, ACO_REGEX, 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().

01727 {
01728    if (aco_info_init(&cfg_info)) {
01729       ast_log(LOG_ERROR, "Unable to initialize configuration info for features\n");
01730       return -1;
01731    }
01732 
01733    aco_option_register_custom(&cfg_info, "featuredigittimeout", ACO_EXACT, global_options,
01734          __stringify(DEFAULT_FEATURE_DIGIT_TIMEOUT), general_handler, 0);
01735    aco_option_register_custom(&cfg_info, "recordingfailsound", ACO_EXACT, global_options,
01736          DEFAULT_RECORDING_FAIL_SOUND, general_handler, 0);
01737    aco_option_register_custom(&cfg_info, "courtesytone", ACO_EXACT, global_options,
01738          DEFAULT_COURTESY_TONE, general_handler, 0);
01739 
01740    aco_option_register_custom(&cfg_info, "transferdigittimeout", ACO_EXACT, global_options,
01741          __stringify(DEFAULT_TRANSFER_DIGIT_TIMEOUT), xfer_handler, 0)
01742    aco_option_register_custom(&cfg_info, "atxfernoanswertimeout", ACO_EXACT, global_options,
01743          __stringify(DEFAULT_NOANSWER_TIMEOUT_ATTENDED_TRANSFER), xfer_handler, 0);
01744    aco_option_register_custom(&cfg_info, "atxferdropcall", ACO_EXACT, global_options,
01745          __stringify(DEFAULT_ATXFER_DROP_CALL), xfer_handler, 0);
01746    aco_option_register_custom(&cfg_info, "atxferloopdelay", ACO_EXACT, global_options,
01747          __stringify(DEFAULT_ATXFER_LOOP_DELAY), xfer_handler, 0);
01748    aco_option_register_custom(&cfg_info, "atxfercallbackretries", ACO_EXACT, global_options,
01749          __stringify(DEFAULT_ATXFER_CALLBACK_RETRIES), xfer_handler, 0);
01750    aco_option_register_custom(&cfg_info, "xfersound", ACO_EXACT, global_options,
01751          DEFAULT_XFERSOUND, xfer_handler, 0);
01752    aco_option_register_custom(&cfg_info, "xferfailsound", ACO_EXACT, global_options,
01753          DEFAULT_XFERFAILSOUND, xfer_handler, 0);
01754    aco_option_register_custom(&cfg_info, "atxferabort", ACO_EXACT, global_options,
01755          DEFAULT_ATXFER_ABORT, xfer_handler, 0);
01756    aco_option_register_custom(&cfg_info, "atxfercomplete", ACO_EXACT, global_options,
01757          DEFAULT_ATXFER_COMPLETE, xfer_handler, 0);
01758    aco_option_register_custom(&cfg_info, "atxferthreeway", ACO_EXACT, global_options,
01759          DEFAULT_ATXFER_THREEWAY, xfer_handler, 0);
01760    aco_option_register_custom(&cfg_info, "atxferswap", ACO_EXACT, global_options,
01761          DEFAULT_ATXFER_SWAP, xfer_handler, 0);
01762    aco_option_register_custom(&cfg_info, "transferdialattempts", ACO_EXACT, global_options,
01763          __stringify(DEFAULT_TRANSFER_DIAL_ATTEMPTS), xfer_handler, 0);
01764    aco_option_register_custom(&cfg_info, "transferretrysound", ACO_EXACT, global_options,
01765          DEFAULT_TRANSFER_RETRY_SOUND, xfer_handler, 0);
01766    aco_option_register_custom(&cfg_info, "transferinvalidsound", ACO_EXACT, global_options,
01767          DEFAULT_TRANSFER_INVALID_SOUND, xfer_handler, 0);
01768 
01769    aco_option_register_custom(&cfg_info, "pickupexten", ACO_EXACT, global_options,
01770          DEFAULT_PICKUPEXTEN, pickup_handler, 0);
01771    aco_option_register_custom(&cfg_info, "pickupsound", ACO_EXACT, global_options,
01772          DEFAULT_PICKUPSOUND, pickup_handler, 0);
01773    aco_option_register_custom(&cfg_info, "pickupfailsound", ACO_EXACT, global_options,
01774          DEFAULT_PICKUPFAILSOUND, pickup_handler, 0);
01775 
01776    aco_option_register_custom_nodoc(&cfg_info, "context", ACO_EXACT, global_options,
01777          "", unsupported_handler, 0);
01778    aco_option_register_custom_nodoc(&cfg_info, "parkext", ACO_EXACT, global_options,
01779          "", unsupported_handler, 0);
01780    aco_option_register_custom_nodoc(&cfg_info, "parkext_exclusive", ACO_EXACT, global_options,
01781          "", unsupported_handler, 0);
01782    aco_option_register_custom_nodoc(&cfg_info, "parkinghints", ACO_EXACT, global_options,
01783          "", unsupported_handler, 0);
01784    aco_option_register_custom_nodoc(&cfg_info, "parkedmusicclass", ACO_EXACT, global_options,
01785          "", unsupported_handler, 0);
01786    aco_option_register_custom_nodoc(&cfg_info, "parkingtime", ACO_EXACT, global_options,
01787          "", unsupported_handler, 0);
01788    aco_option_register_custom_nodoc(&cfg_info, "parkpos", ACO_EXACT, global_options,
01789          "", unsupported_handler, 0);
01790    aco_option_register_custom_nodoc(&cfg_info, "findslot", ACO_EXACT, global_options,
01791          "", unsupported_handler, 0);
01792    aco_option_register_custom_nodoc(&cfg_info, "parkedcalltransfers", ACO_EXACT, global_options,
01793          "", unsupported_handler, 0);
01794    aco_option_register_custom_nodoc(&cfg_info, "parkedcallreparking", ACO_EXACT, global_options,
01795          "", unsupported_handler, 0);
01796    aco_option_register_custom_nodoc(&cfg_info, "parkedcallhangup", ACO_EXACT, global_options,
01797          "", unsupported_handler, 0);
01798    aco_option_register_custom_nodoc(&cfg_info, "parkedcallrecording", ACO_EXACT, global_options,
01799          "", unsupported_handler, 0);
01800    aco_option_register_custom_nodoc(&cfg_info, "comebackcontext", ACO_EXACT, global_options,
01801          "", unsupported_handler, 0);
01802    aco_option_register_custom_nodoc(&cfg_info, "comebacktoorigin", ACO_EXACT, global_options,
01803          "", unsupported_handler, 0);
01804    aco_option_register_custom_nodoc(&cfg_info, "comebackdialtime", ACO_EXACT, global_options,
01805          "", unsupported_handler, 0);
01806    aco_option_register_custom_nodoc(&cfg_info, "parkeddynamic", ACO_EXACT, global_options,
01807          "", unsupported_handler, 0);
01808    aco_option_register_custom_nodoc(&cfg_info, "adsipark", ACO_EXACT, global_options,
01809          "", unsupported_handler, 0);
01810 
01811    aco_option_register_custom(&cfg_info, "blindxfer", ACO_EXACT, featuremap_options,
01812          DEFAULT_FEATUREMAP_BLINDXFER, featuremap_handler, 0);
01813    aco_option_register_custom(&cfg_info, "disconnect", ACO_EXACT, featuremap_options,
01814          DEFAULT_FEATUREMAP_DISCONNECT, featuremap_handler, 0);
01815    aco_option_register_custom(&cfg_info, "automon", ACO_EXACT, featuremap_options,
01816          DEFAULT_FEATUREMAP_AUTOMON, featuremap_handler, 0);
01817    aco_option_register_custom(&cfg_info, "atxfer", ACO_EXACT, featuremap_options,
01818          DEFAULT_FEATUREMAP_ATXFER, featuremap_handler, 0);
01819    aco_option_register_custom(&cfg_info, "parkcall", ACO_EXACT, featuremap_options,
01820          DEFAULT_FEATUREMAP_PARKCALL, featuremap_handler, 0);
01821    aco_option_register_custom(&cfg_info, "automixmon", ACO_EXACT, featuremap_options,
01822          DEFAULT_FEATUREMAP_AUTOMIXMON, featuremap_handler, 0);
01823 
01824    aco_option_register_custom(&cfg_info, "^.*$", ACO_REGEX, applicationmap_options,
01825          "", applicationmap_handler, 0);
01826 
01827    aco_option_register_custom(&cfg_info, "^.*$", ACO_REGEX, featuregroup_options,
01828          "", featuregroup_handler, 0);
01829 
01830    aco_option_register_custom_nodoc(&cfg_info, "^.*$", ACO_REGEX, parkinglot_options,
01831          "", unsupported_handler, 0);
01832 
01833    if (aco_process_config(&cfg_info, 0) == ACO_PROCESS_ERROR) {
01834       RAII_VAR(struct features_config *, features_cfg, features_config_alloc(), ao2_cleanup);
01835 
01836       if (aco_set_defaults(&global_option, "general", features_cfg->global) ||
01837          aco_set_defaults(&featuremap_option, "featuremap", features_cfg->featuremap)) {
01838          ast_log(LOG_ERROR, "Failed to load features.conf and failed to initialize defaults.\n");
01839          return -1;
01840       }
01841 
01842       ast_log(LOG_NOTICE, "Could not load features config; using defaults\n");
01843       ao2_global_obj_replace_unref(globals, features_cfg);
01844    }
01845 
01846    return 0;
01847 }

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

Definition at line 794 of file features_config.c.

References ast_string_fields_copy.

Referenced by global_copy().

00795 {
00796    ast_string_fields_copy(dest, src);
00797 }

static void pickup_destructor ( void *  obj  )  [static]

Definition at line 675 of file features_config.c.

References ast_string_field_free_memory.

Referenced by global_config_alloc().

00676 {
00677    struct ast_features_pickup_config *cfg = obj;
00678 
00679    ast_string_field_free_memory(cfg);
00680 }

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

Definition at line 975 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().

00977 {
00978    int res = 0;
00979 
00980    if (!strcasecmp(field, "pickupsound")) {
00981       ast_copy_string(buf, pickup->pickupsound, len);
00982    } else if (!strcasecmp(field, "pickupfailsound")) {
00983       ast_copy_string(buf, pickup->pickupfailsound, len);
00984    } else if (!strcasecmp(field, "pickupexten")) {
00985       ast_copy_string(buf, pickup->pickupexten, len);
00986    } else {
00987       /* Unrecognized option */
00988       res = -1;
00989    }
00990 
00991    return res;
00992 }

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

Definition at line 1487 of file features_config.c.

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

Referenced by load_config().

01489 {
01490    struct features_global_config *global = obj;
01491    struct ast_features_pickup_config *pickup = global->pickup;
01492 
01493    return pickup_set(pickup, var->name, var->value);
01494 }

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

Definition at line 956 of file features_config.c.

References ast_string_field_set.

Referenced by internal_feature_write(), and pickup_handler().

00958 {
00959    int res = 0;
00960 
00961    if (!strcasecmp(name, "pickupsound")) {
00962       ast_string_field_set(pickup, pickupsound, value);
00963    } else if (!strcasecmp(name, "pickupfailsound")) {
00964       ast_string_field_set(pickup, pickupfailsound, value);
00965    } else if (!strcasecmp(name, "pickupexten")) {
00966       ast_string_field_set(pickup, pickupexten, value);
00967    } else {
00968       /* Unrecognized option */
00969       res = -1;
00970    }
00971 
00972    return res;
00973 }

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

Definition at line 1873 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().

01874 {
01875    struct ast_applicationmap_item *item = obj;
01876    struct ast_cli_args *a = arg;
01877 
01878    ast_cli(a->fd, HFS_FORMAT, item->name, "no def", item->dtmf);
01879    return 0;
01880 }

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

Definition at line 1849 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().

01850 {
01851    struct featuregroup_item *item = obj;
01852    struct ast_cli_args *a = arg;
01853 
01854    ast_cli(a->fd, "===> --> %s (%s)\n", item->appmap_item_name,
01855          S_OR(item->dtmf_override, item->appmap_item->dtmf));
01856 
01857    return 0;
01858 }

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

Definition at line 1860 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().

01861 {
01862    struct featuregroup *group = obj;
01863    struct ast_cli_args *a = arg;
01864 
01865    ast_cli(a->fd, "===> Group: %s\n", group->name);
01866 
01867    ao2_callback(group->items, 0, print_featuregroup, a);
01868    return 0;
01869 }

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

Definition at line 1497 of file features_config.c.

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

Referenced by load_config().

01499 {
01500    if (!parking_warning) {
01501       ast_log(LOG_WARNING, "Parkinglots are no longer configurable in features.conf; "
01502          "parking is now handled by res_parking.conf\n");
01503       parking_warning = 1;
01504    }
01505    ast_log(LOG_WARNING, "The option '%s' is no longer configurable in features.conf.\n", var->name);
01506    return 0;
01507 }

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

static void xfer_destructor ( void *  obj  )  [static]

Definition at line 668 of file features_config.c.

References ast_string_field_free_memory.

Referenced by global_config_alloc().

00669 {
00670    struct ast_features_xfer_config *cfg = obj;
00671 
00672    ast_string_field_free_memory(cfg);
00673 }

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

Definition at line 915 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().

00917 {
00918    int res = 0;
00919 
00920    if (!strcasecmp(field, "transferdigittimeout")) {
00921       snprintf(buf, len, "%u", xfer->transferdigittimeout);
00922    } else if (!strcasecmp(field, "atxfernoanswertimeout")) {
00923       snprintf(buf, len, "%u", xfer->atxfernoanswertimeout);
00924    } else if (!strcasecmp(field, "atxferloopdelay")) {
00925       snprintf(buf, len, "%u", xfer->atxferloopdelay);
00926    } else if (!strcasecmp(field, "atxfercallbackretries")) {
00927       snprintf(buf, len, "%u", xfer->atxfercallbackretries);
00928    } else if (!strcasecmp(field, "atxferdropcall")) {
00929       snprintf(buf, len, "%u", xfer->atxferdropcall);
00930    } else if (!strcasecmp(field, "xfersound")) {
00931       ast_copy_string(buf, xfer->xfersound, len);
00932    } else if (!strcasecmp(field, "xferfailsound")) {
00933       ast_copy_string(buf, xfer->xferfailsound, len);
00934    } else if (!strcasecmp(field, "atxferabort")) {
00935       ast_copy_string(buf, xfer->atxferabort, len);
00936    } else if (!strcasecmp(field, "atxfercomplete")) {
00937       ast_copy_string(buf, xfer->atxfercomplete, len);
00938    } else if (!strcasecmp(field, "atxferthreeway")) {
00939       ast_copy_string(buf, xfer->atxferthreeway, len);
00940    } else if (!strcasecmp(field, "atxferswap")) {
00941       ast_copy_string(buf, xfer->atxferswap, len);
00942    } else if (!strcasecmp(field, "transferdialattempts")) {
00943       snprintf(buf, len, "%u", xfer->transferdialattempts);
00944    } else if (!strcasecmp(field, "transferretrysound")) {
00945       ast_copy_string(buf, xfer->transferretrysound, len);
00946    } else if (!strcasecmp(field, "transferinvalidsound")) {
00947       ast_copy_string(buf, xfer->transferinvalidsound, len);
00948    } else {
00949       /* Unrecognized option */
00950       res = -1;
00951    }
00952 
00953    return res;
00954 }

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

Definition at line 1478 of file features_config.c.

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

Referenced by load_config().

01480 {
01481    struct features_global_config *global = obj;
01482    struct ast_features_xfer_config *xfer = global->xfer;
01483 
01484    return xfer_set(xfer, var->name, var->value);
01485 }

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

Definition at line 874 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().

00876 {
00877    int res = 0;
00878 
00879    if (!strcasecmp(name, "transferdigittimeout")) {
00880       res = ast_parse_arg(value, PARSE_INT32, &xfer->transferdigittimeout);
00881    } else if (!strcasecmp(name, "atxfernoanswertimeout")) {
00882       res = ast_parse_arg(value, PARSE_INT32, &xfer->atxfernoanswertimeout);
00883    } else if (!strcasecmp(name, "atxferloopdelay")) {
00884       res = ast_parse_arg(value, PARSE_INT32, &xfer->atxferloopdelay);
00885    } else if (!strcasecmp(name, "atxfercallbackretries")) {
00886       res = ast_parse_arg(value, PARSE_INT32, &xfer->atxfercallbackretries);
00887    } else if (!strcasecmp(name, "atxferdropcall")) {
00888       xfer->atxferdropcall = ast_true(value);
00889    } else if (!strcasecmp(name, "xfersound")) {
00890       ast_string_field_set(xfer, xfersound, value);
00891    } else if (!strcasecmp(name, "xferfailsound")) {
00892       ast_string_field_set(xfer, xferfailsound, value);
00893    } else if (!strcasecmp(name, "atxferabort")) {
00894       ast_string_field_set(xfer, atxferabort, value);
00895    } else if (!strcasecmp(name, "atxfercomplete")) {
00896       ast_string_field_set(xfer, atxfercomplete, value);
00897    } else if (!strcasecmp(name, "atxferthreeway")) {
00898       ast_string_field_set(xfer, atxferthreeway, value);
00899    } else if (!strcasecmp(name, "atxferswap")) {
00900       ast_string_field_set(xfer, atxferswap, value);
00901    } else if (!strcasecmp(name, "transferdialattempts")) {
00902       res = ast_parse_arg(value, PARSE_INT32, &xfer->transferdialattempts);
00903    } else if (!strcasecmp(name, "transferretrysound")) {
00904       ast_string_field_set(xfer, transferretrysound, value);
00905    } else if (!strcasecmp(name, "transferinvalidsound")) {
00906       ast_string_field_set(xfer, transferinvalidsound, value);
00907    } else {
00908       /* Unrecognized option */
00909       res = -1;
00910    }
00911 
00912    return res;
00913 }


Variable Documentation

Definition at line 594 of file features_config.c.

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

Definition at line 623 of file features_config.c.

Initial value:

 {
   AST_CLI_DEFINE(handle_feature_show, "Lists configured features"),
}

Definition at line 1942 of file features_config.c.

Initial value:

 {
   .type = "FEATURE",
   .destroy = feature_ds_destroy,
   .duplicate = feature_ds_duplicate,
}

Definition at line 1057 of file features_config.c.

Initial value:

 {
   .name = "FEATURE",
   .read = feature_read,
   .write = feature_write
}

Definition at line 1714 of file features_config.c.

struct aco_type featuregroup_option [static]

Definition at line 602 of file features_config.c.

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

Definition at line 624 of file features_config.c.

Initial value:

 {
   .name = "FEATUREMAP",
   .read = featuremap_read,
   .write = featuremap_write
}

Definition at line 1720 of file features_config.c.

struct aco_type featuremap_option [static]

Definition at line 586 of file features_config.c.

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

Definition at line 622 of file features_config.c.

struct aco_file features_conf [static]

Initial value:

Definition at line 627 of file features_config.c.

struct aco_type global_option [static]

Definition at line 578 of file features_config.c.

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

Definition at line 621 of file features_config.c.

int parking_warning = 0 [static]

Definition at line 1496 of file features_config.c.

Referenced by ast_features_config_reload(), and unsupported_handler().

struct aco_type parkinglot_option [static]

Definition at line 612 of file features_config.c.

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

Definition at line 625 of file features_config.c.


Generated on Thu Apr 16 06:30:59 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6