For Programmers: Free Programming Magazines  


Home > Archive > Unix Programming > May 2004 > Config file parsing









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Config file parsing
Jeff Rodriguez

2004-05-12, 9:08 pm

Now I've STFW, and freshmeat and sourceforge, and I found a C++ implementation
which MAY work however I'm looking for something in the public domain. Since
just about everything in unix uses config files, is there some library out there
to parse them automatically under public domain or even BSD style license?

Thanks
Jeff
Måns Rullgård

2004-05-12, 9:08 pm

Jeff Rodriguez <newsgroup1@gurug.EXAMPLENOSPAM.com> writes:

> Now I've STFW, and freshmeat and sourceforge, and I found a C++
> implementation which MAY work however I'm looking for something in the
> public domain. Since just about everything in unix uses config files,
> is there some library out there to parse them automatically under
> public domain or even BSD style license?


libtc has a BSD license and will parse files of a certain format. It
supports nested sections and references between config entries.

--
Måns Rullgård
mru@kth.se
Chuck Dillon

2004-05-12, 9:08 pm

Jeff Rodriguez wrote:
> Now I've STFW, and freshmeat and sourceforge, and I found a C++
> implementation which MAY work however I'm looking for something in the
> public domain. Since just about everything in unix uses config files, is
> there some library out there to parse them automatically under public
> domain or even BSD style license?
>
> Thanks
> Jeff


Xlib

-- ced

--
Chuck Dillon
Senior Software Engineer
NimbleGen Systems Inc.
Ian Zimmerman

2004-05-12, 9:08 pm


Jeff> Now I've STFW, and freshmeat and sourceforge, and I found a C++
Jeff> implementation which MAY work however I'm looking for something in
Jeff> the public domain. Since just about everything in unix uses config
Jeff> files, is there some library out there to parse them automatically
Jeff> under public domain or even BSD style license?

I've tried a couple of such libraries (last time, it was libproplist
from the GNUstep project). I was disappointed every time. The problem
is always the same: in order to provide the desired generality (entries
must be all of strings, integers, enumerations, lists, nested sections,
etc.) the library must provide the information untyped (ie void* or
similar), and the programmer is responsible for determining the type.
For configurations of any complexity beyond trivial, this makes for much
messy code.

I now feel it is best to write a yacc grammar for the config file.
See http://biosconfig.sf.net for an example.

All this assumes you're writing in C/C++; with a higher level language
the options change. In an interpreted language, you can just load
the config file as if it was source code, for example.

--
Nothing can be explained to a stone.
Or to a stoned person, either.
Ian Zimmerman

2004-05-12, 9:08 pm


Following myself:

Ian> See http://biosconfig.sf.net for an example.

Hmm, I don't understand sourceforge yet. Try

http://sf.net/projects/biosconfig

Sorry for that.

--
Nothing can be explained to a stone.
Or to a stoned person, either.
Alex Sisson

2004-05-12, 9:08 pm

Jeff Rodriguez <newsgroup1@gurug.EXAMPLENOSPAM.com> wrote in message news:<RJZnc.17631$k24.4780@fed1read01>...
> Now I've STFW, and freshmeat and sourceforge, and I found a C++ implementation
> which MAY work however I'm looking for something in the public domain. Since
> just about everything in unix uses config files, is there some library out there
> to parse them automatically under public domain or even BSD style license?
>
> Thanks
> Jeff


something crude i have done before is to build up an argc and argv of
all the things in the config, prepend each with --, then parse with
getopt. your options need to be foo=bar with no space tho. the main
reason i did this though was so i could parse command line settings
and config files with same bit of code iirc.
William Ahern

2004-05-12, 9:08 pm

Jeff Rodriguez <newsgroup1@gurug.examplenospam.com> wrote:
> Now I've STFW, and freshmeat and sourceforge, and I found a C++ implementation
> which MAY work however I'm looking for something in the public domain. Since
> just about everything in unix uses config files, is there some library out there
> to parse them automatically under public domain or even BSD style license?


Last time I went on this quest I found:

http://ndevilla.free.fr/iniparser/

Since then I've written a few of my own. FWIW, every platform seems to have
their own particular set of utility functions to assist in this perennial
endeavour. Linux/glibc has getline()--which doesn't do that much--and
OpenBSD (and other BSDs?) have fparseln(). I like the fparseln() interface,
but it's not that easy to move from the OpenBSD sources into your project
sources (too many dependencies, IIRC).

Jeff Rodriguez

2004-05-12, 10:31 pm

Jeff Rodriguez wrote:
> Now I've STFW, and freshmeat and sourceforge, and I found a C++
> implementation which MAY work however I'm looking for something in the
> public domain. Since just about everything in unix uses config files, is
> there some library out there to parse them automatically under public
> domain or even BSD style license?
>
> Thanks
> Jeff

Just poking around, libtc is the best choice so far.

Thanks all,
Jeff
Måns Rullgård

2004-05-13, 3:31 am

Jeff Rodriguez <newsgroup1@gurug.EXAMPLENOSPAM.com> writes:

> Jeff Rodriguez wrote:
> Just poking around, libtc is the best choice so far.


That's nice to know, being the author. Let me know any problems or
compilation issues. I can't test it personally on all the various
Unixes.

--
Måns Rullgård
mru@kth.se
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com