[Asterisk-code-review] pbx spool: Set AST OUTGOING ATTEMPT variable on channel (asterisk[master])
Sean Bright
asteriskteam at digium.com
Tue Mar 7 06:26:15 CST 2017
Sean Bright has uploaded a new change for review. ( https://gerrit.asterisk.org/5132 )
Change subject: pbx_spool: Set AST_OUTGOING_ATTEMPT variable on channel
......................................................................
pbx_spool: Set AST_OUTGOING_ATTEMPT variable on channel
Set a variable on the channel that indicates which attempt number we
are currently performing to allow for attempt-specific behavior.
ASTERISK-26568 #close
Reported by: Roman Shubovich
Change-Id: Iacd7e8d43b0ed5b6cb021c62f41f1a1f5733dd89
---
M pbx/pbx_spool.c
1 file changed, 21 insertions(+), 14 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/32/5132/1
diff --git a/pbx/pbx_spool.c b/pbx/pbx_spool.c
index 0c6c401..325df66 100644
--- a/pbx/pbx_spool.c
+++ b/pbx/pbx_spool.c
@@ -161,6 +161,19 @@
return o;
}
+static void append_variable(struct outgoing *o, const char *name, const char *value)
+{
+ struct ast_variable *var = ast_variable_new(name, value, o->fn);
+
+ if (!var) {
+ return;
+ }
+
+ /* Always insert at the end, because some people want to treat the spool
+ * file as a script */
+ ast_variable_list_append(&o->vars, var);
+}
+
static void parse_line(char *line, unsigned int lineno, struct outgoing *o)
{
char *c;
@@ -261,20 +274,7 @@
strsep(&c2, "=");
if (c2) {
- struct ast_variable *var = ast_variable_new(c, c2, o->fn);
-
- if (var) {
- /*
- * Always insert at the end, because some people
- * want to treat the spool file as a script
- */
- struct ast_variable **tail = &o->vars;
-
- while (*tail) {
- tail = &(*tail)->next;
- }
- *tail = var;
- }
+ append_variable(o, c, c2);
} else {
ast_log(LOG_WARNING, "Malformed \"%s\" argument. Should be \"%s: variable=value\"\n", line, line);
}
@@ -297,6 +297,7 @@
{
char buf[LINE_BUFFER_SIZE];
unsigned int lineno = 0;
+ char *attempt;
while (fgets(buf, sizeof(buf), f)) {
size_t len = strlen(buf);
@@ -328,6 +329,12 @@
"along with tech and dest in file %s\n", o->fn);
return -1;
}
+
+ if (ast_asprintf(&attempt, "%d", o->retries + 1) >= 0) {
+ append_variable(o, "AST_OUTGOING_ATTEMPT", attempt);
+ ast_free(attempt);
+ }
+
return 0;
}
--
To view, visit https://gerrit.asterisk.org/5132
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iacd7e8d43b0ed5b6cb021c62f41f1a1f5733dd89
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Sean Bright <sean.bright at gmail.com>
More information about the asterisk-code-review
mailing list