From e66d53a35c7b59f46e31451da90b306a9beeacc6 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 4 Mar 2016 22:22:51 -0800 Subject: 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. --- stream.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'stream.h') 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))) -- cgit v1.2.3