summaryrefslogtreecommitdiff
path: root/plugins/Db3x_mmap/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2021-12-26 15:58:40 +0300
committerGeorge Hazan <ghazan@miranda.im>2021-12-26 15:58:40 +0300
commitfcbb395dc7ff3edab972b6d4b27dbbfb3305f5d7 (patch)
tree8807aea6f2afce38b30ce60aa5ebf84a26992b73 /plugins/Db3x_mmap/src
parentaf2958f2e82cb68392983da6f7f69fa3cd0c5276 (diff)
PBYTE -> uint8_t*
Diffstat (limited to 'plugins/Db3x_mmap/src')
-rw-r--r--plugins/Db3x_mmap/src/dbcache.cpp6
-rw-r--r--plugins/Db3x_mmap/src/dbcontacts.cpp12
-rw-r--r--plugins/Db3x_mmap/src/dbcrypt.cpp8
-rw-r--r--plugins/Db3x_mmap/src/dbevents.cpp2
-rw-r--r--plugins/Db3x_mmap/src/dbintf.h32
-rw-r--r--plugins/Db3x_mmap/src/dbsettings.cpp16
6 files changed, 38 insertions, 38 deletions
diff --git a/plugins/Db3x_mmap/src/dbcache.cpp b/plugins/Db3x_mmap/src/dbcache.cpp
index 73c0475858..4d9cee8392 100644
--- a/plugins/Db3x_mmap/src/dbcache.cpp
+++ b/plugins/Db3x_mmap/src/dbcache.cpp
@@ -33,7 +33,7 @@ void CDb3Mmap::Map()
m_hMap = CreateFileMapping(m_hDbFile, nullptr, dwProtectMode, 0, m_dwFileSize, nullptr);
if (m_hMap) {
- m_pDbCache = (PBYTE)MapViewOfFile(m_hMap, dwAccess, 0, 0, 0);
+ m_pDbCache = (uint8_t*)MapViewOfFile(m_hMap, dwAccess, 0, 0, 0);
if (!m_pDbCache)
DatabaseCorruption(L"%s (MapViewOfFile failed. Code: %d)");
}
@@ -85,7 +85,7 @@ void CDb3Mmap::DBMoveChunk(DWORD ofsDest, DWORD ofsSource, int bytes)
}
//we are assumed to be in a mutex here
-PBYTE CDb3Mmap::DBRead(DWORD ofs, int *bytesAvail)
+uint8_t* CDb3Mmap::DBRead(DWORD ofs, int *bytesAvail)
{
// buggy read
if (ofs >= m_dwFileSize) {
@@ -175,7 +175,7 @@ int CDb3Mmap::InitMap(void)
Map();
// zero region for reads outside the file
- m_pNull = (PBYTE)calloc(m_ChunkSize, 1);
+ m_pNull = (uint8_t*)calloc(m_ChunkSize, 1);
return 0;
}
diff --git a/plugins/Db3x_mmap/src/dbcontacts.cpp b/plugins/Db3x_mmap/src/dbcontacts.cpp
index 19aebdc779..04e4aa5a78 100644
--- a/plugins/Db3x_mmap/src/dbcontacts.cpp
+++ b/plugins/Db3x_mmap/src/dbcontacts.cpp
@@ -216,18 +216,18 @@ BOOL CDb3Mmap::MetaMergeHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub)
dbMeta->eventCount = arEvents.getCount();
DBEvent *pFirst = arEvents[0];
- dbMeta->ofsFirstEvent = DWORD(PBYTE(pFirst) - m_pDbCache);
+ dbMeta->ofsFirstEvent = DWORD((uint8_t*)pFirst - m_pDbCache);
pFirst->ofsPrev = 0;
dbMeta->ofsFirstUnread = pFirst->markedRead() ? 0 : dbMeta->ofsFirstEvent;
DBEvent *pLast = arEvents[arEvents.getCount() - 1];
- dbMeta->ofsLastEvent = DWORD(PBYTE(pLast) - m_pDbCache);
+ dbMeta->ofsLastEvent = DWORD((uint8_t*)pLast - m_pDbCache);
pLast->ofsNext = 0;
for (int i = 1; i < arEvents.getCount(); i++) {
DBEvent *pPrev = arEvents[i - 1], *pNext = arEvents[i];
- pPrev->ofsNext = DWORD(PBYTE(pNext) - m_pDbCache);
- pNext->ofsPrev = DWORD(PBYTE(pPrev) - m_pDbCache);
+ pPrev->ofsNext = DWORD((uint8_t*)pNext - m_pDbCache);
+ pNext->ofsPrev = DWORD((uint8_t*)pPrev - m_pDbCache);
if (dbMeta->ofsFirstUnread == 0 && !pNext->markedRead())
dbMeta->ofsFirstUnread = pPrev->ofsNext;
@@ -280,7 +280,7 @@ BOOL CDb3Mmap::MetaSplitHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub)
dbSub.eventCount++;
if (evSub != nullptr) {
evSub->ofsNext = dwOffset;
- evCurr->ofsPrev = DWORD(PBYTE(evSub) - m_pDbCache);
+ evCurr->ofsPrev = DWORD((uint8_t*)evSub - m_pDbCache);
}
else {
dbSub.ofsFirstEvent = dwOffset;
@@ -297,7 +297,7 @@ BOOL CDb3Mmap::MetaSplitHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub)
dbMeta.eventCount++;
if (evMeta != nullptr) {
evMeta->ofsNext = dwOffset;
- evCurr->ofsPrev = DWORD(PBYTE(evMeta) - m_pDbCache);
+ evCurr->ofsPrev = DWORD((uint8_t*)evMeta - m_pDbCache);
}
else {
dbMeta.ofsFirstEvent = dwOffset;
diff --git a/plugins/Db3x_mmap/src/dbcrypt.cpp b/plugins/Db3x_mmap/src/dbcrypt.cpp
index 01cafc0271..7778535d2c 100644
--- a/plugins/Db3x_mmap/src/dbcrypt.cpp
+++ b/plugins/Db3x_mmap/src/dbcrypt.cpp
@@ -39,7 +39,7 @@ struct VarDescr
iLen(0)
{}
- VarDescr(LPCSTR var, PBYTE value, int len) :
+ VarDescr(LPCSTR var, uint8_t *value, int len) :
szVar(mir_strdup(var)),
szValue((char*)memcpy(mir_alloc(len), value, len)),
iLen(len)
@@ -119,7 +119,7 @@ STDMETHODIMP_(BOOL) CDb3Mmap::StoreProvider(CRYPTO_PROVIDER *pProvider)
{
DBCONTACTWRITESETTING dbcws = { "CryptoEngine", "Provider" };
dbcws.value.type = DBVT_BLOB;
- dbcws.value.pbVal = (PBYTE)pProvider->pszName;
+ dbcws.value.pbVal = (uint8_t*)pProvider->pszName;
dbcws.value.cpbVal = (WORD)mir_strlen(pProvider->pszName) + 1;
WriteContactSetting(0, &dbcws);
return TRUE;
@@ -182,7 +182,7 @@ void CDb3Mmap::ToggleSettingsEncryption(MCONTACT contactID)
char szSetting[256];
int bytesRemaining, len;
DWORD ofsBlobPtr = offset + offsetof(DBContactSettings, blob), ofsNext = setting->ofsNext;
- PBYTE pBlob = (PBYTE)DBRead(ofsBlobPtr, &bytesRemaining);
+ uint8_t *pBlob = (uint8_t*)DBRead(ofsBlobPtr, &bytesRemaining);
while (pBlob[0]) {
NeedBytes(1);
len = pBlob[0];
@@ -247,7 +247,7 @@ void CDb3Mmap::ToggleSettingsEncryption(MCONTACT contactID)
}
else {
size_t realLen;
- ptrA decoded(m_crypto->decodeString((PBYTE)(char*)p->szValue, p->iLen, &realLen));
+ ptrA decoded(m_crypto->decodeString((uint8_t*)(char*)p->szValue, p->iLen, &realLen));
if (decoded != nullptr) {
DBCONTACTWRITESETTING dbcws = { szModule, p->szVar };
dbcws.value.type = DBVT_UNENCRYPTED;
diff --git a/plugins/Db3x_mmap/src/dbevents.cpp b/plugins/Db3x_mmap/src/dbevents.cpp
index 0b4aeb4a18..69928a404c 100644
--- a/plugins/Db3x_mmap/src/dbevents.cpp
+++ b/plugins/Db3x_mmap/src/dbevents.cpp
@@ -296,7 +296,7 @@ BOOL CDb3Mmap::GetEvent(MEVENT hDbEvent, DBEVENTINFO *dbei)
DWORD cbBlob = dbe->cbBlob;
size_t bytesToCopy = cbBlob;
if (dbei->cbBlob == -1)
- dbei->pBlob = (PBYTE)mir_calloc(cbBlob + 2);
+ dbei->pBlob = (uint8_t*)mir_calloc(cbBlob + 2);
else if (dbei->cbBlob < cbBlob)
bytesToCopy = dbei->cbBlob;
diff --git a/plugins/Db3x_mmap/src/dbintf.h b/plugins/Db3x_mmap/src/dbintf.h
index 67dc4b084e..43907534cf 100644
--- a/plugins/Db3x_mmap/src/dbintf.h
+++ b/plugins/Db3x_mmap/src/dbintf.h
@@ -65,10 +65,10 @@ DBHeader
#define MARKED_READ (DBEF_READ | DBEF_SENT)
-#define NeedBytes(n) if (bytesRemaining<(n)) pBlob = (PBYTE)DBRead(ofsBlobPtr,&bytesRemaining)
+#define NeedBytes(n) if (bytesRemaining<(n)) pBlob = (uint8_t*)DBRead(ofsBlobPtr,&bytesRemaining)
#define MoveAlong(n) {int x = n; pBlob += (x); ofsBlobPtr += (x); bytesRemaining -= (x);}
-DWORD __forceinline GetSettingValueLength(PBYTE pSetting)
+DWORD __forceinline GetSettingValueLength(uint8_t *pSetting)
{
if (pSetting[0] & DBVTF_VARIABLELENGTH)
return 2 + *(PWORD)(pSetting + 1);
@@ -245,24 +245,24 @@ public:
STDMETHODIMP_(DATABASELINK*) GetDriver() override;
protected:
- DWORD GetSettingsGroupOfsByModuleNameOfs(DBContact *dbc, DWORD ofsModuleName);
- void InvalidateSettingsGroupOfsCacheEntry(DWORD) {}
+ DWORD GetSettingsGroupOfsByModuleNameOfs(DBContact *dbc, DWORD ofsModuleName);
+ void InvalidateSettingsGroupOfsCacheEntry(DWORD) {}
- void DBMoveChunk(DWORD ofsDest, DWORD ofsSource, int bytes);
- PBYTE DBRead(DWORD ofs, int *bytesAvail);
- void DBWrite(DWORD ofs, PVOID pData, int bytes);
- void DBFill(DWORD ofs, int bytes);
- void DBFlush(int setting);
- int InitMap(void);
- void FillContacts(void);
+ void DBMoveChunk(DWORD ofsDest, DWORD ofsSource, int bytes);
+ uint8_t* DBRead(DWORD ofs, int *bytesAvail);
+ void DBWrite(DWORD ofs, PVOID pData, int bytes);
+ void DBFill(DWORD ofs, int bytes);
+ void DBFlush(int setting);
+ int InitMap(void);
+ void FillContacts(void);
- PBYTE m_pNull;
+ uint8_t* m_pNull;
- void Map();
- void ReMap(DWORD needed);
+ void Map();
+ void ReMap(DWORD needed);
protected:
- wchar_t* m_tszProfileName;
+ wchar_t* m_tszProfileName;
HANDLE m_hDbFile;
DBHeader m_dbHeader;
DWORD m_ChunkSize;
@@ -273,7 +273,7 @@ protected:
public:
UINT_PTR m_flushBuffersTimerId;
DWORD m_flushFailTick;
- PBYTE m_pDbCache;
+ uint8_t* m_pDbCache;
HANDLE m_hMap;
protected:
diff --git a/plugins/Db3x_mmap/src/dbsettings.cpp b/plugins/Db3x_mmap/src/dbsettings.cpp
index f435c3a98c..9ed7ba662e 100644
--- a/plugins/Db3x_mmap/src/dbsettings.cpp
+++ b/plugins/Db3x_mmap/src/dbsettings.cpp
@@ -103,7 +103,7 @@ LBL_Seek:
int bytesRemaining;
unsigned varLen;
DWORD ofsBlobPtr = ofsSettingsGroup + offsetof(DBContactSettings, blob);
- PBYTE pBlob = DBRead(ofsBlobPtr, &bytesRemaining);
+ uint8_t *pBlob = DBRead(ofsBlobPtr, &bytesRemaining);
while (pBlob[0]) {
NeedBytes(1 + settingNameLen);
if (pBlob[0] == settingNameLen && !memcmp(pBlob + 1, szSetting, settingNameLen)) {
@@ -236,7 +236,7 @@ STDMETHODIMP_(BOOL) CDb3Mmap::WriteContactSettingWorker(MCONTACT contactID, DBCO
return 1;
// make sure the module group exists
- PBYTE pBlob;
+ uint8_t *pBlob;
int bytesRequired, bytesRemaining;
DBContactSettings dbcs;
DWORD ofsSettingsGroup = GetSettingsGroupOfsByModuleNameOfs(&dbc, ofsModuleName);
@@ -263,14 +263,14 @@ STDMETHODIMP_(BOOL) CDb3Mmap::WriteContactSettingWorker(MCONTACT contactID, DBCO
DBWrite(ofsContact, &dbc, sizeof(DBContact));
DBWrite(ofsSettingsGroup, &dbcs, sizeof(DBContactSettings));
ofsBlobPtr = ofsSettingsGroup + offsetof(DBContactSettings, blob);
- pBlob = (PBYTE)DBRead(ofsBlobPtr, &bytesRemaining);
+ pBlob = (uint8_t*)DBRead(ofsBlobPtr, &bytesRemaining);
}
else {
dbcs = *(DBContactSettings*)DBRead(ofsSettingsGroup, &bytesRemaining);
// find if the setting exists
ofsBlobPtr = ofsSettingsGroup + offsetof(DBContactSettings, blob);
- pBlob = (PBYTE)DBRead(ofsBlobPtr, &bytesRemaining);
+ pBlob = (uint8_t*)DBRead(ofsBlobPtr, &bytesRemaining);
while (pBlob[0]) {
NeedBytes(settingNameLen + 1);
if (pBlob[0] == settingNameLen && !memcmp(pBlob + 1, dbcws.szSetting, settingNameLen))
@@ -306,7 +306,7 @@ STDMETHODIMP_(BOOL) CDb3Mmap::WriteContactSettingWorker(MCONTACT contactID, DBCO
}
DBMoveChunk(ofsSettingToCut, ofsSettingToCut + nameLen + valLen, ofsBlobPtr + 1 - ofsSettingToCut);
ofsBlobPtr -= nameLen + valLen;
- pBlob = (PBYTE)DBRead(ofsBlobPtr, &bytesRemaining);
+ pBlob = (uint8_t*)DBRead(ofsBlobPtr, &bytesRemaining);
}
else {
// replace existing setting at pBlob
@@ -386,7 +386,7 @@ STDMETHODIMP_(BOOL) CDb3Mmap::WriteContactSettingWorker(MCONTACT contactID, DBCO
}
ofsBlobPtr += ofsNew - ofsSettingsGroup;
ofsSettingsGroup = ofsNew;
- pBlob = (PBYTE)DBRead(ofsBlobPtr, &bytesRemaining);
+ pBlob = (uint8_t*)DBRead(ofsBlobPtr, &bytesRemaining);
}
// we now have a place to put it and enough space: make it
@@ -467,7 +467,7 @@ STDMETHODIMP_(BOOL) CDb3Mmap::DeleteContactSetting(MCONTACT contactID, LPCSTR sz
// find if the setting exists
DWORD ofsBlobPtr = ofsSettingsGroup + offsetof(DBContactSettings, blob);
int bytesRemaining;
- PBYTE pBlob = (PBYTE)DBRead(ofsBlobPtr, &bytesRemaining);
+ uint8_t *pBlob = (uint8_t*)DBRead(ofsBlobPtr, &bytesRemaining);
while (pBlob[0]) {
NeedBytes(settingNameLen + 1);
if (pBlob[0] == settingNameLen && !memcmp(pBlob + 1, szSetting, settingNameLen))
@@ -539,7 +539,7 @@ STDMETHODIMP_(BOOL) CDb3Mmap::EnumContactSettings(MCONTACT contactID, DBSETTINGE
DWORD ofsBlobPtr = ofsSettings + offsetof(DBContactSettings, blob);
int bytesRemaining;
- PBYTE pBlob = (PBYTE)DBRead(ofsBlobPtr, &bytesRemaining);
+ uint8_t *pBlob = (uint8_t*)DBRead(ofsBlobPtr, &bytesRemaining);
if (pBlob[0] == 0)
return -1;