Skip to content
API Documentation
BastionGuard™
anonymous_namespace{BastionGuard-mailproxy.cpp}::SmtpIO Struct Reference

Public Member Functions

bool send_all (const std::string &s) const
bool recv_byte (char &ch) const
bool recv_line (std::string &out) const
void close_ssl ()

Public Attributes

int fd = -1
SSL * ssl = nullptr

Detailed Description

Definition at line 1592 of file BastionGuard-mailproxy.cpp.

Member Function Documentation

◆ close_ssl()

void anonymous_namespace{BastionGuard-mailproxy.cpp}::SmtpIO::close_ssl ( )
inline

Definition at line 1627 of file BastionGuard-mailproxy.cpp.

1627 {
1628 if (ssl) {
1629 SSL_shutdown(ssl);
1630 SSL_free(ssl);
1631 ssl = nullptr;
1632 }
1633 }

References ssl.

Referenced by anonymous_namespace{BastionGuard-mailproxy.cpp}::handle_client().

◆ recv_byte()

bool anonymous_namespace{BastionGuard-mailproxy.cpp}::SmtpIO::recv_byte ( char & ch) const
inline

Definition at line 1609 of file BastionGuard-mailproxy.cpp.

1609 {
1610 int n = ssl ? SSL_read(ssl, &ch, 1)
1611 : static_cast<int>(::recv(fd, &ch, 1, 0));
1612 return n == 1;
1613 }

References fd, and ssl.

Referenced by recv_line().

◆ recv_line()

bool anonymous_namespace{BastionGuard-mailproxy.cpp}::SmtpIO::recv_line ( std::string & out) const
inline

Definition at line 1615 of file BastionGuard-mailproxy.cpp.

1615 {
1616 out.clear();
1617 char ch = 0;
1618 while (recv_byte(ch)) {
1619 out.push_back(ch);
1620 if (out.size() >= 2 &&
1621 out[out.size()-2] == '\r' && out[out.size()-1] == '\n')
1622 return true;
1623 }
1624 return false;
1625 }

References recv_byte().

Referenced by anonymous_namespace{BastionGuard-mailproxy.cpp}::handle_client(), and anonymous_namespace{BastionGuard-mailproxy.cpp}::receive_data_block().

◆ send_all()

bool anonymous_namespace{BastionGuard-mailproxy.cpp}::SmtpIO::send_all ( const std::string & s) const
inline

Definition at line 1596 of file BastionGuard-mailproxy.cpp.

1596 {
1597 const char* p = s.c_str();
1598 size_t left = s.size();
1599 while (left > 0) {
1600 int n = ssl ? SSL_write(ssl, p, static_cast<int>(left))
1601 : static_cast<int>(::send(fd, p, left, 0));
1602 if (n <= 0) return false;
1603 p += n;
1604 left -= static_cast<size_t>(n);
1605 }
1606 return true;
1607 }

References fd, and ssl.

Referenced by anonymous_namespace{BastionGuard-mailproxy.cpp}::handle_client(), and anonymous_namespace{BastionGuard-mailproxy.cpp}::send_ehlo_capabilities().

Member Data Documentation

◆ fd

◆ ssl


The documentation for this struct was generated from the following file: