Ejemplo n.º 1
0
HRESULT KComMD5::GetMD5String( 
	void*          pBuffer, 
	int            nBufSize, 
	char*          pszMD5String, 
	int            nSize 
	)
{
	if( nSize < 33 )          // 32 bytes md5 characters and 1 byte '\0'
		return E_INVALIDARG;

	if( pBuffer == NULL || pszMD5String == NULL )
		return E_INVALIDARG;


	const int nMD5Size = 16;
	unsigned char md5[nMD5Size] = {0};
	HRESULT hr = GetMD5Code( pBuffer, nBufSize, md5 );
	if( FAILED( hr ) )
		return hr;


	hr = Bin2Str( md5, nMD5Size, pszMD5String, nSize );

	return hr;
}
Ejemplo n.º 2
0
bool CHelpDB::NewItem(CTSTRING& _sAlias, CTSTRING& sText, CTSTRING& sCreator)
{
    MSXML::IXMLDOMElementPtr El;
    bool r = false;
    if(m_doc == 0) return false;
    TSTRING sAlias;

    {
        TCHAR* tsz = _tcsdup(_sAlias.c_str());
        _tcsupr(tsz);
        sAlias = tsz;
        SAFE_FREE(tsz);
    }

    // Just determine if it exists.
    if(GetItemElement(sAlias, El, false))
    {
        // it already exists; fail.
        sprintf(m_err, _T("%s already exists.  If you want to change the existing entry, use !msgchange."), sAlias.c_str());
        g_pLog->msg(_T("%s"), m_err.c_str());
    }
    else
    {
        // doesn't already exist... we're golden like the shower.  This time
        // just call GetItemElement() with bCreate set to true.
        if(!GetItemElement(sAlias, El, true))
        {
            sprintf(m_err, _T("%s could not be added."), sAlias.c_str());
            g_pLog->msg(_T("%s"), m_err.c_str());
        }
        else
        {
            El->setAttribute(TAG_ALIAS, sAlias.c_str());
            El->setAttribute(TAG_CREATOR, sCreator.c_str());
            El->setAttribute(TAG_TEXT, sText.c_str());
            El->setAttribute(TAG_USAGE, _T("0"));
            SYSTEMTIME st;
            TSTRING sTime;
            GetLocalTime(&st);
            Bin2Str(sTime, (BYTE*)&st, sizeof(st));
            El->setAttribute(TAG_TIME, sTime.c_str());

            g_pLog->msg(_T("New db item: %s = %s"), _sAlias.c_str(), sText.c_str());

            r = true;
        }
    }

    return r;
}
Ejemplo n.º 3
0
HRESULT KComMD5::GetFileMD5String( 
	LPCTSTR        pszFilePath, 
	char*          pszMD5String, 
	int            nSize 
	)
{
	if( nSize < 33 )          // 32 bytes md5 characters and 1 byte '\0'
		return E_INVALIDARG;

	if( pszFilePath == NULL || pszFilePath[0] == 0 || pszMD5String == NULL )
		return E_INVALIDARG;


	const int nMD5Size = 16;
	unsigned char md5[nMD5Size] = {0};
	HRESULT hr = GetFileMD5Code( pszFilePath, md5 );
	if( FAILED( hr ) )
		return hr;


	hr = Bin2Str( md5, nMD5Size, pszMD5String, nSize );

	return hr;
}
Ejemplo n.º 4
0
string Bin2Str(const string &sourceStr)
{
	return Bin2Str(sourceStr.data(),sourceStr.size());
}
Ejemplo n.º 5
0
string Bin2Str(const ByteBuffer &sourceBuf)
{
	return Bin2Str((const byte*)sourceBuf.contents(),sourceBuf.size());
}
Ejemplo n.º 6
0
string Bin2Str(const char *data,size_t count)
{
	return Bin2Str((const byte*)data,count);
}