Author Topic: human readable config file handling - libs we have  (Read 7777 times)

Andi B.

  • Hero Member
  • *****
  • Posts: 811
  • Karma: +11/-2
    • View Profile
human readable config file handling - libs we have
« 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.

Lars

  • Hero Member
  • *****
  • Posts: 1271
  • Karma: +65/-0
    • View Profile
Re: human readable config file handling - libs we have
« Reply #1 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.

Lars

  • Hero Member
  • *****
  • Posts: 1271
  • Karma: +65/-0
    • View Profile
Re: human readable config file handling - libs we have
« Reply #2 on: February 06, 2021, 02:15:50 pm »
Sorry, that supports the WinNT type of registry.

Andreas Schnellbacher

  • Hero Member
  • *****
  • Posts: 827
  • Karma: +14/-0
    • View Profile
Re: human readable config file handling - libs we have
« Reply #3 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"

Andi B.

  • Hero Member
  • *****
  • Posts: 811
  • Karma: +11/-2
    • View Profile
Re: human readable config file handling - libs we have
« Reply #4 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?

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4786
  • Karma: +99/-1
    • View Profile
Re: human readable config file handling - libs we have
« Reply #5 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 or can simply search for "parsing config files"

Andreas Schnellbacher

  • Hero Member
  • *****
  • Posts: 827
  • Karma: +14/-0
    • View Profile
Re: human readable config file handling - libs we have
« Reply #6 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.

David Graser

  • Hero Member
  • *****
  • Posts: 870
  • Karma: +84/-0
    • View Profile
Re: human readable config file handling - libs we have
« Reply #7 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

« Last Edit: February 07, 2021, 01:29:20 am by David Graser »

Pete

  • Hero Member
  • *****
  • Posts: 1281
  • Karma: +9/-0
    • View Profile
Re: human readable config file handling - libs we have
« Reply #8 on: February 07, 2021, 02:06:38 am »

Andi B.

  • Hero Member
  • *****
  • Posts: 811
  • Karma: +11/-2
    • View Profile
Re: human readable config file handling - libs we have
« Reply #9 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.

Andi B.

  • Hero Member
  • *****
  • Posts: 811
  • Karma: +11/-2
    • View Profile
Re: human readable config file handling - libs we have
« Reply #10 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 ....

Andi B.

  • Hero Member
  • *****
  • Posts: 811
  • Karma: +11/-2
    • View Profile
Re: human readable config file handling - libs we have
« Reply #11 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 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.

Andreas Schnellbacher

  • Hero Member
  • *****
  • Posts: 827
  • Karma: +14/-0
    • View Profile
Re: human readable config file handling - libs we have
« Reply #12 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.

Doodle

  • Newbie
  • *
  • Posts: 6
  • Karma: +1/-0
    • View Profile
Re: human readable config file handling - libs we have
« Reply #13 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

Andreas Schnellbacher

  • Hero Member
  • *****
  • Posts: 827
  • Karma: +14/-0
    • View Profile
Re: human readable config file handling - libs we have
« Reply #14 on: February 08, 2021, 09:20:03 am »
Regarding Christian's lib: The source file is wtkfinit.c.

This might give a better overview:

Code: [Select]
start view wtkref /s "File access functions for text initialization files"
« Last Edit: February 08, 2021, 10:01:39 am by Andreas Schnellbacher »