[asterisk-commits] russell: branch group/res_config_ldap r63984 -
/team/group/res_config_ldap/res/
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Fri May 11 13:34:20 MST 2007
Author: russell
Date: Fri May 11 15:34:19 2007
New Revision: 63984
URL: http://svn.digium.com/view/asterisk?view=rev&rev=63984
Log:
code cleanup
Modified:
team/group/res_config_ldap/res/res_config_ldap.c
Modified: team/group/res_config_ldap/res/res_config_ldap.c
URL: http://svn.digium.com/view/asterisk/team/group/res_config_ldap/res/res_config_ldap.c?view=diff&rev=63984&r1=63983&r2=63984
==============================================================================
--- team/group/res_config_ldap/res/res_config_ldap.c (original)
+++ team/group/res_config_ldap/res/res_config_ldap.c Fri May 11 15:34:19 2007
@@ -1160,8 +1160,7 @@
char *last_category = NULL;
int last_category_metric = 0;
struct category_and_metric *categories;
- struct ast_variable **p;;
-
+ struct ast_variable **p;
if (!file || !strcasecmp(file, RES_CONFIG_LDAP_CONF)) {
ast_log(LOG_WARNING, "Cannot configure myself.\n");
@@ -1230,30 +1229,31 @@
for (i = 0; i < vars_count; i++) {
if (!strcmp(categories[i].variable_name, "#include")) {
- if (!ast_config_internal_load(categories[i].variable_value, cfg, 0)) {
+ if (!ast_config_internal_load(categories[i].variable_value, cfg, 0))
break;
- return NULL;
- }
- } else {
- if (!last_category || strcmp(last_category, categories[i].name) ||
- last_category_metric != categories[i].metric) {
- cur_cat = ast_category_new(categories[i].name);
- if (!cur_cat)
- break;
- last_category = categories[i].name;
- last_category_metric = categories[i].metric;
- ast_category_append(cfg, cur_cat);
- }
- new_v = ast_variable_new(categories[i].variable_name, categories[i].variable_value);
- ast_variable_append(cur_cat, new_v);
- }
+ continue;
+ }
+
+ if (!last_category || strcmp(last_category, categories[i].name) ||
+ last_category_metric != categories[i].metric) {
+ cur_cat = ast_category_new(categories[i].name);
+ if (!cur_cat)
+ break;
+ last_category = categories[i].name;
+ last_category_metric = categories[i].metric;
+ ast_category_append(cfg, cur_cat);
+ }
+
+ if (!(new_v = ast_variable_new(categories[i].variable_name, categories[i].variable_value)))
+ break;
+
+ ast_variable_append(cur_cat, new_v);
}
free(vars);
free(categories);
return cfg;
-
}
/* \brief Function to update a set of values in ldap
@@ -1264,14 +1264,14 @@
{
int error=0;
LDAPMessage *ldap_entry = NULL;
- LDAPMod ** ldap_mods;
+ LDAPMod **ldap_mods;
const char *newparam = NULL;
const char *newval = NULL;
- char * dn;
- int num_entries=0;
- int i=0;
- int mods_size=0;
- int mod_exists=0;
+ char *dn;
+ int num_entries = 0;
+ int i = 0;
+ int mods_size = 0;
+ int mod_exists = 0;
struct ldap_table_config *table_config = NULL;
char *clean_basedn = NULL;
char *filter = NULL;
@@ -1287,7 +1287,7 @@
if (!attribute || !lookup) {
ast_log(LOG_WARNING,
- "LINE(%d): search parameters are empty.\n",__LINE__);
+ "LINE(%d): search parameters are empty.\n", __LINE__);
return -1;
}
ast_mutex_lock(&ldap_lock);
@@ -1350,9 +1350,9 @@
newval = va_arg(ap, const char *);
mod_exists = 0;
- for(i=0;i<mods_size-1;i++){
- if(ldap_mods[i] != NULL && strcmp(ldap_mods[i]->mod_type, newparam) == 0){
- /* We have the parameter allready, adding the value as a semicolon delimited value */
+ for (i = 0; i < mods_size - 1; i++){
+ if (ldap_mods[i]&& !strcmp(ldap_mods[i]->mod_type, newparam)) {
+ /* We have the parameter allready, adding the value as a semicolon delimited value */
ldap_mods[i]->mod_values[0] = realloc(ldap_mods[i]->mod_values[0], sizeof(char)*( strlen(ldap_mods[i]->mod_values[0]) + strlen(newval) + 2 ));
strcat(ldap_mods[i]->mod_values[0],";");
strcat(ldap_mods[i]->mod_values[0],newval);
More information about the asterisk-commits
mailing list