Cleanup formatting in config.c

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@3235 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.0
James Golovich 22 years ago
parent 4f72a1da77
commit e5629ea138

@ -627,7 +627,6 @@ static int cfg_process(struct ast_config *tmp, struct ast_category **_tmpc, stru
} else {
if (*_last)
(*_last)->blanklines++;
}
#endif
}
@ -739,16 +738,15 @@ static struct ast_config *__ast_load(char *configfile, struct ast_config *tmp, s
#endif
);
load_func=NULL;
if (strcmp(configfile,config_conf_file) && strcmp(configfile,"asterisk.conf") && ast_cust_config_list) {
if(global_load_func)
if (global_load_func) {
load_func = global_load_func;
else {
} else {
reg = get_ast_cust_config_keyword(configfile);
if(reg && reg->func)
if (reg && reg->func) {
load_func = reg->func;
else {
} else {
reg = get_ast_cust_config_keyword("global");
if (reg && reg->func)
global_load_func = load_func = reg->func;
@ -768,9 +766,6 @@ static struct ast_config *__ast_load(char *configfile, struct ast_config *tmp, s
}
}
if (configfile[0] == '/') {
strncpy(fn, configfile, sizeof(fn)-1);
} else {
@ -828,19 +823,23 @@ static struct ast_config *__ast_load(char *configfile, struct ast_config *tmp, s
return tmp;
}
struct ast_config_reg *get_ast_cust_config_keyword(char *name) {
struct ast_config_reg *get_ast_cust_config_keyword(char *name)
{
struct ast_config_reg *reg,*ret=NULL;
int x=0;
ast_mutex_lock(&ast_cust_config_lock);
for(reg=ast_cust_config_list;reg && !ret;reg=reg->next)
for(x=0;x<reg->keycount && !ret ;x++)
for (reg=ast_cust_config_list;reg && !ret;reg=reg->next) {
for (x=0;x<reg->keycount && !ret ;x++) {
if (!strcmp(reg->keywords[x],name))
ret=reg;
}
}
ast_mutex_unlock(&ast_cust_config_lock);
return ret;
}
struct ast_config_reg *get_ast_cust_config(char *name) {
struct ast_config_reg *get_ast_cust_config(char *name)
{
struct ast_config_reg *ptr=NULL;
ast_mutex_lock(&ast_cust_config_lock);
for (ptr=ast_cust_config_list;ptr;ptr=ptr->next) {
@ -851,7 +850,8 @@ struct ast_config_reg *get_ast_cust_config(char *name) {
return ptr;
}
void ast_config_destroy_all(void) {
void ast_config_destroy_all(void)
{
struct ast_config_reg *key;
ast_mutex_lock(&ast_cust_config_lock);
for (key=ast_cust_config_list;key;key=key->next) {
@ -861,17 +861,19 @@ void ast_config_destroy_all(void) {
ast_mutex_unlock(&ast_cust_config_lock);
}
struct ast_config_reg *get_config_registrations(void) {
struct ast_config_reg *get_config_registrations(void)
{
return ast_cust_config_list;
}
int ast_config_register(struct ast_config_reg *new) {
int ast_config_register(struct ast_config_reg *new)
{
struct ast_config_reg *ptr;
ast_mutex_lock(&ast_cust_config_lock);
new->keycount = 0;
if(!ast_cust_config_list)
if (!ast_cust_config_list) {
ast_cust_config_list = new;
else {
} else {
for(ptr=ast_cust_config_list;ptr->next;ptr=ptr->next);
ptr->next = new;
}
@ -880,21 +882,19 @@ int ast_config_register(struct ast_config_reg *new) {
return 1;
}
int ast_config_deregister(struct ast_config_reg *del) {
int ast_config_deregister(struct ast_config_reg *del)
{
struct ast_config_reg *ptr=NULL,*last=NULL;
ast_mutex_lock(&ast_cust_config_lock);
for (ptr=ast_cust_config_list;ptr;ptr=ptr->next) {
if (ptr == del) {
if (last && ptr->next) {
last->next = ptr->next;
}
else if(last && ! ptr->next) {
} else if (last && ! ptr->next) {
last->next = NULL;
}
else if(! last && ptr->next) {
} else if (!last && ptr->next) {
ast_cust_config_list = ptr->next;
}
else if(! last && ! ptr->next) {
} else if (!last && !ptr->next) {
ast_cust_config_list = NULL;
}
}
@ -959,7 +959,8 @@ char *ast_category_browse(struct ast_config *config, char *prev)
}
struct ast_config *ast_new_config(void) {
struct ast_config *ast_new_config(void)
{
struct ast_config *config;
config = malloc(sizeof(struct ast_config));
memset(config,0,sizeof(struct ast_config));
@ -968,7 +969,8 @@ struct ast_config *ast_new_config(void) {
struct ast_category *ast_new_category(char *name) {
struct ast_category *ast_new_category(char *name)
{
struct ast_category *category;
category = malloc(sizeof(struct ast_category));
if (category) {
@ -979,7 +981,8 @@ struct ast_category *ast_new_category(char *name) {
}
struct ast_variable *ast_new_variable(char *name,char *value) {
struct ast_variable *ast_new_variable(char *name, char *value)
{
struct ast_variable *variable;
variable = malloc(sizeof(struct ast_variable));
if (variable) {
@ -991,8 +994,7 @@ struct ast_variable *ast_new_variable(char *name,char *value) {
variable->value = malloc(strlen(value)+1);
if (variable->value) {
strcpy(variable->value,value);
}
else {
} else {
free(variable->name);
variable->name = NULL;
}
@ -1006,18 +1008,21 @@ struct ast_variable *ast_new_variable(char *name,char *value) {
return variable;
}
int ast_cust_config_register(struct ast_config_reg *new) {
int ast_cust_config_register(struct ast_config_reg *new)
{
ast_config_register(new);
read_ast_cust_config();
return 1;
}
int ast_cust_config_deregister(struct ast_config_reg *new) {
int ast_cust_config_deregister(struct ast_config_reg *new)
{
ast_config_deregister(new);
read_ast_cust_config();
return 1;
}
static void clear_cust_keywords(void) {
static void clear_cust_keywords(void)
{
struct ast_config_reg *key;
int x;
ast_mutex_lock(&ast_cust_config_lock);
@ -1030,7 +1035,8 @@ static void clear_cust_keywords(void) {
ast_mutex_unlock(&ast_cust_config_lock);
}
static int config_command(int fd, int argc, char **argv) {
static int config_command(int fd, int argc, char **argv)
{
struct ast_config_reg *key;
int x;
@ -1051,16 +1057,19 @@ static struct ast_cli_entry config_command_struct = {
{ "show","config","handles", NULL }, config_command,
"Show Config Handles", NULL };
int register_config_cli() {
int register_config_cli()
{
return ast_cli_register(&config_command_struct);
}
int read_ast_cust_config(void) {
int read_ast_cust_config(void)
{
char *cfg = config_conf_file;
struct ast_config *config;
struct ast_variable *v;
struct ast_config_reg *ptr;
struct ast_config_reg *test = NULL;
clear_cust_keywords();
config = ast_load(cfg);
if (config) {
@ -1070,16 +1079,14 @@ int read_ast_cust_config(void) {
if (ptr) {
if (ptr->keycount >= CONFIG_KEYWORD_ARRAYLEN) {
ast_log(LOG_WARNING,"Max Number of Bindings exceeded for %s->%s %d/%d\n",v->name,v->value,ptr->keycount,CONFIG_KEYWORD_ARRAYLEN);
}
else {
} else {
if (strcmp(v->name,config_conf_file) && strcmp(v->name,"asterisk.conf")) {
if (!(test = get_ast_cust_config_keyword(v->name))) {
ast_log(LOG_NOTICE,"Binding: %s to %s\n",v->name,v->value);
strncpy(ptr->keywords[ptr->keycount],v->name,sizeof(ptr->keywords[ptr->keycount]));
ptr->keycount++;
}
}
else {
} else {
ast_log(LOG_WARNING,"Cannot bind %s, Permission Denied\n",v->name);
}
}
@ -1088,8 +1095,6 @@ int read_ast_cust_config(void) {
ast_destroy(config);
}
else
ast_log(LOG_WARNING,"config loader has no config file so nevermind.\n");
return 0;
}

Loading…
Cancel
Save