Exemple #1
0
#include "internal.h"

/*! \brief Locking container for safe configuration access. */
static AO2_GLOBAL_OBJ_STATIC(confs);

/*! \brief Mapping of the ARI conf struct's globals to the
 *         general context in the config file. */
static struct aco_type general_option = {
	.type = ACO_GLOBAL,
	.name = "general",
	.item_offset = offsetof(struct ast_ari_conf, general),
	.category = "^general$",
	.category_match = ACO_WHITELIST,
};

static struct aco_type *general_options[] = ACO_TYPES(&general_option);

/*! \brief Encoding format handler converts from boolean to enum. */
static int encoding_format_handler(const struct aco_option *opt,
	struct ast_variable *var, void *obj)
{
	struct ast_ari_conf_general *general = obj;

	if (!strcasecmp(var->name, "pretty")) {
		general->format = ast_true(var->value) ?
			AST_JSON_PRETTY : AST_JSON_COMPACT;
	} else {
		return -1;
	}

	return 0;
	}

	return cfg;
}

static struct aco_type notify_option = {
	.type = ACO_ITEM,
	.name = "notify",
	.category_match = ACO_BLACKLIST,
	.category = "^general$",
	.item_offset = offsetof(struct notify_cfg, notify_options),
	.item_alloc = notify_option_alloc,
	.item_find = notify_option_find
};

static struct aco_type *notify_options[] = ACO_TYPES(&notify_option);

static struct aco_file module_conf = {
	.filename = notify_config,
	.types = ACO_TYPES(&notify_option),
};

AO2_GLOBAL_OBJ_STATIC(globals);

CONFIG_INFO_STANDARD(notify_cfg, globals, notify_cfg_alloc,
	.files = ACO_FILES(&module_conf)
);

/*!
 * \internal
 * \brief Structure to hold task data for notifications.