| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* ftw.c (ftw_callback): Pass path to stat_to_struct function.
* socket.c (path_s): Variable definition removed from here.
(sock_load_init): Do not intern path symbol here.
* sysif.c (path_s): Variable definition moved here.
(stat_to_struct): New parameter, path. Store its argument in
the path slot of the structure.
(stat_impl): New parameter, path. Pass argument to
stat_to_struct.
(statp, statl): Pass path down to stat_impl.
(statf): Pass nil down as path argument of stat_impl.
(sysif_init): Intern path symbol here.
Add path_s to the slot list in the make_struct_type
call which creates the stat structure type.
* sysif.h (path_s): Declared here now.
(stat_to_struct): Declaration updated.
* txr.1: Documented new slot of stat structure and
behavior of stat, lstat and fstat w.r.t. this slot.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* lib.h (default_bool_arg): Inline function renamed to
default_null_arg.
* eval.c (if_fun, pad, ginterate, giterate, range_star, range,
constantp, macroexpand_1, macro_form_p, expand_with_free_refs,
do_expand, eval_intrinsic, func_get_name, make_env_intrinsic):
Follow rename.
* arith.c (lognot): Likewise.
* gc.c (gc_finalize): Likewise.
* glob.c (glob_wrap): Likewise.
* hash.c (group_reduce, gethash_n): Likewise.
* lib.c (print, multi_sort, lazy_str, vector, iff, tok_str,
split_str_keep, search_str, remove_if, val): Likewise.
* match.c (match_fun): Likewise.
* parser.c (lisp_parse_impl, regex_parse): Likewise.
* rand.c (make_random_state): Likewise.
* regex.c (read_until_match, search_regex, regex_compile):
Likewise.
* socket.c (sock_accept, sock_connect): Likewise.
* stream.c (open_files_star, open_files, run, open_process,
open_tail, get_string, record_adapter): Likewise.
* struct.c (static_slot_ensure, static_slot_ens_rec,
clear_struct, make_struct_type): Likewise.
* sysif.c (exec_wrap, errno_wrap, cobj_ops_init): Likewise.
* unwind.c (uw_capture_cont, uw_find_frames_impl): Likewise.
|
|
|
|
|
| |
* sock.c, sock.h: This module was not introduced in 2010,
but in 2016.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* socket.c (dgram_get_byte_callback): nbytes must be volatile
because we assign to it after setting up the catch, and then
access it in the unwind code.
(sock_accept): Likewise.
* stream.c (generic_get_line): buf variable must be volatile.
(struct save_fds): The members of this structure must
be volatile; it's used as a local variable in a number of
functions in a way that requires volatile.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is some infrastructure which will support *print-circle*.
* lib.h (struct strm_ctx): Forward declared.
(struct cobj_ops): Add context parameter to print function
pointer.
(cobj_print_op, obj_print_impl): Add context parameter to
declarations.
* hash.c (hash_print_op): Take context argument and
pass it down in obj_print_impl calls.
* lib.c (cobj_print_op, out_quasi_str): Likewise
(obj_print_impl): Likewise, and also pass to
COBJ print method.
(obj_print, obj_pprint): Pass null pointer
as context argument to obj_print_impl.
* regex.c (regex_print): Take context parameter and ignore it.
* socket.c (dgram_print): Likewise.
* stream.h (struct strm_ctx): New struct type.
(struct strm_base): New ctx member, pointer to struct
strm_ctx.
(stream_print_op): Add context parameter to declaration.
(get_set_ctx, get_ctx): Declared.
* stream.c (strm_base_init): Add null pointer to initializer.
(strm_base_cleanup): Add assertion against context pointer
being non-null: that indicates that some stream operation
installed a context pointer and neglected to restore it to
null before returning, which is bad because context will be
stack allocated.
(stream_print_op, stdio_stream_print, cat_stream_print): Take
context parameter and ignore it.
(get_set_ctx, get_ctx): New functions.
* struct.c (struct_type_print): Take context parameter and
ignore it.
(struct_inst_print): Take context parameter and pass
down to obj_print_impl.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Makefile, args.c, args.h, arith.c, arith.h, cadr.c, cadr.h, combi.c,
combi.h, configure, debug.c, debug.h, eval.c, eval.h, filter.c,
filter.h, ftw.c, ftw.h, gc.c, gc.h, glob.c, glob.h, hash.c, hash.h,
jmp.S, lib.c, lib.h, lisplib.c, lisplib.h, match.c, match.h, parser.c,
parser.h, parser.l, parser.y, rand.c, rand.h, regex.c, regex.h,
share/txr/stdlib/awk.tl, share/txr/stdlib/build.tl,
share/txr/stdlib/cadr.tl, share/txr/stdlib/conv.tl,
share/txr/stdlib/except.tl, share/txr/stdlib/hash.tl,
share/txr/stdlib/ifa.tl, share/txr/stdlib/path-test.tl,
share/txr/stdlib/place.tl, share/txr/stdlib/socket.tl,
share/txr/stdlib/struct.tl, share/txr/stdlib/termios.tl,
share/txr/stdlib/txr-case.tl, share/txr/stdlib/type.tl,
share/txr/stdlib/with-resources.tl, share/txr/stdlib/with-stream.tl,
share/txr/stdlib/yield.tl, signal.c, signal.h, socket.c, socket.h,
stream.c, stream.h, struct.c, struct.h, sysif.c, sysif.h, syslog.c,
syslog.h, termios.c, termios.h, txr.1, txr.c, txr.h, unwind.c,
unwind.h, utf8.c, utf8.h: Revert to verbatim 2-Clause BSD.
|
|
|
|
|
|
|
| |
* socket.c (getaddrinfo_wrap): Initialize alist to null,
because getaddrinfo doesn't set it in the failure case!
Then, avoid calling freeaddrinfo for null pointer;
POSIX doesn't require that to work.
|
|
|
|
|
| |
* socket.c (dgram_destroy): Free the dgram_stream
structure too, not just its buffers.
|
|
|
|
|
|
|
|
| |
* socket.c (struct dgram): Members is_connected and
is_byte_oriented widened from 1 to 8 bits. This allows
byte-access instructions to be used on architectures like x86.
All the flags still fit into a word, so the structure doesn't
get bigger.
|
|
|
|
|
|
|
|
|
| |
* socket.c (struct dgram_stream): New member, is_byte_oriented.
(dgram_get_char): In byte oriented mode, just get one byte
and convert to a character just like stdio_get_char: zero
goes to U+DC00, and 0x01-0xFF go to U+0001 to U+FFFF.
(dgram_get_prop, dgram_set_prop): Handle :byte-oriented
property for getting and setting the is_byte_oriented flag.
|
|
|
|
|
|
|
| |
* socket.c (struct dgram_stream): Member sock_connected
renamed to is_connected.
(make_dgram_sock_stream, dgram_flush, sock_connect,
sock_mark_connected): Follow rename.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* glob.c (glob_wrap): Perform argument conversions
that might throw before allocating UTF-8 string.
* parser.y (text): In the action for SPACE, the lexeme
is not needed so free($1) right away. If regex_compile
were to throw an exception, that lexeme will leak.
* socket.c (getaddrinfo_wrap): Harden against leakage of
node_u8 and service_u8 strings with an unwind block.
For instance, the hints structure could contain
bad values which cause addrinfo_in to throw.
* stream.c (make_string_byte_input_stream): Perform
possibly throwing argument conversions before allocating
resources.
* sysif.c (mkdir_wrap, mknod_wrap, chmod_wrap, symlink_wrap,
link_wrap, setenv_wrap, crypt_wrap): Likewise.
* syslog.c (openlog_wrap, syslog_wrapv): Likewise.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* regex.c (ead_until_match): Use rcyc_pop instead of pop
to move the conses to the recycle list. We know these
are not shared with anything. Adding additional logic
to completely recycle the stack.
* socket.c (dgram_get_char): Use rcyc_pop to
get the character from the push-back list.
* stream.c (stdio_get_char): Likewise.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Fixing read_until_match will require this feature.
* socket.c (dgram_get_char): Treat unget_c as a
cons-based stack; pop a character from it if
available.
(dgram_unget_char): Push the character onto unget_c
rather than storing the characer into unget_c.
* stream.c (stdio_get_char, stdio_unget_char): Closely
analogous changes to the ones in dgram_get_char
and dgram_unget_char, respectively.
* txr.1: Documentation improved and updated.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* lisplib.c (sock_set_entries): Add auto-load entry
for open-socket.
* socket.c (open_socket): Change to static.
(sock_load_init): Register open-socket intrinsic
here rather than in stream.c.
* stream.c (stream_init): Remove registration of
open-socket intrinsic.
* stream.h (open_socket): Declaration removed.
|
|
|
|
|
|
|
|
|
| |
The open_sockfd function is only called within socket.c
* socket.c (open_sockfd): More function up and
change to static.
* stream.h (open_sockfd): Declaration removed.
|
|
|
|
|
|
|
|
|
|
|
| |
* lisplib.c (sock_set_entries): Add open-socket-pair to
autoload list.
* socket.c (sock_mark_connected, socketpair_wrap): New static
functions.
(sock_load_init): Register open-socket-pair intrinsic.
* txr.1: Documented.
|
|
|
|
|
|
| |
* socket.c (sockaddr_unpack): New static function.
(sock_accept): Use sockaddr_unpack instead of two
copies of if/else code.
|
|
|
|
|
|
|
| |
* socket.c (sock_accept): Reduce scope of unwind catch around
recvfrom call. Add missing check nbytes == -1. Branch to
failed label in dup failed case, instead of throwing
exception with truncated "unable to" message.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Making it work as already documented.
* socket.c (MIN): New macro.
(sockaddr_pack): Use utf8_dup_to_buf to convert
Unix socket path to a buffer of UTF-8 bytes, possibly with one
or more embedded null bytes. Copy as much of this as fits into
the sun_path member of struct sockaddr_un.
* txr.1: Improve documentation about the abstract names
on Linux.
|
|
|
|
|
|
|
|
|
|
|
|
| |
Merely setting a peer doesn't actually connect the socket,
so it must not be marked connected. If it is wrongly
marked connected, then dgram_flush will wrongly use
send rather than sendto.
* socket.c (dgram_set_sock_peer): Don't set sock_connected
flag.
(sock_connect): Set the sock_connected flag here, for dgram
sockets.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Also rename its related functions for consistency.
* socket.c (sockaddr_in_out): Renamed to sockaddr_in_unpack.
The "in" stands for internet, and is juxtaposed to "out".
(sockaddr_in6_out): Renamed to sockaddr_in6_unpack.
(unix_sockaddr_out): Renamed to sockaddr_un_unpack.
(getaddrinfo_wrap): Calls to *_out functions renamed
to *_unpack.
(sockaddr_in): Renamed to sockaddr_pack. Original name is
confusing against the struct tag name in struct sockaddr_in.
(dgram_set_sock_peer, sock_bind, sock_connect, sock_accept):
Calls updated to sockaddr_pack.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
There is more to this patch than just more permissive
mode strings. Now if a socket can be opened with mode
"l2" for instance, and these options are effectively applied
to the socket-specific "r+b" default, not to "r".
* stream.c (parse_mode): New argument specifying a default
mode. The syntax is relaxed, allowing previously required
elements to be omitted.
(normalize_mode): New argument specifying a default mode.
Format mode is always called now, because an input string
is no longer necessarily a valid fopen string even in cases
when it doesn't specify any extensions.
(open_file, open_fileno, open_tail, open_command,
open_process): Use new normalize_mode argument for defaulting;
normalize_mode no longer defaults to "r".
* stream.h (stdio_mode_init_trivial): Macro removed.
(stdio_mode_init_blank, stdio_mode_init_r,
stdio_mode_init_rpb): New initializer macros.
(parse_mode, normalize_mode): Declarations updated.
* socket.c (sock_accept): In datagram socket case, use new
parse_mode argument for defaulting using stdio_mode_init_rpb,
rather than overriding a missing string with "r+b".
(open_sockfd): Likewise, and use new normalize_mode
argument similarly for defaulting the mode on a stream socket.
* txr.1: Documented mode string permissiveness.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* socket.c (struct dgram_stream): new rx_max member.
(make_dgram_sock_stream): New arguments: a struct stdio_mode,
and pointer to prototype dgram socket. If a size is specified
in the mode, then use that as rx_max. Otherwise if a prototype
socket is specified, use its rx_max as the new socket's rx_max.
Otherwise default on 65536.
(dgram_get_byte_callback): Use d->rx_max as the capture size,
rather than a hard-coded 65536.
(sock_accept): Use d->rx_max as capture size for datagram.
Parse the mode. Pass the parsed mode to make_dgram_sock_stream,
as well as the accepting socket, so it can set up the rx_max
for the new socket.
(open_sockfd): Parse the mode and pass to make_dgram_sock_stream.
* stream.c (parse_mode): Static function becomes extern.
* stream.h (parse_mode): Declared.
* txr.1: Documented.
|
|
|
|
|
| |
* socket.c: Inadvertently introduced tabs recently
while working on Solaris. Grr!
|
|
|
|
|
|
| |
* socket.c (open_sockfd): Default mode string is "r+b".
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
| |
* socket.c (sock_accept): New third parameter specifying
timeout. If a timeout is specified, use the select function to
select socket for reading, datagram or stream.
(sock_load_init): Update registration of sock-accept
intrinsic to three arguments, one optional.
* txr.1: Documented sock-accept's timeout parameter.
|
|
|
|
|
|
|
|
|
|
| |
* socket.c (to_connect): New static function.
(sock_connect): Use to_connect instead of calling
connect directly.
(lock_load_init): sock-connect intrinsic registration
updated to three arguments, one optional.
* txr.1: Documented sock-connect timeout.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* lib.c (timeout_error_s): New symbol variable.
(obj_init): Intern timeout-error, init new variable.
* lib.h (timeout_error_s): Declared.
* socket.c (sock_timeout, sock_send_timeout,
sock_recv_timeout): New static functions.
(sock_load_init): Register sock-send-timeout and
sock-recv-timeout intrinsics.
* stream.c (stdio_maybe_read_error, stdio_maybe_error):
Convert EAGAIN into timeout_error_s.
* txr.1: Documented.
|
|
|
|
|
|
|
| |
* socket.c (sock_connect): return a useful value rather than
t, namely the socket.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
| |
* socket.c (open_sockfd): We no longer need to set
stream sockets to line buffered mode here;
it's done in set_mode_props.
* stream.c (set_mode_props): If the mode specifies interactive,
streams open for writing are also switched to line buffering.
* txr.1: Documented under open-file, and open-socket.
|
|
|
|
|
|
|
|
|
|
| |
Undocumented members in struct sockaddr_in, and possibly
sockaddr_in6 also, must be cleared to all zero bits, otherwise
bind fails for the loopback address, even if the relevant
addressing members are correctly set.
* socket.c (sockaddr_in): memset the IPv4 or IPv6 address
to zero before filing it.
|
|
|
|
|
|
|
|
| |
* socket.c (struct dgram_stream): New member, sock_connected.
(make_dgram_sock_stream): Initialize sock_connected to zero.
(dgram_flush): Use send if sock_connected is nonzero, otherwise
sendto.
(dgram_set_sock_peer): Set sock_connected to 1.
|
|
|
|
|
| |
* socket.c (sock_bind, sock_connect, sock_listen,
sock_accept): If the socket is closed, throw an error.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* socket.c (struct dgram_stream): New member, addr.
(make_dgram_sock_stream): Initialize addr to nil.
(dgram_print): Instead of printing the numeric fd, print the
stream description, obtained from the name_k property.
(dgram_mark): Mark the addr member.
(dgram_get_prop): Calculate a descriptive string from the
dgram stream state for the name_k property.
(dgram_set_prop): New static function.
(dgram_strm_ops): Name change to dgram-sock. Wire in
dgram_set_prop function.
(sock_bind): Set the addr_k property of the stream
to the local address that was just bound.
* stream.c (addr_k): New keyword symbol variable.
(stdio_handle): New member, addr.
(stdio_stream_print): Obtain descr by calling get_prop
method rather than directly from h->descr, in case it is
dynamically computed. Use ~a rather than ~s for incorporating
string properties into printed form, to eliminate quotes.
(stdio_stream_mark): Mark new addr member.
(sock_get_prop, sock_set_prop): New static functions.
(stdio_set_sock_peer): Invalidate h->descr by setting
it to nil.
(make_stdio_stream_common): Initialize h->addr to nil.
(make_sock_stream): Specify description as nil rather
than "socket".
(stream_init): Intern the addr keyword, and initialize
the addr_k variable.
Set the name of stdio_sock_ops to "stream-sock"
rather than leaving it inherited as "file-stream".
Wire in the sock_get_prop and sock_set_prop functions into
stdio_sock_ops.
* stream.h (addr_k): Declared.
|
|
|
|
|
| |
* socket.c (sock_accept): The address length passed to
recvfrom was not initialized to the storage length.
|
|
|
|
|
|
|
|
| |
* socket.c (dgram_set_sock_peer): Assign to struct
dgram_stream using using set macro.
* stream.c (stdio_set_sock_peer): Assign to struct
stdio_handle peer using set macro.
|
|
|
|
|
| |
* socket.c (sock_connect): If connect fails, show socket and
address in error message.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* socket.c (struct dgram_stream): New struct.
(make_dgram_sock_stream, dgram_print, dgram_mark,
dgram_destroy, dgram_overflow, dgram_put_byte_callback,
dgram_put_string, dgram_put_char, dgram_put_byte,
dgram_get_byte_callback, dgram_get_char, dgram_get_byte,
dgram_unget_char, dgram_unget_byte, dgram_flush, dgram_close,
dgram_get_prop, dgram_get_fd, dgram_get_sock_family,
dgram_get_sock_type, dgram_get_sock_peer,
dgram_set_sock_peer, dgram_get_error, dgram_get_error_str,
dgram_clear_error): New static functions.
(dgram_strm_ops): New static structure.
(sock_listen): Check against datagram sockets which have
a peer; otherwise a no-op for datagram sockets.
(sock_accept): Special logic for dgram sockets.
(open_sockfd): Function moved here from stream.c, and
augmented to open dgram stream for dgram sockets.
(open_socket): Function moved here from stream.c.
(sock_load_init): Fill in some operations in dgram_strm_ops.
* stream.c (generic_get_line, make_sock_stream,
errno_to_string): Statics become external.
(open_sockfd, open_socket): Functions removed from here,
moved to socket.c.
* stream.h (generic_get_line, make_sock_stream,
errno_to_string): Declared.
|
|
|
|
|
|
| |
* socket.c (sock_bind, sock_connect, sock_listen): Report
function name as sock-bind, sock-connect and sock-listen,
rather than bind, connect and listen.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* stream.c (struct stdio_handle): New member, peer.
(stdio_stream_mark): Mark the new member.
(sock_peer, sock_set_peer): New functions.
(stream_init): Registered sock-peer intrinsic.
* stream.h (sock_peer, sock_set_peer): Declared.
* socket.c (sock_connect): If the connect is successful,
then store the address into the stream as the peer.
|
|
|
|
|
| |
* socket.c (sock_bind): Set the SO_REUSEADDR option before
binding the socket, to thwart the EADDRINUSE nuisance.
|
|
* 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.
|