diff options
author | Werner Koch <wk@gnupg.org> | 1998-02-11 04:25:44 +0100 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 1998-02-11 04:25:44 +0100 |
commit | 4c0c155922b70b62793905490e210e9af4e3b18d (patch) | |
tree | a0d8d84a89cfd4579817a993715e750917961c3e /util/iobuf.c | |
parent | release 0.2.3 (diff) | |
download | gnupg2-4c0c155922b70b62793905490e210e9af4e3b18d.tar.xz gnupg2-4c0c155922b70b62793905490e210e9af4e3b18d.zip |
a couple of changes; but some parts are now broken
Diffstat (limited to 'util/iobuf.c')
-rw-r--r-- | util/iobuf.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/util/iobuf.c b/util/iobuf.c index d429d4c1e..65efc0ef5 100644 --- a/util/iobuf.c +++ b/util/iobuf.c @@ -313,7 +313,7 @@ iobuf_close( IOBUF a ) size_t dummy_len; int rc=0; - for( ; a; a = a2 ) { + for( ; a && !rc ; a = a2 ) { a2 = a->chain; if( a->usage == 2 && (rc=iobuf_flush(a)) ) log_error("iobuf_flush failed on close: %s\n", g10_errstr(rc)); @@ -724,6 +724,26 @@ iobuf_readbyte(IOBUF a) int +iobuf_read(IOBUF a, byte *buf, unsigned buflen ) +{ + int c, n; + + for(n=0 ; n < buflen; n++, buf++ ) { + if( (c = iobuf_readbyte(a)) == -1 ) { + if( !n ) + return -1; /* eof */ + break; + } + else + *buf = c; + } + return n; +} + + + + +int iobuf_writebyte(IOBUF a, unsigned c) { if( a->d.len == a->d.size ) |