summaryrefslogtreecommitdiff
path: root/main/sorcery.c
diff options
context:
space:
mode:
authorMark Michelson <mmichelson@digium.com>2014-03-17 19:35:17 +0000
committerMark Michelson <mmichelson@digium.com>2014-03-17 19:35:17 +0000
commiteba91d2a98ac5a6558513549670162ab20ab6d68 (patch)
tree82010a695584ef98e0ea29d87cec74b61c1c8956 /main/sorcery.c
parentd44aefeef476d744f2915d47c3fdc9b138cdd584 (diff)
Revert changes to sorcery that accidentally got committed.
These changes were still up for review and have not been approved yet. I must have had the changes in my working copy when making a different change. ........ Merged revisions 410696 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@410699 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/sorcery.c')
-rw-r--r--main/sorcery.c47
1 files changed, 13 insertions, 34 deletions
diff --git a/main/sorcery.c b/main/sorcery.c
index 94a11103b..2ab4933be 100644
--- a/main/sorcery.c
+++ b/main/sorcery.c
@@ -580,14 +580,6 @@ struct ast_sorcery *__ast_sorcery_open(const char *module_name)
}
strcpy(sorcery->module_name, module_name); /* Safe */
-
- if (__ast_sorcery_apply_config(sorcery, module_name, module_name) == AST_SORCERY_APPLY_FAIL) {
- ast_log(LOG_ERROR, "Error attempting to apply configuration %s to sorcery.", module_name);
- ao2_cleanup(sorcery);
- sorcery = NULL;
- goto done;
- }
-
ao2_link_flags(instances, sorcery, OBJ_NOLOCK);
done:
@@ -631,7 +623,7 @@ static struct ast_sorcery_object_type *sorcery_object_type_alloc(const char *typ
}
/* Order matters for object wizards */
- if (!(object_type->wizards = ao2_container_alloc_options(AO2_ALLOC_OPT_LOCK_NOLOCK, 1, NULL, sorcery_wizard_cmp))) {
+ if (!(object_type->wizards = ao2_container_alloc_options(AO2_ALLOC_OPT_LOCK_NOLOCK, 1, NULL, NULL))) {
ao2_ref(object_type, -1);
return NULL;
}
@@ -691,8 +683,7 @@ static void sorcery_object_wizard_destructor(void *obj)
}
/*! \brief Internal function which creates an object type and adds a wizard mapping */
-static enum ast_sorcery_apply_result sorcery_apply_wizard_mapping(struct ast_sorcery *sorcery,
- const char *type, const char *module, const char *name, const char *data, unsigned int caching)
+static int sorcery_apply_wizard_mapping(struct ast_sorcery *sorcery, const char *type, const char *module, const char *name, const char *data, unsigned int caching)
{
RAII_VAR(struct ast_sorcery_object_type *, object_type, ao2_find(sorcery->types, type, OBJ_KEY), ao2_cleanup);
RAII_VAR(struct ast_sorcery_wizard *, wizard, ao2_find(wizards, name, OBJ_KEY), ao2_cleanup);
@@ -700,30 +691,18 @@ static enum ast_sorcery_apply_result sorcery_apply_wizard_mapping(struct ast_sor
int created = 0;
if (!wizard || !object_wizard) {
- return AST_SORCERY_APPLY_FAIL;
+ return -1;
}
if (!object_type) {
if (!(object_type = sorcery_object_type_alloc(type, module))) {
- return AST_SORCERY_APPLY_FAIL;
+ return -1;
}
created = 1;
}
- if (!created) {
- struct ast_sorcery_wizard *found;
-
- found = ao2_find(object_type->wizards, wizard, OBJ_SEARCH_OBJECT);
- if (found) {
- ast_debug(1, "Wizard %s already applied to object type %s\n",
- wizard->name, object_type->name);
- ao2_cleanup(found);
- return AST_SORCERY_APPLY_DUPLICATE;
- }
- }
-
if (wizard->open && !(object_wizard->data = wizard->open(data))) {
- return AST_SORCERY_APPLY_FAIL;
+ return -1;
}
ast_module_ref(wizard->module);
@@ -737,18 +716,18 @@ static enum ast_sorcery_apply_result sorcery_apply_wizard_mapping(struct ast_sor
ao2_link(sorcery->types, object_type);
}
- return AST_SORCERY_APPLY_SUCCESS;
+ return 0;
}
-enum ast_sorcery_apply_result __ast_sorcery_apply_config(struct ast_sorcery *sorcery, const char *name, const char *module)
+int __ast_sorcery_apply_config(struct ast_sorcery *sorcery, const char *name, const char *module)
{
struct ast_flags flags = { 0 };
struct ast_config *config = ast_config_load2("sorcery.conf", "sorcery", flags);
struct ast_variable *mapping;
- int res = AST_SORCERY_APPLY_SUCCESS;
+ int res = 0;
if (!config || config == CONFIG_STATUS_FILEINVALID) {
- return AST_SORCERY_APPLY_FAIL;
+ return -1;
}
for (mapping = ast_variable_browse(config, name); mapping; mapping = mapping->next) {
@@ -771,8 +750,8 @@ enum ast_sorcery_apply_result __ast_sorcery_apply_config(struct ast_sorcery *so
}
/* Any error immediately causes us to stop */
- if (sorcery_apply_wizard_mapping(sorcery, type, module, wizard, data, caching) == AST_SORCERY_APPLY_FAIL) {
- res = AST_SORCERY_APPLY_FAIL;
+ if (sorcery_apply_wizard_mapping(sorcery, type, module, wizard, data, caching)) {
+ res = -1;
break;
}
}
@@ -782,13 +761,13 @@ enum ast_sorcery_apply_result __ast_sorcery_apply_config(struct ast_sorcery *so
return res;
}
-enum ast_sorcery_apply_result __ast_sorcery_apply_default(struct ast_sorcery *sorcery, const char *type, const char *module, const char *name, const char *data)
+int __ast_sorcery_apply_default(struct ast_sorcery *sorcery, const char *type, const char *module, const char *name, const char *data)
{
RAII_VAR(struct ast_sorcery_object_type *, object_type, ao2_find(sorcery->types, type, OBJ_KEY), ao2_cleanup);
/* Defaults can not be added if any existing mapping exists */
if (object_type) {
- return AST_SORCERY_APPLY_DEFAULT_UNNECESSARY;
+ return -1;
}
return sorcery_apply_wizard_mapping(sorcery, type, module, name, data, 0);