Date: Wed, 01 Jan 2003 21:24:01 -0800 From: Terry Lambert <tlambert2@mindspring.com> To: kientzle@acm.org Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: Reading rc.conf from C programs? Message-ID: <3E13CCF1.FA78AD5D@mindspring.com> References: <3E1362FD.6070001@acm.org>
index | next in thread | previous in thread | raw e-mail
Tim Kientzle wrote:
> 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.
#!/bin/sh
#
# Throw all of rc.conf into the environemnet so a C program
# named "fred" can read any of them with "getenv".
. /etc/rc.conf
fred
8-).
> Has anyone done anything like this before?
Yeah. fopen(3), for(;;) { fgets(3), strtok(3) } fclose(3).
-- Terry
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3E13CCF1.FA78AD5D>
