From cddcd7483a7c472598af098e759e5d309024f606 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 26 Dec 2021 20:31:39 +0300 Subject: DWORD -> uint32_t --- plugins/HTTPServer/src/FileShareNode.cpp | 4 ++-- plugins/HTTPServer/src/FileShareNode.h | 10 ++++----- plugins/HTTPServer/src/Glob.h | 6 ++--- plugins/HTTPServer/src/GuiElements.cpp | 12 +++++----- plugins/HTTPServer/src/HttpUser.cpp | 38 ++++++++++++++++---------------- plugins/HTTPServer/src/IndexCreation.h | 4 ++-- plugins/HTTPServer/src/IndexHTML.cpp | 4 ++-- plugins/HTTPServer/src/IndexXML.cpp | 6 ++--- plugins/HTTPServer/src/main.cpp | 22 +++++++++--------- 9 files changed, 53 insertions(+), 53 deletions(-) (limited to 'plugins/HTTPServer/src') diff --git a/plugins/HTTPServer/src/FileShareNode.cpp b/plugins/HTTPServer/src/FileShareNode.cpp index 939c46f364..ea884f86dd 100644 --- a/plugins/HTTPServer/src/FileShareNode.cpp +++ b/plugins/HTTPServer/src/FileShareNode.cpp @@ -99,7 +99,7 @@ void CLShareUser::CloseSocket() // Member Function : dwGetDownloadSpeed // Type : Private / Public / Protected // Parameters : None -// Returns : DWORD +// Returns : uint32_t // Description : // // References : - @@ -108,7 +108,7 @@ void CLShareUser::CloseSocket() // Developer : KN ///////////////////////////////////////////////////////////////////// -DWORD CLShareUser::dwGetDownloadSpeed() +uint32_t CLShareUser::dwGetDownloadSpeed() { return dwSpeed; } diff --git a/plugins/HTTPServer/src/FileShareNode.h b/plugins/HTTPServer/src/FileShareNode.h index c47117291f..065b115ea7 100644 --- a/plugins/HTTPServer/src/FileShareNode.h +++ b/plugins/HTTPServer/src/FileShareNode.h @@ -27,20 +27,20 @@ public: virtual ~CLShareUser(); CLShareUser * pclNext; in_addr stAddr; - DWORD dwCurrentDL; - DWORD dwTotalSize; + uint32_t dwCurrentDL; + uint32_t dwTotalSize; char szCurrentDLSrvPath[MAX_PATH]; - virtual DWORD dwGetDownloadSpeed(); + virtual uint32_t dwGetDownloadSpeed(); virtual bool bCloseTransfers() = NULL; virtual const char * pszCustomInfo() = NULL; void CloseSocket(); protected: HNETLIBCONN hConnection; - DWORD dwSpeed; + uint32_t dwSpeed; }; class CLFileShareNode { -public://, DWORD dwAllowedIP, DWORD dwAllowedMask, int nMaxDownloads ); +public://, uint32_t dwAllowedIP, uint32_t dwAllowedMask, int nMaxDownloads ); CLFileShareNode(char * pszSrvPath, char * pszRealPath); CLFileShareNode(STFileShareInfo * pstInfo); ~CLFileShareNode(); diff --git a/plugins/HTTPServer/src/Glob.h b/plugins/HTTPServer/src/Glob.h index d688dbe351..15d5636943 100644 --- a/plugins/HTTPServer/src/Glob.h +++ b/plugins/HTTPServer/src/Glob.h @@ -76,9 +76,9 @@ bool bOpenLogFile(); extern char szPluginPath[MAX_PATH]; extern int nPluginPathLen; -extern DWORD dwLocalIpAddress; -extern DWORD dwLocalPortUsed; -extern DWORD dwExternalIpAddress; +extern uint32_t dwLocalIpAddress; +extern uint32_t dwLocalPortUsed; +extern uint32_t dwExternalIpAddress; extern int nMaxUploadSpeed; extern int nMaxConnectionsTotal; diff --git a/plugins/HTTPServer/src/GuiElements.cpp b/plugins/HTTPServer/src/GuiElements.cpp index be8df43712..5a409ad9e3 100644 --- a/plugins/HTTPServer/src/GuiElements.cpp +++ b/plugins/HTTPServer/src/GuiElements.cpp @@ -198,7 +198,7 @@ string sCreateLink(const char * pszSrvPath) ReplaceAll(sLink, "%LocalIP%", szTemp); if (sLink.find("%ExternalIP%") != sLink.npos) { - static DWORD dwExternalIpAddressGenerated = 0; + static uint32_t dwExternalIpAddressGenerated = 0; // Get the IP again after 10 minutes if (!dwExternalIpAddress || GetTickCount() - dwExternalIpAddressGenerated > 10 * 60 * 1000) { @@ -405,7 +405,7 @@ UINT_PTR CALLBACK ShareNewFileDialogHook( switch (LOWORD(wParam)) { case IDC_TOGGLE_MASK: { - DWORD dwCur; + uint32_t dwCur; SendDlgItemMessage(hDlg, IDC_ALLOWED_IP_MASK, IPM_GETADDRESS, 0, (LPARAM)&dwCur); SendDlgItemMessage(hDlg, IDC_ALLOWED_IP_MASK, IPM_SETADDRESS, 0, (LPARAM)dwCur == 0xFFFFFFFF ? 0 : 0xFFFFFFFF); return TRUE; @@ -599,7 +599,7 @@ void UpdateStatisticView(HWND hwndDlg, bool bRefressUsersOnly = false) sItem.pszText = szTmp; ListView_SetItem(hUserList, &sItem); - DWORD dwSpeed = pclCurUser->dwGetDownloadSpeed(); + uint32_t dwSpeed = pclCurUser->dwGetDownloadSpeed(); if (dwSpeed > 10000) { dwSpeed += 512; // make sure we round ot down correctly. dwSpeed /= 1024; @@ -689,12 +689,12 @@ static INT_PTR CALLBACK DlgProcStatsticView(HWND hwndDlg, UINT msg, WPARAM wPara HWND hUserList = GetDlgItem(hwndDlg, IDC_CURRENT_USERS); { // init adv. win styles - DWORD dw = ListView_GetExtendedListViewStyle(hShareList); + uint32_t dw = ListView_GetExtendedListViewStyle(hShareList); dw |= LVS_EX_HEADERDRAGDROP | LVS_EX_FULLROWSELECT; ListView_SetExtendedListViewStyle(hShareList, dw /*| LVS_EX_LABELTIP*/); } { // init adv. win styles - DWORD dw = ListView_GetExtendedListViewStyle(hUserList); + uint32_t dw = ListView_GetExtendedListViewStyle(hUserList); dw |= LVS_EX_HEADERDRAGDROP | LVS_EX_FULLROWSELECT; ListView_SetExtendedListViewStyle(hUserList, dw /*| LVS_EX_LABELTIP*/); } @@ -1172,7 +1172,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP char szKeyWord[1000]; GetDlgItemText(hwndDlg, IDC_URL_ADDRESS, szUrl, _countof(szUrl)); GetDlgItemText(hwndDlg, IDC_PAGE_KEYWORD, szKeyWord, _countof(szKeyWord)); - DWORD dwExternalIP = GetExternIP(szUrl, szKeyWord); + uint32_t dwExternalIP = GetExternIP(szUrl, szKeyWord); mir_snprintf(szKeyWord, Translate("Your external IP was detected as %d.%d.%d.%d\r\nby: %s"), SplitIpAddress(dwExternalIP), diff --git a/plugins/HTTPServer/src/HttpUser.cpp b/plugins/HTTPServer/src/HttpUser.cpp index 5b738240b0..6c7a93c509 100644 --- a/plugins/HTTPServer/src/HttpUser.cpp +++ b/plugins/HTTPServer/src/HttpUser.cpp @@ -243,7 +243,7 @@ void CLHttpUser::SendError(int iErrorCode, const char * pszError, const char * p pszDescription = pszError; char szBuf[1000]; - DWORD dwBytesToWrite = mir_snprintf(szBuf, + uint32_t dwBytesToWrite = mir_snprintf(szBuf, "HTTP/1.1 %i %s\r\n" "Date: %s\r\n" "Server: MirandaWeb/%s\r\n" @@ -294,7 +294,7 @@ void CLHttpUser::SendRedir(int iErrorCode, const char * pszError, const char * p pszDescription = pszError; char szBuff[1000]; - DWORD dwBytesToWrite = mir_snprintf(szBuff, + uint32_t dwBytesToWrite = mir_snprintf(szBuff, "HTTP/1.1 %i %s\r\n" "Date: %s\r\n" "Server: MirandaWeb/%s\r\n" @@ -390,7 +390,7 @@ bool CLHttpUser::bProcessGetRequest(char * pszRequest, bool bIsGetCommand) return false; } - DWORD dwRemoteIP = ntohl(stAddr.S_un.S_addr); + uint32_t dwRemoteIP = ntohl(stAddr.S_un.S_addr); for (CLFileShareNode * pclCur = pclFirstNode; pclCur; pclCur = pclCur->pclNext) { if ((pclCur->st.dwAllowedIP ^ dwRemoteIP) & pclCur->st.dwAllowedMask) continue; // Not an allowed IP address @@ -528,7 +528,7 @@ bool CLHttpUser::bProcessGetRequest(char * pszRequest, bool bIsGetCommand) mir_strcpy(this->szCurrentDLSrvPath, pszSrvPath); - DWORD nDataSize = GetFileSize(hFile, nullptr); + uint32_t nDataSize = GetFileSize(hFile, nullptr); dwTotalSize = nDataSize; FILETIME stFileTime; @@ -563,8 +563,8 @@ bool CLHttpUser::bProcessGetRequest(char * pszRequest, bool bIsGetCommand) lck.unlock(); - DWORD dwFileStart = 0; - DWORD dwDataToSend = nDataSize; + uint32_t dwFileStart = 0; + uint32_t dwDataToSend = nDataSize; char szETag[50]; { @@ -580,12 +580,12 @@ bool CLHttpUser::bProcessGetRequest(char * pszRequest, bool bIsGetCommand) char *pszEnd; if (pszRange[0] == '-') { // its a suffix-byte-range-spec - DWORD dwLen = strtol(pszRange + 1, &pszEnd, 10); + uint32_t dwLen = strtol(pszRange + 1, &pszEnd, 10); if (dwLen < nDataSize) dwFileStart = nDataSize - dwLen; } else { - DWORD dwLen = strtol(pszRange, &pszEnd, 10); + uint32_t dwLen = strtol(pszRange, &pszEnd, 10); if (*pszEnd == '-' && dwLen < nDataSize) { dwFileStart = dwLen; pszRange = pszEnd + 1; @@ -664,24 +664,24 @@ bool CLHttpUser::bProcessGetRequest(char * pszRequest, bool bIsGetCommand) static int nThreadCount = 0; nThreadCount++; - DWORD dwLastUpdate = GetTickCount(); - DWORD dwLastCurrentDL = 0; + uint32_t dwLastUpdate = GetTickCount(); + uint32_t dwLastCurrentDL = 0; /* dwLastDLSTickCount = dwCurTick; dwCurrentDL;*/ - //DWORD dwMaxSpeed = 8192;// Byte pr Sek - //DWORD dwMaxSpeed = 20000;// Byte pr Sek - //DWORD dwMaxSpeed = 163840;// Byte pr Sek - //DWORD dwMaxSpeed = 4096;// Byte pr Sek + //uint32_t dwMaxSpeed = 8192;// Byte pr Sek + //uint32_t dwMaxSpeed = 20000;// Byte pr Sek + //uint32_t dwMaxSpeed = 163840;// Byte pr Sek + //uint32_t dwMaxSpeed = 4096;// Byte pr Sek - DWORD dwLastResetTime = GetTickCount(); + uint32_t dwLastResetTime = GetTickCount(); int nMaxBytesToSend = nMaxUploadSpeed / nThreadCount; for (;;) { { - DWORD dwCurTick = GetTickCount(); + uint32_t dwCurTick = GetTickCount(); if (dwCurTick - dwLastUpdate >= 1000) { dwSpeed = ((dwCurrentDL - dwLastCurrentDL) * 1000) / (dwCurTick - dwLastUpdate); dwLastUpdate = dwCurTick; @@ -696,7 +696,7 @@ bool CLHttpUser::bProcessGetRequest(char * pszRequest, bool bIsGetCommand) bool bSpeedLimit = (nMaxUploadSpeed >= 0) && (bIsOnline || !bLimitOnlyWhenOnline); - DWORD dwCurOpr = sizeof(szBuf); + uint32_t dwCurOpr = sizeof(szBuf); if (bSpeedLimit) dwCurOpr = min(nMaxBytesToSend, sizeof(szBuf)); @@ -712,7 +712,7 @@ bool CLHttpUser::bProcessGetRequest(char * pszRequest, bool bIsGetCommand) if (bSpeedLimit) nMaxBytesToSend -= dwBytesToWrite; - DWORD dwSend = Netlib_Send(hConnection, szBuf, dwBytesToWrite, MSG_NODUMP); + uint32_t dwSend = Netlib_Send(hConnection, szBuf, dwBytesToWrite, MSG_NODUMP); if (dwSend == SOCKET_ERROR) break; dwCurrentDL += dwSend; @@ -724,7 +724,7 @@ bool CLHttpUser::bProcessGetRequest(char * pszRequest, bool bIsGetCommand) if (bSpeedLimit && nMaxBytesToSend <= 0) { // we have reached the limmit - DWORD dwTimeUsed = GetTickCount() - dwLastResetTime; + uint32_t dwTimeUsed = GetTickCount() - dwLastResetTime; if (dwTimeUsed < 1000) Sleep(1000 - dwTimeUsed); dwLastResetTime = GetTickCount(); diff --git a/plugins/HTTPServer/src/IndexCreation.h b/plugins/HTTPServer/src/IndexCreation.h index c3892c4308..71ffaef294 100644 --- a/plugins/HTTPServer/src/IndexCreation.h +++ b/plugins/HTTPServer/src/IndexCreation.h @@ -34,8 +34,8 @@ enum eIndexCreationMode { extern eIndexCreationMode indexCreationMode; -bool bCreateIndexXML(const char * pszRealPath, const char * pszIndexPath, const char * pszSrvPath, DWORD dwRemoteIP); -bool bCreateIndexHTML(const char * pszRealPath, const char * pszIndexPath, const char * pszSrvPath, DWORD dwRemoteIP); +bool bCreateIndexXML(const char * pszRealPath, const char * pszIndexPath, const char * pszSrvPath, uint32_t dwRemoteIP); +bool bCreateIndexHTML(const char * pszRealPath, const char * pszIndexPath, const char * pszSrvPath, uint32_t dwRemoteIP); void FreeIndexHTMLTemplate(); bool LoadIndexHTMLTemplate(); diff --git a/plugins/HTTPServer/src/IndexHTML.cpp b/plugins/HTTPServer/src/IndexHTML.cpp index 7b85a20d4e..74ba85c384 100644 --- a/plugins/HTTPServer/src/IndexHTML.cpp +++ b/plugins/HTTPServer/src/IndexHTML.cpp @@ -75,7 +75,7 @@ bool LoadIndexHTMLTemplate() DWORD dwBytesRead = 0; if (ReadFile(hFile, pszBuf, sizeof(szBuf), &dwBytesRead, nullptr) || dwBytesRead <= 0) { - while (dwBytesRead > (DWORD)(pszBuf - szBuf)) { + while (dwBytesRead > (uint32_t)(pszBuf - szBuf)) { if (*pszBuf == '[') { char* pszKeywordBegin = pszBuf + 1; bool bHasParameters = false; @@ -279,7 +279,7 @@ void FreeIndexHTMLTemplate() ///////////////////////////////////////////////////////////////////// bool bCreateIndexHTML(const char * pszRealPath, const char * pszIndexPath, - const char * pszSrvPath, DWORD /* dwRemoteIP */) + const char * pszSrvPath, uint32_t /* dwRemoteIP */) { #define RelativeJump(begin) { pszPos += *((uint16_t*)(begin+1)) & 0x7FFF; } diff --git a/plugins/HTTPServer/src/IndexXML.cpp b/plugins/HTTPServer/src/IndexXML.cpp index ea94a2cadc..33c86dfdf6 100644 --- a/plugins/HTTPServer/src/IndexXML.cpp +++ b/plugins/HTTPServer/src/IndexXML.cpp @@ -63,7 +63,7 @@ static void ReplaceSign(char* pszSrc, int MaxLength, const char pszReplace, // Developer : Houdini ///////////////////////////////////////////////////////////////////// -bool bCreateIndexXML(const char * pszRealPath, const char * pszIndexPath, const char * pszSrvPath, DWORD dwRemoteIP) +bool bCreateIndexXML(const char * pszRealPath, const char * pszIndexPath, const char * pszSrvPath, uint32_t dwRemoteIP) { char szMask[MAX_PATH + 1]; mir_snprintf(szMask, "%s*", pszRealPath); @@ -116,7 +116,7 @@ bool bCreateIndexXML(const char * pszRealPath, const char * pszIndexPath, const strncpy(szBuffer, "index.xsl", BUFFER_SIZE); } - WriteFile(hFile, szBuffer, (DWORD)mir_strlen(szBuffer), &dwBytesWritten, nullptr); + WriteFile(hFile, szBuffer, (uint32_t)mir_strlen(szBuffer), &dwBytesWritten, nullptr); WriteFile(hFile, szXmlHeader2, sizeof(szXmlHeader2) - 1, &dwBytesWritten, nullptr); @@ -209,7 +209,7 @@ bool bCreateIndexXML(const char * pszRealPath, const char * pszIndexPath, const pszExt++; } - DWORD dwFileSize = 0; + uint32_t dwFileSize = 0; FILETIME ftFileCreateTime; FILETIME ftFileAccessTime; FILETIME ftFileModifyTime; diff --git a/plugins/HTTPServer/src/main.cpp b/plugins/HTTPServer/src/main.cpp index e8f227172d..8a6342f025 100644 --- a/plugins/HTTPServer/src/main.cpp +++ b/plugins/HTTPServer/src/main.cpp @@ -70,9 +70,9 @@ static HGENMENU hAcceptConnectionsMenuItem = nullptr; char szPluginPath[MAX_PATH] = { 0 }; int nPluginPathLen = 0; -DWORD dwLocalIpAddress = 0; -DWORD dwLocalPortUsed = 0; -DWORD dwExternalIpAddress = 0; +uint32_t dwLocalIpAddress = 0; +uint32_t dwLocalPortUsed = 0; +uint32_t dwExternalIpAddress = 0; int nMaxUploadSpeed = -1; int nMaxConnectionsTotal = -1; @@ -139,7 +139,7 @@ bool bWriteToFile(HANDLE hFile, const char * pszSrc, int nLen = -1) if (nLen < 0) nLen = (int)mir_strlen(pszSrc); DWORD dwBytesWritten; - return WriteFile(hFile, pszSrc, nLen, &dwBytesWritten, nullptr) && (dwBytesWritten == (DWORD)nLen); + return WriteFile(hFile, pszSrc, nLen, &dwBytesWritten, nullptr) && (dwBytesWritten == (uint32_t)nLen); } @@ -189,7 +189,7 @@ void LogEvent(const char * pszTitle, const char * pszLog) // Member Function : dwReadIPAddress // Type : Global // Parameters : pszStr - ? -// Returns : DWORD +// Returns : uint32_t // Description : // // References : - @@ -198,9 +198,9 @@ void LogEvent(const char * pszTitle, const char * pszLog) // Developer : KN ///////////////////////////////////////////////////////////////////// -DWORD dwReadIPAddress(char * pszStr, bool &bError) +uint32_t dwReadIPAddress(char * pszStr, bool &bError) { - DWORD ip = 0; + uint32_t ip = 0; char *pszEnd; for (int n = 0; n < 4; n++) { int nVal = strtol(pszStr, &pszEnd, 10); @@ -245,11 +245,11 @@ bool bReadConfigurationFile() bool bEof = false; while (!bEof) { - DWORD dwBytesInBuffer = 0; + uint32_t dwBytesInBuffer = 0; // move rest of buffer to front if (pszCurPos && pszCurPos != szBuf) { - dwBytesInBuffer = DWORD(sizeof(szBuf) - (pszCurPos - szBuf)); + dwBytesInBuffer = uint32_t(sizeof(szBuf) - (pszCurPos - szBuf)); memmove(szBuf, pszCurPos, dwBytesInBuffer * sizeof(wchar_t)); } @@ -346,7 +346,7 @@ bool bWriteConfigurationFile() if (WriteFile(hFile, szXmlHeader, sizeof(szXmlHeader) - 1, &dwBytesWriten, nullptr)) { CLFileShareNode *pclCur = pclFirstNode; while (pclCur) { - DWORD dwBytesToWrite = mir_snprintf(szBuf, szXmlData, + uint32_t dwBytesToWrite = mir_snprintf(szBuf, szXmlData, pclCur->st.pszSrvPath, pclCur->pszOrigRealPath, pclCur->st.nMaxDownloads, @@ -566,7 +566,7 @@ void __cdecl HandleNewConnection(CLHttpUser *pclUser) // Developer : KN ///////////////////////////////////////////////////////////////////// -void ConnectionOpen(HNETLIBCONN hNewConnection, DWORD dwRemoteIP, void*) +void ConnectionOpen(HNETLIBCONN hNewConnection, uint32_t dwRemoteIP, void*) { in_addr stAddr; stAddr.S_un.S_addr = htonl(dwRemoteIP); -- cgit v1.2.3