From owner-freebsd-hackers Wed Jan 1 15:29:55 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 5434C37B401 for ; Wed, 1 Jan 2003 15:29:54 -0800 (PST) Received: from april.chuckr.org (april.chuckr.org [66.92.147.143]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1478543EA9 for ; Wed, 1 Jan 2003 15:29:53 -0800 (PST) (envelope-from chuckr@chuckr.org) Received: from april.chuckr.org (localhost [127.0.0.1]) by april.chuckr.org (8.12.6/8.12.5) with ESMTP id h01NOfgJ032955; Wed, 1 Jan 2003 18:24:41 -0500 (EST) (envelope-from chuckr@chuckr.org) Received: from localhost (chuckr@localhost) by april.chuckr.org (8.12.6/8.12.5/Submit) with ESMTP id h01NOeMa032952; Wed, 1 Jan 2003 18:24:40 -0500 (EST) X-Authentication-Warning: april.chuckr.org: chuckr owned process doing -bs Date: Wed, 1 Jan 2003 18:24:40 -0500 (EST) From: Chuck Robey To: Matthew West Cc: Tim Kientzle , Subject: Re: Reading rc.conf from C programs? In-Reply-To: <20030102012042.A16965@apotheosis.org.za> Message-ID: <20030101181840.P29988-100000@april.chuckr.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Thu, 2 Jan 2003, Matthew West wrote: > On Wed, Jan 01, 2003 at 01:51:57PM -0800, Tim Kientzle wrote: > > I'm trying to figure out how to read and use /etc/rc.conf > > configuration variables from within a C program. > > 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. If I had full control over a system, I'd write me lex script for it, that's easily the best way to parse args. Flexible as hell, really 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. > > ---------------------------------------------------------------------------- Chuck Robey | Interests include C & Java programming, FreeBSD, chuckr@chuckr.org | electronics, communications, and SF/Fantasy. New Year's Resolution: I will not sphroxify gullible people into looking up fictitious words in the dictionary. ---------------------------------------------------------------------------- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message