From owner-freebsd-hackers@FreeBSD.ORG Fri Apr 16 04:19:47 2004 Return-Path: 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 5C61A16A4CE for ; Fri, 16 Apr 2004 04:19:47 -0700 (PDT) Received: from rwcrmhc11.comcast.net (rwcrmhc11.comcast.net [204.127.198.35]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1E47D43D41 for ; Fri, 16 Apr 2004 04:19:47 -0700 (PDT) (envelope-from rodrigc@h00609772adf0.ne.client2.attbi.com) Received: from dibbler.crodrigues.org (h00609772adf0.ne.client2.attbi.com[66.31.45.197]) by comcast.net (rwcrmhc11) with ESMTP id <2004041611194601300fbsope>; Fri, 16 Apr 2004 11:19:46 +0000 Received: from dibbler.crodrigues.org (localhost.crodrigues.org [127.0.0.1]) i3GBJjSu023311; Fri, 16 Apr 2004 07:19:45 -0400 (EDT) (envelope-from rodrigc@h00609772adf0.ne.client2.attbi.com) Received: (from rodrigc@localhost) by dibbler.crodrigues.org (8.12.11/8.12.11/Submit) id i3GBJjI5023310; Fri, 16 Apr 2004 07:19:45 -0400 (EDT) (envelope-from rodrigc) Date: Fri, 16 Apr 2004 07:19:45 -0400 From: Craig Rodrigues To: Tim Kientzle Message-ID: <20040416111945.GA23290@crodrigues.org> References: <20040414215601.GA3923@crodrigues.org> <407DD3FE.5010303@kientzle.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <407DD3FE.5010303@kientzle.com> User-Agent: Mutt/1.4.1i cc: freebsd-hackers@freebsd.org Subject: Re: C code for parsing rc.conf? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Apr 2004 11:19:47 -0000 On Wed, Apr 14, 2004 at 05:14:54PM -0700, Tim Kientzle wrote: > There was a detailed discussion of this topic about a year > ago. Here is how to obtain the current settings from rc.conf > from within a C program: > > * Clear the current environment > > * popen() a shell command that sources rc.conf, then > runs printenv > > * read and parse the output of printenv I like this. Would it be worth putting a small writeup of this in the Developer's Handbook? Being able to write programs which can parse and edit rc.conf is actually quite useful in certain cases. An analogy for this would be the API that is used to read/write settings to the Windows registry. On a side note, is there any code in sysinstall that could be reused outside of the sysinstall application in order to parse rc.conf? -- Craig Rodrigues http://crodrigues.org rodrigc@crodrigues.org