mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-30 02:26:23 +00:00
config.c: Cleanup AST_INCLUDE_GLOB
* In main/config.c, AST_INCLUDE_GLOB is fixed to '1' making the #ifdefs pointless. * In utils/extconf.c, AST_INCLUDE_GLOB is never defined so there is a lot of dead code. Change-Id: I1bad1a46d7466ddf90d52cc724e997195495226c
This commit is contained in:
@@ -48,8 +48,6 @@
|
|||||||
#include <math.h> /* HUGE_VAL */
|
#include <math.h> /* HUGE_VAL */
|
||||||
#include <regex.h>
|
#include <regex.h>
|
||||||
|
|
||||||
#define AST_INCLUDE_GLOB 1
|
|
||||||
|
|
||||||
#include "asterisk/config.h"
|
#include "asterisk/config.h"
|
||||||
#include "asterisk/cli.h"
|
#include "asterisk/cli.h"
|
||||||
#include "asterisk/lock.h"
|
#include "asterisk/lock.h"
|
||||||
@@ -2047,10 +2045,8 @@ static struct ast_config *config_text_file_load(const char *database, const char
|
|||||||
/*! Growable string buffer */
|
/*! Growable string buffer */
|
||||||
struct ast_str *comment_buffer = NULL; /*!< this will be a comment collector.*/
|
struct ast_str *comment_buffer = NULL; /*!< this will be a comment collector.*/
|
||||||
struct ast_str *lline_buffer = NULL; /*!< A buffer for stuff behind the ; */
|
struct ast_str *lline_buffer = NULL; /*!< A buffer for stuff behind the ; */
|
||||||
#ifdef AST_INCLUDE_GLOB
|
|
||||||
int glob_ret;
|
int glob_ret;
|
||||||
glob_t globbuf;
|
glob_t globbuf;
|
||||||
#endif
|
|
||||||
|
|
||||||
if (cfg) {
|
if (cfg) {
|
||||||
cat = ast_config_get_current_category(cfg);
|
cat = ast_config_get_current_category(cfg);
|
||||||
@@ -2073,7 +2069,7 @@ static struct ast_config *config_text_file_load(const char *database, const char
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef AST_INCLUDE_GLOB
|
|
||||||
globbuf.gl_offs = 0; /* initialize it to silence gcc */
|
globbuf.gl_offs = 0; /* initialize it to silence gcc */
|
||||||
glob_ret = glob(fn, MY_GLOB_FLAGS, NULL, &globbuf);
|
glob_ret = glob(fn, MY_GLOB_FLAGS, NULL, &globbuf);
|
||||||
if (glob_ret == GLOB_NOSPACE) {
|
if (glob_ret == GLOB_NOSPACE) {
|
||||||
@@ -2101,7 +2097,7 @@ static struct ast_config *config_text_file_load(const char *database, const char
|
|||||||
}
|
}
|
||||||
for (i=0; i<globbuf.gl_pathc; i++) {
|
for (i=0; i<globbuf.gl_pathc; i++) {
|
||||||
ast_copy_string(fn, globbuf.gl_pathv[i], sizeof(fn));
|
ast_copy_string(fn, globbuf.gl_pathv[i], sizeof(fn));
|
||||||
#endif
|
|
||||||
/*
|
/*
|
||||||
* The following is not a loop, but just a convenient way to define a block
|
* The following is not a loop, but just a convenient way to define a block
|
||||||
* (using do { } while(0) ), and be able to exit from it with 'continue'
|
* (using do { } while(0) ), and be able to exit from it with 'continue'
|
||||||
@@ -2160,9 +2156,7 @@ static struct ast_config *config_text_file_load(const char *database, const char
|
|||||||
|
|
||||||
if (unchanged) {
|
if (unchanged) {
|
||||||
AST_LIST_UNLOCK(&cfmtime_head);
|
AST_LIST_UNLOCK(&cfmtime_head);
|
||||||
#ifdef AST_INCLUDE_GLOB
|
|
||||||
globfree(&globbuf);
|
globfree(&globbuf);
|
||||||
#endif
|
|
||||||
ast_free(comment_buffer);
|
ast_free(comment_buffer);
|
||||||
ast_free(lline_buffer);
|
ast_free(lline_buffer);
|
||||||
return CONFIG_STATUS_FILEUNCHANGED;
|
return CONFIG_STATUS_FILEUNCHANGED;
|
||||||
@@ -2336,14 +2330,12 @@ static struct ast_config *config_text_file_load(const char *database, const char
|
|||||||
if (comment) {
|
if (comment) {
|
||||||
ast_log(LOG_WARNING,"Unterminated comment detected beginning on line %d\n", nest[comment - 1]);
|
ast_log(LOG_WARNING,"Unterminated comment detected beginning on line %d\n", nest[comment - 1]);
|
||||||
}
|
}
|
||||||
#ifdef AST_INCLUDE_GLOB
|
|
||||||
if (cfg == NULL || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) {
|
if (cfg == NULL || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
globfree(&globbuf);
|
globfree(&globbuf);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
ast_free(comment_buffer);
|
ast_free(comment_buffer);
|
||||||
ast_free(lline_buffer);
|
ast_free(lline_buffer);
|
||||||
|
@@ -75,16 +75,6 @@
|
|||||||
static void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...) __attribute__((format(printf, 5, 6)));
|
static void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...) __attribute__((format(printf, 5, 6)));
|
||||||
void ast_verbose(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
|
void ast_verbose(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
|
||||||
|
|
||||||
#define ASINCLUDE_GLOB 1
|
|
||||||
#ifdef AST_INCLUDE_GLOB
|
|
||||||
|
|
||||||
#if !defined(GLOB_ABORTED)
|
|
||||||
#define GLOB_ABORTED GLOB_ABEND
|
|
||||||
#endif
|
|
||||||
|
|
||||||
# include <glob.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define AST_API_MODULE 1 /* gimme the inline defs! */
|
#define AST_API_MODULE 1 /* gimme the inline defs! */
|
||||||
struct ast_channel
|
struct ast_channel
|
||||||
{
|
{
|
||||||
@@ -3153,29 +3143,6 @@ static struct ast_config *config_text_file_load(const char *database, const char
|
|||||||
CB_INIT();
|
CB_INIT();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef AST_INCLUDE_GLOB
|
|
||||||
{
|
|
||||||
int glob_ret;
|
|
||||||
glob_t globbuf;
|
|
||||||
|
|
||||||
globbuf.gl_offs = 0; /* initialize it to silence gcc */
|
|
||||||
#ifdef SOLARIS
|
|
||||||
glob_ret = glob(fn, GLOB_NOCHECK, NULL, &globbuf);
|
|
||||||
#else
|
|
||||||
glob_ret = glob(fn, GLOB_NOMAGIC|GLOB_BRACE, NULL, &globbuf);
|
|
||||||
#endif
|
|
||||||
if (glob_ret == GLOB_NOSPACE)
|
|
||||||
ast_log(LOG_WARNING,
|
|
||||||
"Glob Expansion of pattern '%s' failed: Not enough memory\n", fn);
|
|
||||||
else if (glob_ret == GLOB_ABORTED)
|
|
||||||
ast_log(LOG_WARNING,
|
|
||||||
"Glob Expansion of pattern '%s' failed: Read error\n", fn);
|
|
||||||
else {
|
|
||||||
/* loop over expanded files */
|
|
||||||
int i;
|
|
||||||
for (i=0; i<globbuf.gl_pathc; i++) {
|
|
||||||
ast_copy_string(fn, globbuf.gl_pathv[i], sizeof(fn));
|
|
||||||
#endif
|
|
||||||
do {
|
do {
|
||||||
if (stat(fn, &statbuf))
|
if (stat(fn, &statbuf))
|
||||||
continue;
|
continue;
|
||||||
@@ -3285,14 +3252,6 @@ static struct ast_config *config_text_file_load(const char *database, const char
|
|||||||
if (comment) {
|
if (comment) {
|
||||||
ast_log(LOG_WARNING,"Unterminated comment detected beginning on line %d\n", nest[comment]);
|
ast_log(LOG_WARNING,"Unterminated comment detected beginning on line %d\n", nest[comment]);
|
||||||
}
|
}
|
||||||
#ifdef AST_INCLUDE_GLOB
|
|
||||||
if (!cfg)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
globfree(&globbuf);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (cfg && cfg->include_level == 1 && withcomments && comment_buffer) {
|
if (cfg && cfg->include_level == 1 && withcomments && comment_buffer) {
|
||||||
if (comment_buffer) {
|
if (comment_buffer) {
|
||||||
free(comment_buffer);
|
free(comment_buffer);
|
||||||
|
Reference in New Issue
Block a user