| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
#include "asterisk.h" |
| 31 |
|
| 32 |
#include "asterisk/module.h" |
| 33 |
#include "asterisk/channel.h" |
| 34 |
#include "asterisk/pbx.h" |
| 35 |
#include "asterisk/utils.h" |
| 36 |
#include "asterisk/app.h" |
| 37 |
#include "asterisk/stringfields.h" |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
static int func_export_write(struct ast_channel *chan, const char *function, char *data, const char *value) |
| 70 |
{ |
| 71 |
struct ast_channel *ochan; |
| 72 |
|
| 73 |
AST_DECLARE_APP_ARGS(args, |
| 74 |
AST_APP_ARG(channel); |
| 75 |
AST_APP_ARG(var); |
| 76 |
); |
| 77 |
AST_STANDARD_APP_ARGS(args, data); |
| 78 |
|
| 79 |
if (!args.channel) { |
| 80 |
ast_log(LOG_WARNING, "No channel was provided to %s function.\n", function); |
| 81 |
return -1; |
| 82 |
} |
| 83 |
if (!args.var) { |
| 84 |
ast_log(LOG_WARNING, "No variable name was provided to %s function.\n", function); |
| 85 |
return -1; |
| 86 |
} |
| 87 |
ochan = ast_channel_get_by_name(args.channel); |
| 88 |
if (!ochan) { |
| 89 |
ast_log(LOG_WARNING, "Channel '%s' not found! '%s' not set.\n", args.channel, args.var); |
| 90 |
return -1; |
| 91 |
} |
| 92 |
|
| 93 |
pbx_builtin_setvar_helper(ochan, args.var, value); |
| 94 |
ast_channel_unref(ochan); |
| 95 |
return 0; |
| 96 |
} |
| 97 |
|
| 98 |
static struct ast_custom_function export_function = { |
| 99 |
.name = "EXPORT", |
| 100 |
.write = func_export_write, |
| 101 |
}; |
| 102 |
|
| 103 |
static int unload_module(void) |
| 104 |
{ |
| 105 |
return ast_custom_function_unregister(&export_function); |
| 106 |
} |
| 107 |
|
| 108 |
static int load_module(void) |
| 109 |
{ |
| 110 |
return ast_custom_function_register(&export_function); |
| 111 |
} |
| 112 |
|
| 113 |
AST_MODULE_INFO_STANDARD_EXTENDED(ASTERISK_GPL_KEY, "Set variables and functions on other channels"); |