Index: pbx/pbx_realtime.c =================================================================== --- pbx/pbx_realtime.c (revision 76346) +++ pbx/pbx_realtime.c (working copy) @@ -54,6 +54,7 @@ #include "asterisk/utils.h" #include "asterisk/crypto.h" #include "asterisk/astdb.h" +#include "asterisk/pbx_realtime.h" #define MODE_MATCH 0 #define MODE_MATCHMORE 1 @@ -75,7 +76,24 @@ */ +static void realtime_switch_free(void *data); +/* Globally accessible, to be reachable from app_macro */ +struct ast_datastore_info realtime_switch_info = { + .type = "EXTENSIONS_INFO", + .destroy = realtime_switch_free, +}; + +static void realtime_switch_free(void *data) +{ + struct realtime_switch_frame *frame = data; + if (frame->app) + ast_free(frame->app); + if (frame->data) + ast_free(frame->data); + ast_free(frame); +} + static struct ast_variable *realtime_switch_common(const char *table, const char *context, const char *exten, int priority, int mode) { struct ast_variable *var; @@ -175,17 +193,46 @@ { int res = -1; struct ast_variable *var = realtime_common(context, exten, priority, data, MODE_MATCH); + struct ast_datastore *realtime_switch_store = ast_channel_datastore_find(chan, &realtime_switch_info, NULL); + struct realtime_switch_frame *frame = NULL; + if (realtime_switch_store) { + frame = realtime_switch_store->data; + if (frame->app) { + ast_free(frame->app); + frame->app = NULL; + } + if (frame->data) { + ast_free(frame->data); + frame->data = NULL; + } + } else { + realtime_switch_store = ast_channel_datastore_alloc(&realtime_switch_info, NULL); + if (realtime_switch_store) { + frame = ast_calloc(sizeof(*frame)); + if (frame) { + realtime_switch_store->data = frame; + ast_channel_datastore_add(chan, realtime_switch_store); + } else + ast_channel_datastore_destroy(realtime_switch_store); + } + } + if (var) { char *tmp=""; char app[256]; struct ast_variable *v; for (v = var; v ; v = v->next) { - if (!strcasecmp(v->name, "app")) + if (!strcasecmp(v->name, "app")) { ast_copy_string(app, v->value, sizeof(app)); - else if (!strcasecmp(v->name, "appdata")) + if (frame) + frame->app = ast_strdup(app); + } else if (!strcasecmp(v->name, "appdata")) { tmp = ast_strdupa(v->value); + if (frame) + frame->data = ast_strdup(data); + } } ast_variables_destroy(var); if (!ast_strlen_zero(app)) { Index: apps/app_macro.c =================================================================== --- apps/app_macro.c (revision 76346) +++ apps/app_macro.c (working copy) @@ -44,6 +44,7 @@ #include "asterisk/config.h" #include "asterisk/utils.h" #include "asterisk/lock.h" +#include "asterisk/pbx_realtime.h" #define MAX_ARGS 80 @@ -293,6 +294,13 @@ if (e) { /* This will only be undefined for pbx_realtime, which is majorly broken. */ ast_copy_string(runningapp, ast_get_extension_app(e), sizeof(runningapp)); ast_copy_string(runningdata, ast_get_extension_app_data(e), sizeof(runningdata)); + } else { /* Something for pbx_realtime */ + struct ast_datastore *store = ast_channel_datastore_find(chan, &realtime_switch_info, NULL); + if (store && store->data) { + struct realtime_switch_frame *frame = store->data; + ast_copy_string(runningapp, frame->app, sizeof(runningapp)); + ast_copy_string(runningdata, frame->data, sizeof(runningdata)); + } } ast_unlock_context(c); } Index: include/asterisk/pbx_realtime.h =================================================================== --- include/asterisk/pbx_realtime.h (revision 0) +++ include/asterisk/pbx_realtime.h (revision 0) @@ -0,0 +1,26 @@ +/* + * Asterisk -- An open source telephony toolkit. + * + * Copyright (C) 2007, Digium, Inc. + * + * Tilghman Lesher + * + * See http://www.asterisk.org for more information about + * the Asterisk project. Please do not directly contact + * any of the maintainers of this project for assistance; + * the project provides a web site, mailing lists and IRC + * channels for your use. + * + * This program is free software, distributed under the terms of + * the GNU General Public License Version 2. See the LICENSE file + * at the top of the source tree. + */ + + +extern struct ast_datastore_info realtime_switch_info; + +struct realtime_switch_frame { + char *app; + char *data; +}; + Property changes on: include/asterisk/pbx_realtime.h ___________________________________________________________________ Name: svn:eol-style + native