summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/HTTPServer/src/FileShareNode.cpp5
-rw-r--r--plugins/HTTPServer/src/GuiElements.cpp14
-rw-r--r--plugins/HTTPServer/src/HttpUser.cpp160
-rw-r--r--plugins/HTTPServer/src/IndexXML.cpp6
-rw-r--r--plugins/HTTPServer/src/main.cpp13
5 files changed, 98 insertions, 100 deletions
diff --git a/plugins/HTTPServer/src/FileShareNode.cpp b/plugins/HTTPServer/src/FileShareNode.cpp
index cb5c3144b9..988c98fe42 100644
--- a/plugins/HTTPServer/src/FileShareNode.cpp
+++ b/plugins/HTTPServer/src/FileShareNode.cpp
@@ -86,7 +86,7 @@ void CLShareUser::CloseSocket() {
int nBytesRead;
do {
char szBuf[100];
- nBytesRead = Netlib_Recv(hConnection, szBuf, sizeof(szBuf), 0);
+ nBytesRead = Netlib_Recv(hConnection, szBuf, SIZEOF(szBuf), 0);
} while (nBytesRead && nBytesRead != SOCKET_ERROR);
//shutdown( s, SD_RECEIVE );
}
@@ -147,7 +147,8 @@ CLFileShareNode::CLFileShareNode(TCHAR *pszSrvPath, TCHAR *pszRealPath)
// Developer : KN
/////////////////////////////////////////////////////////////////////
-CLFileShareNode::CLFileShareNode(STFileShareInfo * pstInfo) {
+CLFileShareNode::CLFileShareNode(STFileShareInfo * pstInfo)
+{
memset(&st, 0, sizeof(STFileShareInfo));
st.lStructSize = sizeof(STFileShareInfo);
pclNext = NULL;
diff --git a/plugins/HTTPServer/src/GuiElements.cpp b/plugins/HTTPServer/src/GuiElements.cpp
index 244ec26e8c..b4f2e1428a 100644
--- a/plugins/HTTPServer/src/GuiElements.cpp
+++ b/plugins/HTTPServer/src/GuiElements.cpp
@@ -95,8 +95,8 @@ void ReplaceAll(tstring &sSrc, const TCHAR * pszReplace, const TCHAR * pszNew) {
tstring DBGetString(MCONTACT hContact, const char *szModule, const char *szSetting, const TCHAR * pszError) {
tstring ret;
DBVARIANT dbv = {0};
- if (! db_get(hContact, szModule, szSetting, &dbv)) {
- if (dbv.type != DBVT_ASCIIZ) {
+ if (!db_get(hContact, szModule, szSetting, &dbv)) {
+ if (dbv.type != DBVT_TCHAR) {
MessageBox(NULL, _T("DB: Attempt to get wrong type of value, string"), MSG_BOX_TITEL, MB_OK);
ret = pszError;
} else {
@@ -146,8 +146,7 @@ void UpdateStatisticsView() {
unsigned long GetExternIP(const char *szURL, const char *szPattern) {
HCURSOR hPrevCursor = ::SetCursor(::LoadCursor(0, IDC_WAIT));
- NETLIBHTTPREQUEST nlhr;
- ZeroMemory(&nlhr, sizeof(nlhr));
+ NETLIBHTTPREQUEST nlhr = { 0 };
nlhr.cbSize = sizeof(nlhr);
nlhr.requestType = REQUEST_GET;
nlhr.flags = NLHRF_DUMPASTEXT;
@@ -875,7 +874,7 @@ static INT_PTR CALLBACK DlgProcStatsticView(HWND hwndDlg, UINT msg, WPARAM wPara
STFileShareInfo stShareInfo = {0};
stShareInfo.lStructSize = sizeof(STFileShareInfo);
stShareInfo.pszSrvPath = szTmp;
- stShareInfo.dwMaxSrvPath = sizeof(szTmp);
+ stShareInfo.dwMaxSrvPath = SIZEOF(szTmp);
sItem.iItem = ListView_GetNextItem(hShareList, -1, LVIS_SELECTED);
while (sItem.iItem != -1) {
@@ -1490,10 +1489,9 @@ void InitGuiElements() {
return;
}
- CLISTMENUITEM mi;
- ZeroMemory(&mi, sizeof(mi));
+ CLISTMENUITEM mi = { 0 };
mi.cbSize = sizeof(mi);
- mi.flags = 0;
+ mi.flags = CMIF_TCHAR;
mi.pszContactOwner = NULL; //all contacts
mi.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_SHARE_NEW_FILE));
mi.position = -2000019955;
diff --git a/plugins/HTTPServer/src/HttpUser.cpp b/plugins/HTTPServer/src/HttpUser.cpp
index d84826cc8c..ad47914ba6 100644
--- a/plugins/HTTPServer/src/HttpUser.cpp
+++ b/plugins/HTTPServer/src/HttpUser.cpp
@@ -223,37 +223,37 @@ bool CLHttpUser::bReadGetParameters(TCHAR *pszRequest) {
void CLHttpUser::SendError(int iErrorCode, const TCHAR *pszError, const TCHAR *pszDescription)
{
- char szCurTime[ 100 ];
+ TCHAR szCurTime[100];
time_t ltime;
time(&ltime);
- strftime(szCurTime, sizeof(szCurTime), "%a, %d %b %Y %H:%M:%S GMT", gmtime(&ltime));
+ _tcsftime(szCurTime, SIZEOF(szCurTime), _T("%a, %d %b %Y %H:%M:%S GMT"), gmtime(&ltime));
if (!pszDescription)
pszDescription = pszError;
- char szBuf[1000];
- DWORD dwBytesToWrite = mir_snprintf(szBuf, sizeof(szBuf),
- "HTTP/1.1 %i %s\r\n"
- "Date: %s\r\n"
- "Server: MirandaWeb/%s\r\n"
- "Transfer-Encoding: chunked\r\n"
- "Content-Type: text/html; charset=iso-8859-1\r\n"
- "\r\n"
- "10f\r\n"
- "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n"
- "<HTML><HEAD>\n"
- "<TITLE>%i %s</TITLE>\n"
- "</HEAD><BODY>\n"
- "<H1>%s</H1>\n"
- "%s<P>\n"
- "<HR>\n"
- "<ADDRESS>MirandaWeb/%s</ADDRESS>\n"
- "</BODY></HTML>\n"
- "\r\n"
- "\r\n",
+ TCHAR szBuf[1000];
+ DWORD dwBytesToWrite = mir_sntprintf(szBuf, SIZEOF(szBuf),
+ _T("HTTP/1.1 %i %s\r\n")
+ _T("Date: %s\r\n")
+ _T("Server: MirandaWeb/%s\r\n")
+ _T("Transfer-Encoding: chunked\r\n")
+ _T("Content-Type: text/html; charset=iso-8859-1\r\n")
+ _T("\r\n")
+ _T("10f\r\n")
+ _T("<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n")
+ _T("<HTML><HEAD>\n")
+ _T("<TITLE>%i %s</TITLE>\n")
+ _T("</HEAD><BODY>\n")
+ _T("<H1>%s</H1>\n")
+ _T("%s<P>\n")
+ _T("<HR>\n")
+ _T("<ADDRESS>MirandaWeb/%s</ADDRESS>\n")
+ _T("</BODY></HTML>\n")
+ _T("\r\n")
+ _T("\r\n"),
iErrorCode, pszError, szCurTime, PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM), iErrorCode, pszError, pszError, pszDescription, PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM));
- Netlib_Send(hConnection, szBuf, dwBytesToWrite, 0);
+ Netlib_Send(hConnection, _T2A(szBuf), dwBytesToWrite, 0);
}
/////////////////////////////////////////////////////////////////////
@@ -274,38 +274,38 @@ void CLHttpUser::SendError(int iErrorCode, const TCHAR *pszError, const TCHAR *p
void CLHttpUser::SendRedir(int iErrorCode, const TCHAR *pszError, const TCHAR *pszDescription, const TCHAR *pszRedirect)
{
- char szCurrTime[ 100 ];
+ TCHAR szCurrTime[100];
time_t ltime;
time(&ltime);
- strftime(szCurrTime, sizeof(szCurrTime), "%a, %d %b %Y %H:%M:%S GMT", gmtime(&ltime));
+ _tcsftime(szCurrTime, SIZEOF(szCurrTime), _T("%a, %d %b %Y %H:%M:%S GMT"), gmtime(&ltime));
if (!pszDescription)
pszDescription = pszError;
- char szBuff[1000];
- DWORD dwBytesToWrite = mir_snprintf(szBuff, sizeof(szBuff),
- "HTTP/1.1 %i %s\r\n"
- "Date: %s\r\n"
- "Server: MirandaWeb/%s\r\n"
- "Location: %s/\r\n"
- "Transfer-Encoding: chunked\r\n"
- "Content-Type: text/html; charset=iso-8859-1\r\n"
- "\r\n"
- "10f\r\n"
- "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n"
- "<HTML><HEAD>\n"
- "<TITLE>%i %s</TITLE>\n"
- "</HEAD><BODY>\n"
- "<H1>%s</H1>\n"
- "%s<P>\n"
- "<HR>\n"
- "<ADDRESS>MirandaWeb/%s</ADDRESS>\n"
- "</BODY></HTML>\n"
- "\r\n"
- "\r\n",
+ TCHAR szBuff[1000];
+ DWORD dwBytesToWrite = mir_sntprintf(szBuff, SIZEOF(szBuff),
+ _T("HTTP/1.1 %i %s\r\n")
+ _T("Date: %s\r\n")
+ _T("Server: MirandaWeb/%s\r\n")
+ _T("Location: %s/\r\n")
+ _T("Transfer-Encoding: chunked\r\n")
+ _T("Content-Type: text/html; charset=iso-8859-1\r\n")
+ _T("\r\n")
+ _T("10f\r\n")
+ _T("<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n")
+ _T("<HTML><HEAD>\n")
+ _T("<TITLE>%i %s</TITLE>\n")
+ _T("</HEAD><BODY>\n")
+ _T("<H1>%s</H1>\n")
+ _T("%s<P>\n")
+ _T("<HR>\n")
+ _T("<ADDRESS>MirandaWeb/%s</ADDRESS>\n")
+ _T("</BODY></HTML>\n")
+ _T("\r\n")
+ _T("\r\n"),
iErrorCode, pszError, szCurrTime, PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM), pszRedirect, iErrorCode, pszError, pszError, pszDescription, PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM));
- Netlib_Send(hConnection, szBuff, dwBytesToWrite, 0);
+ Netlib_Send(hConnection, _T2A(szBuff), dwBytesToWrite, 0);
}
/////////////////////////////////////////////////////////////////////
@@ -515,10 +515,10 @@ bool CLHttpUser::bProcessGetRequest(TCHAR *pszRequest, bool bIsGetCommand) {
FILETIME stFileTime;
GetFileTime(hFile, NULL, NULL, &stFileTime);
- char szCurTime[ 100 ];
+ TCHAR szCurTime[100];
time_t ltime;
time(&ltime);
- strftime(szCurTime, sizeof(szCurTime), "%a, %d %b %Y %H:%M:%S GMT", gmtime(&ltime));
+ _tcsftime(szCurTime, SIZEOF(szCurTime), _T("%a, %d %b %Y %H:%M:%S GMT"), gmtime(&ltime));
TCHAR szFileTime[100];
FileTimeToUnixTime(&stFileTime, &ltime);
@@ -599,7 +599,7 @@ bool CLHttpUser::bProcessGetRequest(TCHAR *pszRequest, bool bIsGetCommand) {
// Ethernet, IP and TCP headers use some of this space and leaves 1460 bytes
// for data transfer.
// We will use a multiply of this to always send optimal sized packages.
- char szBuf[1460 * 4];
+ TCHAR szBuf[1460 * 4];
if (dwFileStart > 0 || dwDataToSend != nDataSize) {
if (SetFilePointer(hFile, dwFileStart, NULL, FILE_BEGIN) == INVALID_SET_FILE_POINTER) {
@@ -607,41 +607,41 @@ bool CLHttpUser::bProcessGetRequest(TCHAR *pszRequest, bool bIsGetCommand) {
return true;
}
- const char szHttpPartial[] = "HTTP/1.1 206 Partial Content\r\n"
- "Connection: Keep-Alive\r\n"
- "Date: %s\r\n"
- "Server: MirandaWeb/%s\r\n"
- "Accept-Ranges: bytes\r\n"
- "ETag: %s\r\n"
- "Content-Length: %d\r\n"
- "Content-Type: %s\r\n"
- "Content-Range: bytes %d-%d/%d\r\n"
- "Last-Modified: %s\r\n"
- "\r\n";
-
- dwBytesToWrite = mir_snprintf(szBuf, sizeof(szBuf), szHttpPartial,
+ const TCHAR szHttpPartial[] = _T("HTTP/1.1 206 Partial Content\r\n")
+ _T("Connection: Keep-Alive\r\n")
+ _T("Date: %s\r\n")
+ _T("Server: MirandaWeb/%s\r\n")
+ _T("Accept-Ranges: bytes\r\n")
+ _T("ETag: %s\r\n")
+ _T("Content-Length: %d\r\n")
+ _T("Content-Type: %s\r\n")
+ _T("Content-Range: bytes %d-%d/%d\r\n")
+ _T("Last-Modified: %s\r\n")
+ _T("\r\n");
+
+ dwBytesToWrite = mir_sntprintf(szBuf, SIZEOF(szBuf), szHttpPartial,
szCurTime,
PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
szETag,
dwDataToSend,
- _T2A(pszGetMimeType(pszRealPath)),
+ pszGetMimeType(pszRealPath),
dwFileStart,
(dwFileStart + dwDataToSend - 1),
nDataSize,
szFileTime);
} else {
- const char szHttpOk[] = "HTTP/1.1 200 OK\r\n"
- "Connection: Keep-Alive\r\n"
- "Date: %s\r\n"
- "Server: MirandaWeb/%s\r\n"
- "Accept-Ranges: bytes\r\n"
- "ETag: %s\r\n"
- "Content-Length: %d\r\n"
- "Content-Type: %s\r\n"
- "Last-Modified: %s\r\n"
- "\r\n";
-
- dwBytesToWrite = mir_snprintf(szBuf, sizeof(szBuf), szHttpOk,
+ const TCHAR szHttpOk[] = _T("HTTP/1.1 200 OK\r\n")
+ _T("Connection: Keep-Alive\r\n")
+ _T("Date: %s\r\n")
+ _T("Server: MirandaWeb/%s\r\n")
+ _T("Accept-Ranges: bytes\r\n")
+ _T("ETag: %s\r\n")
+ _T("Content-Length: %d\r\n")
+ _T("Content-Type: %s\r\n")
+ _T("Last-Modified: %s\r\n")
+ _T("\r\n");
+
+ dwBytesToWrite = mir_sntprintf(szBuf, SIZEOF(szBuf), szHttpOk,
szCurTime,
PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
szETag,
@@ -650,7 +650,7 @@ bool CLHttpUser::bProcessGetRequest(TCHAR *pszRequest, bool bIsGetCommand) {
szFileTime);
}
- Netlib_Send(hConnection, szBuf, dwBytesToWrite, 0);
+ Netlib_Send(hConnection, _T2A(szBuf), dwBytesToWrite, 0);
if (bIsGetCommand) {
static int nThreadCount = 0;
@@ -688,9 +688,9 @@ bool CLHttpUser::bProcessGetRequest(TCHAR *pszRequest, bool bIsGetCommand) {
bool bSpeedLimit = (nMaxUploadSpeed >= 0) && (bIsOnline || !bLimitOnlyWhenOnline);
- DWORD dwCurOpr = sizeof(szBuf);
+ DWORD dwCurOpr = SIZEOF(szBuf);
if (bSpeedLimit)
- dwCurOpr = min(nMaxBytesToSend, sizeof(szBuf));
+ dwCurOpr = min(nMaxBytesToSend, SIZEOF(szBuf));
if (!ReadFile(hFile, szBuf, dwCurOpr, &dwBytesToWrite, NULL))
break;
@@ -704,7 +704,7 @@ bool CLHttpUser::bProcessGetRequest(TCHAR *pszRequest, bool bIsGetCommand) {
if (bSpeedLimit)
nMaxBytesToSend -= dwBytesToWrite;
- DWORD dwSend = Netlib_Send(hConnection, szBuf, dwBytesToWrite, MSG_NODUMP);
+ DWORD dwSend = Netlib_Send(hConnection, _T2A(szBuf), dwBytesToWrite, MSG_NODUMP);
if (dwSend == SOCKET_ERROR)
break;
dwCurrentDL += dwSend;
diff --git a/plugins/HTTPServer/src/IndexXML.cpp b/plugins/HTTPServer/src/IndexXML.cpp
index b34ef3c5b0..098725b9a8 100644
--- a/plugins/HTTPServer/src/IndexXML.cpp
+++ b/plugins/HTTPServer/src/IndexXML.cpp
@@ -99,7 +99,7 @@ bool bCreateIndexXML(const TCHAR *pszRealPath, const TCHAR *pszIndexPath, const
_tcscpy(szFileName, pszTemp + 1);
// Write Header
- WriteFile(hFile, szXmlHeader1, sizeof(szXmlHeader1) - 1, &dwBytesWritten, NULL);
+ WriteFile(hFile, szXmlHeader1, SIZEOF(szXmlHeader1) - 1, &dwBytesWritten, NULL);
// check if a index.xsl exists in the same directory otherwise use the global
_tcscpy(szMask, pszRealPath);
@@ -118,7 +118,7 @@ bool bCreateIndexXML(const TCHAR *pszRealPath, const TCHAR *pszIndexPath, const
WriteFile(hFile, szBuffer, (DWORD)_tcslen(szBuffer), &dwBytesWritten, NULL);
- WriteFile(hFile, szXmlHeader2, sizeof(szXmlHeader2) - 1, &dwBytesWritten, NULL);
+ WriteFile(hFile, szXmlHeader2, SIZEOF(szXmlHeader2) - 1, &dwBytesWritten, NULL);
// Write dirname
ReplaceSign(szFileName, MAX_PATH, '&', _T("&amp;"));
@@ -246,7 +246,7 @@ bool bCreateIndexXML(const TCHAR *pszRealPath, const TCHAR *pszIndexPath, const
}
}
- WriteFile(hFile, szXmlTail, sizeof(szXmlTail) - 1, &dwBytesWritten, NULL);
+ WriteFile(hFile, szXmlTail, SIZEOF(szXmlTail) - 1, &dwBytesWritten, NULL);
SetEndOfFile(hFile);
CloseHandle(hFile);
diff --git a/plugins/HTTPServer/src/main.cpp b/plugins/HTTPServer/src/main.cpp
index 7f0099609a..405dcf1816 100644
--- a/plugins/HTTPServer/src/main.cpp
+++ b/plugins/HTTPServer/src/main.cpp
@@ -305,7 +305,7 @@ bool bReadConfigurationFile()
}
// refill buffer
- if (!bEof && pszCurPos - szBuf > sizeof(szBuf) / 2)
+ if (!bEof && pszCurPos - szBuf > SIZEOF(szBuf) / 2)
break;
}
}
@@ -343,7 +343,7 @@ bool bWriteConfigurationFile()
}
DWORD dwBytesWriten = 0;
- if (! WriteFile(hFile, szXmlHeader, sizeof(szXmlHeader) - 1, &dwBytesWriten, NULL)) {
+ if (! WriteFile(hFile, szXmlHeader, SIZEOF(szXmlHeader) - 1, &dwBytesWriten, NULL)) {
TCHAR temp[200];
mir_sntprintf(temp, SIZEOF(temp), _T("%s%s"), TranslateT("Failed to write xml header to file "), szConfigFile);
MessageBox(NULL, temp, MSG_BOX_TITEL, MB_OK);
@@ -366,7 +366,7 @@ bool bWriteConfigurationFile()
pclCur = pclCur->pclNext;
}
- if (! WriteFile(hFile, szXmlTail, sizeof(szXmlTail) - 1, &dwBytesWriten, NULL)) {
+ if (! WriteFile(hFile, szXmlTail, SIZEOF(szXmlTail) - 1, &dwBytesWriten, NULL)) {
TCHAR temp[200];
mir_sntprintf(temp, SIZEOF(temp), _T("%s%s"), TranslateT("Failed to write xml tail to file "), szConfigFile);
MessageBox(NULL, temp, MSG_BOX_TITEL, MB_OK);
@@ -627,7 +627,7 @@ static int nProtoAck(WPARAM /*wParam*/, LPARAM lParam) {
INT_PTR nToggelAcceptConnections(WPARAM wparam, LPARAM /*lparam*/) {
CLISTMENUITEM mi = { sizeof(mi) };
- mi.flags = CMIM_NAME | CMIM_ICON;
+ mi.flags = CMIF_TCHAR | CMIM_NAME | CMIM_ICON;
if (!hDirectBoundPort) {
NETLIBUSERSETTINGS nus = { 0 };
@@ -723,11 +723,10 @@ int MainInit(WPARAM /*wparam*/, LPARAM /*lparam*/) {
TCHAR szRealPath[MAX_PATH];
TCHAR szSrvPath[MAX_PATH] = {0};
- STFileShareInfo share;
+ STFileShareInfo share = { 0 };
const TCHAR** p = pszDefaultShares;
while (*p) {
- memset(&share, 0, sizeof(share));
share.lStructSize = sizeof(share);
share.dwAllowedIP = 0;
share.dwAllowedMask = 0;
@@ -903,7 +902,7 @@ int nSystemShutdown(WPARAM /*wparam*/, LPARAM /*lparam*/) {
return 1;
}
- if(CallService(MS_DB_GETPROFILEPATH,MAX_PATH,(LPARAM)szPluginPath))
+ if(CallService(MS_DB_GETPROFILEPATHT,MAX_PATH,(LPARAM)szPluginPath))
{
MessageBox(NULL, _T("Failed to retrieve plugin path."), MSG_BOX_TITEL, MB_OK);
return 1;