From 869c570ea8231596b374fd8fa62b6646d61f234e Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 21 Oct 2015 06:28:41 -0700 Subject: Implementing truncate-stream. * configure: Test for ftruncate and chsize. * stream.c (unimpl_truncate): New static function. (fill_stream_ops): Default the truncate operation to unimpl_truncate. (null_ops): Initialize truncate to unimpl_truncate. (stdio_truncate): New static function. (stdio_ops, tail_ops): Initialize truncate to stdio_truncate. (pipe_ops, dir_ops, string_ops, byte_in_ops, string_out_ops, strlist_out_ops, cat_stream_ops): Initialize truncate to null, so it gets defaulted by fill_stream_ops. (truncate_stream): New function. (stream_init): Register truncate-stream intrinsic. * stream.h (struct strm_ops): New member, truncate. (strm_ops_init): New truncate argument added to macro. (truncate_stream): Declared. *syslog.c (syslog_strm_ops): Initialize truncate to null. * txr.1: Documented. --- stream.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'stream.h') diff --git a/stream.h b/stream.h index e5d58d26..d3ec649a 100644 --- a/stream.h +++ b/stream.h @@ -58,6 +58,7 @@ struct strm_ops { val (*close)(val, val); val (*flush)(val); val (*seek)(val, cnum, enum strm_whence); + val (*truncate)(val, val); val (*get_prop)(val, val ind); val (*set_prop)(val, val ind, val); val (*get_error)(val); @@ -67,12 +68,12 @@ struct strm_ops { #define strm_ops_init(cobj_init_macro, name, put_string, put_char, put_byte, \ get_line, get_char, get_byte, unget_char, unget_byte, \ - close, flush, seek, get_prop, set_prop, \ + close, flush, seek, truncate, get_prop, set_prop, \ get_error, get_error_str, clear_error) \ { \ cobj_init_macro, name, put_string, put_char, put_byte, get_line, \ get_char, get_byte, unget_char, unget_byte, \ - close, flush, seek, get_prop, set_prop, \ + close, flush, seek, truncate, get_prop, set_prop, \ get_error, get_error_str, clear_error \ } @@ -132,6 +133,7 @@ val put_strings(val strings, val stream); val put_lines(val lines, val stream); val flush_stream(val stream); val seek_stream(val stream, val offset, val whence); +val truncate_stream(val stream, val len); val get_indent_mode(val stream); val test_set_indent_mode(val stream, val compare, val mode); val set_indent_mode(val stream, val mode); -- cgit v1.2.3