From owner-freebsd-hackers Wed Jan 1 21:25:27 2003 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 835E037B401 for ; Wed, 1 Jan 2003 21:25:26 -0800 (PST) Received: from puffin.mail.pas.earthlink.net (puffin.mail.pas.earthlink.net [207.217.120.139]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3571443EB2 for ; Wed, 1 Jan 2003 21:25:26 -0800 (PST) (envelope-from tlambert2@mindspring.com) Received: from pool0014.cvx21-bradley.dialup.earthlink.net ([209.179.192.14] helo=mindspring.com) by puffin.mail.pas.earthlink.net with asmtp (SSLv3:RC4-MD5:128) (Exim 3.33 #1) id 18Txr6-0002r3-00; Wed, 01 Jan 2003 21:25:20 -0800 Message-ID: <3E13CCF1.FA78AD5D@mindspring.com> Date: Wed, 01 Jan 2003 21:24:01 -0800 From: Terry Lambert X-Mailer: Mozilla 4.79 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: kientzle@acm.org Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: Reading rc.conf from C programs? References: <3E1362FD.6070001@acm.org> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-ELNK-Trace: b1a02af9316fbb217a47c185c03b154d40683398e744b8a411e2d88a592deae8baaf4db8f2a3589f667c3043c0873f7e350badd9bab72f9c350badd9bab72f9c Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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