Hello,
I am not sure if everybody is aware of that, but the sip-router core has inherited a standalone configuration file parser from SER. The parser lives in files cfg_parser.[ch] and can be used to parse configuration files of form:
# comment... [section] name1 = value1 name2 = value2 ...
The format of section identifiers as well as the format of configuration values are extensible it can be anything from booleans, integers, strings, and even more complicated compound formats of your own.
Two SER modules currently use the parser. The tls module uses it to parse standalone configuration files with TLS related configuration. The ldap SER module uses the parser to parse a configuration file that maps LDAP objects to tables and columns for the database API.
Here is an example of a non-trivial configuration file the parse can parse: http://git.sip-router.org/cgi-bin/gitweb.cgi?p=sip-router;a=blob_plain;f=mod...
Some documentation can be found in file sip_router/cfg_parser.c. For examples how to use it have a look at the following files: http://git.sip-router.org/cgi-bin/gitweb.cgi?p=sip-router;a=blob;f=modules_s... http://git.sip-router.org/cgi-bin/gitweb.cgi?p=sip-router;a=blob;f=modules/t...
Jan.
Hello,
On 24.09.2009 13:52 Uhr, Jan Janak wrote:
Hello,
I am not sure if everybody is aware of that, but the sip-router core has inherited a standalone configuration file parser from SER.
good to know, I think there are some modules -- iirc, some K module use libconfuse for own config, maybe this one fits to remove extra dependency.
Does it have support for custom memory manger? e.g., load config either in shm or pkg as needed.
Daniel
The parser lives in files cfg_parser.[ch] and can be used to parse configuration files of form:
# comment... [section] name1 = value1 name2 = value2 ...
The format of section identifiers as well as the format of configuration values are extensible it can be anything from booleans, integers, strings, and even more complicated compound formats of your own.
Two SER modules currently use the parser. The tls module uses it to parse standalone configuration files with TLS related configuration. The ldap SER module uses the parser to parse a configuration file that maps LDAP objects to tables and columns for the database API.
Here is an example of a non-trivial configuration file the parse can parse: http://git.sip-router.org/cgi-bin/gitweb.cgi?p=sip-router;a=blob_plain;f=mod...
Some documentation can be found in file sip_router/cfg_parser.c. For examples how to use it have a look at the following files: http://git.sip-router.org/cgi-bin/gitweb.cgi?p=sip-router;a=blob;f=modules_s... http://git.sip-router.org/cgi-bin/gitweb.cgi?p=sip-router;a=blob;f=modules/t...
Jan.
sr-dev mailing list sr-dev@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
On Thu, Sep 24, 2009 at 2:02 PM, Daniel-Constantin Mierla miconda@gmail.com wrote:
Hello,
On 24.09.2009 13:52 Uhr, Jan Janak wrote:
Hello,
I am not sure if everybody is aware of that, but the sip-router core has inherited a standalone configuration file parser from SER.
good to know, I think there are some modules -- iirc, some K module use libconfuse for own config, maybe this one fits to remove extra dependency.
Does it have support for custom memory manger? e.g., load config either in shm or pkg as needed.
Yes. All functions that allocate memory memory for the result can be controlled with flags. One of the flags controls which memory allocator is to be used. You can configure this individually for every option. The example bellow shows how this is done in the tls module (look for the flag CFG_STR_SHMMEM).
static cfg_option_t options[] = { {"method", .param = methods, .f = cfg_parse_enum_opt}, {"tls_method", .param = methods, .f = cfg_parse_enum_opt}, {"verify_certificate", .f = cfg_parse_bool_opt}, {"verify_cert", .f = cfg_parse_bool_opt}, {"verify_depth", .f = cfg_parse_int_opt}, {"require_certificate", .f = cfg_parse_bool_opt}, {"require_cert", .f = cfg_parse_bool_opt}, {"private_key", .f = cfg_parse_str_opt, .flags = CFG_STR_SHMMEM}, {"pkey_file", .f = cfg_parse_str_opt, .flags = CFG_STR_SHMMEM}, {"calist_file", .f = cfg_parse_str_opt, .flags = CFG_STR_SHMMEM}, {"certificate", .f = cfg_parse_str_opt, .flags = CFG_STR_SHMMEM}, {"cert_file", .f = cfg_parse_str_opt, .flags = CFG_STR_SHMMEM}, {"cipher_list", .f = cfg_parse_str_opt, .flags = CFG_STR_SHMMEM}, {"ca_list", .f = cfg_parse_str_opt, .flags = CFG_STR_SHMMEM}, {0} };
Jan.