From owner-freebsd-hackers Thu Jan 2 12:54:19 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 CC71D37B401; Thu, 2 Jan 2003 12:54:17 -0800 (PST) Received: from webmail1.isg.siue.edu (webmail1.isg.siue.edu [146.163.5.167]) by mx1.FreeBSD.org (Postfix) with ESMTP id EAB3E43E4A; Thu, 2 Jan 2003 12:54:16 -0800 (PST) (envelope-from wgrim@siue.edu) Received: (from nobody@localhost) by webmail1.isg.siue.edu (8.11.6/8.11.6) id h02KsQE29349; Thu, 2 Jan 2003 14:54:26 -0600 X-Authentication-Warning: webmail1.isg.siue.edu: nobody set sender to wgrim@siue.edu using -f Received: from 199.96.8.151 ( [199.96.8.151]) as user wgrim@146.163.5.4 by webmail1.isg.siue.edu with HTTP; Thu, 2 Jan 2003 14:54:26 -0600 Message-ID: <1041540866.3e14a7026b17c@webmail1.isg.siue.edu> Date: Thu, 2 Jan 2003 14:54:26 -0600 From: wgrim@siue.edu To: phk@FreeBSD.ORG Cc: kientzle@acm.org, Terry Lambert , freebsd-hackers@FreeBSD.ORG Subject: Re: Reading rc.conf from C programs? References: <4351.1041538966@critter.freebsd.dk> In-Reply-To: <4351.1041538966@critter.freebsd.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.1 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 Oh, and changing a bit of what I said in my previous post, you could instead just pass the strtok to strlen I think and then rewind your file pointer. This should save some CPU cycles or at least save code complexity by doing it this way (in my mind at least). Anyway, just a couple thoughts. -Mike Quoting phk@FreeBSD.ORG: > In message <3E149EAF.9040100@acm.org>, Tim Kientzle writes: > >Terry Lambert wrote: > > > >> Tim Kientzle wrote: > >>>I'm trying to figure out how to read and use > >>>/etc/rc.conf configuration variables from within > >>>a C program. > >> > >> #!/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 > > You can get a decent simulation this way: > > #!/bin/sh > echo "*** NOISE" > set > echo "*** DATA+NOISE" > . /etc/rc.conf > set > > Then pipe this into your program and separate the data from the noise. > > -- > Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 > phk@FreeBSD.ORG | TCP/IP since RFC 956 > FreeBSD committer | BSD since 4.3-tahoe > Never attribute to malice what can adequately be explained by incompetence. > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-hackers" in the body of the message > ------------------------------------------------- SIUE Web Mail To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message