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 /share | |
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 'share')
-rw-r--r-- | share/txr/stdlib/socket.tl | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/share/txr/stdlib/socket.tl b/share/txr/stdlib/socket.tl new file mode 100644 index 00000000..beff73be --- /dev/null +++ b/share/txr/stdlib/socket.tl @@ -0,0 +1,46 @@ +;; Copyright 2016 +;; Kaz Kylheku <kaz@kylheku.com> +;; Vancouver, Canada +;; All rights reserved. +;; +;; Redistribution of this software in source and binary forms, with or without +;; modification, is permitted provided that the following two conditions are met. +;; +;; Use of this software in any manner constitutes agreement with the disclaimer +;; which follows the two conditions. +;; +;; 1. Redistributions of source code must retain the above copyright +;; notice, this list of conditions and the following disclaimer. +;; 2. Redistributions in binary form must reproduce the above copyright +;; notice, this list of conditions and the following disclaimer in +;; the documentation and/or other materials provided with the +;; distribution. +;; +;; THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED +;; WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF +;; MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE +;; COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DAMAGES, HOWEVER CAUSED, +;; AND UNDER ANY THEORY OF LIABILITY, ARISING IN ANY WAY OUT OF THE USE OF THIS +;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +(defstruct sockaddr nil) + +(defstruct sockaddr-in sockaddr + (addr 0) (port 0)) + +(defstruct sockaddr-in6 sockaddr + (addr 0) (port 0) (flow-info 0) (scope-id 0)) + +(defstruct sockaddr-un sockaddr + path) + +(defstruct addrinfo nil + (flags 0) + (family 0) + (socktype 0) + (protocol 0) + (canonname 0)) + +(defvarl shut-rd 0) +(defvarl shut-wr 1) +(defvarl shut-rdwr 2) |