From 8c6afa35bea1a5ea8a94a3c60d1988999cb41bcc Mon Sep 17 00:00:00 2001 From: jhb Date: Tue, 11 Dec 2001 00:49:34 +0000 Subject: - Add 'fwrite' and 'fseek' words for writing to and seeking on files. - Change the 'fopen' keyword to accept a mode parameter. Note that this will break existing 4th scripts that use fopen. Thus, the loader version has been bumped and loader.4th has been changed to check for a sufficient version on i386 and alpha. Be sure that you either do a full world build or install or full build and install of sys/boot after this since loader.old won't work with the new 4th files and vice versa. PR: kern/32389 Submitted by: Jonathan Mini Sponsored by: ClickArray, Inc. --- sys/boot/forth/support.4th | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'sys/boot/forth/support.4th') diff --git a/sys/boot/forth/support.4th b/sys/boot/forth/support.4th index 7988012..d711094 100644 --- a/sys/boot/forth/support.4th +++ b/sys/boot/forth/support.4th @@ -80,6 +80,16 @@ 8 constant before_load_error 9 constant after_load_error +\ I/O constants + +0 constant SEEK_SET +1 constant SEEK_CUR +2 constant SEEK_END + +0 constant O_RDONLY +1 constant O_WRONLY +2 constant O_RDWR + \ Crude structure support : structure: @@ -931,23 +941,12 @@ support-functions definitions only forth also support-functions definitions -: create_null_terminated_string { addr len -- addr' len } - len char+ allocate if out_of_memory throw then - >r - addr r@ len move - 0 r@ len + c! - r> len -; - \ Interface to loading conf files : load_conf ( addr len -- ) 0 to end_of_file? reset_line_reading - create_null_terminated_string - over >r - fopen fd ! - r> free-memory + O_RDONLY fopen fd ! fd @ -1 = if open_error throw then ['] process_conf catch fd @ fclose -- cgit v1.1