Index: pbx.c =================================================================== --- pbx.c (revision 81359) +++ pbx.c (working copy) @@ -267,6 +271,7 @@ static int pbx_builtin_saycharacters(struct ast_channel *, void *); static int pbx_builtin_sayphonetic(struct ast_channel *, void *); int pbx_builtin_setvar(struct ast_channel *, void *); +int pbx_builtin_setvar_multiple(struct ast_channel *, void *); static int pbx_builtin_importvar(struct ast_channel *, void *); AST_RWLOCK_DEFINE_STATIC(globalslock); @@ -475,7 +480,7 @@ }, { "Set", pbx_builtin_setvar, - "Set channel variable(s) or function value(s)", + "Set channel variable or function value", " Set(name=value)\n" "This function can be used to set the value of channel variables or dialplan\n" "functions. When setting variables, if the variable name is prefixed with _,\n" @@ -485,6 +490,18 @@ "channels.\n" }, + { "MSet", pbx_builtin_setvar_multiple, + "Set channel variable(s) or function value(s)", + " MSet(name1=value1,name2=value2,...)\n" + "This function can be used to set the value of channel variables or dialplan\n" + "functions. When setting variables, if the variable name is prefixed with _,\n" + "the variable will be inherited into channels created from the current\n" + "channel. If the variable name is prefixed with __, the variable will be\n" + "inherited into channels created from the current channel and all children\n" + "channels.\n\n" + "MSet will do multiple sets in one go - like Set used work in 1.2/1.4\n" + }, + { "SetAMAFlags", pbx_builtin_setamaflags, "Set the AMA Flags", " SetAMAFlags([flag]): This application will set the channel's AMA Flags for\n" @@ -5873,6 +5906,42 @@ return(0); } +/* SLD: resurrect the old Set that supported multiple arguments. Its made available as MSet */ +int pbx_builtin_setvar_multiple(struct ast_channel *chan, void *data) +{ + char *name, *value, *mydata; + int argc; + char *argv[24]; /* this will only support a maximum of 24 variables being set in a single operation */ + int global = 0; + int x; + + if (ast_strlen_zero(data)) { + ast_log(LOG_WARNING, "MSet requires at least one variable name/value pair.\n"); + return 0; + } + + mydata = ast_strdupa(data); + argc = ast_app_separate_args(mydata, '|', argv, sizeof(argv) / sizeof(argv[0])); + + /* check for a trailing flags argument */ + if ((argc > 1) && !strchr(argv[argc-1], '=')) { + argc--; + if (strchr(argv[argc], 'g')) + global = 1; + } + + for (x = 0; x < argc; x++) { + name = argv[x]; + if ((value = strchr(name, '='))) { + *value++ = '\0'; + pbx_builtin_setvar_helper((global) ? NULL : chan, name, value); + } else + ast_log(LOG_WARNING, "Ignoring entry '%s' with no = (and not last 'options' entry)\n", name); + } + + return(0); +} + int pbx_builtin_importvar(struct ast_channel *chan, void *data) { char *name;