diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2022-05-27 06:43:09 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2022-05-27 06:43:09 -0700 |
commit | d527345d0d968bdb2a1a90aaa70aa10319aa29fe (patch) | |
tree | 37fbd94767dab59c8fb7198ad441b6b08d2fcbbb /gzio.c | |
parent | 070c343bfb9dc26248ab73719f37f6b5888f5217 (diff) | |
download | txr-d527345d0d968bdb2a1a90aaa70aa10319aa29fe.tar.gz txr-d527345d0d968bdb2a1a90aaa70aa10319aa29fe.tar.bz2 txr-d527345d0d968bdb2a1a90aaa70aa10319aa29fe.zip |
gzio: support :byte-oriented prop.
* gzio.c (gzio_get_prop, gzio_set_prop): Handle :byte-oriented
symbol, connecting it to the is_byte_oriented flag.
This is already implemented, by copy and paste from the
stdio routines.
Diffstat (limited to 'gzio.c')
-rw-r--r-- | gzio.c | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -381,22 +381,30 @@ static ucnum gzio_put_buf(val stream, mem_t *ptr, ucnum len, ucnum pos) static val gzio_get_prop(val stream, val ind) { + struct gzio_handle *h = coerce(struct gzio_handle *, stream->co.handle); + if (ind == name_k) { struct strm_ops *ops = coerce(struct strm_ops *, stream->co.ops); val name = static_str(ops->name); - struct gzio_handle *h = coerce(struct gzio_handle *, stream->co.handle); return format(nil, lit("~a ~a"), name, h->descr, nao); + } else if (ind == byte_oriented_k) { + return h->is_byte_oriented ? t : nil; } return nil; } static val gzio_set_prop(val stream, val ind, val prop) { + struct gzio_handle *h = coerce(struct gzio_handle *, stream->co.handle); + if (ind == name_k) { - struct gzio_handle *h = coerce(struct gzio_handle *, stream->co.handle); h->descr = prop; return t; + } else if (ind == byte_oriented_k) { + h->is_byte_oriented = prop ? 1 : 0; + return t; } + return nil; } |