--- /dev/null
+Subject: channel_internal_api
+
+CHANNEL(lastcontext) and CHANNEL(lastexten)
+are now available for use in the dialplan.
<enum name="context">
<para>R/O returns the context for an outbound channel.</para>
</enum>
+ <enum name="lastexten">
+ <para>R/O returns the last unique extension for an outbound channel.</para>
+ </enum>
+ <enum name="lastcontext">
+ <para>R/O returns the last unique context for an outbound channel.</para>
+ </enum>
<enum name="channame">
<para>R/O returns the channel name for an outbound channel.</para>
</enum>
locked_copy_string(chan, buf, ast_channel_exten(chan), len);
else if (!strcasecmp(data, "context"))
locked_copy_string(chan, buf, ast_channel_context(chan), len);
+ else if (!strcasecmp(data, "lastexten"))
+ locked_copy_string(chan, buf, ast_channel_lastexten(chan), len);
+ else if (!strcasecmp(data, "lastcontext"))
+ locked_copy_string(chan, buf, ast_channel_lastcontext(chan), len);
else if (!strcasecmp(data, "userfield"))
locked_copy_string(chan, buf, ast_channel_userfield(chan), len);
else if (!strcasecmp(data, "channame"))
const char *ast_channel_data(const struct ast_channel *chan);
void ast_channel_data_set(struct ast_channel *chan, const char *value);
+const char *ast_channel_lastcontext(const struct ast_channel *chan);
const char *ast_channel_context(const struct ast_channel *chan);
void ast_channel_context_set(struct ast_channel *chan, const char *value);
+const char *ast_channel_lastexten(const struct ast_channel *chan);
const char *ast_channel_exten(const struct ast_channel *chan);
void ast_channel_exten_set(struct ast_channel *chan, const char *value);
const char *ast_channel_macrocontext(const struct ast_channel *chan);
char context[AST_MAX_CONTEXT]; /*!< Dialplan: Current extension context */
char exten[AST_MAX_EXTENSION]; /*!< Dialplan: Current extension number */
+ char lastcontext[AST_MAX_CONTEXT]; /*!< Dialplan: Previous extension context */
+ char lastexten[AST_MAX_EXTENSION]; /*!< Dialplan: Previous extension number */
char macrocontext[AST_MAX_CONTEXT]; /*!< Macro: Current non-macro context. See app_macro.c */
char macroexten[AST_MAX_EXTENSION]; /*!< Macro: Current non-macro extension. See app_macro.c */
char unbridged; /*!< non-zero if the bridge core needs to re-evaluate the current
{
return chan->context;
}
+const char *ast_channel_lastcontext(const struct ast_channel *chan)
+{
+ return chan->lastcontext;
+}
void ast_channel_context_set(struct ast_channel *chan, const char *value)
{
+ if (!*chan->lastcontext || strcmp(value, chan->context)) {
+ /* only copy to last context when it changes, unless it's empty to begin with */
+ ast_copy_string(chan->lastcontext, chan->context, sizeof(chan->lastcontext));
+ }
ast_copy_string(chan->context, value, sizeof(chan->context));
}
const char *ast_channel_exten(const struct ast_channel *chan)
{
return chan->exten;
}
+const char *ast_channel_lastexten(const struct ast_channel *chan)
+{
+ return chan->lastexten;
+}
void ast_channel_exten_set(struct ast_channel *chan, const char *value)
{
+ if (!*chan->lastexten || strcmp(value, chan->exten)) {
+ /* only copy to last exten when it changes, unless it's empty to begin with */
+ ast_copy_string(chan->lastexten, chan->exten, sizeof(chan->lastexten));
+ }
ast_copy_string(chan->exten, value, sizeof(chan->exten));
}
const char *ast_channel_macrocontext(const struct ast_channel *chan)