summaryrefslogtreecommitdiffstats
path: root/stream.h
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-07-07 06:45:45 -0700
committerKaz Kylheku <kaz@kylheku.com>2015-07-07 06:45:45 -0700
commit2f792610c11dd2a82a5e9b35be55a227665e76d1 (patch)
tree2f0777fd1b4caa4d0c2f0364bcfb55b0120717d2 /stream.h
parent1e1d6176ebac760a396caf705acfb2feab371068 (diff)
downloadtxr-2f792610c11dd2a82a5e9b35be55a227665e76d1.tar.gz
txr-2f792610c11dd2a82a5e9b35be55a227665e76d1.tar.bz2
txr-2f792610c11dd2a82a5e9b35be55a227665e76d1.zip
Improved printing of stream objects.
* stream.c (null_stream_print): Static function removed. (stream_print_op): New function. Prints stream's name and address. (null_get_prop): Pull stream name from strm_ops structure rather than hard-coding to "null-stream". (null_ops, stdio_ops, tail_ops, pipe_ops, string_in_ops, byte_in_ops, string_out_ops, strlist_out_ops, dir_ops, cat_stream_ops): Use stream_print_op in place of cobj_print_op. Initialize name. (stdio_stream_print): Use name from ops structure, and include object address. (string_in_get_prop): Likewise. (cat_stream_print): Likewise. * stream.h (struct strm_ops): New member, name. (strm_ops_init): Initialize name. (stream_print_op): Declared. * syslog.c (syslog_strm_ops): Use stream_print_op. Initialize name.
Diffstat (limited to 'stream.h')
-rw-r--r--stream.h20
1 files changed, 11 insertions, 9 deletions
diff --git a/stream.h b/stream.h
index 2162045e..1d84e5b2 100644
--- a/stream.h
+++ b/stream.h
@@ -32,6 +32,7 @@ enum strm_whence {
struct strm_ops {
struct cobj_ops cobj_ops;
+ const wchli_t *name;
val (*put_string)(val, val);
val (*put_char)(val, val);
val (*put_byte)(val, int);
@@ -50,15 +51,15 @@ struct strm_ops {
val (*clear_error)(val);
};
-#define strm_ops_init(cobj_init_macro, put_string, put_char, put_byte, \
- get_line, get_char, get_byte, unget_char, unget_byte, \
- close, flush, seek, get_prop, set_prop, \
- get_error, get_error_str, clear_error) \
-{ \
- cobj_init_macro, put_string, put_char, put_byte, get_line, \
- get_char, get_byte, unget_char, unget_byte, \
- close, flush, seek, get_prop, set_prop, \
- get_error, get_error_str, clear_error \
+#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, \
+ 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, \
+ get_error, get_error_str, clear_error \
}
#define std_input (deref(lookup_var_l(nil, stdin_s)))
@@ -78,6 +79,7 @@ extern val format_s;
extern val stdin_s, stdout_s, stddebug_s, stderr_s, stdnull_s;
void fill_stream_ops(struct strm_ops *ops);
+void stream_print_op(val stream, val out);
val make_null_stream(void);
val make_stdio_stream(FILE *, val descr);
val make_tail_stream(FILE *, val descr);