[asterisk-commits] twilson: branch twilson/config_work r367838 - in /team/twilson/config_work: a...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue May 29 11:37:51 CDT 2012
Author: twilson
Date: Tue May 29 11:37:47 2012
New Revision: 367838
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=367838
Log:
Update tests and rename post_init callback to pre_process
Since the "post_init" callback is now run possibly multiple
times (for each file) and not just after defaults are initially
set, rename it to pre_process.
Modified:
team/twilson/config_work/apps/app_skel.c
team/twilson/config_work/include/asterisk/config_options.h
team/twilson/config_work/include/asterisk/stringfields.h
team/twilson/config_work/include/asterisk/utils.h
team/twilson/config_work/main/config_options.c
team/twilson/config_work/tests/test_config.c
Modified: team/twilson/config_work/apps/app_skel.c
URL: http://svnview.digium.com/svn/asterisk/team/twilson/config_work/apps/app_skel.c?view=diff&rev=367838&r1=367837&r2=367838
==============================================================================
--- team/twilson/config_work/apps/app_skel.c (original)
+++ team/twilson/config_work/apps/app_skel.c Tue May 29 11:37:47 2012
@@ -170,7 +170,7 @@
/*! \brief Allocate a skel_level based on a category in a configuration file
* \param cat The category to base the level on
* \returns A void pointer to a newly allocated skel_level
- */
+ */
static void *skel_level_alloc(const char *cat);
/*! \brief Find a skel level in the specified container
Modified: team/twilson/config_work/include/asterisk/config_options.h
URL: http://svnview.digium.com/svn/asterisk/team/twilson/config_work/include/asterisk/config_options.h?view=diff&rev=367838&r1=367837&r2=367838
==============================================================================
--- team/twilson/config_work/include/asterisk/config_options.h (original)
+++ team/twilson/config_work/include/asterisk/config_options.h Tue May 29 11:37:47 2012
@@ -82,7 +82,7 @@
* \retval 0 succes, continue processing
* \retval non-zero failure, stop processing
*/
-typedef int (*aco_type_post_item_init)(void *newitem);
+typedef int (*aco_type_item_pre_process)(void *newitem);
/*! \brief Callback function that is called after config processing, but before linking
*
@@ -119,7 +119,7 @@
/* non-global callbacks */
aco_type_item_alloc item_alloc; /*!< An allocation function for item associated with this type */
aco_type_item_find item_find; /*!< A callback function to find an existing item in a particular container */
- aco_type_post_item_init item_post_init; /*!< An optional callback function that is called after defaults are applied, but before config processing */
+ aco_type_item_pre_process item_pre_process; /*!< An optional callback function that is called after defaults are applied, but before config processing */
aco_type_prelink item_prelink; /*!< An optional callback function that is called after config processing, but before applying changes */
struct aco_type_internal *internal;
};
Modified: team/twilson/config_work/include/asterisk/stringfields.h
URL: http://svnview.digium.com/svn/asterisk/team/twilson/config_work/include/asterisk/stringfields.h?view=diff&rev=367838&r1=367837&r2=367838
==============================================================================
--- team/twilson/config_work/include/asterisk/stringfields.h (original)
+++ team/twilson/config_work/include/asterisk/stringfields.h Tue May 29 11:37:47 2012
@@ -310,7 +310,7 @@
\brief Set a field to a simple string value
\param x Pointer to a structure containing fields
\param ptr Pointer to a field within the structure
- \param data String value to be copied into the field
+ \param data String value to be copied into the field
\return nothing
*/
#define ast_string_field_ptr_set(x, ptr, data) ast_string_field_ptr_set_by_fields((x)->__field_mgr_pool, (x)->__field_mgr, ptr, data)
Modified: team/twilson/config_work/include/asterisk/utils.h
URL: http://svnview.digium.com/svn/asterisk/team/twilson/config_work/include/asterisk/utils.h?view=diff&rev=367838&r1=367837&r2=367838
==============================================================================
--- team/twilson/config_work/include/asterisk/utils.h (original)
+++ team/twilson/config_work/include/asterisk/utils.h Tue May 29 11:37:47 2012
@@ -868,7 +868,7 @@
* \param varname The name of the variable
* \param initval The initial value of the variable
* \param dtor The destructor function of type' void func(vartype *)'
- *
+ *
* \code
* void mything_cleanup(struct mything *t)
* {
Modified: team/twilson/config_work/main/config_options.c
URL: http://svnview.digium.com/svn/asterisk/team/twilson/config_work/main/config_options.c?view=diff&rev=367838&r1=367837&r2=367838
==============================================================================
--- team/twilson/config_work/main/config_options.c (original)
+++ team/twilson/config_work/main/config_options.c Tue May 29 11:37:47 2012
@@ -338,10 +338,8 @@
}
}
- /* XXX Should we only call the post_init after the initial default setting, or allow each
- * type to do a pre-process step? Right now, going with allowing each type. */
- if (type->item_post_init && type->item_post_init(new_item)) {
- ast_log(LOG_ERROR, "In %s: Post-init callback for %s failed\n", file->filename, cat);
+ if (type->item_pre_process && type->item_pre_process(new_item)) {
+ ast_log(LOG_ERROR, "In %s: Preprocess callback for %s failed\n", file->filename, cat);
return -1;
}
Modified: team/twilson/config_work/tests/test_config.c
URL: http://svnview.digium.com/svn/asterisk/team/twilson/config_work/tests/test_config.c?view=diff&rev=367838&r1=367837&r2=367838
==============================================================================
--- team/twilson/config_work/tests/test_config.c (original)
+++ team/twilson/config_work/tests/test_config.c Tue May 29 11:37:47 2012
@@ -368,10 +368,9 @@
ao2_cleanup(cfg);
return NULL;
}
-static int test_item_exists(struct ao2_container *container, const char *cat)
-{
- RAII_VAR(struct test_item *, item, ao2_find(container, cat, OBJ_KEY), ao2_cleanup);
- return item ? 1 : 0;
+static void *test_item_find(struct ao2_container *container, const char *cat)
+{
+ return ao2_find(container, cat, OBJ_KEY);
}
static int customopt_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
@@ -403,12 +402,18 @@
.category_match = ACO_BLACKLIST,
.category = "^(global|global_defaults)$",
.item_alloc = test_item_alloc,
- .item_exists = test_item_exists,
+ .item_find = test_item_find,
.item_offset = offsetof(struct test_config, items),
};
+
+struct aco_file config_test_conf = {
+ .filename = "config_test.conf",
+ .types = ACO_TYPES(&global, &global_defaults, &item),
+};
+
static AO2_GLOBAL_OBJ_STATIC(global_obj);
-CONFIG_INFO_STANDARD(cfg_info, "config_test.conf", global_obj, test_config_alloc,
- .types = ACO_TYPES(&global, &global_defaults, &item),
+CONFIG_INFO_STANDARD(cfg_info, global_obj, test_config_alloc,
+ .files = ACO_FILES(&config_test_conf),
);
AST_TEST_DEFINE(config_options_test)
@@ -424,7 +429,7 @@
switch (cmd) {
case TEST_INIT:
info->name = "config_options_test";
- info->category = "/main/config/";
+ info->category = "/config/";
info->summary = "Config opptions unit test";
info->description =
"Tests the Config Options API";
@@ -459,18 +464,16 @@
}
/* Register all options */
- for (x = 0; x < 3; x++) {
- aco_option_register(&cfg_info, "intopt", cfg_info.types[x], INT_DEFAULT, OPT_INT_T, 0, FLDSET(struct test_item, intopt));
- aco_option_register(&cfg_info, "uintopt", cfg_info.types[x], UINT_DEFAULT, OPT_UINT_T, 0, FLDSET(struct test_item, uintopt));
- aco_option_register(&cfg_info, "doubleopt", cfg_info.types[x], DOUBLE_DEFAULT, OPT_DOUBLE_T, 0, FLDSET(struct test_item, doubleopt));
- aco_option_register(&cfg_info, "sockaddropt", cfg_info.types[x], SOCKADDR_DEFAULT, OPT_SOCKADDR_T, 0, FLDSET(struct test_item, sockaddropt));
- aco_option_register(&cfg_info, "boolopt", cfg_info.types[x], BOOL_DEFAULT, OPT_BOOL_T, 1, FLDSET(struct test_item, boolopt));
- aco_option_register(&cfg_info, "aclpermitopt", cfg_info.types[x], ACL_DEFAULT, OPT_ACL_T, 1, FLDSET(struct test_item, aclopt), "permit");
- aco_option_register(&cfg_info, "acldenyopt", cfg_info.types[x], ACL_DEFAULT, OPT_ACL_T, 0, FLDSET(struct test_item, aclopt), "deny");
- aco_option_register(&cfg_info, "codecopt", cfg_info.types[x], CODEC_DEFAULT, OPT_CODEC_T, 1, FLDSET(struct test_item, codecprefopt, codeccapopt));
- aco_option_register(&cfg_info, "stropt", cfg_info.types[x], STR_DEFAULT, OPT_STRINGFIELD_T, 0, STRFLDSET(struct test_item, stropt));
- aco_option_register_custom(&cfg_info, "customopt", cfg_info.types[x], CUSTOM_DEFAULT, customopt_handler, 0);
- }
+ aco_option_register(&cfg_info, "intopt", ACO_EXACT, config_test_conf.types, INT_DEFAULT, OPT_INT_T, 0, FLDSET(struct test_item, intopt));
+ aco_option_register(&cfg_info, "uintopt", ACO_EXACT, config_test_conf.types, UINT_DEFAULT, OPT_UINT_T, 0, FLDSET(struct test_item, uintopt));
+ aco_option_register(&cfg_info, "doubleopt", ACO_EXACT, config_test_conf.types, DOUBLE_DEFAULT, OPT_DOUBLE_T, 0, FLDSET(struct test_item, doubleopt));
+ aco_option_register(&cfg_info, "sockaddropt", ACO_EXACT, config_test_conf.types, SOCKADDR_DEFAULT, OPT_SOCKADDR_T, 0, FLDSET(struct test_item, sockaddropt));
+ aco_option_register(&cfg_info, "boolopt", ACO_EXACT, config_test_conf.types, BOOL_DEFAULT, OPT_BOOL_T, 1, FLDSET(struct test_item, boolopt));
+ aco_option_register(&cfg_info, "aclpermitopt", ACO_EXACT, config_test_conf.types, ACL_DEFAULT, OPT_ACL_T, 1, FLDSET(struct test_item, aclopt), "permit");
+ aco_option_register(&cfg_info, "acldenyopt", ACO_EXACT, config_test_conf.types, ACL_DEFAULT, OPT_ACL_T, 0, FLDSET(struct test_item, aclopt), "deny");
+ aco_option_register(&cfg_info, "codecopt", ACO_EXACT, config_test_conf.types, CODEC_DEFAULT, OPT_CODEC_T, 1, FLDSET(struct test_item, codecprefopt, codeccapopt));
+ aco_option_register(&cfg_info, "stropt", ACO_EXACT, config_test_conf.types, STR_DEFAULT, OPT_STRINGFIELD_T, 0, STRFLDSET(struct test_item, stropt));
+ aco_option_register_custom(&cfg_info, "customopt", ACO_EXACT, config_test_conf.types, CUSTOM_DEFAULT, customopt_handler, 0);
if (aco_process_config(&cfg_info, 0)) {
ast_test_status_update(test, "Could not parse config\n");
More information about the asterisk-commits
mailing list