OS2 World Community Forum
OS/2, eCS & ArcaOS - Technical => Programming => Topic started by: Andi B. on February 06, 2021, 11:18:20 am
-
OS/2 software usually stores application data in os2.ini or some application.ini. But nowadays I prefer human readable config files. We have such for a lot of ported software like smb.conf or http.conf or ...
Someone knows which libraries are used for (simple) config file processing? I want to store some application settings of my own program in a human readable form. For sure I don't need to reinvent all these text parsing stuff again. Which sources should I look for? Thanks.
-
Use the old Win31 API. That comes as part of the DAPI extensions. You will need to search a little to find the documentation.
-
Sorry, that supports the WinNT type of registry.
-
Christian's WPSTK lib contains functions to access text ini files.
start view wtkref /s "text initialization"
-
Christian's WPSTK lib contains functions to access text ini files.
start view wtkref /s "text initialization"
As far as I can see it produces and works with .ini file format. Not what you can read and edit with standard text editors. Have I missed something?
-
Using libxml for parsing config files seems popular. This search returns a bunch of hits, https://duckduckgo.com/?q=libxml+for+parsing+config+files (https://duckduckgo.com/?q=libxml+for+parsing+config+files) or can simply search for "parsing config files"
-
Christian's WPSTK lib contains functions to access text ini files.
start view wtkref /s "text initialization"
As far as I can see it produces and works with .ini file format. Not what you can read and edit with standard text editors. Have I missed something?
It's for text ini files.
-
Here are some REXX scripts to convert OS/2 INI files to human editable Rexx scripts. The scripts may help you with your idea.
Converts OS/2 INI files to human editable Rexx scripts
https://hobbes.nmsu.edu/download/pub/os2/util/wps/ini2rexx.zip
-
Hi Andi
You may find genini useful see https://hobbes.nmsu.edu/?detail=%2Fpub%2Fos2%2Futil%2Fconvert%2FGenINI_2.0.zip
Regards
Pete
-
Christian's WPSTK lib contains functions to access text ini files.
start view wtkref /s "text initialization"
As far as I can see it produces and works with .ini file format. Not what you can read and edit with standard text editors. Have I missed something?
It's for text ini files.
I searched the documentation a while and tried the _settings sample as I think this is the right sample. Unfortunately what it produces is a .ini file. Some portions are 'human readable' but not a text file. See attached. Had to rename it to .txt as otherwise I can't upload it here.
-
Hi Andi
You may find genini useful see https://hobbes.nmsu.edu/?detail=%2Fpub%2Fos2%2Futil%2Fconvert%2FGenINI_2.0.zip
Regards
Pete
Thanks. That was my first idea. I started a thread about that at weasel group as I know Peter is there. But Peters tools and samples are in Modula2. And while thinking about making a C interface to inidata.dll I thought there must be similar better alternative exist in applications we have already ported from nix. Thinking of samba.conf or http.conf or ....
-
Using libxml for parsing config files seems popular. This search returns a bunch of hits, https://duckduckgo.com/?q=libxml+for+parsing+config+files (https://duckduckgo.com/?q=libxml+for+parsing+config+files) or can simply search for "parsing config files"
I came across libconfig. I can't make it compile until now. Autoconf .... too less basic nix porting know ledge here.
First thought was xml is a bit overkill to my needs. But maybe I should start learning about. Seems all these apps with 'text file config' do all that fget/sprintf/strcmp handling on there own.
-
I searched the documentation a while and tried the _settings sample as I think this is the right sample.
No, that binary file looks like a part of the WPSTK settings and details manager. Hence the contained setup string. It's not an OS/2 ini file. Text ini files are human readable.
-
In Doodle's Screen Saver, I've written my own (low-cost) function to parse simple text-based config files which contains lines formatted like 'key'='value' (that is what DSSaver uses to store its settings). To generate those text files, it's simple, just use fprintf() with proper format strings. To parse it, it's not that hard either.
For an example, check this:
https://github.com/OS2World/UTIL-WPS-Doodle-Screen-Saver/blob/master/SSCore.c#L337
-
Regarding Christian's lib: The source file is wtkfinit.c (http://trac.netlabs.org/wpstk/browser/trunk/source/lib/wtkfinit.c).
This might give a better overview:
start view wtkref /s "File access functions for text initialization files"