diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2019-05-10 08:02:03 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2019-05-10 08:02:03 +0300 |
commit | 9223032f5025f8bc4820dfdfb081be1c7fcd1c4e (patch) | |
tree | e1209bcc78f5a48673c36ea5ad4d820f4ab1bd98 /modules | |
parent | 462c760d4605787a6f5baecc87dfee5e8ee5238b (diff) | |
download | smap-9223032f5025f8bc4820dfdfb081be1c7fcd1c4e.tar.gz smap-9223032f5025f8bc4820dfdfb081be1c7fcd1c4e.tar.bz2 |
Support for Guile 2.2
* NEWS: Update.
* README: Update.
* configure.ac: Drop support for Guile versions prior to 2.2 and
Mailutils prior to 3.0
* modules/guile/getpw.scm: Use inet-ntop instead of the withdrawn
inet-ntoa.
* modules/guile/guile.c: Rewrite for Guile 2.2
Diffstat (limited to 'modules')
-rw-r--r-- | modules/guile/getpw.scm | 4 | ||||
-rw-r--r-- | modules/guile/guile.c | 89 |
2 files changed, 20 insertions, 73 deletions
diff --git a/modules/guile/getpw.scm b/modules/guile/getpw.scm index 168badb..2a8bc39 100644 --- a/modules/guile/getpw.scm +++ b/modules/guile/getpw.scm @@ -1,5 +1,5 @@ ;;;; This file is part of Smap. -;;;; Copyright (C) 2010, 2014 Sergey Poznyakoff +;;;; Copyright (C) 2010, 2014, 2019 Sergey Poznyakoff ;;;; ;;;; Smap is free software; you can redistribute it and/or modify ;;;; it under the terms of the GNU General Public License as published by @@ -87,7 +87,7 @@ (let ((src (car rest))) (format (current-error-port) "connect from ~A~%" (if (= (sockaddr:fam src) AF_INET) - (inet-ntoa (sockaddr:addr src)) + (inet-ntop AF_INET (sockaddr:addr src)) "UNIX socket"))) ;; Select appropriate handler and call it (let ((elt (assoc map map-list))) diff --git a/modules/guile/guile.c b/modules/guile/guile.c index ae63a51..2ce66c5 100644 --- a/modules/guile/guile.c +++ b/modules/guile/guile.c @@ -1,5 +1,5 @@ /* This file is part of Smap. - Copyright (C) 2010, 2014, 2015 Sergey Poznyakoff + Copyright (C) 2010, 2014, 2015, 2019 Sergey Poznyakoff Smap is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -171,7 +171,7 @@ argv_to_scm(int argc, char **argv) return scm_first; } -static scm_t_bits scm_tc16_smap_output_port; +static scm_t_port_type *scm_smap_output_port_type; struct _guile_smap_output_port { smap_stream_t stream; }; @@ -180,78 +180,32 @@ static SCM _make_smap_output_port(smap_stream_t stream) { struct _guile_smap_output_port *dp; - SCM port; - scm_port *pt; - dp = scm_gc_malloc(sizeof (struct _guile_smap_output_port), - "smap-output_-port"); + dp = scm_gc_typed_calloc (struct _guile_smap_output_port); dp->stream = stream; - - port = scm_new_port_table_entry(scm_tc16_smap_output_port); - pt = SCM_PTAB_ENTRY(port); - pt->rw_random = 0; - SCM_SET_CELL_TYPE(port, - (scm_tc16_smap_output_port | - SCM_OPN | SCM_WRTNG | SCM_BUF0)); - SCM_SETSTREAM(port, dp); - return port; + return scm_c_make_port (scm_smap_output_port_type, + SCM_WRTNG | SCM_BUF0, + (scm_t_bits) dp); } #define SMAP_OUTPUT_PORT(x) ((struct _guile_smap_output_port *) SCM_STREAM (x)) -static SCM -_smap_output_port_mark(SCM port) -{ - return SCM_BOOL_F; -} - static void -_smap_output_port_flush(SCM port) -{ - scm_port *pt = SCM_PTAB_ENTRY(port); - struct _guile_smap_output_port *dp = SMAP_OUTPUT_PORT(port); - if (dp && pt->write_pos > pt->write_buf) - smap_stream_write(dp->stream, "\n", 1, NULL); -} - -static int _smap_output_port_close(SCM port) { struct _guile_smap_output_port *dp = SMAP_OUTPUT_PORT(port); - if (dp) { - _smap_output_port_flush(port); - SCM_SETSTREAM(port, NULL); - scm_gc_free(dp, sizeof(struct _guile_smap_output_port), - "smap-output-port"); + if (dp && dp->stream) { + smap_stream_flush(dp->stream); } - return 0; } -static scm_sizet -_smap_output_port_free(SCM port) -{ - _smap_output_port_close(port); - return 0; -} - -static int -_smap_output_port_fill_input(SCM port) -{ - return EOF; -} - -static void -_smap_output_port_write(SCM port, const void *data, size_t size) +static size_t +_smap_output_port_write(SCM port, SCM src, size_t start, size_t count) { struct _guile_smap_output_port *dp = SMAP_OUTPUT_PORT(port); - smap_stream_write(dp->stream, data, size, NULL); -} - -static scm_t_off -_smap_output_port_seek (SCM port, scm_t_off offset, int whence) -{ - return -1; + smap_stream_write(dp->stream, SCM_BYTEVECTOR_CONTENTS (src) + start, count, NULL); + return count; } static int @@ -264,19 +218,12 @@ _smap_output_port_print(SCM exp, SCM port, scm_print_state *pstate) static void _init_smap_output_port() { - scm_tc16_smap_output_port = scm_make_port_type("smap-output-port", - _smap_output_port_fill_input, - _smap_output_port_write); - scm_set_port_mark (scm_tc16_smap_output_port, _smap_output_port_mark); - scm_set_port_free (scm_tc16_smap_output_port, _smap_output_port_free); - scm_set_port_print (scm_tc16_smap_output_port, - _smap_output_port_print); - scm_set_port_flush (scm_tc16_smap_output_port, - _smap_output_port_flush); - scm_set_port_close (scm_tc16_smap_output_port, - _smap_output_port_close); - scm_set_port_seek (scm_tc16_smap_output_port, - _smap_output_port_seek); + scm_smap_output_port_type = scm_make_port_type("smap-output-port", + NULL, + _smap_output_port_write); + scm_set_port_print(scm_smap_output_port_type, _smap_output_port_print); + scm_set_port_close(scm_smap_output_port_type, _smap_output_port_close); + scm_set_port_needs_close_on_gc(scm_smap_output_port_type, 1); } static void |