OS2 World Community Forum

OS/2, eCS & ArcaOS - Technical => Programming => Topic started by: Andi B. on February 06, 2021, 11:18:20 am

Title: human readable config file handling - libs we have
Post 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.
Title: Re: human readable config file handling - libs we have
Post by: Lars on February 06, 2021, 02:11:35 pm
Use the old Win31 API. That comes as part of the DAPI extensions. You will need to search a little to find the documentation.
Title: Re: human readable config file handling - libs we have
Post by: Lars on February 06, 2021, 02:15:50 pm
Sorry, that supports the WinNT type of registry.
Title: Re: human readable config file handling - libs we have
Post by: Andreas Schnellbacher on February 06, 2021, 03:41:46 pm
Christian's WPSTK lib contains functions to access text ini files.

Code: [Select]
start view wtkref /s "text initialization"
Title: Re: human readable config file handling - libs we have
Post by: Andi B. on February 06, 2021, 06:02:26 pm
Christian's WPSTK lib contains functions to access text ini files.

Code: [Select]
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?
Title: Re: human readable config file handling - libs we have
Post by: Dave Yeo on February 06, 2021, 06:41:52 pm
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"
Title: Re: human readable config file handling - libs we have
Post by: Andreas Schnellbacher on February 06, 2021, 08:57:16 pm
Christian's WPSTK lib contains functions to access text ini files.

Code: [Select]
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.
Title: Re: human readable config file handling - libs we have
Post by: David Graser on February 07, 2021, 01:02:22 am
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

Title: Re: human readable config file handling - libs we have
Post by: Pete on February 07, 2021, 02:06:38 am
Hi Andi

You may find genini useful see https://hobbes.nmsu.edu/?detail=%2Fpub%2Fos2%2Futil%2Fconvert%2FGenINI_2.0.zip


Regards

Pete
Title: Re: human readable config file handling - libs we have
Post by: Andi B. on February 07, 2021, 12:08:00 pm
Christian's WPSTK lib contains functions to access text ini files.

Code: [Select]
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.
Title: Re: human readable config file handling - libs we have
Post by: Andi B. on February 07, 2021, 12:11:37 pm
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 ....
Title: Re: human readable config file handling - libs we have
Post by: Andi B. on February 07, 2021, 12:17:20 pm
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.
Title: Re: human readable config file handling - libs we have
Post by: Andreas Schnellbacher on February 07, 2021, 05:05:55 pm
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.
Title: Re: human readable config file handling - libs we have
Post by: Doodle on February 07, 2021, 05:45:39 pm
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
Title: Re: human readable config file handling - libs we have
Post by: Andreas Schnellbacher on February 08, 2021, 09:20:03 am
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:

Code: [Select]
start view wtkref /s "File access functions for text initialization files"