Craig Rodrigues wrote:Is there a C library that comes with FreeBSD which can be used to parse, append to, and validate rc.conf? I'd like to customize some of the settings in /etc/rc.conf with my own GUI-based program. It's not too hard to write something on my own, but I was wondering if a reusable library existed in FreeBSD 4.x or 5.x for doing this.
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.
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.
Greg Shenaut
_______________________________________________ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]"