aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/app_voicemail.c6
-rw-r--r--include/asterisk/config.h3
-rw-r--r--main/config.c65
-rw-r--r--main/manager.c10
4 files changed, 39 insertions, 45 deletions
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 29ecd100a..fe37ec717 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -798,7 +798,7 @@ static void vm_change_password(struct ast_vm_user *vmu, const char *newpassword)
ast_log(LOG_WARNING, "Failed to get category structure.\n");
break;
}
- ast_variable_update(cat, vmu->mailbox, new, NULL);
+ ast_variable_update(cat, vmu->mailbox, new, NULL, 0);
}
}
/* save the results */
@@ -830,7 +830,7 @@ static void vm_change_password(struct ast_vm_user *vmu, const char *newpassword)
break;
}
if (!var)
- ast_variable_update(cat, "vmsecret", new, NULL);
+ ast_variable_update(cat, "vmsecret", new, NULL, 0);
else
ast_variable_append(cat, var);
}
@@ -3842,7 +3842,7 @@ static int vm_forwardoptions(struct ast_channel *chan, struct ast_vm_user *vmu,
*duration += prepend_duration;
msg_cat = ast_category_get(msg_cfg, "message");
snprintf(duration_str, 11, "%ld", *duration);
- if (!ast_variable_update(msg_cat, "duration", duration_str, NULL)) {
+ if (!ast_variable_update(msg_cat, "duration", duration_str, NULL, 0)) {
config_text_file_save(textfile, msg_cfg, "app_voicemail");
STORE(curdir, vmu->mailbox, context, curmsg, chan, vmu, vmfmts, *duration, vms);
}
diff --git a/include/asterisk/config.h b/include/asterisk/config.h
index a16de0b53..88833d603 100644
--- a/include/asterisk/config.h
+++ b/include/asterisk/config.h
@@ -184,7 +184,8 @@ void ast_category_rename(struct ast_category *cat, const char *name);
struct ast_variable *ast_variable_new(const char *name, const char *value);
void ast_variable_append(struct ast_category *category, struct ast_variable *variable);
int ast_variable_delete(struct ast_category *category, char *variable, char *match);
-int ast_variable_update(struct ast_category *category, char *variable, char *value, char *match);
+int ast_variable_update(struct ast_category *category, const char *variable,
+ const char *value, const char *match, unsigned int object);
int config_text_file_save(const char *filename, const struct ast_config *cfg, const char *generator);
diff --git a/main/config.c b/main/config.c
index 153478c08..9dafa72fd 100644
--- a/main/config.c
+++ b/main/config.c
@@ -467,54 +467,41 @@ int ast_variable_delete(struct ast_category *category, char *variable, char *mat
return res;
}
-int ast_variable_update(struct ast_category *category, char *variable, char *value, char *match)
+int ast_variable_update(struct ast_category *category, const char *variable,
+ const char *value, const char *match, unsigned int object)
{
struct ast_variable *cur, *prev=NULL, *newer;
- newer = ast_variable_new(variable, value);
- if (!newer)
+
+ if (!(newer = ast_variable_new(variable, value)))
return -1;
- cur = category->root;
- while (cur) {
- if (cur->name == variable) {
- newer->next = cur->next;
- newer->object = cur->object;
- if (prev)
- prev->next = newer;
- else
- category->root = newer;
- if (category->last == cur)
- category->last = newer;
- cur->next = NULL;
- ast_variables_destroy(cur);
- return 0;
- }
- prev = cur;
- cur = cur->next;
- }
+
+ newer->object = object;
- prev = NULL;
- cur = category->root;
- while (cur) {
- if (!strcasecmp(cur->name, variable) && (ast_strlen_zero(match) || !strcasecmp(cur->value, match))) {
- newer->next = cur->next;
- newer->object = cur->object;
- if (prev)
- prev->next = newer;
- else
- category->root = newer;
- if (category->last == cur)
- category->last = newer;
- cur->next = NULL;
- ast_variables_destroy(cur);
- return 0;
- }
- prev = cur;
- cur = cur->next;
+ for (cur = category->root; cur; prev = cur, cur = cur->next) {
+ if (strcasecmp(cur->name, variable) ||
+ (!ast_strlen_zero(match) && strcasecmp(cur->value, match)))
+ continue;
+
+ newer->next = cur->next;
+ newer->object = cur->object || object;
+ if (prev)
+ prev->next = newer;
+ else
+ category->root = newer;
+ if (category->last == cur)
+ category->last = newer;
+
+ cur->next = NULL;
+ ast_variables_destroy(cur);
+
+ return 0;
}
+
if (prev)
prev->next = newer;
else
category->root = newer;
+
return 0;
}
diff --git a/main/manager.c b/main/manager.c
index a937bc931..7c2e1b37a 100644
--- a/main/manager.c
+++ b/main/manager.c
@@ -1068,6 +1068,8 @@ static void handle_updates(struct mansession *s, const struct message *m, struct
struct ast_variable *v;
for (x=0;x<100000;x++) {
+ unsigned int object = 0;
+
snprintf(hdr, sizeof(hdr), "Action-%06d", x);
action = astman_get_header(m, hdr);
if (ast_strlen_zero(action))
@@ -1078,6 +1080,10 @@ static void handle_updates(struct mansession *s, const struct message *m, struct
var = astman_get_header(m, hdr);
snprintf(hdr, sizeof(hdr), "Value-%06d", x);
value = astman_get_header(m, hdr);
+ if (!ast_strlen_zero(value) && *value == '>') {
+ object = 1;
+ value++;
+ }
snprintf(hdr, sizeof(hdr), "Match-%06d", x);
match = astman_get_header(m, hdr);
if (!strcasecmp(action, "newcat")) {
@@ -1098,7 +1104,7 @@ static void handle_updates(struct mansession *s, const struct message *m, struct
ast_category_delete(cfg, (char *) cat);
} else if (!strcasecmp(action, "update")) {
if (!ast_strlen_zero(cat) && !ast_strlen_zero(var) && (category = ast_category_get(cfg, cat)))
- ast_variable_update(category, (char *) var, (char *) value, (char *) match);
+ ast_variable_update(category, var, value, match, object);
} else if (!strcasecmp(action, "delete")) {
if (!ast_strlen_zero(cat) && !ast_strlen_zero(var) && (category = ast_category_get(cfg, cat)))
ast_variable_delete(category, (char *) var, (char *) match);
@@ -1106,7 +1112,7 @@ static void handle_updates(struct mansession *s, const struct message *m, struct
if (!ast_strlen_zero(cat) && !ast_strlen_zero(var) &&
(category = ast_category_get(cfg, cat)) &&
(v = ast_variable_new(var, value))){
- if (match && !strcasecmp(match, "object"))
+ if (object || (match && !strcasecmp(match, "object")))
v->object = 1;
ast_variable_append(category, v);
}