From owner-freebsd-hackers Wed Jan 10 17:41:41 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from peach.ocn.ne.jp (peach.ocn.ne.jp [210.145.254.87]) by hub.freebsd.org (Postfix) with ESMTP id 4B4C537B401 for ; Wed, 10 Jan 2001 17:41:23 -0800 (PST) Received: from newsguy.com (p51-dn02kiryunisiki.gunma.ocn.ne.jp [211.0.245.116]) by peach.ocn.ne.jp (8.9.1a/OCN/) with ESMTP id KAA01741; Thu, 11 Jan 2001 10:41:11 +0900 (JST) Message-ID: <3A5D0EAC.4E6E00B1@newsguy.com> Date: Thu, 11 Jan 2001 10:38:52 +0900 From: "Daniel C. Sobral" X-Mailer: Mozilla 4.7 [en] (Win98; I) X-Accept-Language: en,pt-BR MIME-Version: 1.0 To: Chris Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: forth/loader question.. References: <3A472397.A806A3FD@iastate.edu> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Chris wrote: > > I am attempting to add some functionality to the loader, but have come > across a minor problem. Is there some way to include forth files, > given a string? > > s" file" included (gforth example) Yes, there is... I just can't recall the exact name right now. :-) You can always do a s" include file" evaluate, but... :-) Also, "include" is a builtin, so you can pass arguments to it when compiling it: : whatever s" file" include ; Read the finer details for builtins on the loader.4th(8) man page, or, worse yet, check out it's exact definition on /sys/boot/common/interp_forth.c. Their behavior is highly complex... > What I would like to do is read in a /boot/loader.rc.$ip or something > similar. This would allow a number of machines to be booted diskless > and yet have different boot configurations. IMHO, what *should* be done is expanding environment variables in the loader_conf_files="xyzyz" lines. Previously, there was no support in loader(8) to be able to do this on support.4th, but now there is. A function that went through all environment variables in a string and expanded them would be an useful addition in a number of places. One such a function is written, it can be used at set_conf_files, right after strdup. Then you can have loader_conf_files="loader.conf.$ip". If you still wish to have Forth code executing, you can just place an exec="include loader.rc.whatever" line there, but I'd prefer to keep the configuration passive as much as possible. > : read_loader_rc_specific > s" boot.netif.hwaddr" getenv > dup -1 = if > drop > s" boot.netif.ip" getenv > dup -1 = if > drop 0 0 > then > then > s" /boot/loader.rc." > 2over nip over + allocate > if ( out of memory ) > 2drop 2drop > 100 exit > then > 0 2swap strcat 2swap strcat > read-conf > ; read-conf reads conf files, it doesn't execute anything. In a private discussion long ago, Jordan said he would like for .rc and .4th files to remain scripts, and .conf files to be variable-setting files (like they are now :). Except, of course, that there are a couple of exceptions on the .conf files format to allow for the cases where it is absolutely necessary to execute code. -- Daniel C. Sobral (8-DCS) dcs@newsguy.com dcs@freebsd.org capo@a.crazy.bsdconspiracy.net "There is no spoon." -- Kiki To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message