summaryrefslogtreecommitdiff
path: root/libguile/socket.c
AgeCommit message (Collapse)AuthorFilesLines
2011-03-20Make VM string literals immutable.Ludovic Courtès1-1/+1
* libguile/strings.c (scm_i_make_string, scm_i_make_wide_string): Add `read_only_p' parameter. All callers updated. * libguile/vm-i-loader.c (load_string, load_wide_string): Push read-only strings. * test-suite/tests/strings.test ("literals"): New test prefix.
2011-02-13Set sockaddr_in.sin_len field when it exists.Noah Lavine1-1/+5
* configure.ac: Detect when struct sockaddr_in has a sin_len field. Remove obsolete comment. * libguile/socket.c (scm_to_sockaddr, scm_fill_sockaddr): Set the sin_len field in our struct sockaddr_in when it exists.
2011-02-13zero newly allocated sockaddrsNoah Lavine1-0/+3
* libguile/socket.c (scm_to_sockaddr, scm_fill_sockaddr): Zero the sockaddrs, so we do not pass uninitialized memory to the kernel.
2011-01-29Make `inet-ntop' and `inet-pton' available even when !HAVE_IPV6.Ludovic Courtès1-37/+61
* libguile/socket.c (scm_inet_pton, scm_inet_ntop): Move out of `#ifdef HAVE_IPV6' and conditionalize the IPv6-specific bits. Reported by Jan Nieuwenhuizen <janneke@gnu.org>.
2011-01-29Have `recv!', `send', etc. accept a bytevector.Ludovic Courtès1-72/+162
* libguile/socket.c (scm_recv, scm_send, scm_recvfrom, scm_sendto): Expect the buffer to be a bytevector. Move the string-handling code under `#if SCM_ENABLE_DEPRECATED == 1' and issue a deprecation warning. * test-suite/tests/socket.test ("AF_UNIX/SOCK_DGRAM")["sendto", "sendto/sockaddr"]: Adjust accordingly. * doc/ref/posix.texi (Network Sockets and Communication): Update documentation of `recv!', `send', `recvfrom!', and `sendto'.
2010-12-02scm_accept no longer leaves guile modeAndy Wingo1-17/+1
* libguile/socket.c (scm_accept): Revert 7d1fc8721724ab64ccdc44d6f4f84abad43751b4. Now that we don't need to leave guile mode in order for GC to happen, don't do so, as we assume that anyone who cares has already done a select() beforehand.
2010-10-20Add support for more multicast sockopts.Tristan Colgate-McFarlane1-0/+18
* libguile/socket.c: Add support for IP_MULTICAST_TTL and IP_MILTICAST_IF sockopts.
2009-11-17Remove references to undefined macros.Ludovic Courtès1-4/+4
The intent is to allow compilation with `-Wundef', which in turn should make it easier to catch erroneous uses of nonexistent macros. * libguile/__scm.h: Don't assume `BUILDING_LIBGUILE' is defined. * libguile/conv-uinteger.i.c (SCM_TO_TYPE_PROTO): Remove unneeded CPP conditional on `TYPE_MIN == 0'. * libguile/fports.c: Check for the definition of `HAVE_CHSIZE' and `HAVE_FTRUNCATE', not for their value. * libguile/ports.c: Likewise. * libguile/numbers.c (guile_ieee_init): Likewise with `HAVE_DINFINITY' and `HAVE_DQNAN'. * test-suite/standalone/test-conversion.c (ieee_init): Likewise. * libguile/strings.c: Likewise with `SCM_STRING_LENGTH_HISTOGRAM'. * libguile/strings.h: Likewise. * libguile/tags.h: Likewise with `HAVE_INTTYPES_H' and `HAVE_STDINT_H'. * libguile/threads.c: Likewise with `HAVE_PTHREAD_GET_STACKADDR_NP'. * libguile/vm-engine.c (VM_NAME): Likewise with `VM_CHECK_IP'. * libguile/gen-scmconfig.c (main): Use "#ifdef HAVE_", not "#if HAVE_". * libguile/socket.c (scm_setsockopt): Likewise.
2009-11-16Deprecate `inet-ntoa' and `inet-aton'.Ludovic Courtès1-47/+0
Suggested by Bruno Haible. * libguile/inet_aton.c: Remove. * libguile/Makefile.am (EXTRA_libguile_la_SOURCES): Remove `inet_aton.c'. * libguile/deprecated.c (scm_inet_aton, scm_inet_ntoa): New functions. * libguile/deprecated.h: Update accordingly. * libguile/socket.c (scm_inet_aton, scm_inet_ntoa): Remove. * doc/ref/posix.texi (Network Address Conversion): Mark `inet-ntoa' and `inet-aton' as deprecated.
2009-11-16Use Gnulib's `inet_ntop' and `inet_pton' modules.Ludovic Courtès1-4/+0
* m4/gnulib-cache.m4: Add `inet_ntop' and `inet_pton'. * configure.ac: Don't check for `inet_ntop' and `inet_pton'. * libguile/socket.c (scm_inet_pton, scm_inet_ntop): Compile regardless of `HAVE_INET_PTON' and `HAVE_INET_NTOP' respectively. * libguile/filesys.c: Use <stdlib.h> instead of <canonicalize.h>.
2009-10-01Fix doc for inet-ntop: always produces a stringNeil Jerram1-2/+2
Thanks to Scott McPeak for reporting this. * libguile/socket.c (scm_inet_ntop): In docstring, add quotes around IPv6 address (+ reflow a bit). * doc/ref/posix.texi (Network Address Conversion): Corresponding change. * doc/maint/guile.texi: Corresponding change.
2009-10-01Fix handling of IPv6 addressesNeil Jerram1-2/+3
Thanks to Scott McPeak for reporting this and providing a patch. * libguile/socket.c (scm_to_ipv6): When address is the wrong type, provide more information in the exception message. (scm_to_sockaddr): scm_to_ipv6 expects just an address, not the whole vector. * test-suite/tests/socket.test ("AF_INET6/SOCK_STREAM"): New set of tests.
2009-08-25Merge commit 'origin/master'Andy Wingo1-8/+24
Conflicts: libguile/unif.c
2009-08-25Merge wip-array refactor, up to cd43fdc5b7a7cAndy Wingo1-2/+2
Conflicts: NEWS libguile/print.c
2009-08-23Modify socket and time functions for wide stringsMichael Gran1-8/+24
* libguile/socket.c (scm_recv): receive the message without holding the stringbuf writing lock (scm_send): try to narrow a string before using it * libguile/stime.c (strftime): convert string to UTF-8 so that it can be safely passed to strftime (strptime): convert input string to UTF-8 so that it can be safely passed through strptime * libguile/strings.c (narrow_stringbuf): new function (scm_i_try_narrow_string): new function * libguile/strings.h: new declaration for scm_i_try_narrow_string
2009-08-08Add Unicode strings and symbolsMichael Gran1-0/+3
This adds full Unicode strings as a datatype, and it adds some minimal functionality. The terminal and port encoding is assumed to be ISO-8859-1. Non-ISO-8859-1 characters are written or input as string character escapes. The string character escapes now have 3 forms: \xXX \uXXXX and \UXXXXXX, for unprintable characters that have 2, 4 or 6 hex digits. The process for writing to strings has been modified. There is now a function scm_i_string_start_writing that does the copy-on-write conversion if necessary. To compile strings that may be wide, the VM storage of strings and string-likes has changed. Most string-using functions have not yet been updated and may break when used with wide strings. * module/language/assembly/compile-bytecode.scm (write-bytecode): use variable width string bytecode format * module/language/assembly.scm (byte-length): use variable width bytecode format * libguile/vm-i-loader.c (load-string, load-symbol): (load-keyword, define): use variable-width bytecode format * libguile/vm-engine.h (FETCH_WIDTH): new macro * libguile/strings.h: new declarations * libguile/strings.c (make_wide_stringbuf): new function (widen_stringbuf): new function (scm_i_make_wide_string): new function (scm_i_is_narrow_string): new function (scm_i_string_wide_chars): new function (scm_i_string_start_writing): new function (scm_i_string_ref): new function (scm_i_string_set_x): new function (scm_i_is_narrow_symbol): new function (scm_i_symbol_wide_chars, scm_i_symbol_ref): new function (scm_string_width): new function (unistring_escapes_to_guile_escapes): new function (scm_to_stringn): new function (scm_i_stringbuf_free): modify for wide strings (scm_i_substring_copy): modify for wide strings (scm_i_string_chars, scm_string_append): modify for wide strings (scm_i_make_symbol, scm_to_locale_stringn): modify for wide strings (scm_string_dump, scm_symbol_dump, scm_to_locale_stringbuf): (scm_string, scm_i_deprecated_string_chars): modify for wide strings (scm_from_locale_string, scm_from_locale_stringn): add null test * libguile/srfi-13.c: add calls for scm_i_string_start_writing for each call of scm_i_string_stop_writing (scm_string_for_each): modify for wide strings * libguile/socket.c: add calls for scm_i_string_start_writing for each call of scm_i_string_stop_writing * libguile/rw.c: add calls for scm_i_string_start_writing for each call of scm_i_string_stop_writing * libguile/read.c (scm_read_string): allow reading of wide strings * libguile/print.h: add declaration for scm_charprint * libguile/print.c (iprin1): print wide strings and add new string escapes (scm_charprint): new function * libguile/ports.h: new declarations for scm_lfwrite_substr and scm_lfwrite_str * libguile/ports.c (update_port_lf): new function (scm_lfwrite): use update_port_lf (scm_lfwrite_substr): new function (scm_lfwrite_str): new function * test-suite/tests/asm-to-bytecode.test ("compiler"): add string width byte to sting-like asm tests
2009-07-19rename unif.[ch] to arrays.[ch]Andy Wingo1-2/+2
* libguile/Makefile.am: * libguile/unif.c: * libguile/unif.h: * libguile/arrays.c: * libguile/arrays.h: Rename unif.[ch] to arrays.[ch]. * libguile.h: * libguile/array-handle.c: * libguile/array-map.c: * libguile/bitvectors.c: * libguile/bytevectors.c: * libguile/eq.c: * libguile/gc-card.c: * libguile/gc-malloc.c: * libguile/gc-mark.c: * libguile/gc.c: * libguile/init.c: * libguile/inline.h: * libguile/print.c: * libguile/random.c: * libguile/read.c: * libguile/socket.c: * libguile/sort.c: * libguile/srfi-4.c: * libguile/srfi-4.h: * libguile/strports.c: * libguile/vectors.c: * libguile/vectors.h: Update includers.
2009-06-17Change Guile license to LGPLv3+Neil Jerram1-6/+7
(Not quite finished, the following will be done tomorrow. module/srfi/*.scm module/rnrs/*.scm module/scripts/*.scm testsuite/*.scm guile-readline/* )
2008-09-13Include <config.h> in all C files; use `#ifdef HAVE_CONFIG_H' rather than `#if'.Ludovic Courtès1-1/+1
2007-12-04Changes from arch/CVS synchronizationLudovic Courtès1-1/+17
2007-09-02Changes from arch/CVS synchronizationLudovic Courtès1-57/+65
2007-09-02Changes from arch/CVS synchronizationLudovic Courtès1-3/+7
2007-06-12Changes from arch/CVS synchronizationLudovic Courtès1-5/+17
2006-10-09merge from 1.8 branchKevin Ryde1-25/+33
2006-04-17merge from 1.8 branchKevin Ryde1-1/+1
2006-02-09(scm_c_make_socket_address): Pass address_size pointerNeil Jerram1-2/+1
on to scm_fill_sockaddr call.
2006-01-29Renamed the "frames" that are related to dynamic-wind to "dynamicMarius Vollmer1-3/+3
contexts. Renamed all functions from scm_frame_ to scm_dynwind_. Updated documentation.
2005-11-26(scm_fill_sockaddr): Remove SCM_C_INLINE_KEYWORD, this isKevin Ryde1-1/+1
much too big to want to inline.
2005-11-12(scm_setsockopt): Missing @defvar in docstring. ReportedKevin Ryde1-1/+2
by Ludovic Courtès.
2005-10-272005-10-27 Ludovic Courtès <ludovic.courtes@laas.fr>Kevin Ryde1-33/+265
* socket.c (scm_fill_sockaddr): No need to check NULL from scm_malloc. (scm_connect, scm_bind, scm_sendto): Accept sockaddr object. (scm_addr_vector): Renamed to _scm_from_sockaddr, update usages. (scm_from_sockaddr, scm_to_sockaddr, scm_make_socket_address, scm_c_make_socket_address): New functions.
2005-10-23(scm_getsockopt, scm_setsockopt): Update docstrings from posix.texi.Kevin Ryde1-18/+107
2005-10-23(scm_init_socket): Add IPPROTO_IP, IPPROTO_TCP,Kevin Ryde1-7/+14
IPPROTO_UDP. Remove SOL_IP, SOL_TCP, SOL_UDP. The former are in POSIX spec examples, the latter are not available on for instance NetBSD.
2005-07-10(scm_inet_pton, scm_inet_ntop): Pointer cast to scm_t_uint8Kevin Ryde1-8/+8
for scm ipv6 funcs, gcc 4 is picky about char* vs uchar*. (scm_getsockopt, scm_accept, scm_getsockname, scm_getpeername, scm_recvfrom) Use socklen_t, gcc 4 is picky about int* vs socklen_t*.
2005-06-05* hashtab.h: Bugfix: use SCM_API (WAS: extern).Marius Vollmer1-4/+5
* socket.c: Remove obsolete comment about socklen_t. (s_scm_setsockopt)[!HAVE_IP_MREQ]: Do not use ip_mreq code. * numbers.h (isnan)[__MINGW32__]: Remove. * Makefile.am (gen_scmconfig_SOURCES): Bugfix: Add DEFAULT_INCLUDES when cross compiling. * threads.c (ETIMEDOUT, pipe)[__MINGW32__]: Add defines. * stime.c (s_scm_strftime)[!HAVE_TM_ZONE]: Use SCM_SIMPLE_VECTOR_REF instead of SCM_VELTS. (Changed slightly from Jan's patch.)
2005-05-23The FSF has a new address.Marius Vollmer1-1/+1
2005-02-27(scm_setsockopt): Handle IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIPMarius Vollmer1-40/+43
options. Also, reorganized the code a bit for cleanliness. Thanks to Greg Troxel!
2005-01-02Use new vector elements API or simple vector API, as appropriate.Marius Vollmer1-15/+15
Removed SCM_HAVE_ARRAYS ifdefery. Replaced all uses of SCM_HASHTABLE_BUCKETS with SCM_HASHTABLE_BUCKET.
2004-12-10(scm_from_ipv6): Just use mpz_import. Don't bother tryingKevin Ryde1-59/+10
to fit scm_from_ulong_long, since that uses mpz_import anyway. Don't bother trying to fit scm_from_ulong, not really worth the trouble if addresses are more than 4 bytes usually.
2004-09-22*** empty log message ***Marius Vollmer1-5/+5
2004-08-27(scm_fill_sockaddr): Use HAVE_STRUCT_SOCKADDR_SIN_LEN andKevin Ryde1-4/+2
HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN for sockaddr fields, SIN_LEN and SIN_LEN6 are not defined on all systems. Reported by Michael Tuexen.
2004-08-19* strings.h, strings.c: (scm_i_string_chars, scm_i_string_length,Marius Vollmer1-15/+23
scm_i_string_writable_chars, scm_i_string_stop_writing): New, to replace SCM_I_STRING_CHARS and SCM_I_STRING_LENGTH. Updated all uses. (scm_i_make_string, scm_c_make_string): New, to replace scm_allocate_string. Updated all uses. (SCM_STRINGP, SCM_STRING_CHARS, SCM_STRING_UCHARS, SCM_STRING_LENGTH): Deprecated. (scm_allocate_string, scm_take_str, scm_take0str, scm_mem2string, scm_str2string, scm_makfrom0str, scm_makfrom0str_opt): Discouraged. Replaced all uses with scm_from_locale_string or similar, as appropriate. (scm_c_string_length, scm_c_string_ref, scm_c_string_set_x, scm_c_substring, scm_c_substring_shared, scm_c_substring_copy, scm_substring_shared, scm_substring_copy): New. * symbols.c, symbols.h (SCM_SYMBOLP, SCM_SYMBOL_FUNC, SCM_SET_SYMBOL_FUNC, SCM_SYMBOL_PROPS, SCM_SET_SYMBOL_PROPS, SCM_SYMBOL_HASH, SCM_SYMBOL_INTERNED_P, scm_mem2symbol, scm_str2symbol, scm_mem2uninterned_symbol): Discouraged. (SCM_SYMBOL_LENGTH, SCM_SYMBOL_CHARS, scm_c_symbol2str): Deprecated. (SCM_MAKE_SYMBOL_TAG, SCM_SET_SYMBOL_LENGTH, SCM_SET_SYMBOL_CHARS, SCM_PROP_SLOTS, SCM_SET_PROP_SLOTS): Removed. (scm_is_symbol, scm_from_locale_symbol, scm_from_locale_symboln): New, to replace scm_str2symbol and scm_mem2symbol, respectively. Updated all uses. (scm_gensym): Generate only the number suffix in the buffer, just string-append the prefix.
2004-08-17(scm_init_socket): Add SOCK_SEQPACKET and SOCK_RDM.Kevin Ryde1-1/+11
2004-08-12* socket.c (scm_inet_aton, scm_inet_pton): Convert SCM strings toMarius Vollmer1-12/+35
locale strings instead of accessing their internals. (scm_recv, scm_send, scm_recvfrom, scm_sendto): Use SCM_I_STRING_CHARS and SCM_I_STRING_LENGTH instead of SCM_STRING_CHARS and SCM_STRING_LENGTH. * socket.c, rw.c, deprecated.h, validate.h (SCM_VALIDATE_STRING_COPY): Deprecated. Replaced all uses with SCM_VALIDATE_STRING plus SCM_I_STRING_CHARS or scm_to_locale_string, etc. (SCM_VALIDATE_SUBSTRING_SPEC_COPY): Deprecated. Replaced as above, plus scm_i_get_substring_spec.
2004-08-10* stime.c, socket.c, simpos.c, procs.c, posix.c, ports.c,Marius Vollmer1-6/+11
net_db.c, fports.c, filesys.c, eval.c, deprecation.c, dynl.c: Replaced uses of SCM_STRING_CHARS with proper uses of scm_to_locale_string. Replaced SCM_STRINGP with scm_is_string. Replaced scm_mem2string with scm_from_locale_string. * simpos.c, posix.c (allocate_string_pointers, environ_list_to_c): Removed, replaced all uses with scm_i_allocate_string_pointers.
2004-08-02* numbers.h, numbers.c, discouraged.h, discouraged.c (scm_short2num,Marius Vollmer1-26/+29
scm_ushort2num, scm_int2num, scm_uint2num, scm_long2num, scm_ulong2num, scm_size2num, scm_ptrdiff2num, scm_num2short, scm_num2ushort, scm_num2int, scm_num2uint, scm_num2long, scm_num2ulong, scm_num2size, scm_num2ptrdiff, scm_long_long2num, scm_ulong_long2num, scm_num2long_long, scm_num2ulong_long): Discouraged by moving to discouraged.h and discouraged.c and reimplementing in terms of scm_from_* and scm_to_*. Changed all uses to the new scm_from_* and scm_to_* functions.
2004-07-23* deprecated.h, deprecated.c, numbers.h (SCM_INUMP, SCM_NINUMP,Marius Vollmer1-38/+38
SCM_INUM): Deprecated by reenaming them to SCM_I_INUMP, SCM_I_NINUMP and SCM_I_INUM, respectively and adding deprecated versions to deprecated.h and deprecated.c. Changed all uses to either use the SCM_I_ variants or scm_is_*, scm_to_*, or scm_from_*, as appropriate.
2004-07-10(ipv6_net_to_num, scm_from_ipv6): RenamedMarius Vollmer1-89/+48
ipv6_net_to_num to scm_from_ipv6, for converting from an IPv& byte-wise address to a SCM integer. Changed all uses. (ipv6_num_to_net, scm_to_ipv6): Renamed ipv6_num_to_net to scm_to_ipv6 and added type and range checking, for converting from an IPv& byte-wise address to a SCM integer. Changed all uses. (bignum_in_ipv6_range_p, VALIDATE_INET6): Removed, their function is now done by scm_to_ipv6. * validate.h, deprecated.h (SCM_VALIDATE_INUM, SCM_VALIDATE_INUM_COPY, SCM_VALIDATE_BIGINT, SCM_VALIDATE_INUM_MIN, SCM_VALIDATE_INUM_MIN_COPY, SCM_VALIDATE_INUM_MIN_DEF_COPY,SCM_VALIDATE_INUM_DEF, SCM_VALIDATE_INUM_DEF_COPY, SCM_VALIDATE_INUM_RANGE, SCM_VALIDATE_INUM_RANGE_COPY): Deprecated because they make the fixnum/bignum distinction visible. Changed all uses to scm_to_size_t or similar.
2004-07-08* numbers.h (SCM_MAKINUM, SCM_I_MAKINUM): Renamed SCM_MAKINUM toMarius Vollmer1-41/+41
SCM_I_MAKINUM and changed all uses.
2004-04-24Add a copyright year, based on the changelog.Kevin Ryde1-1/+1
2004-04-24(VALIDATE_INET6): Correction to bignum_in_ipv6_range_pKevin Ryde1-2/+3
call. Reported by Hyperdivision.