diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2016-02-26 22:55:54 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2016-02-26 22:55:54 -0800 |
commit | 4496c575892fa34ae9aabf4e1c0f7da87f10c4c2 (patch) | |
tree | 5e662b6f6bc1bcc42aa834a7703deaa43f92cec5 /stream.h | |
parent | 4f14d3a2ded6137c5dd6449f4ec2d566947c4157 (diff) | |
download | txr-4496c575892fa34ae9aabf4e1c0f7da87f10c4c2.tar.gz txr-4496c575892fa34ae9aabf4e1c0f7da87f10c4c2.tar.bz2 txr-4496c575892fa34ae9aabf4e1c0f7da87f10c4c2.zip |
Adding socket support: unix, ipv4, ipv6.
* socket.c, socket.h: New files.
* Makefile: include new socket.o among objects if have_objects
variable is defined to 'y'.
* configure (have_sockets): New variable. New configure test
for socket-related functionality.
(HAVE_SOCKETS, HAVE_GETADDRINFO): New configuration
preprocessor symbols.
Also, reordering the shell probing so that /usr/xpg4/bin/sh
is the last fallback. On Solaris, it chokes on some code
that is needed for Solaris.
* lisplib.c (sock_set_entries, sock_instantiate): New static
functions.
(lisplib_init): Register new functions as autoload hooks.
* share/txr/stdlib/socket.tl: New file.
* stream.c (socket_error_s): New symbol variable.
(struct stdio_handle): New members, family and type, helping
stdio streams represent sockets too.
(stdio_stream_mark): Mark new members of struct stdio_handle.
(make_stdio_stream_common): Initialize new members.
(make_sock_stream, stream_fd, sock_family, sock_type,
open_socket, open_sockfd): New functions.
(stream_init): Initialize socket_error_s variable. Register
sock-family, sock-type and open-socket intrinsic functions.
Register socket-error subtype.
* stream.h (socket_error_s, make_sock_stream, stream_fd,
sock_family, sock_type, open_socket, open_sockfd):
Declared.
Diffstat (limited to 'stream.h')
-rw-r--r-- | stream.h | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -95,6 +95,10 @@ extern val stdin_s, stdout_s, stddebug_s, stderr_s, stdnull_s; extern val print_flo_precision_s, print_flo_digits_s, print_flo_format_s; extern val print_base_s; +#if HAVE_SOCKETS +extern val socket_error_s; +#endif + void strm_base_init(struct strm_base *s); void strm_base_cleanup(struct strm_base *s); void strm_base_mark(struct strm_base *s); @@ -106,6 +110,14 @@ val make_null_stream(void); val make_stdio_stream(FILE *, val descr); val make_tail_stream(FILE *, val descr); val make_pipe_stream(FILE *, val descr); +#if HAVE_SOCKETS +val make_sock_stream(FILE *, val family, val type); +#endif +val stream_fd(val stream); +#if HAVE_SOCKETS +val sock_family(val stream); +val sock_type(val stream); +#endif val make_string_input_stream(val); val make_string_byte_input_stream(val); val make_string_output_stream(void); @@ -151,6 +163,10 @@ val get_string(val stream, val nchars, val close_after_p); val open_directory(val path); val open_file(val path, val mode_str); val open_fileno(val fd, val mode_str); +#if HAVE_SOCKETS +val open_sockfd(val fd, val family, val type, val mode_str); +val open_socket(val family, val type, val mode_str); +#endif val open_tail(val path, val mode_str, val seek_end_p); val open_command(val path, val mode_str); val open_process(val path, val mode_str, val args); |