mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 20:20:07 +00:00
remove unused code, and simplify the logic for #include/#exec
(still a lot of cleanup needed here). git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@91983 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -937,7 +937,10 @@ static int process_text_line(struct ast_config *cfg, struct ast_category **cat,
|
|||||||
if (newcat)
|
if (newcat)
|
||||||
ast_category_append(cfg, *cat);
|
ast_category_append(cfg, *cat);
|
||||||
} else if (cur[0] == '#') { /* A directive - #include or #exec */
|
} else if (cur[0] == '#') { /* A directive - #include or #exec */
|
||||||
int do_exec, do_include;
|
char *cur2;
|
||||||
|
char real_inclusion_name[256];
|
||||||
|
struct ast_config_include *inclu;
|
||||||
|
int do_include = 0; /* otherwise, it is exec */
|
||||||
|
|
||||||
cur++;
|
cur++;
|
||||||
c = cur;
|
c = cur;
|
||||||
@@ -950,20 +953,26 @@ static int process_text_line(struct ast_config *cfg, struct ast_category **cat,
|
|||||||
c = NULL;
|
c = NULL;
|
||||||
} else
|
} else
|
||||||
c = NULL;
|
c = NULL;
|
||||||
do_include = !strcasecmp(cur, "include");
|
if (!strcasecmp(cur, "include")) {
|
||||||
if (!do_include)
|
do_include = 1;
|
||||||
do_exec = !strcasecmp(cur, "exec");
|
} else if (!strcasecmp(cur, "exec")) {
|
||||||
else
|
if (!ast_opt_exec_includes) {
|
||||||
do_exec = 0;
|
|
||||||
if (do_exec && !ast_opt_exec_includes) {
|
|
||||||
ast_log(LOG_WARNING, "Cannot perform #exec unless execincludes option is enabled in asterisk.conf (options section)!\n");
|
ast_log(LOG_WARNING, "Cannot perform #exec unless execincludes option is enabled in asterisk.conf (options section)!\n");
|
||||||
do_exec = 0;
|
return 0; /* XXX is this correct ? or we should return -1 ? */
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ast_log(LOG_WARNING, "Unknown directive '%s' at line %d of %s\n", cur, lineno, configfile);
|
||||||
|
return 0; /* XXX is this correct ? or we should return -1 ? */
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c == NULL) {
|
||||||
|
ast_log(LOG_WARNING, "Directive '#%s' needs an argument (%s) at line %d of %s\n",
|
||||||
|
do_include ? "include" : "exec",
|
||||||
|
do_include ? "filename" : "/path/to/executable",
|
||||||
|
lineno,
|
||||||
|
configfile);
|
||||||
|
return 0; /* XXX is this correct ? or we should return -1 ? */
|
||||||
}
|
}
|
||||||
if (do_include || do_exec) {
|
|
||||||
if (c) {
|
|
||||||
char *cur2;
|
|
||||||
char real_inclusion_name[256];
|
|
||||||
struct ast_config_include *inclu;
|
|
||||||
|
|
||||||
/* Strip off leading and trailing "'s and <>'s */
|
/* Strip off leading and trailing "'s and <>'s */
|
||||||
while ((*c == '<') || (*c == '>') || (*c == '\"')) c++;
|
while ((*c == '<') || (*c == '>') || (*c == '\"')) c++;
|
||||||
@@ -979,7 +988,7 @@ static int process_text_line(struct ast_config *cfg, struct ast_category **cat,
|
|||||||
}
|
}
|
||||||
/* #exec </path/to/executable>
|
/* #exec </path/to/executable>
|
||||||
We create a tmp file, then we #include it, then we delete it. */
|
We create a tmp file, then we #include it, then we delete it. */
|
||||||
if (do_exec) {
|
if (!do_include) {
|
||||||
if (!ast_test_flag(&flags, CONFIG_FLAG_NOCACHE))
|
if (!ast_test_flag(&flags, CONFIG_FLAG_NOCACHE))
|
||||||
config_cache_attribute(configfile, ATTRIBUTE_EXEC, NULL);
|
config_cache_attribute(configfile, ATTRIBUTE_EXEC, NULL);
|
||||||
snprintf(exec_file, sizeof(exec_file), "/var/tmp/exec.%d.%ld", (int)time(NULL), (long)pthread_self());
|
snprintf(exec_file, sizeof(exec_file), "/var/tmp/exec.%d.%ld", (int)time(NULL), (long)pthread_self());
|
||||||
@@ -993,24 +1002,15 @@ static int process_text_line(struct ast_config *cfg, struct ast_category **cat,
|
|||||||
}
|
}
|
||||||
/* A #include */
|
/* A #include */
|
||||||
/* record this inclusion */
|
/* record this inclusion */
|
||||||
inclu = ast_include_new(cfg, configfile, cur, do_exec, cur2, lineno, real_inclusion_name, sizeof(real_inclusion_name));
|
inclu = ast_include_new(cfg, configfile, cur, !do_include, cur2, lineno, real_inclusion_name, sizeof(real_inclusion_name));
|
||||||
|
|
||||||
do_include = ast_config_internal_load(cur, cfg, flags, real_inclusion_name) ? 1 : 0;
|
do_include = ast_config_internal_load(cur, cfg, flags, real_inclusion_name) ? 1 : 0;
|
||||||
if (!ast_strlen_zero(exec_file))
|
if (!ast_strlen_zero(exec_file))
|
||||||
unlink(exec_file);
|
unlink(exec_file);
|
||||||
if (!do_include)
|
if (!do_include)
|
||||||
return 0;
|
return 0;
|
||||||
|
/* XXX otherwise what ? the default return is 0 anyways */
|
||||||
|
|
||||||
} else {
|
|
||||||
ast_log(LOG_WARNING, "Directive '#%s' needs an argument (%s) at line %d of %s\n",
|
|
||||||
do_exec ? "exec" : "include",
|
|
||||||
do_exec ? "/path/to/executable" : "filename",
|
|
||||||
lineno,
|
|
||||||
configfile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
ast_log(LOG_WARNING, "Unknown directive '%s' at line %d of %s\n", cur, lineno, configfile);
|
|
||||||
} else {
|
} else {
|
||||||
/* Just a line (variable = value) */
|
/* Just a line (variable = value) */
|
||||||
if (!(*cat)) {
|
if (!(*cat)) {
|
||||||
@@ -1071,14 +1071,8 @@ static struct ast_config *config_text_file_load(const char *database, const char
|
|||||||
struct ast_variable *last_var = 0;
|
struct ast_variable *last_var = 0;
|
||||||
struct ast_category *last_cat = 0;
|
struct ast_category *last_cat = 0;
|
||||||
/*! Growable string buffer */
|
/*! Growable string buffer */
|
||||||
struct ast_str *comment_buffer = NULL, *lline_buffer = NULL;
|
struct ast_str *comment_buffer = NULL; /*!< this will be a comment collector.*/
|
||||||
#if 0
|
struct ast_str *lline_buffer = NULL; /*!< A buffer for stuff behind the ; */
|
||||||
char *comment_buffer=0; /*!< this will be a comment collector.*/
|
|
||||||
int comment_buffer_size=0; /*!< the amount of storage so far alloc'd for the comment_buffer */
|
|
||||||
|
|
||||||
char *lline_buffer=0; /*!< A buffer for stuff behind the ; */
|
|
||||||
int lline_buffer_size=0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (cfg)
|
if (cfg)
|
||||||
cat = ast_config_get_current_category(cfg);
|
cat = ast_config_get_current_category(cfg);
|
||||||
|
Reference in New Issue
Block a user