Date: Thu, 15 Apr 2004 22:48:56 -0700 From: Tim Kientzle <tim@kientzle.com> To: Greg Shenaut <gkshenaut@ucdavis.edu> Cc: Craig Rodrigues <rodrigc@crodrigues.org> Subject: Re: C code for parsing rc.conf? Message-ID: <407F73C8.8090306@kientzle.com> In-Reply-To: <B0676729-8EA5-11D8-9EC1-000A9590A44E@ucdavis.edu> References: <20040414215601.GA3923@crodrigues.org> <407DD3FE.5010303@kientzle.com> <B0676729-8EA5-11D8-9EC1-000A9590A44E@ucdavis.edu>
next in thread | previous in thread | raw e-mail | index | archive | help
Greg Shenaut wrote: > On Apr 14, 2004, at 5:14 PM, Tim Kientzle wrote: >> Craig Rodrigues wrote: >> >>> Is there a C library that comes with FreeBSD which >>> can be used to parse, append to, and validate >>> rc.conf? >> >> * Clear the current environment >> * popen() a shell command that sources rc.conf, then >> runs printenv >> * read and parse the output of printenv >> >> The basic idea is to just let the shell do >> the work for you. > > It's a little more awkward, but another way to do this is to use a shell > shim > along the lines of > > #!/bin/sh > . /etc/whatever > exec /your/program > > The shell's environment will be exported to your program's environment. Not quite. This approach gives you the rc.conf settings intermingled with the rest of the environment, which is probably not what you want. (It's okay if you're just testing a few particular rc.conf settings, but if you want to collect an accurate list of all rc.conf settings, it won't do.) Tim Kientzle
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?407F73C8.8090306>