Date: Wed, 01 Jan 2003 13:51:57 -0800 From: Tim Kientzle <kientzle@acm.org> To: freebsd-hackers@FreeBSD.ORG Subject: Reading rc.conf from C programs? Message-ID: <3E1362FD.6070001@acm.org>
next in thread | raw e-mail | index | archive | help
I'm trying to figure out how to read and use /etc/rc.conf configuration variables from within a C program. The standard technique, of course, is to use a shell-script wrapper and pass the extracted values to the C program on the command line. But I want access to _all_ of the rc.conf variables, not just a couple of them, and I don't see any reasonable way to accomplish that with a shell wrapper. One approach would embed /bin/sh and drive that from my program. (E.g., tell the embedded interpreter to read and interpret the config file, then programmatically query the config variables.) It's not clear to me how simple it would be to build an embeddable /bin/sh. Alternatively, I suppose I could fire up /bin/sh via popen and drive it from my program (passing 'echo $var' to query variables, etc.). But I'm not entirely convinced this would work; what if a variable value has a newline in it, for example? Has anyone done anything like this before? Thanks, Tim Kientzle To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3E1362FD.6070001>