summaryrefslogtreecommitdiffstats
path: root/stream.h
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-03-04 22:22:51 -0800
committerKaz Kylheku <kaz@kylheku.com>2016-03-04 22:22:51 -0800
commite66d53a35c7b59f46e31451da90b306a9beeacc6 (patch)
treeefb5e575815c647888784d34a1c7345aa58e7d02 /stream.h
parenta32a39a344b069dadae76a3a2de3887edfe30e72 (diff)
downloadtxr-e66d53a35c7b59f46e31451da90b306a9beeacc6.tar.gz
txr-e66d53a35c7b59f46e31451da90b306a9beeacc6.tar.bz2
txr-e66d53a35c7b59f46e31451da90b306a9beeacc6.zip
Socket operations become proper stream virtuals.
* stream.c (unimpl_get_sock_family, unimpl_get_sock_type, unimpl_get_sock_peer, unimpl_set_sock_peer): New static functions. (fill_stream_ops): Set new function pointers in struct strm_ops to point to the unimpl_* functions. (stdio_get_sock_family, stdio_get_sock_type, stdio_get_sock_peer, stdio_set_sock_peer): New static functions. (stdio_sock_ops): New static structure. (make_sock_stream): Use stdio_sock_ops for socket object. (sock_family, sock_type, sock_peer, sock_set_peer): These API functions now just call their corresponding virtuals. (stream_init): Set up stdio_sock_ops as a copy of stdio_ops, and then override the socket-specific virtuals from the unimpl_* stubs to the stdio_get_sock_* and stdio_set_sock_* functions. * stream.h (struct strm_ops): New members, get_sock_family, get_sock_type, get_sock_peer and set_sock_peer. (strm_ops_init): Set new members to zero.
Diffstat (limited to 'stream.h')
-rw-r--r--stream.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/stream.h b/stream.h
index c7e70c12..ff5ee9f8 100644
--- a/stream.h
+++ b/stream.h
@@ -64,6 +64,10 @@ struct strm_ops {
val (*get_error)(val);
val (*get_error_str)(val);
val (*clear_error)(val);
+ val (*get_sock_family)(val);
+ val (*get_sock_type)(val);
+ val (*get_sock_peer)(val);
+ val (*set_sock_peer)(val, val);
};
#define strm_ops_init(cobj_init_macro, name, put_string, put_char, put_byte, \
@@ -74,7 +78,7 @@ struct strm_ops {
cobj_init_macro, name, put_string, put_char, put_byte, get_line, \
get_char, get_byte, unget_char, unget_byte, \
close, flush, seek, truncate, get_prop, set_prop, \
- get_error, get_error_str, clear_error \
+ get_error, get_error_str, clear_error, 0, 0, 0, 0, \
}
#define std_input (deref(lookup_var_l(nil, stdin_s)))