本文整理汇总了C++中CContext::Init方法的典型用法代码示例。如果您正苦于以下问题:C++ CContext::Init方法的具体用法?C++ CContext::Init怎么用?C++ CContext::Init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CContext
的用法示例。
在下文中一共展示了CContext::Init方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void CHmac32::SetKey(const Byte *key, size_t keySize)
{
UInt32 keyTemp[kBlockSizeInWords];
size_t i;
for (i = 0; i < kBlockSizeInWords; i++)
keyTemp[i] = 0;
if(keySize > kBlockSize)
{
CContext sha;
sha.Init();
sha.Update(key, keySize);
Byte digest[kDigestSize];
sha.Final(digest);
for (int i = 0 ; i < kDigestSizeInWords; i++)
keyTemp[i] =
((UInt32)(digest[i * 4 + 0]) << 24) |
((UInt32)(digest[i * 4 + 1]) << 16) |
((UInt32)(digest[i * 4 + 2]) << 8) |
((UInt32)(digest[i * 4 + 3]));
keySize = kDigestSizeInWords;
}
else
for (size_t i = 0; i < keySize; i++)
keyTemp[i / 4] |= (key[i] << (24 - 8 * (i & 3)));
for (i = 0; i < kBlockSizeInWords; i++)
keyTemp[i] ^= 0x36363636;
_sha.Init();
_sha.Update(keyTemp, kBlockSizeInWords);
for (i = 0; i < kBlockSizeInWords; i++)
keyTemp[i] ^= 0x36363636 ^ 0x5C5C5C5C;
_sha2.Init();
_sha2.Update(keyTemp, kBlockSizeInWords);
}
示例2: HasAccess
STDMETHODIMP CPermissionChecker::HasAccess(
BSTR bstrLocalUrl,
VARIANT_BOOL *pfRetVal)
{
HRESULT rc = E_FAIL;
try
{
if (bstrLocalUrl == NULL || pfRetVal == NULL)
return ::ReportError(E_POINTER);
*pfRetVal = VARIANT_FALSE;
CContext cxt;
if ( cxt.Init( CContext::get_Server ) != S_OK )
{
return ::ReportError( E_NOINTERFACE );
}
// Map logical filename to a physical filesystem name
CComBSTR bstrPhysicalFile;
HRESULT hr = cxt.Server()->MapPath(bstrLocalUrl, &bstrPhysicalFile);
if (SUCCEEDED(hr))
*pfRetVal = ::DoesUserHaveAccessToFile(bstrPhysicalFile);
else // failed to map as URL, try as regular path
*pfRetVal = ::DoesUserHaveAccessToFile(bstrLocalUrl);
rc = S_OK;
}
catch( alloc_err& )
{
rc = E_OUTOFMEMORY;
}
catch( ... )
{
rc = E_FAIL;
}
return rc;
}
示例3: get_GetAdvertisement
STDMETHODIMP CAdRotator::get_GetAdvertisement(BSTR bstrVirtualPath, BSTR * pVal)
{
SCODE rc = E_FAIL;
try
{
USES_CONVERSION;
CContext cxt;
rc = cxt.Init( CContext::get_Server );
if ( !FAILED(rc) )
{
CComBSTR bstrPhysicalPath;
// determine the physical path
if ( ( rc = cxt.Server()->MapPath( bstrVirtualPath, &bstrPhysicalPath ) ) == S_OK )
{
_TCHAR* szPath = OLE2T( bstrPhysicalPath );
CAdFilePtr pAdFile = AdFile( szPath );
if ( pAdFile.IsValid() )
{
// refresh the ad file (make sure it's up to date)
pAdFile->Refresh();
// block all writers
CReader rdr( *pAdFile );
// if the border hasn't been set, use the default from the ad file
short nBorder;
if ( m_nBorder < 0 )
{
nBorder = pAdFile->Border();
}
else
{
nBorder = m_nBorder;
}
CAdDescPtr pAd = pAdFile->RandomAd();
if ( pAd.IsValid() )
{
// write out the HTML line for this ad
StringOutStream ss;
if ( m_bClickable && ( pAd->m_strLink.size() > 1 ) )
{
// use the href format
ss << _T("<A HREF=\"") << pAdFile->Redirector()
<< _T("?url=") << pAd->m_strLink
<< _T("&image=") << pAd->m_strGif
<< _T("\" ") << m_strTargetFrame << _T(">");
}
// now fill in the rest
ss << _T("<IMG SRC=\"") << pAd->m_strGif
<< _T("\" ALT=\"") << pAd->m_strAlt
<< _T("\" WIDTH=") << pAdFile->Width()
<< _T(" HEIGHT=") << pAdFile->Height();
if ( pAdFile->HSpace() != CAdFile::defaultHSpace )
{
ss << _T(" HSPACE=") << pAdFile->HSpace();
}
if ( pAdFile->VSpace() != CAdFile::defaultVSpace )
{
ss << _T(" VSPACE=") << pAdFile->VSpace();
}
ss << _T(" BORDER=") << nBorder << _T(">");
if ( m_bClickable && ( pAd->m_strLink.size() > 1 ) )
{
// put the trailing tag on
ss << _T("</A>");
}
String str = ss.toString();
if ( pVal )
{
if ( *pVal )
{
::SysFreeString( *pVal );
}
*pVal = T2BSTR( str.c_str() );
THROW_IF_NULL( *pVal );
rc = S_OK;
}
else
{
rc = E_POINTER;
}
}
}
}
}
else
{
_ASSERT(0);
//.........这里部分代码省略.........