mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-03 22:56:33 +02:00
armor rewritten, but still buggy
This commit is contained in:
parent
899b8378ec
commit
9886ad8098
16 changed files with 518 additions and 135 deletions
30
util/iobuf.c
30
util/iobuf.c
|
@ -700,6 +700,15 @@ iobuf_readbyte(IOBUF a)
|
|||
{
|
||||
int c;
|
||||
|
||||
/* nlimit does not work together with unget */
|
||||
/* nbytes is also not valid! */
|
||||
if( a->unget.buf ) {
|
||||
if( a->unget.start < a->unget.len )
|
||||
return a->unget.buf[a->unget.start++];
|
||||
m_free(a->unget.buf);
|
||||
a->unget.buf = NULL;
|
||||
}
|
||||
|
||||
if( a->nlimit && a->nbytes >= a->nlimit )
|
||||
return -1; /* forced EOF */
|
||||
|
||||
|
@ -770,6 +779,27 @@ iobuf_temp_to_buffer( IOBUF a, byte *buffer, size_t buflen )
|
|||
return n;
|
||||
}
|
||||
|
||||
/****************
|
||||
* unget the contents of the temp io stream to A and close temp
|
||||
* Could be optimized!!
|
||||
*/
|
||||
void
|
||||
iobuf_unget_and_close_temp( IOBUF a, IOBUF temp )
|
||||
{
|
||||
if( a->unget.buf ) {
|
||||
if( a->unget.start < a->unget.len )
|
||||
log_fatal("cannot do any more ungets on this buffer\n");
|
||||
/* not yet cleaned up; do it now */
|
||||
m_free(a->unget.buf);
|
||||
a->unget.buf = NULL;
|
||||
}
|
||||
a->unget.size = temp->d.len;
|
||||
a->unget.buf = m_alloc( a->unget.size );
|
||||
a->unget.len = temp->d.len;
|
||||
memcpy( a->unget.buf, temp->d.buf, a->unget.len );
|
||||
iobuf_close(temp);
|
||||
}
|
||||
|
||||
|
||||
/****************
|
||||
* Set a limit, how much bytes may be read from the input stream A.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue