[asterisk-dev] configuration Optimizations

Christian Richter christian.richter at beronet.com
Thu May 11 07:49:44 MST 2006


Hi All,

I'd  like to propose a way of optimizing the configuration handling of 
asterisk modules.

There are a few things each module has in common while handling 
configuration elements especially:

* there is a sort of [general] context, then there are element contexts 
like  sip peers or things like that.
* All the contexts contain different parameter types, but most are 
either int, strings or bools.
* Some modules implement showing the configuration on the cli like "sip 
show peers"
* It is very hard to add/change/remove parameters contexts in each module


So what about having some engine above of the existing config engine, 
which can be feed with an array of possible parameters and with a 
classical ast_cfg object.

The array could be defined in a module like:

enum cfg_elements {
    CFG_PARM1,
    CFG_PARM2
} ;


struct mod_cfg[] {
 {CFG_PARM1, cfg_parser_fct, 1 /*default*/}
};

void cfg_parser_fct(void *target, mod_cfg, ast_cfg);

There would be some obvious predefined parsers, but the user could add 
his own..

Additionally we would have some copy functions to get specific 
parameters regarding their types

cfg_copy( &target, mod_cfg, ast_cfg, CFG_PARM2);

functions to display all the cfg that are saved:

cfg_show(mod_cfg,ast_cfg);


I haven't yet had a good Idea how to make defaults with different 
types... any suggestions?

Ideas and suggestions are welcome.




More information about the asterisk-dev mailing list