aboutsummaryrefslogtreecommitdiffstats
path: root/main/asterisk.c
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2008-01-22 20:33:16 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2008-01-22 20:33:16 +0000
commite5bc0cbd61ef0bafff101817030efb0a4aa78480 (patch)
treeabe3a3bca0ce624381dbdc7cadd7fc2eae8fde66 /main/asterisk.c
parent0c22830419f548c9b8d2eb1f5599fdbc6305cb9a (diff)
Change the Asterisk CLI startup commands feature to read commands to run from cli.conf
after a discussion on the -dev list. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@99642 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/asterisk.c')
-rw-r--r--main/asterisk.c33
1 files changed, 10 insertions, 23 deletions
diff --git a/main/asterisk.c b/main/asterisk.c
index 3b3c2cb2a..54a88a9f5 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -2683,36 +2683,23 @@ static void canary_exit(void)
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[])