Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 2 Jan 2003 16:20:23 -0700
From:      Chad David <davidc@issci.ca>
To:        Miguel Mendez <flynn@energyhq.homeip.net>
Cc:        Chuck Robey <chuckr@chuckr.org>, mwest@uct.ac.za, kientzle@acm.org, freebsd-hackers@FreeBSD.ORG
Subject:   Re: Reading rc.conf from C programs?
Message-ID:  <20030102232023.GA86743@colnta.acns.ab.ca>
In-Reply-To: <20030102152501.64332e55.flynn@energyhq.homeip.net>
References:  <20030102012042.A16965@apotheosis.org.za> <20030101181840.P29988-100000@april.chuckr.org> <20030102152501.64332e55.flynn@energyhq.homeip.net>

next in thread | previous in thread | raw e-mail | index | archive | help

--sm4nu43k4a2Rpi4c
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Thu, Jan 02, 2003 at 03:25:01PM +0100, Miguel Mendez wrote:
> On Wed, 1 Jan 2003 18:24:40 -0500 (EST)
> Chuck Robey <chuckr@chuckr.org> wrote:
> 
> Hi,
> 
> Since my little baby was mentioned, I thought I'd just comment :)
> 
> > > You could perhaps copy the way that "The Fish" does it?
> > >
> > > Take a look at "ports/sysutils/thefish".
> > >
> > > The "parser.c" code appears to read /etc/{,defaults/}rc.conf and
> > > place all the options into a linked list.
> 
> I can tell you I wholeheartedly hate parser.c :) and regret having not
> started with lex/yacc since day 1. Since the next major release will
> support not only FreeBSD, but NetBSD as well, I'm redoing the parser in
> a more flexible way. But again, it was my first parser, and so far seems
> to work fine :) I've concentrated more on other aspects of the program
> too.

Here is a very simple lex/yacc parser that reads simple key value pairs.
The whole thing took about 30 minutes to write.  Exclusive states may not
be the easiest or best way to handle the parts of the sh syntax that need
to be ignored, but it was a quick way to handle the if, which was all I
cared about.

-- 
Chad David        davidc@issci.ca
www.FreeBSD.org   davidc@freebsd.org
ISSci Inc.        Calgary, Alberta Canada

--sm4nu43k4a2Rpi4c
Content-Type: application/x-tar-gz
Content-Disposition: attachment; filename="readrc.tar.gz"
Content-Transfer-Encoding: base64

H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Okh0b+4PVhEdl/YP23sbGzsaj/Wtv0+//Olqj/vguI4k8Uf6L4E8WfKP7+P4q/lXAQ+cEA
LulHUat9eXQ5/xW8NERohMX/sbNA4Cml24ArRVFqRVsf31dWrmrySjBMg1dwcRKP/wAT49k4
IMZ4QLG+AZ59UMbFCoy89mOZ8EvT80KMZ2m7pVdEmP8cxAYoJcPci37lZ7Ip311YSK4Q//wp
QIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAg4E8P/wYLrjEmAFAAAA==

--sm4nu43k4a2Rpi4c--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030102232023.GA86743>