[asterisk-commits] twilson: branch twilson/config_work r366050 - in /team/twilson/config_work: i...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu May 10 10:49:28 CDT 2012
Author: twilson
Date: Thu May 10 10:49:24 2012
New Revision: 366050
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=366050
Log:
More cleanup
Remove aco_type_*_alloc, convert udptl to using static stack-allocated type
Modified:
team/twilson/config_work/include/asterisk/config_options.h
team/twilson/config_work/main/config_options.c
team/twilson/config_work/main/udptl.c
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=366050&r1=366049&r2=366050
==============================================================================
--- team/twilson/config_work/include/asterisk/config_options.h (original)
+++ team/twilson/config_work/include/asterisk/config_options.h Thu May 10 10:49:24 2012
@@ -111,26 +111,25 @@
*/
struct aco_type {
/* common stuff */
- enum aco_type_t type;
+ enum aco_type_t type; /*!< Whether this is a global or private type */
const char *name;
- const char *category;
- const char *matchfield;
- const char *matchvalue;
+ const char *category; /*!< A regular expression for matching categories to be allowed or denied */
+ const char *matchfield; /*!< An option name to match for this type (i.e. a 'type'-like column) */
+ const char *matchvalue; /*!< The value of the option to require for matching (i.e. 'peer' for type= in sip.conf) */
regex_t *regex;
- enum aco_category_op category_allow;
- size_t global_index;
- size_t pvt_index;
- size_t cfg_index;
- aco_type_alloc cfg_alloc;
+ enum aco_category_op category_allow; /*!< Whether the following category regex is a whitelist or blacklist */
+ size_t global_index; /*!< The index in the global object array for the global config */
+ size_t pvt_index; /*!< The index in the global object array for the private container */
+ size_t cfg_index; /*!< The index in the global object array for the private config container */
+ aco_type_alloc cfg_alloc; /*!< An allocation function for ao2 object associated with this type */
/* non-global callbacks */
- aco_type_containers_alloc containers_alloc; /* required. cfgs required, pvts if non-config-related state */
- aco_type_find_or_create_pvt find_or_create_pvt; /* required if there is non-config-related state */
- aco_type_find_pvt find_pvt; /* required if there is non-config-related state */
- aco_type_post_cfg_init post_cfg_init; /*!< Filter global options done if necessary */
- aco_type_prelink prelink; /* optional, can be used to do additional checks on a config */
+ aco_type_containers_alloc containers_alloc; /*!< A callback function for allocating containers for a config object and its associated private */
+ aco_type_find_or_create_pvt find_or_create_pvt; /*!< A callback function to find an existing private, or create a new one if it doesn't exist */
+ aco_type_find_pvt find_pvt; /*!< A callback function to find an existing private in a particular container */
+ aco_type_post_cfg_init post_cfg_init; /*!< An optional callback function that is called after defaults are applied, but before config processing */
+ aco_type_prelink prelink; /*!< An optional callback function that is called after config processing, but before applying changes */
};
-
/*! \brief Allocate a container for aco_types
*
@@ -142,48 +141,6 @@
* \retval non-NULL a new ao2 container for storing aco_type objects
*/
struct ao2_container *aco_type_container_alloc(void);
-
-/*! \brief Allocate a global config type
- *
- * \note Use this to allocate global config types. These types are for configs that
- * are unique and not linked in a container
- *
- * \param name A unique identifier for this type
- * \param global_index The index in the global object array for the global config
- * \param op Whether the following category regex is a whitelist or blacklist
- * \param category A regular expression for matching categories to be allowed or denied
- * \param alloc An allocation function for ao2 object associated with this type
- *
- * \retval NULL error
- * \retval non-NULL A new global aco_type handle
- */
-struct aco_type *aco_type_global_alloc(const char *name, size_t global_index, enum aco_category_op op, const char *category, aco_type_alloc alloc);
-
-/*! \brief Allocate a private config type
- *
- * \note Use this to allocate private config types. These types are for configs that
- * are defined multiple times and stored in an ao2 container.
- *
- * \param name A unique identifier for this type
- * \param pvt_index The index in the global object array for the private container
- * \param cfg_index The index in the global object array for the private config container
- * \param op Whether the following category regex is a whitelist or blacklist
- * \param category A regular expression for matching categories to be allowed or denied
- * \param matchfield An option name to match for this type (i.e. a 'type'-like column)
- * \param matchvalue The value of the option to require for matching (i.e. 'peer' for type= in sip.conf)
- * \param alloc An allocation function for ao2 object associated with this type
- * \param containers_alloc A callback function for allocating both a config object and its associated private
- * \param find_or_create_pvt A callback function to find an existing private, or create a new one if it doesn't exist
- * \param find_pvt A callback function to find an existing private in a particular container
- * \param post_cfg_init An optional callback function that is called after defaults are applied, but before config processing
- * \param prelink An optional callback function that is called after config processing, but before applying changes
- *
- * \retval NULL error
- * \retval non-NULL A new private aco_type handle
- */
-struct aco_type *aco_type_private_alloc(const char *name, size_t pvt_index, size_t cfg_index, enum aco_category_op op, const char *category, const char *matchfield, const char *matchvalue,
- aco_type_alloc alloc, aco_type_containers_alloc containers_alloc, aco_type_find_or_create_pvt find_or_create_pvt,
- aco_type_find_pvt find_pvt, aco_type_post_cfg_init post_cfg_init, aco_type_prelink prelink);
/*! \brief A callback function for applying the config changes
* \retval 0 Success
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=366050&r1=366049&r2=366050
==============================================================================
--- team/twilson/config_work/main/config_options.c (original)
+++ team/twilson/config_work/main/config_options.c Thu May 10 10:49:24 2012
@@ -564,29 +564,6 @@
return;
}
-struct aco_type *aco_type_global_alloc(const char *name, size_t global_index, enum aco_category_op op, const char *category, aco_type_alloc alloc)
-{
- struct aco_type *obj;
-
- if (!(obj = ao2_alloc(sizeof(*obj), config_obj_destructor))) {
- return NULL;
- }
-
- if (!(obj->regex = build_category_regex(category))) {
- ao2_ref(obj, -1);
- return NULL;
- }
-
- obj->type = GLOBAL_OBJ;
- obj->name = name;
- obj->global_index = global_index;
- obj->category_allow = op;
- obj->cfg_alloc = alloc;
- obj->category = category;
-
- return obj;
-}
-
struct aco_type *aco_type_object(struct aco_type *type)
{
struct aco_type *obj;
@@ -599,39 +576,6 @@
ao2_ref(obj, -1);
return NULL;
}
- return obj;
-}
-
-struct aco_type *aco_type_private_alloc(const char *name, size_t pvt_index, size_t cfg_index, enum aco_category_op op, const char *category, const char *matchfield, const char *matchvalue,
- aco_type_alloc alloc, aco_type_containers_alloc containers_alloc, aco_type_find_or_create_pvt find_or_create_pvt,
- aco_type_find_pvt find_pvt, aco_type_post_cfg_init post_cfg_init, aco_type_prelink prelink)
-{
- struct aco_type *obj;
-
- if (!(obj = ao2_alloc(sizeof(*obj), config_obj_destructor))) {
- return NULL;
- }
-
- if (!(obj->regex = build_category_regex(category))) {
- ao2_ref(obj, -1);
- return NULL;
- }
-
- obj->type = PRIVATE_OBJ;
- obj->name = name;
- obj->pvt_index = pvt_index;
- obj->cfg_index = cfg_index;
- obj->category_allow = op;
- obj->cfg_alloc = alloc;
- obj->category = category;
- obj->matchfield = matchfield;
- obj->matchvalue = matchvalue;
- obj->containers_alloc = containers_alloc;
- obj->find_or_create_pvt = find_or_create_pvt;
- obj->find_pvt = find_pvt;
- obj->post_cfg_init = post_cfg_init;
- obj->prelink = prelink;
-
return obj;
}
Modified: team/twilson/config_work/main/udptl.c
URL: http://svnview.digium.com/svn/asterisk/team/twilson/config_work/main/udptl.c?view=diff&rev=366050&r1=366049&r2=366050
==============================================================================
--- team/twilson/config_work/main/udptl.c (original)
+++ team/twilson/config_work/main/udptl.c Thu May 10 10:49:24 2012
@@ -1443,6 +1443,15 @@
return 0;
}
+static struct aco_type general_options = {
+ .type = GLOBAL_OBJ,
+ .name = "global",
+ .global_index = UDPTL_GENERAL,
+ .category_allow = ACO_WHITELIST,
+ .category = "general",
+ .cfg_alloc = udptl_cfg_alloc,
+};
+
void ast_udptl_init(void)
{
RAII_VAR(struct aco_type *, global_type, NULL, ao2_cleanup);
@@ -1451,7 +1460,7 @@
return;
}
- if (!(global_type = aco_type_global_alloc("global", UDPTL_GENERAL, ACO_WHITELIST, "general", udptl_cfg_alloc))) {
+ if (!(global_type = aco_type_object(&general_options))) {
aco_info_destroy(&cfg_info);
return;
}
More information about the asterisk-commits
mailing list