summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>1998-05-04 20:49:26 +0200
committerWerner Koch <wk@gnupg.org>1998-05-04 20:49:26 +0200
commit42b03f6ebdda25a5b61db72cf9aecaaf6788de16 (patch)
treea36d2fe06b19dca6f64009010e2a731b45e6b886 /util
parentfixed last passphrase bug (diff)
downloadgnupg2-42b03f6ebdda25a5b61db72cf9aecaaf6788de16.tar.xz
gnupg2-42b03f6ebdda25a5b61db72cf9aecaaf6788de16.zip
new releaseV0-2-17
Diffstat (limited to 'util')
-rw-r--r--util/ChangeLog5
-rw-r--r--util/iobuf.c49
2 files changed, 44 insertions, 10 deletions
diff --git a/util/ChangeLog b/util/ChangeLog
index 89eedb0c1..31312c7eb 100644
--- a/util/ChangeLog
+++ b/util/ChangeLog
@@ -1,3 +1,8 @@
+Mon May 4 19:48:03 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * iobuf.c (iobuf_read): Code is now faster.
+ * (iobuf_write): ditto.
+
Mon Apr 27 11:01:32 1998 Werner Koch (wk@isil.d.shuttle.de)
* strgutil.c (memicmp): New.
diff --git a/util/iobuf.c b/util/iobuf.c
index 3940f1034..1578d565b 100644
--- a/util/iobuf.c
+++ b/util/iobuf.c
@@ -728,15 +728,38 @@ 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;
+ if( a->unget.buf || a->nlimit ) {
+ /* handle special cases */
+ for(n=0 ; n < buflen; n++, buf++ ) {
+ if( (c = iobuf_readbyte(a)) == -1 ) {
+ if( !n )
+ return -1; /* eof */
+ break;
+ }
+ else
+ *buf = c;
}
- else
- *buf = c;
+ return n;
}
+
+ if( a->filter_eof ) {
+ if( DBG_IOBUF )
+ log_debug("iobuf-%d.%d: filter eof in iobuf_read\n", a->no, a->subno );
+ return -1;
+ }
+ n = 0;
+ do {
+ for( ; n < buflen && a->d.start < a->d.len; n++ )
+ *buf++ = a->d.buf[a->d.start++];
+ if( n < buflen ) {
+ if( (c=underflow(a)) == -1 ) {
+ a->nbytes += n;
+ return n? n : -1/*EOF*/;
+ }
+ *buf++ = c; n++;
+ }
+ } while( n < buflen );
+ a->nbytes += n;
return n;
}
@@ -782,12 +805,18 @@ iobuf_writebyte(IOBUF a, unsigned c)
int
iobuf_write(IOBUF a, byte *buf, unsigned buflen )
{
- for( ; buflen; buflen--, buf++ )
- if( iobuf_writebyte(a, *buf) )
- return -1;
+ do {
+ for( ; buflen && a->d.len < a->d.size; buflen--, buf++ )
+ a->d.buf[a->d.len++] = *buf;
+ if( buflen ) {
+ if( iobuf_flush(a) )
+ return -1;
+ }
+ } while( buflen );
return 0;
}
+
int
iobuf_writestr(IOBUF a, const char *buf )
{