[sword-devel] Saving entries in config files
Troy A. Griffitts
sword-devel@crosswire.org
Sun, 14 May 2000 20:03:33 -0700
Joachim,
:) Yes, SWMgr merges all mods.d/*.conf files into its SWConfig. You
should not .Save this config. The apps/windoze/CBuilder4/InstallMgr has
a dialog for inputting and saving cipherkey values. You might find this
helpful. SWMgr::configPath and SWMgr::prefixPath might be useful.
Here's some code from apps/X11/InstallMgr/src/MainFrm.cpp and
apps/windoze/CBuilder4/InstallMgr/cipherfrm.cpp
SectionMap::iterator section;
ConfigEntMap::iterator entry;
DIR *dir;
struct dirent *ent;
...
if (dir = opendir(manager->configPath)) { // find
and update .conf file
rewinddir(dir);
while ((ent = readdir(dir))) {
if ((strcmp(ent->d_name, ".")) &&
(strcmp(ent->d_name, ".."))) {
modFile = manager->configPath;
modFile += "/";
modFile += ent->d_name;
SWConfig *config = new
SWConfig(modFile.c_str());
section =
config->Sections.find(modName)
if (section !=
config->Sections.end()) {
entry =
section->second.find("CipherKey");
if (entry !=
section->second.end()) {
entry->second =
CipherForm->cipherEdit->Text.c_str();
modconf->Save();
}
}
delete config;
}
}
closedir(dir);
}
slightly modified for your purposes. Hope this helps.
-Troy.
Joachim Ansorg wrote:
>
> Hi Troy,
>
> I found out how to save entries in SWORD's config files myself. I implemented it but it doesn't work correctly.
>
> I think you know that SWMgr proides a SWCofnig called config.
> I'm using this config to save entries using SWConfig::Save() and "SWConfig::Sections["Section"] = <a ConfEntMap>"
>
> This works, but all the entryies are saved in one config file!
> Is it possible that this worked correctly with mods.conf config-management, but IMHO we shoould have a SWConfig for each config file!
>
> Is this right?
>
> -- Joachim
> BibleTime - the bible study program for KDE
> http://www.bibletime.de/
> info@bibletime.de