Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 15 Apr 2004 13:06:31 -0400
From:      Ash Gokhale <ash.gokhale@noaa.gov>
To:        freebsd-hackers@freebsd.org
Subject:   Re: C code for parsing rc.conf?
Message-ID:  <3DFA0E20-8EFF-11D8-AF6E-00039383C51E@noaa.gov>
In-Reply-To: <407DD3FE.5010303@kientzle.com>
References:  <20040414215601.GA3923@crodrigues.org> <407DD3FE.5010303@kientzle.com>

next in thread | previous in thread | raw e-mail | index | archive | help
	I'll give you another 'easy' hack to contemplate.

6 == 12 * 0,5

Make your tool system('sh /etc/rc.conf');
And then use the native [get|set]env(3) functions to read/write the 
values you are intested in.
When you are ready to commit the process scan **environ (7) to rebuild 
it without the redundant stuff (and without your uid env).

	I think it's much better to use the shells logic rather than parsing. 
There may be installations that require a little math or early 
reentrant shell programming to manage startup.

	What ever you do _pleese_ offer automatic failback to the previous 
rc.conf if the system comes up sour with the generated rc. Perhaps this 
should be hooks to rc itself.

	Has anyone used SystemStarter under FreeBSD? It can really haul a 
machine through the startup sequence by parallel execution of non 
critical startup binaries. I've seen it pull an otherwise sluggish 
darwin up in a big hurry.

On Apr 14, 2004, at 8: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?
>
> 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
>
> The basic idea is to just let the shell do
> the work for you.
>
>
Ash.Gokhale@noaa.gov
System Administration Lead,
NOAA/MDL



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3DFA0E20-8EFF-11D8-AF6E-00039383C51E>