Re: Generic config file parser?

2000-05-30 Thread Martin Cracauer

In <[EMAIL PROTECTED]>, Ade Lovett wrote: 
> Be advised, however, the ports/textproc/libxml has a 2.0 version
> floating around "out there" on the GNOME sites, which does have
> a reasonable amount of incompatibility at the API level.. my
> understanding is that the 1.x series is now end-of-life.

Last time I looked there wasn't a clear license statement in libxml.
I contains the GPL and LGPL license files, but no indication which
license is used for what.  Unless that changed or if they intend to
use the GPL...

Martin
-- 
%
Martin Cracauer <[EMAIL PROTECTED]> http://www.cons.org/cracauer/
BSD User Group Hamburg, Germany http://www.bsdhh.org/


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: Generic config file parser?

2000-05-29 Thread Wes Peters

Ade Lovett wrote:
> 
> On Mon, May 29, 2000 at 12:53:59AM -0600, Wes Peters wrote:
> > A better choice might be found in XML.  Exploring the port of libxml
> > (in ports/textproc) might be enlightening.
> 
> XML is almost certainly a better option..  the more I look at it,
> the more I think it will cover most all of the config file issues
> that I have, both at home and RealJob[tm].
> 
> Be advised, however, the ports/textproc/libxml has a 2.0 version
> floating around "out there" on the GNOME sites, which does have
> a reasonable amount of incompatibility at the API level.. my
> understanding is that the 1.x series is now end-of-life.
> 
> Having said that, the port isn't going to change quickly..
> a whole bunch of stuff depends on it right now.

And the geniuses at Gnome didn't make any provision for installing
both libxml and libxml2 simultaneously.  Building libxml2 is trivial,
but installing it overwrites the libxml include files and libraries.
Feh.

-- 
"Where am I, and what am I doing in this handbasket?"

Wes Peters Softweyr LLC
[EMAIL PROTECTED]   http://softweyr.com/


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: Generic config file parser?

2000-05-29 Thread Ade Lovett

On Mon, May 29, 2000 at 12:53:59AM -0600, Wes Peters wrote:
> A better choice might be found in XML.  Exploring the port of libxml
> (in ports/textproc) might be enlightening.

XML is almost certainly a better option..  the more I look at it,
the more I think it will cover most all of the config file issues
that I have, both at home and RealJob[tm].

Be advised, however, the ports/textproc/libxml has a 2.0 version
floating around "out there" on the GNOME sites, which does have
a reasonable amount of incompatibility at the API level.. my
understanding is that the 1.x series is now end-of-life.

Having said that, the port isn't going to change quickly..
a whole bunch of stuff depends on it right now.

-aDe

-- 
Ade Lovett, Austin, TX. [EMAIL PROTECTED]
FreeBSD: The Power to Serve http://www.FreeBSD.org/


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: Generic config file parser?

2000-05-29 Thread Louis A. Mamakos


I usually just embed a TCL interpreter into tools that require a lot 
of configurability.  You can then use that infrastructure to extend
the tool as well.  You can make config files which can just be eval'ed
by TCL to configuration your application.

louie

> Wes Peters wrote:
> > 
> > > I'm really want to make this thing generic and unite it with
> > > others config file parsers (if memory serves me right, Daniel Sobral wrote
> > > RW version for rc.conf style files).
> > 
> > Not needed, there is such a parser library included in OpenSSL, which
> > is included in FreeBSD by default as of 4.0.  The documenation is
> > non-existent, but I suspect it will show up sooner than yet another
> > development effort would produce.
> 
> Well, it _doesn't_ handle loader/rc.conf format, hosts format,
> inetd.conf format, pccard.conf format, etc, which is what bp is talking
> about. And, remember, _his_ library is already in the system too.
> 
> But, alas, the format thing isn't even the beginning. That stuff doesn't
> do HALF the stuff my own libconf does. It doesn't handle nested
> sections, it doesn't handle multiple input files (which is pretty much
> the way we decided to do things), it does _update_ the files, it doesn't
> handle descriptions, it doesn't handle set/unset with comments, it
> doesn't handle unset (commented-out) options for reference purposes,
> doesn't handle multiple instances of a setting... and, then, it's access
> methods are pitiable. You can't enumerate settings in a section,
> enumerate sections, etc.
> 
> Now, my library, which does all of the above, was shot down by msmith
> because *IT* doesn't handle a lot of stuff that ought to be handled.
> 
> > A better choice might be found in XML.  Exploring the port of libxml
> > (in ports/textproc) might be enlightening.
> 
> As long as we don't have to change the format the options are in. :-) It
> can get difficult once you are receiving input by NIS or NDAP, or the
> file formats are beyond your control. :-)
> 
> -- 
> Daniel C. Sobral  (8-DCS)
> [EMAIL PROTECTED]
> [EMAIL PROTECTED]
> [EMAIL PROTECTED]
> 
>   "Sentience hurts."
> 
> 
> To Unsubscribe: send mail to [EMAIL PROTECTED]
> with "unsubscribe freebsd-hackers" in the body of the message




To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: Generic config file parser?

2000-05-29 Thread Tim Vanderhoek

On Mon, May 29, 2000 at 02:00:37AM +0200, A G F Keahan wrote:
>
> This may be a silly question, but is there such a thing?Almost every
> program that I know uses configuration files, often in different,
> incompatible formats.   I personally prefer Samba/Wine-style config

man 3 property

for a start, anyways.


-- 
Signature withheld by request of author.


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: Generic config file parser?

2000-05-29 Thread Daniel C. Sobral

Wes Peters wrote:
> 
> > I'm really want to make this thing generic and unite it with
> > others config file parsers (if memory serves me right, Daniel Sobral wrote
> > RW version for rc.conf style files).
> 
> Not needed, there is such a parser library included in OpenSSL, which
> is included in FreeBSD by default as of 4.0.  The documenation is
> non-existent, but I suspect it will show up sooner than yet another
> development effort would produce.

Well, it _doesn't_ handle loader/rc.conf format, hosts format,
inetd.conf format, pccard.conf format, etc, which is what bp is talking
about. And, remember, _his_ library is already in the system too.

But, alas, the format thing isn't even the beginning. That stuff doesn't
do HALF the stuff my own libconf does. It doesn't handle nested
sections, it doesn't handle multiple input files (which is pretty much
the way we decided to do things), it does _update_ the files, it doesn't
handle descriptions, it doesn't handle set/unset with comments, it
doesn't handle unset (commented-out) options for reference purposes,
doesn't handle multiple instances of a setting... and, then, it's access
methods are pitiable. You can't enumerate settings in a section,
enumerate sections, etc.

Now, my library, which does all of the above, was shot down by msmith
because *IT* doesn't handle a lot of stuff that ought to be handled.

> A better choice might be found in XML.  Exploring the port of libxml
> (in ports/textproc) might be enlightening.

As long as we don't have to change the format the options are in. :-) It
can get difficult once you are receiving input by NIS or NDAP, or the
file formats are beyond your control. :-)

-- 
Daniel C. Sobral(8-DCS)
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]

"Sentience hurts."


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: Generic config file parser?

2000-05-29 Thread Daniel C. Sobral

A G F Keahan wrote:
> 
> Which does not necessarily make it bad, of course, it's just nice to
> separate things out.   Many UNIX applications use similar formats;  you
> don't have to go very far to find an example -- look at e.g.
> /etc/defaults/rc.conf, which has distinct sections separated by comments
> like this one:
> 
> ##
> ###  Important initial Boot-time options  
> ##
> 
> I'll say it again -- I'm not specifically after a Windows-style config
> file parser, just any similar type thing.

You can find libconf on http://people.freebsd.org/~dcs/, which will
parse rc.conf-style files. At one point it was my intention importing it
intou our tree, but I was dissuaded by my senpai, who said do it right
or don't do it at all (even though it was done already :).

-- 
Daniel C. Sobral(8-DCS)
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]

"Sentience hurts."



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: Generic config file parser?

2000-05-29 Thread Martin Cracauer

In <[EMAIL PROTECTED]>, A G F Keahan wrote: 
> This may be a silly question, but is there such a thing?Almost every
> program that I know uses configuration files, often in different,
> incompatible formats.   I personally prefer Samba/Wine-style config
> files which are split into "sections" like this:
> 
> [SECTIONNAME1]
> wibble1 = blah
> wibble2 = 35
> wibble3 = "a string that has more than one word"
> ; this is a comment -- ignored
> wibble4 = 4.567e9
> 
> What I'm after is some kind of a generic parser function, which you can
> give a section name "SECTIONNAME1"), a token name (e.g. "wibble1"), a
> separator (e.g. "=", ":", or white space ""), and a variable of some
> type (char *, int, float, etc), and have it return "true" and the
> requested value if it exists, or "false" if the value was not found or
> datatype was incorrectly specified.   Similarly, I want to be able to
> save a value into a given section of the file, possibly replacing an
> existing value, or adding a new one.

It's exactly this what XML is for.  It gives you a generic way to
define file syntaxes, so that not only your program can read it, but
also generic file checkers, GUI tools that support other people in
writing such files in environments they like.  Also, its would be easy
to use in one of the many languages that have a XML library (no need
to use a foreign interface to your C library).

The syntax can easily include collections of all kinds, including
trees, which is more difficult to make in home-grown parsers.  At
least the history of my applications using config files shows that
sooner or later things become more complex and need such features.
The usual way to hack around the problem is to put collections in
strings, which breaks the normal syntax error reporting.

I have to admit that my main ASCII-parsing application still uses a
hack-up C++ (urgs) parser, basically since I didn't find a sufficient
XML parsing library for C so far, but the mess is incredible (the
applications will be 10 years out this summer).  I can only advice you
to use synaxtes that could (not necessarily from start) be parsed by
existing technology that leave roon for syntax expansion.

Martin
-- 
%
Martin Cracauer <[EMAIL PROTECTED]> http://www.cons.org/cracauer/
BSD User Group Hamburg, Germany http://www.bsdhh.org/


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: Generic config file parser?

2000-05-29 Thread Boris Popov

On Mon, 29 May 2000, Wes Peters wrote:

> > Yes, there is such thing. I've used this format for nwfs/smbfs
> > configuration files. You may look at old version of this parser in
> > src/lib/libncp/ncpl_rcfile.c or download smbfs sources
> > (ftp://ftp.butya.kz/pub/smbfs/smbfs.tar.gz) and look in the
> > lib/smb/rcfile.c for more generalized interface.
> > 
> > I'm really want to make this thing generic and unite it with
> > others config file parsers (if memory serves me right, Daniel Sobral wrote
> > RW version for rc.conf style files).
> 
> Not needed, there is such a parser library included in OpenSSL, which 
> is included in FreeBSD by default as of 4.0.  The documenation is
> non-existent, but I suspect it will show up sooner than yet another
> development effort would produce.
> 
> See /usr/src/crypto/openssl/crypto/conf for more info: UTSL.

No, while we have N_OPEN* switches in the make.conf file, this
library isn't standard. For example, I don't have any of open* programs
compiled and installed, so there is no /usr/lib/libcrypto* files.

--
Boris Popov
http://www.butya.kz/~bp/



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: Generic config file parser?

2000-05-29 Thread Garance A Drosihn

At 5:54 PM -0700 5/28/00, Brian O'Shea wrote:
>You are right, this could be done, but I wouldn't call it
>trivial.  I've always come to the conclusion that the interface
>to something like this would have to be kind of complex in order
>to keep it generic enough to be really useful.  For instance,
>there isn't one standard Unix config file format.  Do you want
>to build into it some of the different [commonly used] formats?
>If so, who defines these formats?  [...etc...]
>
>All of this is managable, it just seems like more trouble than
>it's worth. (but if you write it, I'll probably use it! ;)

For what it's worth, a long time ago and in a operating system
far away, we had something called "command language parser".
It was meant for parsing things more complicated than simple
options on a standard unix command-line, but not complicated
enough to pull out lex & yacc.  As the sun was setting on that
operating-system empire, it was rewritten in C, and then lost
track of...

I recently tracked down the author and picked up a more recent
copy of the C version.  There are licensing issues which were
left in limbo, so I can't just give it out without checking
with him.  Still, it could have easily handled the kind of
config file you're talking about.  While you'll have to do some
guessing as to what the following means, it's almost good enough
to parse the example for:

>   [SECTIONNAME1]
>   wibble1 = blah
>   wibble2 = 35
>   wibble3 = "a string that has more than one word"
>   ; this is a comment -- ignored
>   wibble4 = 4.567e9

// - - - - - - - start of example clparser code
procedure myactions for all;

terminal  is 1 to 100 of "ABCDEFGHIJKLMNOPQRSTUVWXYZ_1234567890";
terminal  is 1 to 15 of "1234567890";
terminal  is 1 or more characters;
terminal  is 1 or more of " \t";
 is  "=" ;
 is  @SaveInt ( "." (  @SaveDecInt ) ) @SaveFloat;

goal 
  is "["  @SaveTerm "]" @SetSection
  or "wibble1"   @SaveTerm @SetW1
  or "wibble2"   @SaveInt @SetW2
  or "wibble3"   @SaveStr @SetW3
  or ";"// Just ignore, do nothing...
  or "wibble4"   @SaveFloat @SetW4;

terminal  is 1 or more excluding ;
 is  @InitStr ()... ;
 is  @String_Seg_1
   or "" @String_Seg_2// embedded double quote
   ;
  is 
   or @Invalid_Qstring;   // must at be end of line

// - - - - - - - end of the example code

Clparser has two pieces.  The first you can think of as a
compiler, which will read in the above source and spit out
an include file and an "object" file (which is just a lot
of tables).  The second part is clplib, which is what you
link your program to.

The '//' starts a comment line (in clpgen).  '@xxx' means
call procedure 'myactions' (which was specified in the first
line) with the semantic action named 'xxx', where the C-value
for 'xxx' will be defined (enum'ed?) in the include library
that clpgen will generate.  You'd use the semantic action in
a switch() statement.  Something like 'SaveInt' would call a
routine in clplib to pick up the character string ("terminal")
just matched, and know how to turn that into an integer which
it would save away somewhere for some other action to pick up.

What I have there is cut & pasted from some examples, and I'm
sure it's not quite right.   is probably bogus, for
instance.  But the idea is that SaveInt would save the integer
value, clparser then would match an optional decimal-point,
followed by another optional integer (which 'myactions' would
save into a different variable), and then 'SaveFloat' would
pick up the two integer pieces and create a floating-point
number to match.

Clparser was very convenient for doing this kind of thing, and
I do hope to dust it off and see about using it once again...


---
Garance Alistair Drosehn   =   [EMAIL PROTECTED]
Senior Systems Programmer  or  [EMAIL PROTECTED]
Rensselaer Polytechnic Institute


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: Generic config file parser?

2000-05-28 Thread Wes Peters

Boris Popov wrote:
> 
> On Mon, 29 May 2000, A G F Keahan wrote:
> 
> > This may be a silly question, but is there such a thing?Almost every
> > program that I know uses configuration files, often in different,
> > incompatible formats.   I personally prefer Samba/Wine-style config
> > files which are split into "sections" like this:
> 
> Yes, there is such thing. I've used this format for nwfs/smbfs
> configuration files. You may look at old version of this parser in
> src/lib/libncp/ncpl_rcfile.c or download smbfs sources
> (ftp://ftp.butya.kz/pub/smbfs/smbfs.tar.gz) and look in the
> lib/smb/rcfile.c for more generalized interface.
> 
> I'm really want to make this thing generic and unite it with
> others config file parsers (if memory serves me right, Daniel Sobral wrote
> RW version for rc.conf style files).

Not needed, there is such a parser library included in OpenSSL, which 
is included in FreeBSD by default as of 4.0.  The documenation is
non-existent, but I suspect it will show up sooner than yet another
development effort would produce.

See /usr/src/crypto/openssl/crypto/conf for more info: UTSL.

A better choice might be found in XML.  Exploring the port of libxml
(in ports/textproc) might be enlightening.

-- 
"Where am I, and what am I doing in this handbasket?"

Wes Peters Softweyr LLC
[EMAIL PROTECTED]   http://softweyr.com/


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: Generic config file parser?

2000-05-28 Thread Boris Popov

On Mon, 29 May 2000, A G F Keahan wrote:

> This may be a silly question, but is there such a thing?Almost every
> program that I know uses configuration files, often in different,
> incompatible formats.   I personally prefer Samba/Wine-style config
> files which are split into "sections" like this:

Yes, there is such thing. I've used this format for nwfs/smbfs
configuration files. You may look at old version of this parser in
src/lib/libncp/ncpl_rcfile.c or download smbfs sources
(ftp://ftp.butya.kz/pub/smbfs/smbfs.tar.gz) and look in the
lib/smb/rcfile.c for more generalized interface.

I'm really want to make this thing generic and unite it with
others config file parsers (if memory serves me right, Daniel Sobral wrote
RW version for rc.conf style files).

The only big problem is the name of the library file - last time
it was discussed there was no consensus on this topic.

--
Boris Popov
http://www.butya.kz/~bp/



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: Generic config file parser?

2000-05-28 Thread Brian O'Shea

On Mon, May 29, 2000 at 02:00:37AM +0200, A G F Keahan scribbled:
> 
> [SECTIONNAME1]
> wibble1 = blah
> wibble2 = 35
> wibble3 = "a string that has more than one word"
> ; this is a comment -- ignored
> wibble4 = 4.567e9
> 



> 
> A trivial thing to write, and a very useful one -- surely it's been done
> before, no?

Not that I know of, but I havn't looked very far.

You are right, this could be done, but I wouldn't call it trivial.  I've
always come to the conclusion that the interface to something like this
would have to be kind of complex in order to keep it generic enough to
be really useful.  For instance, there isn't one standard Unix config
file format.  Do you want to build into it some of the different
[commonly used] formats?  If so, who defines these formats?  What kinds
of restrictions do you want to impose on it?  Do you want to enforce
unique identifiers?  Globally unique or just unique within a section?
Should this be configurable (with a config file?! ;) ?  Why not just use
xml?  (the token xml suggestion, sorry)

All of this is managable, it just seems like more trouble than it's
worth. (but if you write it, I'll probably use it! ;)

-brian

-- 
Brian O'Shea
[EMAIL PROTECTED]


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: Generic config file parser?

2000-05-28 Thread Doug Barton

A G F Keahan wrote:

> > It's possible, though unlikely, since what you're describing is a
> > windows style config format.
> 
> Which does not necessarily make it bad, of course

And I didn't say it was bad. Just unlikely.

-- 
"Live free or die"
- State motto of my ancestral homeland, New Hampshire

Do YOU Yahoo!?


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: Generic config file parser?

2000-05-28 Thread A G F Keahan

Doug Barton wrote:
> 
> A G F Keahan wrote:
> >
> > This may be a silly question, but is there such a thing?Almost every
> > program that I know uses configuration files, often in different,
> > incompatible formats.   I personally prefer Samba/Wine-style config
> > files which are split into "sections" like this:
> >
> > [SECTIONNAME1]
> > wibble1 = blah
> > wibble2 = 35
> > wibble3 = "a string that has more than one word"
> > ; this is a comment -- ignored
> > wibble4 = 4.567e9
> 
> > A trivial thing to write, and a very useful one -- surely it's been done
> > before, no?
> 
> It's possible, though unlikely, since what you're describing is a
> windows style config format.


Which does not necessarily make it bad, of course, it's just nice to
separate things out.   Many UNIX applications use similar formats;  you
don't have to go very far to find an example -- look at e.g.
/etc/defaults/rc.conf, which has distinct sections separated by comments
like this one:

##
###  Important initial Boot-time options  
##

I'll say it again -- I'm not specifically after a Windows-style config
file parser, just any similar type thing.

Alex


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: Generic config file parser?

2000-05-28 Thread Doug Barton

A G F Keahan wrote:
> 
> This may be a silly question, but is there such a thing?Almost every
> program that I know uses configuration files, often in different,
> incompatible formats.   I personally prefer Samba/Wine-style config
> files which are split into "sections" like this:
> 
> [SECTIONNAME1]
> wibble1 = blah
> wibble2 = 35
> wibble3 = "a string that has more than one word"
> ; this is a comment -- ignored
> wibble4 = 4.567e9

> A trivial thing to write, and a very useful one -- surely it's been done
> before, no?

It's possible, though unlikely, since what you're describing is a
windows style config format. 

Doug
-- 
"Live free or die"
- State motto of my ancestral homeland, New Hampshire

Do YOU Yahoo!?


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Generic config file parser?

2000-05-28 Thread A G F Keahan

This may be a silly question, but is there such a thing?Almost every
program that I know uses configuration files, often in different,
incompatible formats.   I personally prefer Samba/Wine-style config
files which are split into "sections" like this:

[SECTIONNAME1]
wibble1 = blah
wibble2 = 35
wibble3 = "a string that has more than one word"
; this is a comment -- ignored
wibble4 = 4.567e9

What I'm after is some kind of a generic parser function, which you can
give a section name "SECTIONNAME1"), a token name (e.g. "wibble1"), a
separator (e.g. "=", ":", or white space ""), and a variable of some
type (char *, int, float, etc), and have it return "true" and the
requested value if it exists, or "false" if the value was not found or
datatype was incorrectly specified.   Similarly, I want to be able to
save a value into a given section of the file, possibly replacing an
existing value, or adding a new one.

A trivial thing to write, and a very useful one -- surely it's been done
before, no?

Alex


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message