[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Confuse-devel] Adding a section programmatically?
From: |
Kelan Champagne |
Subject: |
[Confuse-devel] Adding a section programmatically? |
Date: |
Wed, 9 Nov 2011 13:07:28 -0800 |
Hi-
I'm just started using libConfuse, and am liking it so far. However, I have run into 1 issue.
I'd like to be able to read in a config file, add a section (programmatically), and then write the config info back out to the file (with the newly-added section). But, I don't see a way to do that right now (unless I'm missing something).
Specifically, I was expecting something like cfg_setsec(), but couldn't find anything like that. I was able to add that function myself (by following the example of the other cfg_set*() functions -- so I actually added cfg_setsec(), cfg_setnsec(), and cfg_opt_setnsec()), but my implementation only works when adding a single section. If you try to to pass an index aside from 0, it hits the assert at the top of cfg_opt_getval(), because my repeatable section has the CFGF_MULTI flag set (which applies to sections only) and not the CFGF_LIST flag, which that assert is expecting.
I attached my patch (based on the v2.7 downloadable source).
Can anyone provide some insight on how it might be possible to extend this to support multiple sections?
Thanks,
-Kelan
libConfuse_addSection.patch
Description: Binary data
- [Confuse-devel] Adding a section programmatically?,
Kelan Champagne <=