本文整理汇总了C++中BAIL_ON_FAILURE函数的典型用法代码示例。如果您正苦于以下问题:C++ BAIL_ON_FAILURE函数的具体用法?C++ BAIL_ON_FAILURE怎么用?C++ BAIL_ON_FAILURE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了BAIL_ON_FAILURE函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BAIL_ON_FAILURE
//
// convert unicode string to cipher type
//
HRESULT
Wstr2CipherType
(
_In_ LPCWSTR pszSrc,
_Out_ PIHV_CIPHER_TYPE pCipherType
)
{
HRESULT hr = S_OK;
DWORD dwIndex = 0;
if ( (!pCipherType) || (!pszSrc) )
{
hr = E_INVALIDARG;
BAIL_ON_FAILURE( hr );
}
for ( dwIndex = 0; dwIndex < MAX_CIPHER_TYPES; dwIndex++ )
{
if ( 0 == wcscmp( gppszIhvCipherTypes[dwIndex], pszSrc ) )
{
(*pCipherType) = (IHV_CIPHER_TYPE) dwIndex;
BAIL( );
}
}
// String not found.
hr = E_INVALIDARG;
BAIL_ON_FAILURE( hr );
error:
return hr;
}
示例2: BAIL_ON_FAILURE
HRESULT
CIhvSecurityProfile::GetFullSecurityFlag
(
BOOL* pbUseFullSecurity
)
{
HRESULT hr = S_OK;
BSTR bstrData = NULL;
hr =
GetTextFromNode
(
SEC_FSFLAG_XPATH,
&bstrData
);
BAIL_ON_FAILURE( hr );
hr =
Wstr2Bool
(
bstrData,
pbUseFullSecurity
);
BAIL_ON_FAILURE( hr );
error:
SYS_FREE_STRING( bstrData );
return hr;
}
示例3: BAIL_ON_FAILURE
//
// convert unicode string to auth type
//
HRESULT
Wstr2AuthType
(
IN LPCWSTR pszSrc,
OUT PIHV_AUTH_TYPE pAuthType
)
{
HRESULT hr = S_OK;
DWORD dwIndex = 0;
if ( (!pAuthType) || (!pszSrc) )
{
hr = E_INVALIDARG;
BAIL_ON_FAILURE( hr );
}
for ( dwIndex = 0; dwIndex < MAX_AUTH_TYPES; dwIndex++ )
{
if ( 0 == wcscmp( gppszIhvAuthTypes[dwIndex], pszSrc ) )
{
(*pAuthType) = (IHV_AUTH_TYPE) dwIndex;
BAIL( );
}
}
// String not found.
hr = E_INVALIDARG;
BAIL_ON_FAILURE( hr );
error:
return hr;
}
示例4: BAIL_ON_FAILURE
HRESULT
CIhvConnectivityProfile::GetNativeData
(
LPVOID* ppvData
)
{
HRESULT hr = S_OK;
PIHV_CONNECTIVITY_PROFILE pIhvProfile = NULL;
BSTR bstrParam2 = NULL;
if ( !ppvData )
{
hr = E_INVALIDARG;
BAIL_ON_FAILURE( hr );
}
pIhvProfile = (PIHV_CONNECTIVITY_PROFILE) malloc( sizeof( IHV_CONNECTIVITY_PROFILE ) );
if ( !pIhvProfile )
{
hr = E_OUTOFMEMORY;
BAIL_ON_FAILURE( hr );
}
ZeroMemory( pIhvProfile, sizeof( IHV_CONNECTIVITY_PROFILE ) );
hr =
GetParamBSTR
(
&bstrParam2
);
BAIL_ON_FAILURE( hr );
hr =
Wstr2Wstr
(
bstrParam2,
&(pIhvProfile->pszParam2)
);
BAIL_ON_FAILURE( hr );
hr =
GetParamDWORD
(
&(pIhvProfile->dwParam1)
);
BAIL_ON_FAILURE( hr );
// Transfering local cache to OUT parameter.
(*ppvData) = pIhvProfile;
pIhvProfile = NULL;
error:
if ( pIhvProfile )
{
free( pIhvProfile->pszParam2 ); // NULL Safe.
free( pIhvProfile );
}
SYS_FREE_STRING( bstrParam2 );
return hr;
}
示例5: ASSERT
// base function to obtain text from
// node described by XPATH.
HRESULT
CIhvProfileBase::GetTextFromNode
(
IN LPCWSTR pszQuery,
OUT BSTR* pbstrText
)
{
HRESULT hr = S_OK;
BSTR bstrQuery = NULL;
IXMLDOMNode* pQueryNode = NULL;
ASSERT( pszQuery );
ASSERT( pbstrText );
// if node is NULL, return empty string.
if ( !m_pRootNode )
{
hr =
Wstr2Bstr
(
L"",
pbstrText
);
BAIL( );
}
hr =
Wstr2Bstr
(
pszQuery,
&bstrQuery
);
BAIL_ON_FAILURE( hr );
hr = m_pRootNode->selectSingleNode( bstrQuery, &pQueryNode );
BAIL_ON_FAILURE( hr );
if (!pQueryNode)
{
hr = E_UNEXPECTED;
BAIL_ON_FAILURE( hr );
}
hr = pQueryNode->get_text( pbstrText );
BAIL_ON_FAILURE( hr );
if ( !(*pbstrText) )
{
hr = E_UNEXPECTED;
BAIL_ON_FAILURE( hr );
}
error:
RELEASE_INTERFACE( pQueryNode );
SYS_FREE_STRING( bstrQuery );
return hr;
}
示例6: sizeof
DWORD
ConvertStringToKey
(
BYTE* pbKeyData,
DWORD* pdwKeyLen
)
{
DWORD dwResult = ERROR_SUCCESS;
HRESULT hr = S_OK;
CHAR szKey[ MAX_KEY_STRING_LENGTH + 2 ] = {0};
DWORD dwKeyStringLen = 0;
DWORD dwIndex = 0;
if
(
(!pbKeyData) ||
(!pdwKeyLen) ||
( 0 == (*pdwKeyLen) ) ||
( (*pdwKeyLen) % sizeof( WCHAR ) )
)
{
dwResult = ERROR_INVALID_PARAMETER;
BAIL_ON_WIN32_ERROR( dwResult );
}
dwKeyStringLen = (DWORD) wcslen( (LPWSTR) pbKeyData );
if ( MAX_KEY_STRING_LENGTH < dwKeyStringLen )
{
dwResult = ERROR_BAD_FORMAT;
BAIL_ON_WIN32_ERROR( dwResult );
}
// Converting the UNICODE string to
// ANSI string in scratch pad.
hr =
StringCchPrintfA
(
szKey,
MAX_KEY_STRING_LENGTH + 1,
"%S",
(WCHAR*) pbKeyData
);
BAIL_ON_FAILURE( hr );
ASSERT( dwKeyStringLen == (DWORD) strlen( szKey ));
if ( ( 5 == dwKeyStringLen ) || ( 13 == dwKeyStringLen ) )
{
// Copying the ANSI string back to original buffer.
hr =
StringCchPrintfA
(
(CHAR*) pbKeyData,
(*pdwKeyLen),
"%s",
szKey
);
BAIL_ON_FAILURE( hr );
// The strings are direct representations
// of the Wep Key and can be directly returned.
(*pdwKeyLen) = dwKeyStringLen;
TRACE_MESSAGE_VAL( "Received WEP key of length = ", (*pdwKeyLen) );
BAIL( );
}
if (( 10 != dwKeyStringLen ) && ( 26 != dwKeyStringLen ))
{
// Wrong length input
dwResult = ERROR_BAD_FORMAT;
BAIL_ON_WIN32_ERROR( dwResult );
}
for( dwIndex = 0; dwIndex < (dwKeyStringLen / 2); dwIndex++ )
{
dwResult =
ConvertHexCharToNibble
(
szKey[ 2 * dwIndex ],
TRUE,
&(pbKeyData[ dwIndex ])
);
BAIL_ON_WIN32_ERROR( dwResult );
dwResult =
ConvertHexCharToNibble
(
szKey[ 1 + (2 * dwIndex) ],
FALSE,
&(pbKeyData[ dwIndex ])
);
BAIL_ON_WIN32_ERROR( dwResult );
}
(*pdwKeyLen) = dwKeyStringLen / 2;
//.........这里部分代码省略.........
示例7: WlanHostedNetworkQuerySecondaryKey
HRESULT
CWlanManager::GetHostedNetworkKey(
CAtlString& strKey
)
{
HRESULT hr = S_OK;
DWORD dwError = ERROR_SUCCESS;
BOOL bIsPassPhrase = FALSE;
BOOL bPersistent = FALSE;
PUCHAR pucSecondaryKey = NULL;
DWORD dwSecondaryKeyLength = 0;
WCHAR strSecondaryKey[WLAN_MAX_NAME_LENGTH];
// get the user security key
dwError = WlanHostedNetworkQuerySecondaryKey(
m_WlanHandle,
&dwSecondaryKeyLength,
&pucSecondaryKey,
&bIsPassPhrase,
&bPersistent,
NULL,
NULL
);
BAIL_ON_WIN32_ERROR(dwError, hr);
int cchKey = 0;
if (dwSecondaryKeyLength > 0)
{
// Must be passphrase
_ASSERT(bIsPassPhrase);
// convert the key
if (bIsPassPhrase)
{
#pragma prefast(suppress:26035, "If the key is a pass phrase, it is guaranteed to be null-terminated.")
cchKey = MultiByteToWideChar(
CP_ACP,
MB_ERR_INVALID_CHARS,
(LPCSTR)pucSecondaryKey,
dwSecondaryKeyLength,
strSecondaryKey,
sizeof(strSecondaryKey) / sizeof(strSecondaryKey[0]) -1
);
}
}
if(cchKey == 0)
{
// secondary key is not set or not passphrase
// set a temporary one
CAtlString strTmpKey = L"HostedNetwork12345";
hr = SetHostedNetworkKey(strTmpKey);
BAIL_ON_FAILURE(hr);
strKey = strTmpKey;
}
else
{
// got the key
strKey = strSecondaryKey;
}
error:
if (pucSecondaryKey != NULL)
{
WlanFreeMemory(pucSecondaryKey);
pucSecondaryKey = NULL;
}
return hr;
}
示例8: GetDefaultXml
HRESULT
CIhvProfileBase::LoadXml
(
IN BSTR bstrProfileData
)
{
HRESULT hr = S_OK;
IXMLDOMDocument* pDOMDoc = NULL;
IXMLDOMElement* pDocElem = NULL;
BSTR bstrIhvProfile = NULL;
VARIANT_BOOL vfSuccess;
if ( !bstrProfileData )
{
hr = GetDefaultXml( &bstrIhvProfile );
BAIL_ON_FAILURE( hr );
}
else
{
bstrIhvProfile = bstrProfileData;
}
if ( m_pRootNode )
{
hr = E_UNEXPECTED;
BAIL_ON_FAILURE( hr );
}
hr =
CoCreateInstance
(
CLSID_DOMDocument,
NULL,
CLSCTX_ALL,
IID_IXMLDOMDocument,
(LPVOID *) &pDOMDoc
);
BAIL_ON_FAILURE( hr );
hr =
pDOMDoc->loadXML
(
bstrIhvProfile,
&vfSuccess
);
BAIL_ON_FAILURE( hr );
if ( VARIANT_TRUE != vfSuccess )
{
hr = E_UNEXPECTED;
BAIL_ON_FAILURE( hr );
}
hr =
pDOMDoc->get_documentElement
(
&pDocElem
);
BAIL_ON_FAILURE( hr );
// Caching the pointer to the document element
// in a member variable.
m_pRootNode = pDocElem;
pDocElem = NULL;
error:
if ( !bstrProfileData )
{
SYS_FREE_STRING( bstrIhvProfile );
}
RELEASE_INTERFACE( pDOMDoc );
RELEASE_INTERFACE( pDocElem );
return hr;
}