mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-03 12:11:33 +01:00
gpgscm: Drop 'len' argument from splice.
* tests/gpgscm/ffi.c (do_splice): Drop 'len' argument, no-one uses it. * tests/gpgscm/lib.scm (splice): Document foreign function. Signed-off-by: Justus Winter <justus@g10code.com>
This commit is contained in:
parent
a55393cb5f
commit
4d98a72b88
@ -1001,29 +1001,20 @@ do_splice (scheme *sc, pointer args)
|
|||||||
FFI_PROLOG ();
|
FFI_PROLOG ();
|
||||||
int source;
|
int source;
|
||||||
int sink;
|
int sink;
|
||||||
ssize_t len = -1;
|
|
||||||
char buffer[1024];
|
char buffer[1024];
|
||||||
ssize_t bytes_read;
|
ssize_t bytes_read;
|
||||||
FFI_ARG_OR_RETURN (sc, int, source, number, args);
|
FFI_ARG_OR_RETURN (sc, int, source, number, args);
|
||||||
FFI_ARG_OR_RETURN (sc, int, sink, number, args);
|
FFI_ARG_OR_RETURN (sc, int, sink, number, args);
|
||||||
if (args != sc->NIL)
|
|
||||||
FFI_ARG_OR_RETURN (sc, ssize_t, len, number, args);
|
|
||||||
FFI_ARGS_DONE_OR_RETURN (sc, args);
|
FFI_ARGS_DONE_OR_RETURN (sc, args);
|
||||||
while (len == -1 || len > 0)
|
while (1)
|
||||||
{
|
{
|
||||||
size_t want = sizeof buffer;
|
bytes_read = read (source, buffer, sizeof buffer);
|
||||||
if (len > 0 && (ssize_t) want > len)
|
|
||||||
want = (size_t) len;
|
|
||||||
|
|
||||||
bytes_read = read (source, buffer, want);
|
|
||||||
if (bytes_read == 0)
|
if (bytes_read == 0)
|
||||||
break;
|
break;
|
||||||
if (bytes_read < 0)
|
if (bytes_read < 0)
|
||||||
FFI_RETURN_ERR (sc, gpg_error_from_syserror ());
|
FFI_RETURN_ERR (sc, gpg_error_from_syserror ());
|
||||||
if (write (sink, buffer, bytes_read) != bytes_read)
|
if (write (sink, buffer, bytes_read) != bytes_read)
|
||||||
FFI_RETURN_ERR (sc, gpg_error_from_syserror ());
|
FFI_RETURN_ERR (sc, gpg_error_from_syserror ());
|
||||||
if (len != -1)
|
|
||||||
len -= bytes_read;
|
|
||||||
}
|
}
|
||||||
FFI_RETURN (sc);
|
FFI_RETURN (sc);
|
||||||
}
|
}
|
||||||
|
@ -207,6 +207,9 @@
|
|||||||
;; Get our process id.
|
;; Get our process id.
|
||||||
(ffi-define (getpid))
|
(ffi-define (getpid))
|
||||||
|
|
||||||
|
;; Copy data from file descriptor SOURCE to SINK.
|
||||||
|
(ffi-define (splice source sink))
|
||||||
|
|
||||||
;;
|
;;
|
||||||
;; Random numbers.
|
;; Random numbers.
|
||||||
;;
|
;;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user