[asterisk-commits] twilson: branch twilson/config_work r365710 - in /team/twilson/config_work: a...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue May 8 16:06:14 CDT 2012
Author: twilson
Date: Tue May 8 16:06:10 2012
New Revision: 365710
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=365710
Log:
Standardize on "category" instead of "context"
Also, convert CONTEXT_ALLOW/DENY into ACO_WHITELIST/BLACKLIST
Modified:
team/twilson/config_work/apps/app_skel.c
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/apps/app_skel.c
URL: http://svnview.digium.com/svn/asterisk/team/twilson/config_work/apps/app_skel.c?view=diff&rev=365710&r1=365709&r2=365710
==============================================================================
--- team/twilson/config_work/apps/app_skel.c (original)
+++ team/twilson/config_work/apps/app_skel.c Tue May 8 16:06:10 2012
@@ -501,11 +501,11 @@
goto error;
}
- if (!(global_type = aco_type_global_alloc("global", CONTEXT_ALLOW, "general", (aco_type_alloc) skel_global_alloc))) {
+ if (!(global_type = aco_type_global_alloc("global", ACO_WHITELIST, "general", (aco_type_alloc) skel_global_alloc))) {
goto error;
}
- if (!(priv_type = aco_type_private_alloc("private", CONTEXT_DENY, "general", NULL, NULL, (aco_type_alloc) skel_pvt_cfg_alloc, skel_containers_alloc, skel_find_or_create_pvt, skel_find_pvt, NULL, NULL))) {
+ if (!(priv_type = aco_type_private_alloc("private", ACO_BLACKLIST, "general", NULL, NULL, (aco_type_alloc) skel_pvt_cfg_alloc, skel_containers_alloc, skel_find_or_create_pvt, skel_find_pvt, NULL, NULL))) {
goto error;
}
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=365710&r1=365709&r2=365710
==============================================================================
--- team/twilson/config_work/include/asterisk/config_options.h (original)
+++ team/twilson/config_work/include/asterisk/config_options.h Tue May 8 16:06:10 2012
@@ -41,10 +41,10 @@
PRIVATE_OBJ,
};
-/*! \brief Whether a context regex is a blackist or a whitelist */
-enum aco_context_op {
- CONTEXT_DENY = 0,
- CONTEXT_ALLOW,
+/*! \brief Whether a category regex is a blackist or a whitelist */
+enum aco_category_op {
+ ACO_BLACKLIST = 0,
+ ACO_WHITELIST,
};
/* Callback functions for option parsing via aco_process_config() */
@@ -65,19 +65,19 @@
typedef int (*aco_type_containers_alloc)(struct ao2_container **newpvts, struct ao2_container **newcfgs);
/*! \brief Find an existing private or create a new one
- * \param context The context associated with the private
+ * \param category The category associated with the private
* \retval NULL error
* \retval non-NULL a referenced ao2 private object
*/
-typedef void *(*aco_type_find_or_create_pvt)(const char *context);
-
-/*! \brief Find a private given a context and container of privates
+typedef void *(*aco_type_find_or_create_pvt)(const char *category);
+
+/*! \brief Find a private given a category and container of privates
* \param container The container to search for the private
- * \param context The context associated with the private
+ * \param category The category associated with the private
* \retval NULL error
* \retval non-NULL a referenced ao2 private object
*/
-typedef void *(*aco_type_find_pvt)(struct ao2_container *newcontainer, const char *context);
+typedef void *(*aco_type_find_pvt)(struct ao2_container *newcontainer, const char *category);
/*! \brief Callback function that is called after a config object is initialized with defaults
*
@@ -121,14 +121,14 @@
* are unique and not linked in a container
*
* \param name A unique identifier for this type
- * \param op Whether the following context regex is a whitelist or blacklist
- * \param context A regular expression for matching contexts to be allowed or denied
+ * \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, enum aco_context_op op, const char *context, aco_type_alloc alloc);
+struct aco_type *aco_type_global_alloc(const char *name, enum aco_category_op op, const char *category, aco_type_alloc alloc);
/*! \brief Allocate a global config type
*
@@ -136,8 +136,8 @@
* are defined multiple times and stored in an ao2 container.
*
* \param name A unique identifier for this type
- * \param op Whether the following context regex is a whitelist or blacklist
- * \param context A regular expression for matching contexts to be allowed or denied
+ * \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
@@ -150,7 +150,7 @@
* \retval NULL error
* \retval non-NULL A new private aco_type handle
*/
-struct aco_type *aco_type_private_alloc(const char *name, enum aco_context_op op, const char *context, const char *matchfield, const char *matchvalue,
+struct aco_type *aco_type_private_alloc(const char *name, 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);
@@ -288,14 +288,14 @@
/*! \brief Allocate a container to hold config options */
struct ao2_container *aco_option_container_alloc(void);
-/*! \brief Find a config option that can handle the option \a name in \a context
+/*! \brief Find a config option that can handle the option \a name in \a category
* \param container The container of options to search
* \param name The field name of the option
- * \param context The context of the option
+ * \param category The category of the option
*
* \returns An option or NULL on error
*/
-struct aco_option *aco_option_find(struct ao2_container *container, const char *name, const char *context);
+struct aco_option *aco_option_find(struct ao2_container *container, const char *name, const char *category);
/*! \brief Completely handle simple configs
*
@@ -313,7 +313,7 @@
*/
int aco_process_config(struct aco_info *info, int reload);
-/*! \brief Parse each option defined in a config context
+/*! \brief Parse each option defined in a config category
* \param container The container of options from which to configure \a obj
* \param cfg The ast_config being parsed
* \param cat The config category being parsed
@@ -326,13 +326,13 @@
/*! \brief Set all default options of \a obj
* \param container The container of options from which to apply defaults
- * \param context The configuration context from which \a obj is being configured
+ * \param category The configuration category from which \a obj is being configured
* \param obj The object being configured
*
* \retval 0 Success
* \retval -1 Failure
*/
-int aco_set_defaults(struct ao2_container *container, const char *context, void *obj);
+int aco_set_defaults(struct ao2_container *container, const char *category, void *obj);
/*! \brief build a config option
*
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=365710&r1=365709&r2=365710
==============================================================================
--- team/twilson/config_work/main/config_options.c (original)
+++ team/twilson/config_work/main/config_options.c Tue May 8 16:06:10 2012
@@ -46,11 +46,11 @@
/* common stuff */
enum aco_type_t type;
const char *name;
- const char *context;
+ const char *category;
const char *matchfield;
const char *matchvalue;
regex_t *regex;
- enum aco_context_op context_allow;
+ enum aco_category_op category_allow;
aco_type_alloc cfg_alloc;
/* non-global callbacks */
@@ -73,7 +73,7 @@
const char *default_val;
struct aco_type *obj;
enum aco_option_type type;
- enum aco_context_op context_allow;
+ enum aco_category_op category_allow;
aco_option_handler handler;
unsigned int flags;
size_t argc;
@@ -115,7 +115,7 @@
return NULL;
}
-static regex_t *build_context_regex(const char *text)
+static regex_t *build_category_regex(const char *text)
{
int res;
regex_t *regex;
@@ -197,10 +197,10 @@
static int find_option_cb(void *obj, void *arg, void *data, int flags)
{
- const char *name = arg, *context = data;
+ const char *name = arg, *category = data;
struct aco_option *match = obj;
/* Continue if we don't match on name, or if NOT (regex_matches XOR regex_should_match) */
- return strcasecmp(name, match->name) || !regexec(match->obj->regex, context, 0, NULL, 0) == !match->obj->context_allow ? 0 : CMP_MATCH | CMP_STOP;
+ return strcasecmp(name, match->name) || !regexec(match->obj->regex, category, 0, NULL, 0) == !match->obj->category_allow ? 0 : CMP_MATCH | CMP_STOP;
}
struct aco_option *aco_option_find(struct ao2_container *container, const char *name, const char *cat)
@@ -264,21 +264,21 @@
return 0;
}
-static int type_context_cmp(void *obj, void *arg, void *data, int flags)
+static int type_category_cmp(void *obj, void *arg, void *data, int flags)
{
struct aco_type *match = obj;
- const char *context = arg;
+ const char *category = arg;
struct ast_config *cfg = data;
const char *val;
- /* First make sure we are an object that can service this context */
- if (!regexec(match->regex, context, 0, NULL, 0) == !match->context_allow) {
+ /* First make sure we are an object that can service this category */
+ if (!regexec(match->regex, category, 0, NULL, 0) == !match->category_allow) {
return 0;
}
/* Then, see if we need to match a particular field */
if (!ast_strlen_zero(match->matchfield) && !ast_strlen_zero(match->matchvalue)) {
- if (!(val = ast_variable_retrieve(cfg, context, match->matchfield))) {
+ if (!(val = ast_variable_retrieve(cfg, category, match->matchfield))) {
ast_log(LOG_ERROR, "Required match field '%s' not found\n", match->matchfield);
return CMP_STOP;
}
@@ -290,9 +290,9 @@
return CMP_MATCH | CMP_STOP;
}
-static struct aco_type *internal_aco_type_find(struct ao2_container *container, struct ast_config *cfg, const char *context)
-{
- return ao2_callback_data(container, 0, type_context_cmp, (void *) context, (void *) cfg);
+static struct aco_type *internal_aco_type_find(struct ao2_container *container, struct ast_config *cfg, const char *category)
+{
+ return ao2_callback_data(container, 0, type_category_cmp, (void *) category, (void *) cfg);
}
static int is_preload(struct aco_info *info, const char *cat)
@@ -321,7 +321,7 @@
return 0;
}
- /* Find config object by context, if not found it is an error */
+ /* Find config object by category, if not found it is an error */
if (!(obj = internal_aco_type_find(info->objs, cfg, cat))) {
ast_log(LOG_ERROR, "Could not find config type for category '%s' in '%s'\n", cat, info->filename);
return -1;
@@ -500,22 +500,22 @@
}
}
-/*! \brief match for anything where the context passes (or fails if !context_allow) the context regex
+/*! \brief match for anything where the category passes (or fails if !category_allow) the category regex
*/
-static int match_option_by_context(void *obj, void *arg, int flags)
+static int match_option_by_category(void *obj, void *arg, int flags)
{
struct aco_option *match = obj;
- const char *context = arg;
-
- return !regexec(match->obj->regex, context, 0, NULL, 0) == !match->obj->context_allow ? 0 : CMP_MATCH;
-}
-
-int aco_set_defaults(struct ao2_container *container, const char *context, void *obj)
+ const char *category = arg;
+
+ return !regexec(match->obj->regex, category, 0, NULL, 0) == !match->obj->category_allow ? 0 : CMP_MATCH;
+}
+
+int aco_set_defaults(struct ao2_container *container, const char *category, void *obj)
{
RAII_VAR(struct ao2_iterator *, iter, NULL, ao2_iterator_cleanup);
struct aco_option *opt;
- if (!(iter = ao2_callback(container, OBJ_MULTIPLE, match_option_by_context, (void *) context))) {
+ if (!(iter = ao2_callback(container, OBJ_MULTIPLE, match_option_by_category, (void *) category))) {
return -1;
}
@@ -532,7 +532,7 @@
}
if (opt->handler(opt, var, obj)) {
ao2_ref(opt, -1);
- ast_log(LOG_NOTICE, "Unable to set default for %s, %s=%s\n", context, var->name, var->value);
+ ast_log(LOG_NOTICE, "Unable to set default for %s, %s=%s\n", category, var->name, var->value);
return -1;
}
ao2_ref(opt, -1);
@@ -570,7 +570,7 @@
return;
}
-struct aco_type *aco_type_global_alloc(const char *name, enum aco_context_op op, const char *context, aco_type_alloc alloc)
+struct aco_type *aco_type_global_alloc(const char *name, enum aco_category_op op, const char *category, aco_type_alloc alloc)
{
struct aco_type *obj;
@@ -578,21 +578,21 @@
return NULL;
}
- if (!(obj->regex = build_context_regex(context))) {
+ if (!(obj->regex = build_category_regex(category))) {
ao2_ref(obj, -1);
return NULL;
}
obj->type = GLOBAL_OBJ;
obj->name = name;
- obj->context_allow = op;
+ obj->category_allow = op;
obj->cfg_alloc = alloc;
- obj->context = context;
+ obj->category = category;
return obj;
}
-struct aco_type *aco_type_private_alloc(const char *name, enum aco_context_op op, const char *context, const char *matchfield, const char *matchvalue,
+struct aco_type *aco_type_private_alloc(const char *name, 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)
{
@@ -602,16 +602,16 @@
return NULL;
}
- if (!(obj->regex = build_context_regex(context))) {
+ if (!(obj->regex = build_category_regex(category))) {
ao2_ref(obj, -1);
return NULL;
}
obj->type = PRIVATE_OBJ;
obj->name = name;
- obj->context_allow = op;
+ obj->category_allow = op;
obj->cfg_alloc = alloc;
- obj->context = context;
+ obj->category = category;
obj->matchfield = matchfield;
obj->matchvalue = matchvalue;
obj->containers_alloc = containers_alloc;
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=365710&r1=365709&r2=365710
==============================================================================
--- team/twilson/config_work/main/udptl.c (original)
+++ team/twilson/config_work/main/udptl.c Tue May 8 16:06:10 2012
@@ -1454,7 +1454,7 @@
return;
}
- if (!(global_type = aco_type_global_alloc("global", CONTEXT_ALLOW, "general", udptl_cfg_alloc))) {
+ if (!(global_type = aco_type_global_alloc("global", ACO_WHITELIST, "general", udptl_cfg_alloc))) {
aco_info_destroy(&cfg_info);
return;
}
More information about the asterisk-commits
mailing list