* New CLI commands "dialplan set extenpatternmatching true/false"
* New CLI command: "core set chanvar" to set a channel variable from the CLI.
* Added an easy way to execute Asterisk CLI commands at startup. Any commands
- listed in the startup_commands file in the Asterisk configuration directory
- will get executed.
+ listed in the startup_commands section of cli.conf will get executed.
SIP changes
-----------
static void run_startup_commands(void)
{
- char filename[PATH_MAX];
- char buf[256];
- FILE *f;
int fd;
-
- fd = open("/dev/null", O_RDWR);
- if (fd < 0)
- return;
-
- snprintf(filename, sizeof(filename), "%s/startup_commands", ast_config_AST_CONFIG_DIR);
+ struct ast_config *cfg;
+ struct ast_flags cfg_flags = { 0 };
+ struct ast_variable *v;
- if (!(f = fopen(filename, "r"))) {
- close(fd);
+ if (!(cfg = ast_config_load("cli.conf", cfg_flags)))
return;
- }
- while (fgets(buf, sizeof(buf), f)) {
- size_t res = strlen(buf);
-
- if (!res)
- continue;
-
- if (buf[res - 1] == '\n')
- buf[res - 1] = '\0';
+ fd = open("/dev/null", O_RDWR);
+ if (fd < 0)
+ return;
- ast_cli_command(fd, buf);
- }
+ for (v = ast_variable_browse(cfg, "startup_commands"); v; v = v->next)
+ ast_cli_command(fd, v->name);
- fclose(f);
close(fd);
+ ast_config_destroy(cfg);
}
int main(int argc, char *argv[])