ostream-openssl.c revision 3faa1040e5a3f9f35ffad29110216094ab2f5880
/* Copyright (c) 2009-2012 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "buffer.h"
#include "ostream-private.h"
#include "iostream-openssl.h"
struct ssl_ostream {
struct ostream_private ostream;
struct ssl_iostream *ssl_io;
};
{
}
{
}
static size_t
{
unsigned int i;
for (i = 0; i < iov_count; i++) {
break;
}
size);
bytes_sent += size;
i = iov_count;
}
if (avail > 0)
for (; i < iov_count; i++) {
bytes_sent += size;
break;
}
return bytes_sent;
}
{
int ret = 1;
/* we're writing plaintext data to OpenSSL, which it encrypts
and writes to bio_int's buffer. ssl_iostream_bio_sync()
reads it from there and adds to plain_output stream. */
if (ret <= 0) {
ret, "SSL_write");
if (ret < 0) {
break;
}
if (ret == 0)
break;
} else {
}
}
}
{
int ret;
/* handshake failed */
/* we can try to send some of our buffered data */
}
/* we need to read more data until we can continue. */
FALSE);
ret = 1;
}
return ret;
}
static ssize_t
{
unsigned int i;
*bytes_sent_r = 0;
if (ret <= 0) {
ret, "SSL_write");
if (ret < 0) {
break;
}
if (ret == 0)
break;
} else {
*bytes_sent_r += ret;
else {
i++;
pos = 0;
}
}
}
return ret < 0 ? -1 : 0;
}
static ssize_t
{
size_t bytes_sent = 0;
int ret;
ret = 0;
else {
&bytes_sent);
}
}
{
}
{
/* try to actually flush the pending data */
return -1;
/* we may be able to copy more data, try it */
else
if (ret2 == 0)
if (ret2 < 0)
return -1;
}
static void
{
}
{
}
{
struct ssl_ostream *sstream;
}