[sr-dev] Standalone Configuration File Parser

Jan Janak jan at ryngle.com
Thu Sep 24 14:12:58 CEST 2009


On Thu, Sep 24, 2009 at 2:02 PM, Daniel-Constantin Mierla
<miconda at 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.



More information about the sr-dev mailing list