Revision: 14447
http://xbmc.svn.sourceforge.net/xbmc/?rev=14447&view=rev
Author: yuvalt
Date: 2008-07-25 22:20:59 +0000 (Fri, 25 Jul 2008)
Log Message:
-----------
fix: md5 was giving link errors due to conflict with libgoahead. Wrapped
MD5 with class and fixed all callers.
Modified Paths:
--------------
branches/linuxport/XBMC/xbmc/GUIDialogGamepad.cpp
branches/linuxport/XBMC/xbmc/GUIDialogKeyboard.cpp
branches/linuxport/XBMC/xbmc/GUIDialogNumeric.cpp
branches/linuxport/XBMC/xbmc/LastFmManager.cpp
branches/linuxport/XBMC/xbmc/MusicInfoScanner.cpp
branches/linuxport/XBMC/xbmc/VideoInfoScanner.cpp
branches/linuxport/XBMC/xbmc/lib/libscrobbler/scrobbler.cpp
branches/linuxport/XBMC/xbmc/utils/Makefile
branches/linuxport/XBMC/xbmc/utils/md5.h
Added Paths:
-----------
branches/linuxport/XBMC/xbmc/utils/md5.cpp
Modified: branches/linuxport/XBMC/xbmc/GUIDialogGamepad.cpp
===================================================================
--- branches/linuxport/XBMC/xbmc/GUIDialogGamepad.cpp 2008-07-25 21:43:59 UTC (rev 14446)
+++ branches/linuxport/XBMC/xbmc/GUIDialogGamepad.cpp 2008-07-25 22:20:59 UTC (rev 14447)
@@ -86,12 +86,12 @@
m_bConfirmed = false;
m_bCanceled = false;
- MD5_CTX md5state;
unsigned char md5pword[16];
char md5pword2[33];
- MD5Init(&md5state);
- MD5Update(&md5state, (unsigned char *)m_strUserInput.c_str(), (int)m_strUserInput.size());
- MD5Final(md5pword, &md5state);
+ XBMC::MD5 md5state;
+ md5state.append(m_strUserInput);
+ md5state.getDigest(md5pword);
+
XKGeneral::BytesToHexStr(md5pword,16,md5pword2);
if (!m_strPassword.Equals(md5pword2))
@@ -284,12 +284,11 @@
if (bGetUserInput && !pDialog->IsCanceled())
{
- MD5_CTX md5state;
unsigned char md5pword[16];
char md5pword2[33];
- MD5Init(&md5state);
- MD5Update(&md5state, (unsigned char *)pDialog->m_strUserInput.c_str(), (int)pDialog->m_strUserInput.size());
- MD5Final(md5pword, &md5state);
+ XBMC::MD5 md5state;
+ md5state.append(pDialog->m_strUserInput);
+ md5state.getDigest(md5pword);
XKGeneral::BytesToHexStr(md5pword,16,md5pword2);
strToVerify = md5pword2;
strToVerify.ToLower();
Modified: branches/linuxport/XBMC/xbmc/GUIDialogKeyboard.cpp
===================================================================
--- branches/linuxport/XBMC/xbmc/GUIDialogKeyboard.cpp 2008-07-25 21:43:59 UTC (rev 14446)
+++ branches/linuxport/XBMC/xbmc/GUIDialogKeyboard.cpp 2008-07-25 22:20:59 UTC (rev 14447)
@@ -588,12 +588,11 @@
// check the password
if (checkInput == userInput)
{
- MD5_CTX md5state;
unsigned char md5pword[16];
char md5pword2[33];
- MD5Init(&md5state);
- MD5Update(&md5state, (unsigned char *)userInput.c_str(), (int)userInput.size());
- MD5Final(md5pword, &md5state);
+ XBMC::MD5 md5state;
+ md5state.append(userInput.c_str());
+ md5state.getDigest(md5pword);
XKGeneral::BytesToHexStr(md5pword,16,md5pword2);
newPassword = md5pword2;
newPassword.ToLower();
@@ -634,12 +633,11 @@
if (strPassword == strUserInput)
return 0;
- MD5_CTX md5state;
unsigned char md5pword[16];
char md5pword2[33];
- MD5Init(&md5state);
- MD5Update(&md5state, (unsigned char *)strUserInput.c_str(), (int)strUserInput.size());
- MD5Final(md5pword, &md5state);
+ XBMC::MD5 md5state;
+ md5state.append(strUserInput.c_str());
+ md5state.getDigest(md5pword);
XKGeneral::BytesToHexStr(md5pword, 16, md5pword2);
if (strPassword.Equals(md5pword2))
return 0; // user entered correct password
@@ -649,12 +647,11 @@
{
if (!strUserInput.IsEmpty())
{
- MD5_CTX md5state;
unsigned char md5pword[16];
char md5pword2[33];
- MD5Init(&md5state);
- MD5Update(&md5state, (unsigned char *)strUserInput.c_str(), (int)strUserInput.size());
- MD5Final(md5pword, &md5state);
+ XBMC::MD5 md5state;
+ md5state.append(strUserInput.c_str());
+ md5state.getDigest(md5pword);
XKGeneral::BytesToHexStr(md5pword, 16, md5pword2);
strPassword = md5pword2;
Modified: branches/linuxport/XBMC/xbmc/GUIDialogNumeric.cpp
===================================================================
--- branches/linuxport/XBMC/xbmc/GUIDialogNumeric.cpp 2008-07-25 21:43:59 UTC (rev 14446)
+++ branches/linuxport/XBMC/xbmc/GUIDialogNumeric.cpp 2008-07-25 22:20:59 UTC (rev 14447)
@@ -680,12 +680,11 @@
return false;
}
- MD5_CTX md5state;
unsigned char md5pword[16];
char md5pword2[33];
- MD5Init(&md5state);
- MD5Update(&md5state, (unsigned char *)strInput.c_str(), (int)strInput.size());
- MD5Final(md5pword, &md5state);
+ XBMC::MD5 md5state;
+ md5state.append(strInput.c_str());
+ md5state.getDigest(md5pword);
XKGeneral::BytesToHexStr(md5pword, 16, md5pword2);
if (!bVerifyInput)
Modified: branches/linuxport/XBMC/xbmc/LastFmManager.cpp
===================================================================
--- branches/linuxport/XBMC/xbmc/LastFmManager.cpp 2008-07-25 21:43:59 UTC (rev 14446)
+++ branches/linuxport/XBMC/xbmc/LastFmManager.cpp 2008-07-25 22:20:59 UTC (rev 14447)
@@ -229,7 +229,7 @@
CStdString url;
CStdString html;
url.Format("http://" + m_RadioBaseUrl + m_RadioBasePath + "/adjust.php?session=%s&url=%s&debug=%i", m_RadioSession, strUrl, 0);
- if (!http.Get(url, html))
+ if (!http.Get(url, html))
{
CLog::Log(LOGERROR, "Connect to Last.fm to change station failed.");
CloseProgressDialog();
@@ -280,7 +280,7 @@
url.Format("http://" + m_RadioBaseUrl + m_RadioBasePath + "/xspf.php?sk=%s&discovery=0&desktop=", m_RadioSession);
{
CHTTP http;
- if (!http.Get(url, html))
+ if (!http.Get(url, html))
{
m_RadioSession.empty();
CLog::Log(LOGERROR, "LastFmManager: Connect to Last.fm to request tracks failed.");
@@ -367,7 +367,7 @@
newItem->GetMusicInfoTag()->SetAlbum(child->Value());
}
}
-
+
pElement = pTrackElement->FirstChildElement("duration");
if (pElement)
{
@@ -472,7 +472,7 @@
CSingleLock lock2(m_lockPlaylist);
playlist.Add(item);
}
- else
+ else
{
break;
}
@@ -496,7 +496,7 @@
MovePlaying();
Update();
SendUpdateMessage();
-
+
CLog::Log(LOGDEBUG, "%s: Done (time: %i ms)", __FUNCTION__, (int)(timeGetTime() - start));
}
}
@@ -609,7 +609,7 @@
void CLastFmManager::StopRadio(bool bKillSession /*= true*/)
{
- if (bKillSession)
+ if (bKillSession)
{
m_RadioSession = "";
g_playlistPlayer.SetRepeat(PLAYLIST_MUSIC, m_LastRepeatState);
@@ -635,20 +635,19 @@
}
}
}
-
+
SendUpdateMessage();
}
void CLastFmManager::CreateMD5Hash(const CStdString& bufferToHash, CStdString& hash)
{
- MD5_CTX md5state;
unsigned char md5pword[16];
- MD5Init(&md5state);
- MD5Update(&md5state, (unsigned char *)bufferToHash.c_str(), (int)bufferToHash.size());
- MD5Final(md5pword, &md5state);
+ XBMC::MD5 md5state;
+ md5state.append(bufferToHash);
+ md5state.getDigest(md5pword);
char tmp[33];
strncpy(tmp, "\0", sizeof(tmp));
- for (int j = 0;j < 16;j++)
+ for (int j = 0;j < 16;j++)
{
char a[3];
sprintf(a, "%02x", md5pword[j]);
@@ -690,7 +689,7 @@
CLog::Log(LOGERROR, "Last.fm CallXmlRpc no tracktitle provided.");
return false;
}
-
+
char ti[20];
time_t rawtime;
time ( &rawtime );
@@ -806,7 +805,7 @@
g_application.m_guiDialogKaiToast.QueueNotification("", g_localizeStrings.Get(15200), strMessage, 7000);
return true;
}
- else
+ else
{
strMessage.Format(g_localizeStrings.Get(15290), strTitle);
g_application.m_guiDialogKaiToast.QueueNotification("", g_localizeStrings.Get(15200), strMessage, 7000);
@@ -839,7 +838,7 @@
g_application.m_guiDialogKaiToast.QueueNotification("", g_localizeStrings.Get(15200), strMessage, 7000);
return true;
}
- else
+ else
{
strMessage.Format(g_localizeStrings.Get(15292), strTitle);
g_application.m_guiDialogKaiToast.QueueNotification("", g_localizeStrings.Get(15200), strMessage, 7000);
@@ -858,10 +857,10 @@
CLog::Log(LOGERROR, "LastFmManager Love, lastfm is not enabled.");
return false;
}
-
+
CStdString strTitle = musicinfotag.GetTitle();
CStdString strArtist = musicinfotag.GetArtist();
-
+
CStdString strFilePath;
if (m_CurrentSong.CurrentSong && !m_CurrentSong.CurrentSong->IsLastFM())
{
@@ -899,7 +898,7 @@
CLog::Log(LOGERROR, "LastFmManager Ban, radio is not active");
return false;
}
-
+
if (CallXmlRpc("banTrack", musicinfotag.GetArtist(), musicinfotag.GetTitle()))
{
//we banned this track so skip to the next track
@@ -972,7 +971,7 @@
CLog::Log(LOGERROR, "LastFmManager Unban, lasfm is not enabled");
return false;
}
-
+
CStdString strTitle = musicinfotag.GetTitle();
CStdString strArtist = musicinfotag.GetArtist();
@@ -999,7 +998,7 @@
bool CLastFmManager::IsLastFmEnabled()
{
return (
- !g_guiSettings.GetString("lastfm.username").IsEmpty() &&
+ !g_guiSettings.GetString("lastfm.username").IsEmpty() &&
!g_guiSettings.GetString("lastfm.password").IsEmpty()
);
}
@@ -1010,11 +1009,11 @@
m_CurrentSong.CurrentSong &&
!m_CurrentSong.IsLoved &&
IsLastFmEnabled() &&
- (m_CurrentSong.CurrentSong->IsLastFM() ||
+ (m_CurrentSong.CurrentSong->IsLastFM() ||
(
- m_CurrentSong.CurrentSong->HasMusicInfoTag() &&
+ m_CurrentSong.CurrentSong->HasMusicInfoTag() &&
m_CurrentSong.CurrentSong->GetMusicInfoTag()->Loaded() &&
- !m_CurrentSong.CurrentSong->GetMusicInfoTag()->GetArtist().IsEmpty() &&
+ !m_CurrentSong.CurrentSong->GetMusicInfoTag()->GetArtist().IsEmpty() &&
!m_CurrentSong.CurrentSong->GetMusicInfoTag()->GetTitle().IsEmpty()
))
);
@@ -1028,7 +1027,7 @@
bool CLastFmManager::CanScrobble(const CFileItem &fileitem)
{
return (
- (!fileitem.IsInternetStream() && g_guiSettings.GetBool("lastfm.enable")) ||
+ (!fileitem.IsInternetStream() && g_guiSettings.GetBool("lastfm.enable")) ||
(fileitem.IsLastFM() && g_guiSettings.GetBool("lastfm.recordtoprofile"))
);
}
Modified: branches/linuxport/XBMC/xbmc/MusicInfoScanner.cpp
===================================================================
--- branches/linuxport/XBMC/xbmc/MusicInfoScanner.cpp 2008-07-25 21:43:59 UTC (rev 14446)
+++ branches/linuxport/XBMC/xbmc/MusicInfoScanner.cpp 2008-07-25 22:20:59 UTC (rev 14447)
@@ -161,10 +161,10 @@
m_pObserver->OnDirectoryChanged(it->strArtist+" - "+it->strAlbum);
m_pObserver->OnSetProgress(iCurrentItem++, m_albumsToScan.size());
}
-
+
CMusicAlbumInfo albumInfo;
bool bCanceled;
- DownloadAlbumInfo(it->strGenre,it->strArtist,it->strAlbum, bCanceled, albumInfo); // genre field holds path - see fetchalbuminfo()
+ DownloadAlbumInfo(it->strGenre,it->strArtist,it->strAlbum, bCanceled, albumInfo); // genre field holds path - see fetchalbuminfo()
if (m_bStop)
break;
@@ -230,7 +230,7 @@
CFileItemList items;
if (strDirectory.IsEmpty())
- {
+ {
m_musicDatabase.Open();
m_musicDatabase.GetAlbumsNav("musicdb://3/",items,-1,-1);
m_musicDatabase.Close();
@@ -245,7 +245,7 @@
items.Add(item);
}
}
-
+
for (int i=0;i<items.Size();++i)
{
if (CMusicDatabaseDirectory::IsAllItem(items[i]->m_strPath) || items[i]->IsParentFolder())
@@ -271,7 +271,7 @@
CFileItemList items;
if (strDirectory.IsEmpty())
- {
+ {
m_musicDatabase.Open();
m_musicDatabase.GetArtistsNav("musicdb://2/",items,-1,false);
m_musicDatabase.Close();
@@ -493,7 +493,7 @@
long iAlbum = m_musicDatabase.GetAlbumByName(song.strAlbum,song.strArtist);
CStdString strPath;
strPath.Format("musicdb://3/%u/",iAlbum);
-
+
CMusicAlbumInfo albumInfo;
bool bCanceled;
if (find(m_albumsScanned.begin(),m_albumsScanned.end(),iAlbum) == m_albumsScanned.end())
@@ -706,22 +706,21 @@
{
// Create a hash based on the filenames, filesize and filedate. Also count the number of files
if (0 == items.Size()) return 0;
- MD5_CTX md5state;
unsigned char md5hash[16];
char md5HexString[33];
- MD5Init(&md5state);
+ XBMC::MD5 md5state;
int count = 0;
for (int i = 0; i < items.Size(); ++i)
{
const CFileItemPtr pItem = items[i];
- MD5Update(&md5state, (unsigned char *)pItem->m_strPath.c_str(), (int)pItem->m_strPath.size());
- MD5Update(&md5state, (unsigned char *)&pItem->m_dwSize, sizeof(pItem->m_dwSize));
+ md5state.append(pItem->m_strPath);
+ md5state.append((unsigned char *)&pItem->m_dwSize, sizeof(pItem->m_dwSize));
FILETIME time = pItem->m_dateTime;
- MD5Update(&md5state, (unsigned char *)&time, sizeof(FILETIME));
+ md5state.append((unsigned char *)&time, sizeof(FILETIME));
if (pItem->IsAudio() && !pItem->IsPlayList() && !pItem->IsNFO())
count++;
}
- MD5Final(md5hash, &md5state);
+ md5state.getDigest(md5hash);
XKGeneral::BytesToHexStr(md5hash, 16, md5HexString);
hash = md5HexString;
return count;
@@ -778,7 +777,7 @@
}
else
{
- CScraperUrl scrUrl(nfoReader.m_strImDbUrl);
+ CScraperUrl scrUrl(nfoReader.m_strImDbUrl);
CMusicAlbumInfo album("nfo",scrUrl);
scraper.GetAlbums().push_back(album);
}
@@ -851,7 +850,7 @@
if (relevance < THRESHOLD)
{
m_musicDatabase.Close();
- return false;
+ return false;
}
}
@@ -862,9 +861,9 @@
pDlg->DoModal();
// and wait till user selects one
- if (pDlg->GetSelectedLabel() < 0)
+ if (pDlg->GetSelectedLabel() < 0)
{ // none chosen
- if (!pDlg->IsButtonPressed())
+ if (!pDlg->IsButtonPressed())
{
bCanceled = true;
return false;
@@ -952,7 +951,7 @@
if (m_pObserver)
{
m_pObserver->OnStateChanged(DOWNLOADING_ARTIST_INFO);
- m_pObserver->OnDirectoryChanged(strArtist);
+ m_pObserver->OnDirectoryChanged(strArtist);
}
CMusicInfoScraper scraper(info);
@@ -977,7 +976,7 @@
}
else
{
- CScraperUrl scrUrl(nfoReader.m_strImDbUrl);
+ CScraperUrl scrUrl(nfoReader.m_strImDbUrl);
CMusicArtistInfo artist("nfo",scrUrl);
scraper.GetArtists().push_back(artist);
}
@@ -1030,7 +1029,7 @@
pDlg->DoModal();
// and wait till user selects one
- if (pDlg->GetSelectedLabel() < 0)
+ if (pDlg->GetSelectedLabel() < 0)
{ // none chosen
if (!pDlg->IsButtonPressed()) return false;
// manual button pressed
@@ -1048,7 +1047,7 @@
iSelectedArtist = pDlg->GetSelectedItem().m_idepth;
}
}
-
+
scraper.LoadArtistinfo(iSelectedArtist);
while (!scraper.Completed())
@@ -1081,7 +1080,7 @@
if (!XFILE::CFile::Exists(thumb))
CScraperUrl::DownloadThumbnail(thumb,artist.thumbURL.m_url[0]);
}
-
+
m_musicDatabase.Close();
return true;
}
Modified: branches/linuxport/XBMC/xbmc/VideoInfoScanner.cpp
===================================================================
--- branches/linuxport/XBMC/xbmc/VideoInfoScanner.cpp 2008-07-25 21:43:59 UTC (rev 14446)
+++ branches/linuxport/XBMC/xbmc/VideoInfoScanner.cpp 2008-07-25 22:20:59 UTC (rev 14447)
@@ -42,7 +42,7 @@
using namespace DIRECTORY;
using namespace XFILE;
-namespace VIDEO
+namespace VIDEO
{
CVideoInfoScanner::CVideoInfoScanner()
@@ -80,7 +80,7 @@
// Create the thread to count all files to be scanned
SetPriority(THREAD_PRIORITY_IDLE);
- CThread fileCountReader(this);
+ CThread fileCountReader(this);
if (m_pObserver)
fileCountReader.Create();
@@ -297,7 +297,7 @@
bSkip = true;
}
}
-
+
if (!m_info.settings.GetPluginRoot() && m_info.settings.GetSettings().IsEmpty()) // check for settings, if they are around load defaults - to workaround the nastyness
{
CScraperParser parser;
@@ -354,7 +354,7 @@
CIMDB IMDB;
IMDB.SetScraperInfo(info);
CRegExp regExSample;
-
+
if (!regExSample.RegComp(REGEXSAMPLEFILE))
{
CLog::Log(LOGERROR, "Unable to compile RegExp for Sample file");
@@ -413,7 +413,7 @@
// Discard all possible sample files defined by regExSample
if (regExSample.RegFind(CUtil::GetFileName(pItem->m_strPath)) > -1)
continue;
-
+
if (info2.strContent.Equals("movies") || info2.strContent.Equals("musicvideos"))
{
if (m_pObserver)
@@ -524,7 +524,7 @@
pDlgProgress->SetLine(0, pItem->GetLabel());
pDlgProgress->SetLine(2,"");
pDlgProgress->Progress();
- if (pDlgProgress->IsCanceled())
+ if (pDlgProgress->IsCanceled())
{
pDlgProgress->Close();
m_database.RollbackTransaction();
@@ -676,7 +676,7 @@
{
CFileItemList items;
CRegExp regExSample;
-
+
if (!regExSample.RegComp(REGEXSAMPLEFILE))
{
CLog::Log(LOGERROR, "Unable to compile RegExp for Sample file");
@@ -770,9 +770,9 @@
char *remainder = reg.GetReplaceString("\\3");
int offset = 0;
-
+
// we want "long circuit" OR below so that both offsets are evaluated
- while (((regexp2pos = reg2.RegFind(remainder + offset)) > -1) | ((regexppos = reg.RegFind(remainder + offset)) > -1))
+ while (((regexp2pos = reg2.RegFind(remainder + offset)) > -1) | ((regexppos = reg.RegFind(remainder + offset)) > -1))
{
if (((regexppos <= regexp2pos) && regexppos != -1) ||
(regexppos >= 0 && regexp2pos == -1))
@@ -787,7 +787,7 @@
episodeList.push_back(myEpisode);
remainder = reg.GetReplaceString("\\3");
offset = 0;
- }
+ }
else if (((regexp2pos < regexppos) && regexp2pos != -1) ||
(regexp2pos >= 0 && regexppos == -1))
{
@@ -1083,7 +1083,7 @@
return items[numNFO]->m_strPath;
}
}
-
+
return nfoFile;
}
@@ -1148,22 +1148,21 @@
{
// Create a hash based on the filenames, filesize and filedate. Also count the number of files
if (0 == items.Size()) return 0;
- MD5_CTX md5state;
unsigned char md5hash[16];
char md5HexString[33];
- MD5Init(&md5state);
+ XBMC::MD5 md5state;
int count = 0;
for (int i = 0; i < items.Size(); ++i)
{
const CFileItemPtr pItem = items[i];
- MD5Update(&md5state, (unsigned char *)pItem->m_strPath.c_str(), (int)pItem->m_strPath.size());
- MD5Update(&md5state, (unsigned char *)&pItem->m_dwSize, sizeof(pItem->m_dwSize));
+ md5state.append(pItem->m_strPath);
+ md5state.append((unsigned char *)&pItem->m_dwSize, sizeof(pItem->m_dwSize));
FILETIME time = pItem->m_dateTime;
- MD5Update(&md5state, (unsigned char *)&time, sizeof(FILETIME));
+ md5state.append((unsigned char *)&time, sizeof(FILETIME));
if (pItem->IsVideo() && !pItem->IsPlayList() && !pItem->IsNFO())
count++;
}
- MD5Final(md5hash, &md5state);
+ md5state.getDigest(md5hash);
XKGeneral::BytesToHexStr(md5hash, 16, md5HexString);
hash = md5HexString;
return count;
@@ -1243,7 +1242,7 @@
nfoReader.GetDetails(movieDetails);
if (m_pObserver)
m_pObserver->OnSetTitle(movieDetails.m_strTitle);
-
+
AddMovieAndGetThumb(pItem, info.strContent, movieDetails, -1, bGrabAny, pDlgProgress);
if (info.strContent.Equals("tvshows"))
{
Modified: branches/linuxport/XBMC/xbmc/lib/libscrobbler/scrobbler.cpp
===================================================================
--- branches/linuxport/XBMC/xbmc/lib/libscrobbler/scrobbler.cpp 2008-07-25 21:43:59 UTC (rev 14446)
+++ branches/linuxport/XBMC/xbmc/lib/libscrobbler/scrobbler.cpp 2008-07-25 22:20:59 UTC (rev 14447)
@@ -15,7 +15,7 @@
along with libscrobbler; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- Copyright \xA9 2003 Russell Garrett (russ-scrobbler@...)
+ Copyright � 2003 Russell Garrett (russ-scrobbler@...)
*/
#include "stdafx.h"
#include "scrobbler.h"
@@ -53,7 +53,7 @@
m_bAuthWarningDone=false;
m_bBadPassWarningDone=false;
m_bReHandShaking=false;
- m_strClientId = CLIENT_ID;
+ m_strClientId = CLIENT_ID;
m_strClientVer = CLIENT_VERSION;
m_bCloseThread = false;
m_Interval = m_LastConnect = m_SongStartTime = 0;
@@ -139,14 +139,13 @@
{
if (strPass.IsEmpty())
return;
- MD5_CTX md5state;
+ XBMC::MD5 md5state;
unsigned char md5pword[16];
- MD5Init(&md5state);
- MD5Update(&md5state, (unsigned char *)strPass.c_str(), (int)strPass.size());
- MD5Final(md5pword, &md5state);
+ md5state.append(strPass);
+ md5state.getDigest(md5pword);
char tmp[33];
strncpy(tmp, "\0", sizeof(tmp));
- for (int j = 0;j < 16;j++)
+ for (int j = 0;j < 16;j++)
{
char a[3];
sprintf(a, "%02x", md5pword[j]);
@@ -238,12 +237,12 @@
time_t now;
time (&now);
- if ((m_Interval + m_LastConnect) < now)
+ if ((m_Interval + m_LastConnect) < now)
{
DoSubmit();
return 1;
- }
- else
+ }
+ else
{
CStdString strMsg;
strMsg.Format("Not submitting, caching for %i more seconds. Cache is %i entries.", (int)(m_Interval + m_LastConnect - now), m_iSongNum);
@@ -255,7 +254,7 @@
void CScrobbler::DoHandshake()
{
m_bReadyToSubmit = false;
- time_t now;
+ time_t now;
time (&now);
m_LastConnect = now;
m_strHsString = "http://post.audioscrobbler.com/?hs=true&p=1.1&c=" + m_strClientId + "&v=" + m_strClientVer + "&u=" + m_strUserName;
@@ -289,22 +288,22 @@
// Doesn't take into account multiple-packet returns (not that I've seen one yet)...
// Ian says: strtok() is not re-entrant, but since it's only being called
- // in only one function at a time, it's ok so far.
+ // in only one function at a time, it's ok so far.
char seps[] = " \n\r";
char *response = strtok(handshake, seps);
- if (!response)
+ if (!response)
{
StatusUpdate(S_HANDSHAKE_INVALID_RESPONSE,"Handshake failed: Response invalid");
return;
}
- do
+ do
{
- if (stricmp("UPTODATE", response) == 0)
+ if (stricmp("UPTODATE", response) == 0)
{
StatusUpdate(S_HANDSHAKE_UP_TO_DATE,"Handshaking: Client up to date.");
- }
- else if (stricmp("UPDATE", response) == 0)
+ }
+ else if (stricmp("UPDATE", response) == 0)
{
char *updateurl = strtok(NULL, seps);
if (!updateurl)
@@ -312,13 +311,13 @@
string msg = "Handshaking: Please update your client at: ";
msg += updateurl;
StatusUpdate(S_HANDSHAKE_OLD_CLIENT,msg.c_str());
- }
- else if (stricmp("BADUSER", response) == 0)
+ }
+ else if (stricmp("BADUSER", response) == 0)
{
StatusUpdate(S_HANDSHAKE_BAD_USERNAME,"Handshake failed: Bad username");
return;
- }
- else
+ }
+ else
{
break;
}
@@ -340,7 +339,7 @@
void CScrobbler::HandleSubmit(char *data)
{
- // submit returned
+ // submit returned
m_bSubmitInProgress = false; //- this should already have been cancelled by the header callback
StatusUpdate(S_DEBUG,data);
@@ -348,12 +347,12 @@
// Doesn't take into account multiple-packet returns (not that I've seen one yet)...
char seps[] = " \n\r";
char * response = strtok(data, seps);
- if (!response)
+ if (!response)
{
StatusUpdate(S_SUBMIT_INVALID_RESPONSE,"Submission failed: Response invalid");
return;
}
- if (stricmp("OK", response) == 0)
+ if (stricmp("OK", response) == 0)
{
StatusUpdate(S_SUBMIT_SUCCESS,"Submission succeeded.");
@@ -361,36 +360,36 @@
ClearCache();
char *inttext = strtok(NULL, seps);
- if (inttext && (stricmp("INTERVAL", inttext) == 0))
+ if (inttext && (stricmp("INTERVAL", inttext) == 0))
{
m_Interval = atoi(strtok(NULL, seps));
CStdString strBuf;
strBuf.Format("Submit interval set to %i seconds.", m_Interval);
StatusUpdate(S_SUBMIT_INTERVAL, strBuf);
}
- }
- else if (stricmp("BADPASS", response) == 0)
+ }
+ else if (stricmp("BADPASS", response) == 0)
{
StatusUpdate(S_SUBMIT_BAD_PASSWORD,"Submission failed: bad password.");
- }
- else if (stricmp("FAILED", response) == 0)
+ }
+ else if (stricmp("FAILED", response) == 0)
{
CStdString strBuf;
strBuf.Format("Submission failed: %s", strtok(NULL, "\n"));
StatusUpdate(S_SUBMIT_FAILED, strBuf);
char *inttext = strtok(NULL, seps);
- if (inttext && (stricmp("INTERVAL", inttext) == 0))
+ if (inttext && (stricmp("INTERVAL", inttext) == 0))
{
m_Interval = atoi(strtok(NULL, seps));
strBuf.Format("Submit interval set to %i seconds.", m_Interval);
StatusUpdate(S_SUBMIT_INTERVAL, strBuf);
}
- }
- else if (stricmp("BADAUTH",response) == 0)
+ }
+ else if (stricmp("BADAUTH",response) == 0)
{
StatusUpdate(S_SUBMIT_BADAUTH,"Submission failed: bad authorization.");
char *inttext = strtok(NULL, seps);
- if (inttext && (stricmp("INTERVAL", inttext) == 0))
+ if (inttext && (stricmp("INTERVAL", inttext) == 0))
{
m_Interval = atoi(strtok(NULL, seps));
CStdString strBuf;
@@ -400,8 +399,8 @@
//re-handshake
m_bReHandShaking = true;
DoHandshake();
- }
- else
+ }
+ else
{
CStdString strBuf;
strBuf.Format("Submission failed: %s", strtok(NULL, "\n"));
@@ -409,7 +408,7 @@
}
}
-void CScrobbler::SetInterval(int in)
+void CScrobbler::SetInterval(int in)
{
m_Interval = in;
CStdString ret;
@@ -417,17 +416,17 @@
StatusUpdate(S_SUBMIT_INTERVAL, ret);
}
-void CScrobbler::GenSessionKey()
+void CScrobbler::GenSessionKey()
{
CStdString clear = m_strPassword + m_strChallenge;
- MD5_CTX md5state;
unsigned char md5pword[16];
- MD5Init(&md5state);
- MD5Update(&md5state, (unsigned char *)clear.c_str(), (int)clear.length());
- MD5Final(md5pword, &md5state);
+ XBMC::MD5 md5state;
+ md5state.append(clear);
+ md5state.getDigest(md5pword);
+
char key[33];
strncpy(key, "\0", sizeof(key));
- for (int j = 0;j < 16;j++)
+ for (int j = 0;j < 16;j++)
{
char a[3];
sprintf(a, "%02x", md5pword[j]);
@@ -437,8 +436,8 @@
m_strSessionKey = key;
}
-int CScrobbler::LoadCache()
-{
+int CScrobbler::LoadCache()
+{
StatusUpdate(S_SUBMITTING,"load cache");
int iNumEntries=0;
@@ -455,11 +454,11 @@
SetCache(strCache, iNumEntries);
return 1;
}
- return 0;
+ return 0;
}
int CScrobbler::SaveCache(const CStdString& strCache, int iNumEntries)
-{
+{
if (iNumEntries<=0)
return 0;
@@ -473,7 +472,7 @@
file.Close();
return 1;
}
- return 0;
+ return 0;
}
void CScrobbler::StatusUpdate(ScrobbleStatus status, const CStdString& strText)
@@ -555,7 +554,7 @@
CHTTP http;
CStdString strHtml;
bool bSuccess;
- if (!m_bReadyToSubmit)
+ if (!m_bReadyToSubmit)
{
bSuccess=http.Get(m_strHsString, strHtml);
if (bSuccess)
@@ -566,8 +565,8 @@
if (m_bReHandShaking)
m_bReHandShaking = false;
}
- }
- else
+ }
+ else
{
bSuccess=http.Post(m_strSubmitUrl, m_strSubmit, strHtml);
if (bSuccess)
@@ -591,7 +590,7 @@
ReleaseMutex(m_hHttpMutex);
// OK, if this was a handshake, it failed since m_bReadyToSubmit isn't true. Submissions get cached.
- while (!m_bReadyToSubmit && !m_bCloseThread)
+ while (!m_bReadyToSubmit && !m_bCloseThread)
{
StatusUpdate(S_HANDHAKE_NOTREADY,"Unable to handshake: sleeping...");
Sleep(HS_FAIL_WAIT);
Modified: branches/linuxport/XBMC/xbmc/utils/Makefile
===================================================================
--- branches/linuxport/XBMC/xbmc/utils/Makefile 2008-07-25 21:43:59 UTC (rev 14446)
+++ branches/linuxport/XBMC/xbmc/utils/Makefile 2008-07-25 22:20:59 UTC (rev 14447)
@@ -1,10 +1,7 @@
INCLUDES=-I. -I.. -I../linux -I../../guilib
-SRCS=AlarmClock.cpp Archive.cpp CharsetConverter.cpp CriticalSection.cpp DelayController.cpp Event.cpp fstrcmp.cpp GUIInfoManager.cpp HTMLTable.cpp HTMLUtil.cpp HttpHeader.cpp IMDB.cpp InfoLoader.cpp log.cpp MusicAlbumInfo.cpp MusicInfoScraper.cpp RegExp.cpp RssReader.cpp ScraperParser.cpp SingleLock.cpp Splash.cpp Stopwatch.cpp SystemInfo.cpp TuxBoxUtil.cpp UdpClient.cpp Weather.cpp Thread.cpp HTTP.cpp SharedSection.cpp Win32Exception.cpp CPUInfo.cpp PCMAmplifier.cpp LabelFormatter.cpp Network.cpp BitstreamStats.cpp PerformanceStats.cpp PerformanceSample.cpp LCDFactory.cpp LCD.cpp EventServer.cpp EventPacket.cpp EventClient.cpp Socket.cpp Fanart.cpp ScraperUrl.cpp MusicArtistInfo.cpp RssFeed.cpp Mutex.cpp
+SRCS=AlarmClock.cpp Archive.cpp CharsetConverter.cpp CriticalSection.cpp DelayController.cpp Event.cpp fstrcmp.cpp GUIInfoManager.cpp HTMLTable.cpp HTMLUtil.cpp HttpHeader.cpp IMDB.cpp InfoLoader.cpp log.cpp MusicAlbumInfo.cpp MusicInfoScraper.cpp RegExp.cpp RssReader.cpp ScraperParser.cpp SingleLock.cpp Splash.cpp Stopwatch.cpp SystemInfo.cpp TuxBoxUtil.cpp UdpClient.cpp Weather.cpp Thread.cpp HTTP.cpp SharedSection.cpp Win32Exception.cpp CPUInfo.cpp PCMAmplifier.cpp LabelFormatter.cpp Network.cpp BitstreamStats.cpp PerformanceStats.cpp PerformanceSample.cpp LCDFactory.cpp LCD.cpp EventServer.cpp EventPacket.cpp EventClient.cpp Socket.cpp Fanart.cpp ScraperUrl.cpp MusicArtistInfo.cpp RssFeed.cpp Mutex.cpp md5.cpp
-# This includes only the objects of the C files
-OBJS=md5.o
-
LIB=utils.a
include ../../Makefile.include
Copied: branches/linuxport/XBMC/xbmc/utils/md5.cpp (from rev 14445, branches/linuxport/XBMC/xbmc/utils/md5.c)
===================================================================
--- branches/linuxport/XBMC/xbmc/utils/md5.cpp (rev 0)
+++ branches/linuxport/XBMC/xbmc/utils/md5.cpp 2008-07-25 22:20:59 UTC (rev 14447)
@@ -0,0 +1,308 @@
+/*
+ * Copyright (C) 2005-2008 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, write to
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ */
+
+#include "md5.h"
+
+static void MD5Init (MD5_CTX *mdContext);
+static void MD5Update (MD5_CTX *mdContext, unsigned char *inBuf, unsigned int inLen);
+static void MD5Final (unsigned char digest[16], MD5_CTX *mdContext);
+
+XBMC::MD5::MD5(void)
+{
+ MD5Init(&m_ctx);
+}
+
+void XBMC::MD5::append(unsigned char *inBuf, unsigned int inLen)
+{
+ MD5Update(&m_ctx, inBuf, inLen);
+}
+
+void XBMC::MD5::append(const CStdString& str)
+{
+ append((unsigned char*) str.c_str(), (unsigned int) str.length());
+}
+
+void XBMC::MD5::getDigest(unsigned char digest[16])
+{
+ MD5Final(digest, &m_ctx);
+}
+
+/*
+ **********************************************************************
+ ** md5.c **
+ ** RSA Data Security, Inc. MD5 Message Digest Algorithm **
+ ** Created: 2/17/90 RLR **
+ ** Revised: 1/91 SRD,AJ,BSK,JT Reference C Version **
+ **********************************************************************
+ */
+
+/*
+ **********************************************************************
+ ** Copyright (C) 1990, RSA Data Security, Inc. All rights reserved. **
+ ** **
+ ** License to copy and use this software is granted provided that **
+ ** it is identified as the "RSA Data Security, Inc. MD5 Message **
+ ** Digest Algorithm" in all material mentioning or referencing this **
+ ** software or this function. **
+ ** **
+ ** License is also granted to make and use derivative works **
+ ** provided that such works are identified as "derived from the RSA **
+ ** Data Security, Inc. MD5 Message Digest Algorithm" in all **
+ ** material mentioning or referencing the derived work. **
+ ** **
+ ** RSA Data Security, Inc. makes no representations concerning **
+ ** either the merchantability of this software or the suitability **
+ ** of this software for any particular purpose. It is provided "as **
+ ** is" without express or implied warranty of any kind. **
+ ** **
+ ** These notices must be retained in any copies of any part of this **
+ ** documentation and/or software. **
+ **********************************************************************
+ */
+
+/* forward declaration */
+static void Transform (UINT4* buf, UINT4* in);
+
+static unsigned char PADDING[64] = {
+ 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+/* F, G and H are basic MD5 functions: selection, majority, parity */
+#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
+#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
+#define H(x, y, z) ((x) ^ (y) ^ (z))
+#define I(x, y, z) ((y) ^ ((x) | (~z)))
+
+/* ROTATE_LEFT rotates x left n bits */
+#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
+
+/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4 */
+/* Rotation is separate from addition to prevent recomputation */
+#define FF(a, b, c, d, x, s, ac) \
+ {(a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \
+ (a) = ROTATE_LEFT ((a), (s)); \
+ (a) += (b); \
+ }
+#define GG(a, b, c, d, x, s, ac) \
+ {(a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \
+ (a) = ROTATE_LEFT ((a), (s)); \
+ (a) += (b); \
+ }
+#define HH(a, b, c, d, x, s, ac) \
+ {(a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \
+ (a) = ROTATE_LEFT ((a), (s)); \
+ (a) += (b); \
+ }
+#define II(a, b, c, d, x, s, ac) \
+ {(a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \
+ (a) = ROTATE_LEFT ((a), (s)); \
+ (a) += (b); \
+ }
+
+static void MD5Init (MD5_CTX *mdContext)
+{
+ mdContext->i[0] = mdContext->i[1] = (UINT4)0;
+
+ /* Load magic initialization constants.
+ */
+ mdContext->buf[0] = (UINT4)0x67452301;
+ mdContext->buf[1] = (UINT4)0xefcdab89;
+ mdContext->buf[2] = (UINT4)0x98badcfe;
+ mdContext->buf[3] = (UINT4)0x10325476;
+}
+
+static void MD5Update (MD5_CTX *mdContext, unsigned char *inBuf, unsigned int inLen)
+{
+ UINT4 in[16];
+ int mdi;
+ unsigned int i, ii;
+
+ /* compute number of bytes mod 64 */
+ mdi = (int)((mdContext->i[0] >> 3) & 0x3F);
+
+ /* update number of bits */
+ if ((mdContext->i[0] + ((UINT4)inLen << 3)) < mdContext->i[0])
+ mdContext->i[1]++;
+ mdContext->i[0] += ((UINT4)inLen << 3);
+ mdContext->i[1] += ((UINT4)inLen >> 29);
+
+ while (inLen--) {
+ /* add new character to buffer, increment mdi */
+ mdContext->in[mdi++] = *inBuf++;
+
+ /* transform if necessary */
+ if (mdi == 0x40) {
+ for (i = 0, ii = 0; i < 16; i++, ii += 4)
+ in[i] = (((UINT4)mdContext->in[ii+3]) << 24) |
+ (((UINT4)mdContext->in[ii+2]) << 16) |
+ (((UINT4)mdContext->in[ii+1]) << 8) |
+ ((UINT4)mdContext->in[ii]);
+ Transform (mdContext->buf, in);
+ mdi = 0;
+ }
+ }
+}
+
+static void MD5Final (unsigned char digest[16], MD5_CTX *mdContext)
+{
+ UINT4 in[16];
+ int mdi;
+ unsigned int i, ii;
+ unsigned int padLen;
+
+ /* save number of bits */
+ in[14] = mdContext->i[0];
+ in[15] = mdContext->i[1];
+
+ /* compute number of bytes mod 64 */
+ mdi = (int)((mdContext->i[0] >> 3) & 0x3F);
+
+ /* pad out to 56 mod 64 */
+ padLen = (mdi < 56) ? (56 - mdi) : (120 - mdi);
+ MD5Update (mdContext, PADDING, padLen);
+
+ /* append length in bits and transform */
+ for (i = 0, ii = 0; i < 14; i++, ii += 4)
+ in[i] = (((UINT4)mdContext->in[ii+3]) << 24) |
+ (((UINT4)mdContext->in[ii+2]) << 16) |
+ (((UINT4)mdContext->in[ii+1]) << 8) |
+ ((UINT4)mdContext->in[ii]);
+ Transform (mdContext->buf, in);
+
+ /* store buffer in digest */
+ for (i = 0, ii = 0; i < 4; i++, ii += 4) {
+ digest[ii] = (unsigned char)(mdContext->buf[i] & 0xFF);
+ digest[ii+1] =
+ (unsigned char)((mdContext->buf[i] >> 8) & 0xFF);
+ digest[ii+2] =
+ (unsigned char)((mdContext->buf[i] >> 16) & 0xFF);
+ digest[ii+3] =
+ (unsigned char)((mdContext->buf[i] >> 24) & 0xFF);
+ }
+}
+
+/* Basic MD5 step. Transform buf based on in.
+ */
+static void Transform (UINT4* buf, UINT4* in)
+{
+ UINT4 a = buf[0], b = buf[1], c = buf[2], d = buf[3];
+
+ /* Round 1 */
+#define S11 7
+#define S12 12
+#define S13 17
+#define S14 22
+ FF (a, b, c, d, in[ 0], S11, 0xd76aa478); /* 1 */
+ FF (d, a, b, c, in[ 1], S12, 0xe8c7b756); /* 2 */
+ FF (c, d, a, b, in[ 2], S13, 0x242070db); /* 3 */
+ FF (b, c, d, a, in[ 3], S14, 0xc1bdceee); /* 4 */
+ FF (a, b, c, d, in[ 4], S11, 0xf57c0faf); /* 5 */
+ FF (d, a, b, c, in[ 5], S12, 0x4787c62a); /* 6 */
+ FF (c, d, a, b, in[ 6], S13, 0xa8304613); /* 7 */
+ FF (b, c, d, a, in[ 7], S14, 0xfd469501); /* 8 */
+ FF (a, b, c, d, in[ 8], S11, 0x698098d8); /* 9 */
+ FF (d, a, b, c, in[ 9], S12, 0x8b44f7af); /* 10 */
+ FF (c, d, a, b, in[10], S13, 0xffff5bb1); /* 11 */
+ FF (b, c, d, a, in[11], S14, 0x895cd7be); /* 12 */
+ FF (a, b, c, d, in[12], S11, 0x6b901122); /* 13 */
+ FF (d, a, b, c, in[13], S12, 0xfd987193); /* 14 */
+ FF (c, d, a, b, in[14], S13, 0xa679438e); /* 15 */
+ FF (b, c, d, a, in[15], S14, 0x49b40821); /* 16 */
+
+ /* Round 2 */
+#define S21 5
+#define S22 9
+#define S23 14
+#define S24 20
+ GG (a, b, c, d, in[ 1], S21, 0xf61e2562); /* 17 */
+ GG (d, a, b, c, in[ 6], S22, 0xc040b340); /* 18 */
+ GG (c, d, a, b, in[11], S23, 0x265e5a51); /* 19 */
+ GG (b, c, d, a, in[ 0], S24, 0xe9b6c7aa); /* 20 */
+ GG (a, b, c, d, in[ 5], S21, 0xd62f105d); /* 21 */
+ GG (d, a, b, c, in[10], S22, 0x2441453); /* 22 */
+ GG (c, d, a, b, in[15], S23, 0xd8a1e681); /* 23 */
+ GG (b, c, d, a, in[ 4], S24, 0xe7d3fbc8); /* 24 */
+ GG (a, b, c, d, in[ 9], S21, 0x21e1cde6); /* 25 */
+ GG (d, a, b, c, in[14], S22, 0xc33707d6); /* 26 */
+ GG (c, d, a, b, in[ 3], S23, 0xf4d50d87); /* 27 */
+ GG (b, c, d, a, in[ 8], S24, 0x455a14ed); /* 28 */
+ GG (a, b, c, d, in[13], S21, 0xa9e3e905); /* 29 */
+ GG (d, a, b, c, in[ 2], S22, 0xfcefa3f8); /* 30 */
+ GG (c, d, a, b, in[ 7], S23, 0x676f02d9); /* 31 */
+ GG (b, c, d, a, in[12], S24, 0x8d2a4c8a); /* 32 */
+
+ /* Round 3 */
+#define S31 4
+#define S32 11
+#define S33 16
+#define S34 23
+ HH (a, b, c, d, in[ 5], S31, 0xfffa3942); /* 33 */
+ HH (d, a, b, c, in[ 8], S32, 0x8771f681); /* 34 */
+ HH (c, d, a, b, in[11], S33, 0x6d9d6122); /* 35 */
+ HH (b, c, d, a, in[14], S34, 0xfde5380c); /* 36 */
+ HH (a, b, c, d, in[ 1], S31, 0xa4beea44); /* 37 */
+ HH (d, a, b, c, in[ 4], S32, 0x4bdecfa9); /* 38 */
+ HH (c, d, a, b, in[ 7], S33, 0xf6bb4b60); /* 39 */
+ HH (b, c, d, a, in[10], S34, 0xbebfbc70); /* 40 */
+ HH (a, b, c, d, in[13], S31, 0x289b7ec6); /* 41 */
+ HH (d, a, b, c, in[ 0], S32, 0xeaa127fa); /* 42 */
+ HH (c, d, a, b, in[ 3], S33, 0xd4ef3085); /* 43 */
+ HH (b, c, d, a, in[ 6], S34, 0x4881d05); /* 44 */
+ HH (a, b, c, d, in[ 9], S31, 0xd9d4d039); /* 45 */
+ HH (d, a, b, c, in[12], S32, 0xe6db99e5); /* 46 */
+ HH (c, d, a, b, in[15], S33, 0x1fa27cf8); /* 47 */
+ HH (b, c, d, a, in[ 2], S34, 0xc4ac5665); /* 48 */
+
+ /* Round 4 */
+#define S41 6
+#define S42 10
+#define S43 15
+#define S44 21
+ II ( a, b, c, d, in[ 0], S41, 0xf4292244); /* 49 */
+ II ( d, a, b, c, in[ 7], S42, 0x432aff97); /* 50 */
+ II ( c, d, a, b, in[14], S43, 0xab9423a7); /* 51 */
+ II ( b, c, d, a, in[ 5], S44, 0xfc93a039); /* 52 */
+ II ( a, b, c, d, in[12], S41, 0x655b59c3); /* 53 */
+ II ( d, a, b, c, in[ 3], S42, 0x8f0ccc92); /* 54 */
+ II ( c, d, a, b, in[10], S43, 0xffeff47d); /* 55 */
+ II ( b, c, d, a, in[ 1], S44, 0x85845dd1); /* 56 */
+ II ( a, b, c, d, in[ 8], S41, 0x6fa87e4f); /* 57 */
+ II ( d, a, b, c, in[15], S42, 0xfe2ce6e0); /* 58 */
+ II ( c, d, a, b, in[ 6], S43, 0xa3014314); /* 59 */
+ II ( b, c, d, a, in[13], S44, 0x4e0811a1); /* 60 */
+ II ( a, b, c, d, in[ 4], S41, 0xf7537e82); /* 61 */
+ II ( d, a, b, c, in[11], S42, 0xbd3af235); /* 62 */
+ II ( c, d, a, b, in[ 2], S43, 0x2ad7d2bb); /* 63 */
+ II ( b, c, d, a, in[ 9], S44, 0xeb86d391); /* 64 */
+
+ buf[0] += a;
+ buf[1] += b;
+ buf[2] += c;
+ buf[3] += d;
+}
+
Modified: branches/linuxport/XBMC/xbmc/utils/md5.h
===================================================================
--- branches/linuxport/XBMC/xbmc/utils/md5.h 2008-07-25 21:43:59 UTC (rev 14446)
+++ branches/linuxport/XBMC/xbmc/utils/md5.h 2008-07-25 22:20:59 UTC (rev 14447)
@@ -40,9 +40,7 @@
#ifndef _MD5_H_
#define _MD5_H_ 1
-#ifdef __cplusplus
-extern "C" {
-#endif
+#include "system.h"
/* typedef a 32 bit type */
typedef unsigned long int UINT4;
@@ -54,13 +52,20 @@
unsigned char in[64]; /* input buffer */
} MD5_CTX;
-void MD5Init (MD5_CTX *mdContext);
-void MD5Update (MD5_CTX *mdContext, unsigned char *inBuf, unsigned int inLen);
-void MD5Final (unsigned char digest[16], MD5_CTX *mdContext);
+namespace XBMC
+{
+ class MD5
+ {
+ public:
+ MD5(void);
+ void append(unsigned char *inBuf, unsigned int inLen);
+ void append(const CStdString& str);
+ void getDigest(unsigned char digest[16]);
-#ifdef __cplusplus
+ private:
+ MD5_CTX m_ctx;
+ };
}
-#endif
#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|