ww-tedit-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ww-tedit-dev] new functions to store sections in .ini files


From: petar marinov
Subject: [ww-tedit-dev] new functions to store sections in .ini files
Date: Mon, 21 Feb 2005 21:24:03 -0800
User-agent: Mozilla Thunderbird 0.9 (Windows/20041103)

ini.c holds all the basic functions to store and read config information. Presently reading employes the TFile primitives while storing is very inflexible -- it uses fprinf(). Using fprintf() means that .ini files could only be regenerated as a whole (fopen-fprintf-fclose) and won't allow for sections to be individually replaced.

It is criticall to remove this barrier for two reasons.

1. Plug-ins must have sane interface to store/access individual sections in the .ini files 2. wglob.ini only touches sections that hold config info which underwent some change during an editor session. At the moment this is achieved by a bisarre combination of TFile functions to remove sections and then the already disdained fprintf() method to append those at the end of the wglob.ini file. No need to see the code -- it is ugly.

At the moment I have implemented this new set of functions (ini.h) to generate/replace sections in an .ini file:

BOOLEAN OpenINI(TFile *pINIFile);
void CloseINI(TFile *pINIFile);

int SearchSection(TFile *pINIFile, const char *sSectionName, int *nSectionStart);
int RemoveSection(TFile *pINIFile, const char *psSectionName);
BOOLEAN SectionBegin(TSectionBuf *pSection);
BOOLEAN SectionPrintF(TSectionBuf *pSection, const char *fmt, ...);
BOOLEAN SectionInsert(TFile *pINIFile, int nAtLine, TSectionBuf *pSection);

The center piece is SectionPrintF() which works as normal printf() but outputs in a temp buffer which can then be SectionInsert()-ed in an existing, and already opened, .ini file.

I began this cleanup work when I had to add a new section to wglob.ini to keep the current font and screen parameters for the GUI version (Windows and later X). Next step is to have all existing code which uses fprintf() be replaced with SectionPrintF().

-petar




reply via email to

[Prev in Thread] Current Thread [Next in Thread]