Skip to content

Commit

Permalink
OrcLib: fix non portable lamba prototype
Browse files Browse the repository at this point in the history
  • Loading branch information
fabienfl-orc committed Nov 9, 2020
1 parent c7746eb commit 3f0cc4f
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 38 deletions.
42 changes: 23 additions & 19 deletions src/OrcLib/DecodeMessageStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,28 @@

using namespace Orc;

namespace {

BOOL CALLBACK StreamOutputCb(IN const void* pvArg, IN BYTE* pbData, IN DWORD cbData, IN BOOL fFinal)
{
auto pStream = (ByteStream*)pvArg;
ULONGLONG ullWritten = 0LL;

if (pStream == nullptr)
return FALSE;

if (FAILED(pStream->Write(pbData, cbData, &ullWritten)))
return FALSE;

if (fFinal)
if (FAILED(pStream->Close()))
return FALSE;

return TRUE;
}

} // namespace

STDMETHODIMP DecodeMessageStream::Initialize(const std::shared_ptr<ByteStream>& pInnerStream)
{
HRESULT hr = E_FAIL;
Expand All @@ -24,25 +46,7 @@ STDMETHODIMP DecodeMessageStream::Initialize(const std::shared_ptr<ByteStream>&

m_StreamInfo.cbContent = CMSG_INDEFINITE_LENGTH;
m_StreamInfo.pvArg = m_pChainedStream.get();
m_StreamInfo.pfnStreamOutput =
(PFN_CMSG_STREAM_OUTPUT)[](IN const void* pvArg, IN BYTE* pbData, IN DWORD cbData, IN BOOL fFinal)->BOOL
{

auto pStream = (ByteStream*)pvArg;
ULONGLONG ullWritten = 0LL;

if (pStream == nullptr)
return FALSE;

if (FAILED(pStream->Write(pbData, cbData, &ullWritten)))
return FALSE;

if (fFinal)
if (FAILED(pStream->Close()))
return FALSE;

return TRUE;
};
m_StreamInfo.pfnStreamOutput = ::StreamOutputCb;

m_hMsg = CryptMsgOpenToDecode(
X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, CMSG_CRYPT_RELEASE_CONTEXT_FLAG, 0L, NULL, NULL, &m_StreamInfo);
Expand Down
42 changes: 23 additions & 19 deletions src/OrcLib/EncodeMessageStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,28 @@

using namespace Orc;

namespace {

BOOL CALLBACK StreamOutputCb(IN const void* pvArg, IN BYTE* pbData, IN DWORD cbData, IN BOOL fFinal)
{
auto pStream = (ByteStream*)pvArg;

if (pStream == nullptr)
return FALSE;

ULONGLONG ullWritten = 0LL;
if (FAILED(pStream->Write(pbData, cbData, &ullWritten)))
return FALSE;

if (fFinal)
if (FAILED(pStream->Close()))
return FALSE;

return TRUE;
};

} // namespace

STDMETHODIMP EncodeMessageStream::AddRecipient(const CBinaryBuffer& buffer)
{
HRESULT hr = E_FAIL;
Expand Down Expand Up @@ -119,25 +141,7 @@ STDMETHODIMP EncodeMessageStream::Initialize(const std::shared_ptr<ByteStream>&

m_StreamInfo.cbContent = CMSG_INDEFINITE_LENGTH;
m_StreamInfo.pvArg = m_pChainedStream.get();
m_StreamInfo.pfnStreamOutput =
(PFN_CMSG_STREAM_OUTPUT)[](IN const void* pvArg, IN BYTE* pbData, IN DWORD cbData, IN BOOL fFinal)->BOOL
{

auto pStream = (ByteStream*)pvArg;

if (pStream == nullptr)
return FALSE;

ULONGLONG ullWritten = 0LL;
if (FAILED(pStream->Write(pbData, cbData, &ullWritten)))
return FALSE;

if (fFinal)
if (FAILED(pStream->Close()))
return FALSE;

return TRUE;
};
m_StreamInfo.pfnStreamOutput = ::StreamOutputCb;

m_hMsg = CryptMsgOpenToEncode(
X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, 0L, CMSG_ENVELOPED, &EncodeInfo, NULL, &m_StreamInfo);
Expand Down

0 comments on commit 3f0cc4f

Please sign in to comment.