diff options
author | Ludovic Courtès <ludo@gnu.org> | 2014-01-16 23:52:01 +0100 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2014-01-18 22:52:07 +0100 |
commit | 122f24cc8a3637ed42d7792ad1ff8ec0c49c58df (patch) | |
tree | 80dd5c071fb1342dd78e24d27ea759d03d42e93e /libguile/ports-internal.h | |
parent | 611563fb05c18ca52f780746e9963ca9735e9bac (diff) | |
download | guile-122f24cc8a3637ed42d7792ad1ff8ec0c49c58df.tar.gz |
Prepare 'setvbuf' to support for non-file ports.
* libguile/ports-internal.h (struct scm_port_internal): Add
setvbuf' field. Change 'pending_eof' to a 1-bit unsigned char.
* libguile/ports.c (scm_new_port_table_entry): Clear 'pti->setvbuf'.
* libguile/fports.c (scm_setvbuf): Accept any open port, and error out
when PORT's setvbuf' field is NULL. Remove explicit 'scm_gc_free' calls.
(scm_i_fdes_to_port): Set PORT's 'setvbuf' field.
* test-suite/tests/ports.test ("setvbuf")["closed port", "string port"]:
New tests.
* doc/ref/posix.texi (Ports and File Descriptors): Suggest that
'setvbuf' works for different port types.
Diffstat (limited to 'libguile/ports-internal.h')
-rw-r--r-- | libguile/ports-internal.h | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/libguile/ports-internal.h b/libguile/ports-internal.h index 8a3a00bc9..48dcaa796 100644 --- a/libguile/ports-internal.h +++ b/libguile/ports-internal.h @@ -1,7 +1,7 @@ /* * ports-internal.h - internal-only declarations for ports. * - * Copyright (C) 2013 Free Software Foundation, Inc. + * Copyright (C) 2013, 2014 Free Software Foundation, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -50,7 +50,17 @@ struct scm_port_internal unsigned at_stream_start_for_bom_write : 1; scm_t_port_encoding_mode encoding_mode; scm_t_iconv_descriptors *iconv_descriptors; - int pending_eof; + unsigned char pending_eof: 1; + + /* When non-NULL, this is the method called by 'setvbuf' for this port. + It must create read and write buffers for PORT with the specified + sizes (a size of 0 is for unbuffered ports, which should use the + 'shortbuf' field.) Size -1 means to use the port's preferred buffer + size. */ + /* XXX: In 2.2 make this a property of the 'scm_t_ptob_descriptor'. */ + void (*setvbuf) (SCM port, long read_size, long write_size); + + /* Key-value properties. */ SCM alist; }; |