Searching \ for '[OT] Code to read/write configuration files on Lin' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: massmind.org/techref/index.htm?key=code+readwrite+configuration
Search entire site for: 'Code to read/write configuration files on Lin'.

Exact match. Not showing close matches.
PICList Thread
'[OT] Code to read/write configuration files on Lin'
2005\04\22@035903 by Ake Hedman

flavicon
face
Hi I have searched the net all morning for code to work with configuration files under Linux, preferable XML format, but without luck. Have anyone seen some open source code that could read write from/to a configuration file in a similar way as the how the registry routines work on WIN32 work. Any pointers or experience would be appreciated.

Cheers
/Ake

--  ---
Ake Hedman (YAP - Yet Another Programmer)
eurosource, Brattbergavägen 17, 820 50 LOS, Sweden
Phone: (46) 657 413430 Cellular: (46) 73 84 84 102
Company home: http://www.eurosource.se      Kryddor/Te/Kaffe: http://www.brattberg.com
Personal homepage: http://www.eurosource.se/akhe
Automated home: http://www.vscp.org

2005\04\22@095656 by Herbert Graf

flavicon
face
On Fri, 2005-04-22 at 09:58 +0200, Ake Hedman wrote:
> Hi I have searched the net all morning for code to work with
> configuration files under Linux, preferable XML format, but without
> luck. Have anyone seen some open source code that could read write
> from/to a configuration file in a similar way as the how the registry
> routines work on WIN32 work. Any pointers or experience would be
> appreciated.

I'm not exactly sure what your asking, however, one thing you may not be
aware of is that in Linux there is no standardization of configuration
data. There is no single file that everything uses (which may sound bad
at first, but then consider what happens if your registry goes boom, no
more windows, in Linux a conifg file "boom" would only affect that
program). Generally each program has it's own configuration file, and
the format of it's configuration file may very well be unique to that
program. There are some "understandings" on what config files should
look like (i.e. only text, certain characters at beginning of line
indicate comments, etc.), but there is by far no universal format.

Now, if you're simply looking for a "mapping" sort of routine that takes
windows style registry accesses and translates them into modifications
to a config file, that's a different story. TTYL


-----------------------------
Herbert's PIC Stuff:
http://repatch.dyndns.org:8383/pic_stuff/

2005\04\22@100105 by Martin McCormick

flavicon
face
Ake Hedman writes:
>Hi I have searched the net all morning for code to work with
>configuration files under Linux, preferable XML format, but without
>luck. Have anyone seen some open source code that could read write
>from/to a configuration file in a similar way as the how the registry
>routines work on WIN32 work. Any pointers or experience would be
>appreciated.

       I am not totally sure I understand all of the question at hand
so my apology if I missed something, but you will find the
configuration files in Linux and UNIX in general to be refreshingly
transparent compared to the fun and games associated with the Windows
registry.

       The configuration files are in plain text which means they are
human-readable at face value and can even contain comments.  Sometimes
their input generates binary data base files but nobody needs to edit those
manually as they can be rebuilt when desired so one does whatever
editing is necessary in the text file and then, if necessary, rebuilds
any data bases.

       You will need to read about the files you want to modify and
understand how they work so you can then modify them safely.

       Some Linux/UNIX configuration files are re-read each time
there is a need for them such as /etc/resolv.conf and others are only
read each time that the process that uses them either starts up after
a reboot or is told to reset itself which is known in the UNIX world
as a kill -HUP directive.  If you change the config file used by such
a process, your changes won't mean a thing until you issue another
kill -HUP or reboot the system.

       Basically, there is no one answer to your question.  You need
to research how Linux works from a configuration standpoint and
proceed from there.


Martin McCormick WB5AGZ  Stillwater, OK
OSU Information Technology Division Network Operations Group

2005\04\22@100905 by Alex Harford

face picon face
On 4/22/05, Ake Hedman <spam_OUTakheTakeThisOuTspameurosource.se> wrote:
> Hi I have searched the net all morning for code to work with
> configuration files under Linux, preferable XML format, but without

Some suggestions for you:

1) wxWindows has routines for config files that are cross platform.  I
think the look like Windows .ini files (which I find nice to read and
edit by hand).

2) Have a look at the config parser code in the OLSR project (http://www.olsr.org).

3) Learn expat for XML parsing.

Alex

2005\04\22@105611 by Ake Hedman
flavicon
face
Hi Herbert,

sorry for not giving all info. First of all I should have included that my project is in C/C++. Do it now instead.

Yes I know the common format for most config. files today and for reading config data I have some stuff in my own code lib. But this time I need to write config data as well so I need a human readable/editable config file from which my program can read/write configdata.

Of course I can add write capabilities to my own config lib but there is a lot to do and if I find something  that is available and working I rather use that to save time. After all that how we open source people work. ;-)  This is such a common thing that its just has to be something available. I know I have seen something mentioned somewhere but can't remember where.

Thanks for taking the time.

/Ake

Herbert Graf wrote:

{Quote hidden}

--  ---
Ake Hedman (YAP - Yet Another Programmer)
eurosource, Brattbergavägen 17, 820 50 LOS, Sweden
Phone: (46) 657 413430 Cellular: (46) 73 84 84 102
Company home: http://www.eurosource.se      Kryddor/Te/Kaffe: http://www.brattberg.com
Personal homepage: http://www.eurosource.se/akhe
Automated home: http://www.vscp.org

2005\04\22@110946 by Ake Hedman

flavicon
face
Thanks Alex,

In wxWidgets!!! :-)  The answer right infront of me...  This is a wxWidgets project so this was the perfect suggestion. I have just worked  about a year with wxWidgets and wxConfigBase has hidden itself in the docs. I use expat in an other part of the project to get configuration data for local nodes from a web server and it was something I considered. But being such a common task I expected there must be tons of code out there doing this. But wxWidgets will be perfect in my case.

A big thanks! Also to all others that took the time to respond. Very much appreciated.

Cheers
/Ake


Alex Harford wrote:

{Quote hidden}

--  ---
Ake Hedman (YAP - Yet Another Programmer)
eurosource, Brattbergavägen 17, 820 50 LOS, Sweden
Phone: (46) 657 413430 Cellular: (46) 73 84 84 102
Company home: http://www.eurosource.se      Kryddor/Te/Kaffe: http://www.brattberg.com
Personal homepage: http://www.eurosource.se/akhe
Automated home: http://www.vscp.org

2005\04\22@122152 by Peter

picon face


On Fri, 22 Apr 2005, Ake Hedman wrote:

> Hi I have searched the net all morning for code to work with configuration
> files under Linux, preferable XML format, but without luck. Have anyone seen
> some open source code that could read write from/to a configuration file in a
> similar way as the how the registry routines work on WIN32 work. Any pointers
> or experience would be appreciated.

http://www.advogato.org/proj/GConf/

Do not be put off by the date of that page, it is in active use.

Peter

2005\04\22@130444 by Ake Hedman

flavicon
face
Peter wrote:

>
>
> On Fri, 22 Apr 2005, Ake Hedman wrote:
>
>> Hi I have searched the net all morning for code to work with
>> configuration files under Linux, preferable XML format, but without
>> luck. Have anyone seen some open source code that could read write
>> from/to a configuration file in a similar way as the how the registry
>> routines work on WIN32 work. Any pointers or experience would be
>> appreciated.
>
>
> http://www.advogato.org/proj/GConf/
>
> Do not be put off by the date of that page, it is in active use.
>
> Peter


Thanks, will have a look at it. Have you worked with it. It appears to be part of gnome so I guess this must be well tested.

Cheers
/Ake

--  ---
Ake Hedman (YAP - Yet Another Programmer)
eurosource, Brattbergavägen 17, 820 50 LOS, Sweden
Phone: (46) 657 413430 Cellular: (46) 73 84 84 102
Company home: http://www.eurosource.se      Kryddor/Te/Kaffe: http://www.brattberg.com
Personal homepage: http://www.eurosource.se/akhe
Automated home: http://www.vscp.org

2005\04\22@130809 by Nicolas

picon face
Qt (C++ library) also has a QSettings class (cross-platform win32/unix/mac)...
see http://doc.trolltech.com/3.3/qsettings.html

On 4/22/05, Peter <plpspamKILLspamactcom.co.il> wrote:
{Quote hidden}

> -

2005\04\22@132914 by Ake Hedman

flavicon
face
Nicolas wrote:

>Qt (C++ library) also has a QSettings class (cross-platform win32/unix/mac)...
>see http://doc.trolltech.com/3.3/qsettings.html
>  
>

qt was  what we wanted to use for this project. But our project is open source for both win32 and Linux so we where unable to use qt. Which was sad. Now I here they will release 4.0 with dual license for win32 as well. To late for us now I guess. For others in the process of deciding on cross platform development take look at qt (http://www.troll.no). But also wxWidgets of course (http://www.wxwidgets.org). IMHO qt is the best graphical development framework for C++ programmers available.

Thanks Nicolas.
/Ake

--  ---
Ake Hedman (YAP - Yet Another Programmer)
eurosource, Brattbergavägen 17, 820 50 LOS, Sweden
Phone: (46) 657 413430 Cellular: (46) 73 84 84 102
Company home: http://www.eurosource.se      Kryddor/Te/Kaffe: http://www.brattberg.com
Personal homepage: http://www.eurosource.se/akhe
Automated home: http://www.vscp.org

2005\04\23@153534 by Peter

picon face

On Fri, 22 Apr 2005, Nicolas wrote:

> Qt (C++ library) also has a QSettings class (cross-platform win32/unix/mac)...
> see http://doc.trolltech.com/3.3/qsettings.html

The difference between the Qt config file engine and Gconf[d] is that
gconfd can parse any text type config file while Qt expects its own
format. Thus if you run your own file format you want to use Qt but if
you need to understand any file then gconf[d] may be better.

Peter

More... (looser matching)
- Last day of these posts
- In 2005 , 2006 only
- Today
- New search...