From owner-freebsd-hackers Thu Jan 2 6:25:19 2003 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5E3FC37B401 for ; Thu, 2 Jan 2003 06:25:17 -0800 (PST) Received: from energyhq.homeip.net (213-97-200-73.uc.nombres.ttd.es [213.97.200.73]) by mx1.FreeBSD.org (Postfix) with ESMTP id CC76843E4A for ; Thu, 2 Jan 2003 06:25:15 -0800 (PST) (envelope-from flynn@energyhq.homeip.net) Received: from christine.energyhq.tk (christine.energyhq.tk [192.168.0.1]) by energyhq.homeip.net (Postfix) with SMTP id E7C90AF585; Thu, 2 Jan 2003 15:25:10 +0100 (CET) Date: Thu, 2 Jan 2003 15:25:01 +0100 From: Miguel Mendez To: Chuck Robey Cc: mwest@uct.ac.za, kientzle@acm.org, freebsd-hackers@FreeBSD.ORG Subject: Re: Reading rc.conf from C programs? Message-Id: <20030102152501.64332e55.flynn@energyhq.homeip.net> In-Reply-To: <20030101181840.P29988-100000@april.chuckr.org> References: <20030102012042.A16965@apotheosis.org.za> <20030101181840.P29988-100000@april.chuckr.org> X-Mailer: Sylpheed version 0.8.8 (GTK+ 1.2.10; i386-portbld-freebsd5.0) X-Face: 1j}k*2E>Y\+C~E|/wehi[:dCM,{N7/uE 3o# P,{t7gA/qnovFDDuyQV.1hdT7&#d)q"xY33}{_GS>kk'S{O]nE$A`T|\4&p\&mQyexOLb8}FO List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Wed, 1 Jan 2003 18:24:40 -0500 (EST) Chuck Robey 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. Jordan has also mentioned the parsing code in sysinstall. I think we took really different approaches to the problem. thefish has no previous knowledge of what it's going to find, save for the 'exception list', that it needs to tell some variables that are set to "NO" but aren't really knobs. It should actually be able to parse /etc/make.conf happily, or any other conf file in the system. > easy to extend, easy to special-case, easy to error-control. Learning > lex is harder than just C code, but it's such a good tool to know just > for general purposes, it's worth the small time spent. Every C > programmer ought to spend some time with lex/flex (and obviously > yacc/bison). If you don't know it for an employer, you're really > hobbled, it's *such* a good tool. Agreed 100% You could also use embedded perl /me ducks Cheers, -- Miguel Mendez - flynn@energyhq.homeip.net GPG Public Key :: http://energyhq.homeip.net/files/pubkey.txt EnergyHQ :: http://www.energyhq.tk Of course it runs NetBSD! To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message