summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* Dgram test: multiple transfers on one stream, IPv6.Kaz Kylheku2016-03-072-0/+39
| | | | | | * tests/014/dgram-stream.tl: New file. * tests/014/dgram-stream.expected: New file.
* Formatting under make-struct.Kaz Kylheku2016-03-071-1/+1
| | | | * txr.1: Syntax issue.
* Basic regression test case for sockets.Kaz Kylheku2016-03-074-0/+45
| | | | | | | | | | * Makefile: suppress --gc-debug for tst/tests/014 directory. * tests/014/socket-basic.tl: New file. * tests/014/socket-basic.expected: New file. * tests/sock-common.tl: New file.
* gc bugs: more instances of wrong mutations.Kaz Kylheku2016-03-072-2/+2
| | | | | | | | * 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.
* gc bug: prepared_msg field of struct parser.Kaz Kylheku2016-03-071-1/+2
| | | | | | | * parser.l (yyerrprepf): Replace wrong bare assignment to parser->prepared_msg with proper set macro which handles the mutation of a mature generation object such that it points to a baby object.
* Show failing address in sock-connect error.Kaz Kylheku2016-03-071-2/+2
| | | | | * socket.c (sock_connect): If connect fails, show socket and address in error message.
* Bugfix: incorrect error string from stdio streams.Kaz Kylheku2016-03-071-1/+1
| | | | | | | * stream.c (errno_to_string): Fix wrong test; it is a nil value of err which is the "no error" case, not non-nil. Due to this bug, any non-numeric error condition will be reported as "no error", including the case t ("eof").
* Fix signed/unsigned warning from g++.Kaz Kylheku2016-03-061-1/+1
| | | | | * sysif.c (repress_called, is_setuid): Change to unsigned int, so comparison with RC_MAGIC constant doesn't elicit warning
* Special implementation of dgram socket streams.Kaz Kylheku2016-03-063-60/+494
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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.
* Refer to correct socket function names in errors.Kaz Kylheku2016-03-061-3/+3
| | | | | | * 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.
* Bugfix: get-string closing stream when told not to.Kaz Kylheku2016-03-061-1/+1
| | | | | | * stream.c (get_string): Use default_arg_strict instead of default_arg, so that the t value is only substituted for a missing argument, not for a nil argument.
* Move error check from operation to wrapper.Kaz Kylheku2016-03-061-3/+2
| | | | | | * stream.c (stdio_unget_char): Remove not-a-character check from character argument. (unget_char): Perform check here, thus for all stream types.
* Access to file descriptor now via stream virtual.Kaz Kylheku2016-03-063-18/+49
| | | | | | | | | | | | | | | | | | | | | | | | | * stream.c (unimpl_get_fd, null_get_fd): New static functions. (fill_stream_ops): Set up get_fd function pointer in strm_ops. (null_ops): Add null_get_fd. (stdio_get_fd): New static function. (stdio_ops, tail_ops, pipe_ops): Specify stdio_get_fd as get_fd function. (stream_fd): Rewritten as call to get_fd operation. (dir_ops, string_in_ops, byte_in_ops, string_out_ops, strlist_out_ops, cat_stream_ops): Specify null as get_fd function, to be defaulted by fill_stream_ops. (delegate_get_fd): New static function. (record_adapter_ops): Specify delegate_get_fd as get_fd function. (stream_init): Change fileno intrinsic registration to point to stream_fd function. * stream.h (struct strm_ops): New member, get_fd. (strm_ops_init): New macro parameter, get_fd. * syslog.c (syslog_strm_ops): Specify null as get_fd function.
* Make stdio_mode type public.Kaz Kylheku2016-03-062-14/+16
| | | | | | | | | | | | * stream.c (struct stdio_mode, stdio_mode_init_trivial): Struct declaration and macro removed from here; moved into stream.h. (normalize_mode, set_mode_props): Static functions made external. * stream.h (struct stdio_mode, stdio_mode_init_trivial): Moved here. (normalize_mode, set_mode_props): Declared.
* Fix in chk_manage_vec resizing from zero.Kaz Kylheku2016-03-061-1/+1
| | | | | | | * lib.c (bounding_pow_two): Eliminate bogus zero versus non-zero case check in return which causes the function to wrongly map 1 to 0, so that chk_manage_vec is then not able to adjust a vector to size 1.
* Replace stdio_get_line with generic routine.Kaz Kylheku2016-03-051-25/+23
| | | | | | | | | | * stream.c (snarf_line): Function renamed to generic_get_line. Interface and implementation changed so it can be used directly as get_line virtual. (stdio_get_line): Function removed. (stdio_ops, pipe_ops): Point get_line to generic_get_line. (tail_get_line): Call generic_get_line instead of stdio_get_line.
* Socket operations become proper stream virtuals.Kaz Kylheku2016-03-042-14/+82
| | | | | | | | | | | | | | | | | | | | | | | * 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.
* Make make_sock_stream static in stream.c.Kaz Kylheku2016-03-042-4/+1
| | | | | | | * stream.c (make_sock_stream): External function becomes static; it is not used outside of this source file. * stream.h (make_sock_stream): Declaration removed.
* Support umask function.Kaz Kylheku2016-03-022-0/+30
| | | | | | | * sysif.c (umask_wrap): New function. (sysif_init): Register umask intrinsic. * txr.1: Documented.
* Version 134.txr-134Kaz Kylheku2016-03-017-436/+491
| | | | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated. * inst.nsi: include .tl files in installer
* Prefix override in IP prefix functions.Kaz Kylheku2016-03-012-14/+35
| | | | | | | | | | | * share/txr/stdlib/socket.tl (sys:str-inaddr-net-impl): New argument weff. Overrides prefix. Bugfix here: we must base the number of octets on the calculated width before wextra is added to it. (str-inaddr-net, str-inaddr6-net): New optional width argument. * txr.1: Documented.
* Fix triple-colon in ipv6 text representation.Kaz Kylheku2016-03-011-18/+17
| | | | | | | | | * share/txr/stdlib/socket.tl (sys:in6addr-condensed-text): New function containing common code. Uses window-mappend to selectively convert a compressed range of zeros to either colon or empty string based on whether it is in the middle or end. (str-in6addr, str-in6addr-net): Use new function.
* Functions for address prefixes to slash notation.Kaz Kylheku2016-02-293-0/+109
| | | | | | | | | | | * lisplib.c (sock_set_entries): Autload entries for str-inaddr-net and str-in6addr-net. * share/txr/stdlib/socket.tl (str-inaddr-net, str-in6addr-net): New functions. * txr.1: Documented str-inaddr, str-in6-addr, str-inaddr-net and str-in6addr-net.
* IP address to string functions.Kaz Kylheku2016-02-292-0/+39
| | | | | | | | * lisplib.c (sock_set_entries): Add str-inaddr and str-in6addr to list of autoload identifiers. * share/txr/stdlib/socket.tl (str-inaddr, str-in6addr): New functions.
* Bugfix: append-each is wrongly destructive.Kaz Kylheku2016-02-291-1/+1
| | | | | * eval.c (op_each): Use list_collect_append not list_collect_nconc. Ouch!
* expand-left and nexpand-left functions.Kaz Kylheku2016-02-292-1/+108
| | | | | | | | * eval.c (expand_left, nexpand_left): New static functions. (eval_init): Registered expand-left and nexpand-left intrinsics. * txr.1: Documented.
* Implement @(next nil).Kaz Kylheku2016-02-292-6/+22
| | | | | | | | * match.c (v_next): If argument to @(next) is nil, then evaluate remaining query in context with no list of files, and no data. * txr.1: Documented @(next nil).
* Missing return type on some inline functions.Kaz Kylheku2016-02-291-2/+2
| | | | | * sysif.h (repress_privilege, drop_privilege): Add missing void.
* Fix typo in configure script message.Kaz Kylheku2016-02-281-1/+1
| | | | * configure: it's, not its.
* Doc: syslog-related fixes.Kaz Kylheku2016-02-281-4/+5
| | | | | | * txr.1: Refer to parameter as options, not option, and use .meta consistently. Don't refer to Syslog section in all caps.
* Doc: elsif doesn't exist.Kaz Kylheku2016-02-281-1/+1
| | | | * txr.1: replace nonexistent @(elsif) in example with @(elif).
* Documenting sockets.Kaz Kylheku2016-02-281-0/+572
| | | | * txr.1: Documented.
* Socket streams know their connected peer address.Kaz Kylheku2016-02-273-0/+22
| | | | | | | | | | | | * 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.
* Do the SO_REUSEADDR thing when binding socket.Kaz Kylheku2016-02-271-2/+5
| | | | | * socket.c (sock_bind): Set the SO_REUSEADDR option before binding the socket, to thwart the EADDRINUSE nuisance.
* Fix descriptor leak on exception in open-fileno.Kaz Kylheku2016-02-271-1/+3
| | | | | * stream.c (open_fileno): If w_fdopen fails, close the file descriptor before throwing exception.
* open-fileno: errno usage.Kaz Kylheku2016-02-271-1/+1
| | | | * stream.c (open_fileno): clear errno to 0 before fdopen.
* Adding socket support: unix, ipv4, ipv6.Kaz Kylheku2016-02-268-1/+682
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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.
* Place C standard I/O based streams into subtype.Kaz Kylheku2016-02-263-3/+10
| | | | | | | | | | | | | | | | | | | * lib.c (subtypep): Handle subtype check here between stream and stdio-stream as a special case, since streams aren't structures related by inheritance, but built-ins. (class_check): If the type of obj doesn't match the class exactly, use a subtypep check. We need this because stream functions use this check, and stdio streams are not of the stream type now. * stream.c (stdio_stream_s): New global symbol variable. (make_stdio_stream_common): Use stdio_stream_s symbol for the type of stdio streams. (stream_init): Intern the stdio-stream symbol, and store in stdio_stream_s variable. (streamp): Replace exact check with typep. * stream.h (stdio_stream_s): Declared.
* Functions for converting between buffers and integers.Kaz Kylheku2016-02-264-0/+60
| | | | | | | | | | | | | | | | | These functions convert between positive integers, and fixed-size memory buffers representing pure binary numbers in big endian byte order. This functionality will be used in some upcoming networking code. * arith.c (num_from_buffer, num_to_buffer): New functions. * arith.h (num_from_buffer, num_to_buffer): Declared. * mpi/mpi.c (mp_to_unsigned_buf): New function. * mpi/mpi.h (mp_to_unsigned_buf): Declared.
* Adding --eargs mechanism.Kaz Kylheku2016-02-022-2/+103
| | | | | | * txr.c (txr_main): Implement --eargs. * txr.1: Documented.
* Support lazy loading of stdlib struct definitions.Kaz Kylheku2016-01-311-2/+6
| | | | | | | * struct.c (make_struct_type): Use find_struct_type rather than direct lookup in struct_type_hash. (find_struct_type): Use lisplib_try_load if a type is not found to trigger autoloading on the symbol.
* Support setuid operation.Kaz Kylheku2016-01-234-1/+136
| | | | | | | | | | | | | | | | | | | | | * sysif.c (orig_euid, real_uid, repress_called, is_setuid): New static variables. (repress_privilege, drop_privilage, simulate_setuid): New functions. (RC_MAGIC): New preprocessor symbol. * sysif.c (repress_privilege, drop_privilage, simulate_setuid): Declared. * txr.c (txr_main): Call repress_privilege to check and remember whether we are in setuid mode, and temporarily drop the effective uid to the real one. (txr_main): Permanently drop privileges in all cases except script execution. In script execution cases, go through simulate_setuid to either set or preserve the effective user ID, or else drop privs. * txr.1: Documented setuid operation in new section.
* Add debug trace to @(require).Kaz Kylheku2016-01-221-1/+3
| | | | * match.c (v_require): Produce trace when require fails.
* Bugfix: @(require) eval not in proper env.Kaz Kylheku2016-01-221-2/+1
| | | | | | | | | I caught this when doing a @(require (boundp 'var)). * match.c (v_require): The correct evaluation was being done here, with the value discarded, followed by an incorrect evaluation in which the TXR bindings are not visible, whose value *is* then used.
* Semantics fix: unhandled exceptions must still unwind.Kaz Kylheku2016-01-222-36/+43
| | | | | | | | | | | | | | | | | * unwind.c (unhandled_ex): New static structure. (unwind_to_exit_point): The code to print the unhandled exception info and bail the process is moved here out of uw_throw. We do this in the situation when we have an unhandled exception, which is represented by the fact that the exception pointer points to the unhandled_ex structure. (uw_throw): If unhandled hook isn't a function, we don't abort; we go through the unwinding and unhandled processing. Also, ditto if the unhandled function returns, ditto. Unhandled processing is entered by substituting unhandled_ex for the not-found exception, and allowing unwind_to_exit point to be called. * txr.1: Document new behavior for unhandled exceptions and *unhandled-hook*.
* Header file cleanup.Kaz Kylheku2016-01-2217-44/+0
| | | | | | | * arith.c, cadr.c, debug.c, eval.c, filter.c, gencadr.txr, glob.c, hash.c, linenoise/linenoise.c, lisplib.c, match.c, parser.c, rand.c, regex.c, signal.c, stream.c, struct.c, sysif.c, syslog.c, txr.c, unwind.c, utf8.c: Remove unncessary header files.
* Reduce header pollution caused by mpi.h.Kaz Kylheku2016-01-224-7/+12
| | | | | | | | | | | | | * eval.c: include <assert.h> that was previously coming via "mpi.h". * mpi/mpi.c: Includes of <stdio.h>, <ctype.h> and <assert.h> moved here. * mpi/mpi.h: Remove include of <stdio.h>, <ctype.h> and <assert.h>. Keeping <limits.h> for now; needed for CHAR_BIT. * mpi/mplogic.c: Needs <assert.h>
* Version 133.txr-133Kaz Kylheku2016-01-216-560/+586
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Support for Base 64 encoding.Kaz Kylheku2016-01-213-1/+208
| | | | | | | | | | | | | * filter.c (tobase64_k, frombase64_k): New keyword symbol variables. (col_check, get_base64_char, b64_code): New static functions. (base64_decode, base64_encode): New functions. (filter_init): Initialize new keyword symbol variables, and register base64-encode and base64-decode intrinsic functions. * filter.h (base64_encode, base64_decode): Declared. * txr.1: Documented base64-encode, base64-decode, as well as :tobase64 and :frombase64.
* bugfix: cached sigmask not populated from OS sigmask.Kaz Kylheku2016-01-191-3/+3
| | | | | | | | | | | | | | | This is responsible for behaviors like Ctrl-C being subsequently ignored after the first time a read is interrupted that way. * signal.c (sig_reload_cache): Eliminate the return statement which was making the memcpy expression unreachable! No warning from gcc. Also, since nobody checks the return value of this function and it doesn't provide one, let's make it void. There is no reason the sigprocmask would fail since the arguments are correct, but let's check its return value anyway.