summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKirill Volinsky <mataes2007@gmail.com>2014-06-19 20:03:37 +0000
committerKirill Volinsky <mataes2007@gmail.com>2014-06-19 20:03:37 +0000
commitee8b6d3e7acadbd3bd87a1c3cfb06e7b7af88c64 (patch)
tree709e1c4b33d035e228091cf8bc3edbd6e2159a53
parent4b546fcda174b787db34d6c95f122f21fb6c99b3 (diff)
revert unicode
git-svn-id: http://svn.miranda-ng.org/main/trunk@9543 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--plugins/HTTPServer/HTTPServer_10.vcxproj8
-rw-r--r--plugins/HTTPServer/HTTPServer_12.vcxproj8
-rw-r--r--plugins/HTTPServer/src/FileShareNode.cpp30
-rw-r--r--plugins/HTTPServer/src/FileShareNode.h14
-rw-r--r--plugins/HTTPServer/src/Glob.h4
-rw-r--r--plugins/HTTPServer/src/GuiElements.cpp275
-rw-r--r--plugins/HTTPServer/src/GuiElements.h4
-rw-r--r--plugins/HTTPServer/src/HttpUser.cpp314
-rw-r--r--plugins/HTTPServer/src/HttpUser.h26
-rw-r--r--plugins/HTTPServer/src/IndexCreation.h6
-rw-r--r--plugins/HTTPServer/src/IndexHTML.cpp134
-rw-r--r--plugins/HTTPServer/src/IndexXML.cpp154
-rw-r--r--plugins/HTTPServer/src/MimeHandling.cpp43
-rw-r--r--plugins/HTTPServer/src/MimeHandling.h22
-rw-r--r--plugins/HTTPServer/src/main.cpp184
15 files changed, 610 insertions, 616 deletions
diff --git a/plugins/HTTPServer/HTTPServer_10.vcxproj b/plugins/HTTPServer/HTTPServer_10.vcxproj
index 174c02160d..222a04b0a1 100644
--- a/plugins/HTTPServer/HTTPServer_10.vcxproj
+++ b/plugins/HTTPServer/HTTPServer_10.vcxproj
@@ -25,21 +25,21 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
- <CharacterSet>Unicode</CharacterSet>
+ <CharacterSet>MultiByte</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
- <CharacterSet>Unicode</CharacterSet>
+ <CharacterSet>MultiByte</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
- <CharacterSet>Unicode</CharacterSet>
+ <CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
- <CharacterSet>Unicode</CharacterSet>
+ <CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
diff --git a/plugins/HTTPServer/HTTPServer_12.vcxproj b/plugins/HTTPServer/HTTPServer_12.vcxproj
index 4887b850de..6b65dc8653 100644
--- a/plugins/HTTPServer/HTTPServer_12.vcxproj
+++ b/plugins/HTTPServer/HTTPServer_12.vcxproj
@@ -25,24 +25,24 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
- <CharacterSet>Unicode</CharacterSet>
+ <CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v120_xp</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
- <CharacterSet>Unicode</CharacterSet>
+ <CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v120_xp</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
- <CharacterSet>Unicode</CharacterSet>
+ <CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v120_xp</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
- <CharacterSet>Unicode</CharacterSet>
+ <CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v120_xp</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
diff --git a/plugins/HTTPServer/src/FileShareNode.cpp b/plugins/HTTPServer/src/FileShareNode.cpp
index 988c98fe42..a5b57ecc14 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 );
}
@@ -124,8 +124,7 @@ DWORD CLShareUser::dwGetDownloadSpeed() {
// Developer : KN
/////////////////////////////////////////////////////////////////////
-CLFileShareNode::CLFileShareNode(TCHAR *pszSrvPath, TCHAR *pszRealPath)
-{
+CLFileShareNode::CLFileShareNode(char * pszSrvPath, char * pszRealPath) {
memset(&st, 0, sizeof(STFileShareInfo));
st.lStructSize = sizeof(STFileShareInfo);
pclNext = NULL;
@@ -147,8 +146,7 @@ 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;
@@ -197,8 +195,7 @@ CLFileShareNode::~CLFileShareNode() {
// Developer : KN
/////////////////////////////////////////////////////////////////////
-bool CLFileShareNode::bSetPaths(TCHAR *pszSrvPath, TCHAR *pszRealPath)
-{
+bool CLFileShareNode::bSetPaths(char * pszSrvPath, char * pszRealPath) {
/* This might be a problem !!
if( nDownloadsInProgress > 0 )
return false;
@@ -210,25 +207,25 @@ bool CLFileShareNode::bSetPaths(TCHAR *pszSrvPath, TCHAR *pszRealPath)
delete [] st.pszSrvPath;
delete [] st.pszRealPath;
- st.dwMaxSrvPath = (int)_tcslen(pszSrvPath) + 1;
- st.pszSrvPath = new TCHAR[st.dwMaxSrvPath];
- _tcscpy(st.pszSrvPath, pszSrvPath);
+ st.dwMaxSrvPath = (int)strlen(pszSrvPath) + 1;
+ st.pszSrvPath = new char[ st.dwMaxSrvPath ];
+ strcpy(st.pszSrvPath, pszSrvPath);
- int nRealLen = (int)_tcslen(pszRealPath);
+ int nRealLen = (int)strlen(pszRealPath);
if (nRealLen <= 2 || !(pszRealPath[1] == ':' ||
(pszRealPath[0] == '\\' && pszRealPath[1] == '\\'))) {
// Relative path
// we will prepend plugin path to avoid problems
st.dwMaxRealPath = nPluginPathLen + nRealLen + 1;
- st.pszRealPath = new TCHAR[st.dwMaxRealPath];
- _tcscpy(st.pszRealPath, szPluginPath);
+ st.pszRealPath = new char[ st.dwMaxRealPath ];
+ strcpy(st.pszRealPath, szPluginPath);
pszOrigRealPath = &st.pszRealPath[nPluginPathLen];
} else {
st.dwMaxRealPath = nRealLen + 1;
- st.pszRealPath = new TCHAR[st.dwMaxRealPath];
+ st.pszRealPath = new char[ st.dwMaxRealPath ];
pszOrigRealPath = st.pszRealPath;
}
- _tcscpy(pszOrigRealPath, pszRealPath);
+ strcpy(pszOrigRealPath, pszRealPath);
return true;
}
@@ -245,8 +242,7 @@ bool CLFileShareNode::bSetPaths(TCHAR *pszSrvPath, TCHAR *pszRealPath)
// Developer : KN
/////////////////////////////////////////////////////////////////////
-bool CLFileShareNode::bSetInfo(STFileShareInfo *pstInfo)
-{
+bool CLFileShareNode::bSetInfo(STFileShareInfo * pstInfo) {
if (! bSetPaths(pstInfo->pszSrvPath, pstInfo->pszRealPath))
return false;
if (pstInfo->nMaxDownloads < -1)
diff --git a/plugins/HTTPServer/src/FileShareNode.h b/plugins/HTTPServer/src/FileShareNode.h
index 304d463eb3..706a31f093 100644
--- a/plugins/HTTPServer/src/FileShareNode.h
+++ b/plugins/HTTPServer/src/FileShareNode.h
@@ -29,10 +29,10 @@ public:
in_addr stAddr;
DWORD dwCurrentDL;
DWORD dwTotalSize;
- TCHAR szCurrentDLSrvPath[MAX_PATH];
+ char szCurrentDLSrvPath[MAX_PATH];
virtual DWORD dwGetDownloadSpeed();
virtual bool bCloseTransfers() = NULL;
- virtual const TCHAR * pszCustomInfo() = NULL;
+ virtual const char * pszCustomInfo() = NULL;
void CloseSocket();
protected:
HANDLE hConnection;
@@ -41,11 +41,11 @@ protected:
class CLFileShareNode {
public://, DWORD dwAllowedIP, DWORD dwAllowedMask, int nMaxDownloads );
- CLFileShareNode(TCHAR *pszSrvPath, TCHAR *pszRealPath);
- CLFileShareNode(STFileShareInfo *pstInfo);
+ CLFileShareNode(char * pszSrvPath, char * pszRealPath);
+ CLFileShareNode(STFileShareInfo * pstInfo);
~CLFileShareNode();
- bool bSetPaths(TCHAR *pszSrvPath, TCHAR *pszRealPath);
- bool bSetInfo(STFileShareInfo *pstInfo);
+ bool bSetPaths(char * pszSrvPath, char * pszRealPath);
+ bool bSetInfo(STFileShareInfo * pstInfo);
int nGetSrvPathLen() {
return st.dwMaxSrvPath -1;
}
@@ -54,7 +54,7 @@ public://, DWORD dwAllowedIP, DWORD dwAllowedMask, int nMaxDownloads );
}
STFileShareInfo st;
- TCHAR *pszOrigRealPath;
+ char *pszOrigRealPath;
CLFileShareNode * pclNext;
//CLHttpUser * pclAddHttpUser( HANDLE hConnection, in_addr stAddr );
//bool bRemoveHttpUser( CLHttpUser * pclUser );
diff --git a/plugins/HTTPServer/src/Glob.h b/plugins/HTTPServer/src/Glob.h
index ce61f1dc1d..f64d28d950 100644
--- a/plugins/HTTPServer/src/Glob.h
+++ b/plugins/HTTPServer/src/Glob.h
@@ -65,10 +65,10 @@ extern HANDLE hNetlibUser;
extern bool bShutdownInProgress;
bool bWriteConfigurationFile();
-void LogEvent(const TCHAR * pszTitle, const TCHAR * pszLog);
+void LogEvent(const char * pszTitle, const char * pszLog);
bool bOpenLogFile();
-extern TCHAR szPluginPath[MAX_PATH];
+extern char szPluginPath[MAX_PATH];
extern int nPluginPathLen;
extern DWORD dwLocalIpAddress;
diff --git a/plugins/HTTPServer/src/GuiElements.cpp b/plugins/HTTPServer/src/GuiElements.cpp
index a3b60ea144..9423afc180 100644
--- a/plugins/HTTPServer/src/GuiElements.cpp
+++ b/plugins/HTTPServer/src/GuiElements.cpp
@@ -37,13 +37,13 @@ HANDLE hMainThread;
bool bShowPopups = true;
-#define szDefaultExternalSrvName _T("http://%ExternalIP%:%Port%%SrvPath%")
+#define szDefaultExternalSrvName "http://%ExternalIP%:%Port%%SrvPath%"
-#define szDefaultUrlAddress _T("http://checkip.dyndns.org")
-#define szDefaultPageKeyword _T("Current IP Address: ")
+#define szDefaultUrlAddress "http://checkip.dyndns.org"
+#define szDefaultPageKeyword "Current IP Address: "
-tstring sUrlAddress = szDefaultUrlAddress;
-tstring sPageKeyword = szDefaultPageKeyword;
+string sUrlAddress = szDefaultUrlAddress;
+string sPageKeyword = szDefaultPageKeyword;
/////////////////////////////////////////////////////////////////////
@@ -61,17 +61,17 @@ tstring sPageKeyword = szDefaultPageKeyword;
// Developer : KN
/////////////////////////////////////////////////////////////////////
-void ReplaceAll(tstring &sSrc, const TCHAR * pszReplace, const tstring &sNew) {
- tstring::size_type nCur = 0;
- int nRepalceLen = (int)_tcslen(pszReplace);
+void ReplaceAll(string &sSrc, const char * pszReplace, const string &sNew) {
+ string::size_type nCur = 0;
+ int nRepalceLen = (int)strlen(pszReplace);
while ((nCur = sSrc.find(pszReplace, nCur)) != sSrc.npos) {
sSrc.replace(nCur, nRepalceLen, sNew);
nCur += sNew.size();
}
}
-void ReplaceAll(tstring &sSrc, const TCHAR * pszReplace, const TCHAR * pszNew) {
- tstring sNew = pszNew;
+void ReplaceAll(string &sSrc, const char * pszReplace, const char * pszNew) {
+ string sNew = pszNew;
ReplaceAll(sSrc, pszReplace, sNew);
}
@@ -92,14 +92,20 @@ void ReplaceAll(tstring &sSrc, const TCHAR * pszReplace, const TCHAR * pszNew) {
// Developer : KN
/////////////////////////////////////////////////////////////////////
-tstring DBGetString(MCONTACT hContact, const char *szModule, const char *szSetting, const TCHAR * pszError) {
- tstring ret;
- ptrT tszStr(db_get_tsa(hContact, szModule, szSetting));
- if (tszStr != NULL)
- return LPTSTR(tszStr);
-
- MessageBox(NULL, _T("DB: Attempt to get wrong type of value, string"), MSG_BOX_TITEL, MB_OK);
- return pszError;
+string DBGetString(MCONTACT hContact, const char *szModule, const char *szSetting, const char * pszError) {
+ string ret;
+ DBVARIANT dbv = {0};
+ if (! db_get(hContact, szModule, szSetting, &dbv)) {
+ if (dbv.type != DBVT_ASCIIZ) {
+ MessageBox(NULL, "DB: Attempt to get wrong type of value, string", MSG_BOX_TITEL, MB_OK);
+ ret = pszError;
+ } else {
+ ret = dbv.pszVal;
+ }
+ } else
+ ret = pszError;
+ db_free(&dbv);
+ return ret;
}
@@ -140,7 +146,8 @@ void UpdateStatisticsView() {
unsigned long GetExternIP(const char *szURL, const char *szPattern) {
HCURSOR hPrevCursor = ::SetCursor(::LoadCursor(0, IDC_WAIT));
- NETLIBHTTPREQUEST nlhr = { 0 };
+ NETLIBHTTPREQUEST nlhr;
+ ZeroMemory(&nlhr, sizeof(nlhr));
nlhr.cbSize = sizeof(nlhr);
nlhr.requestType = REQUEST_GET;
nlhr.flags = NLHRF_DUMPASTEXT;
@@ -191,32 +198,32 @@ unsigned long GetExternIP(const char *szURL, const char *szPattern) {
// Developer : KN
/////////////////////////////////////////////////////////////////////
-tstring sCreateLink(const TCHAR * pszSrvPath) {
- TCHAR szTemp[30];
- tstring sLink = DBGetString(NULL, MODULE, "ExternalSrvName", szDefaultExternalSrvName);
- mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%d.%d.%d.%d"), SplitIpAddress(dwLocalIpAddress));
- ReplaceAll(sLink, _T("%LocalIP%"), szTemp);
+string sCreateLink(const char * pszSrvPath) {
+ char szTemp[30];
+ string sLink = DBGetString(NULL, MODULE, "ExternalSrvName", szDefaultExternalSrvName);
+ mir_snprintf(szTemp, sizeof(szTemp), "%d.%d.%d.%d", SplitIpAddress(dwLocalIpAddress));
+ ReplaceAll(sLink, "%LocalIP%", szTemp);
- if (sLink.find(_T("%ExternalIP%")) != sLink.npos) {
+ if (sLink.find("%ExternalIP%") != sLink.npos) {
static DWORD dwExternalIpAddressGenerated = 0;
// Get the IP again after 10 minutes
if (! dwExternalIpAddress || GetTickCount() - dwExternalIpAddressGenerated > 10 * 60 * 1000) {
- dwExternalIpAddress = GetExternIP(_T2A(sUrlAddress.c_str()), _T2A(sPageKeyword.c_str()));
+ dwExternalIpAddress = GetExternIP(sUrlAddress.c_str(), sPageKeyword.c_str());
dwExternalIpAddressGenerated = GetTickCount();
}
- mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%d.%d.%d.%d"), SplitIpAddress(dwExternalIpAddress));
- ReplaceAll(sLink, _T("%ExternalIP%"), szTemp);
+ mir_snprintf(szTemp, sizeof(szTemp), "%d.%d.%d.%d", SplitIpAddress(dwExternalIpAddress));
+ ReplaceAll(sLink, "%ExternalIP%", szTemp);
}
- mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%d"), dwLocalPortUsed);
- ReplaceAll(sLink, _T("%Port%"), szTemp);
+ mir_snprintf(szTemp, sizeof(szTemp), "%d", dwLocalPortUsed, szTemp);
+ ReplaceAll(sLink, "%Port%", szTemp);
- tstring sSrvPath = pszSrvPath;
- ReplaceAll(sSrvPath, _T(" "), _T("%20"));
- ReplaceAll(sLink, _T("%SrvPath%"), sSrvPath);
+ string sSrvPath = pszSrvPath;
+ ReplaceAll(sSrvPath, " ", "%20");
+ ReplaceAll(sLink, "%SrvPath%", sSrvPath);
return sLink;
}
@@ -242,7 +249,7 @@ UINT_PTR CALLBACK ShareNewFileDialogHook(
WPARAM wParam, // message parameter
LPARAM lParam // message parameter
) {
- static const TCHAR* pszShareDirStr = TranslateT("Share Current Directory");
+ static const char* pszShareDirStr = Translate("Share Current Directory");
static int nInit = 0;
@@ -269,22 +276,22 @@ UINT_PTR CALLBACK ShareNewFileDialogHook(
switch (pNotify->hdr.code) {
case CDN_FOLDERCHANGE:
case CDN_SELCHANGE: {
- static TCHAR szSelection[MAX_PATH] = _T("");
+ static char szSelection[MAX_PATH] = "";
HWND hWndFileDlg = GetParent(hDlg);
*szSelection = '/';
CommDlg_OpenSave_GetSpec(hWndFileDlg, (LPARAM)(&szSelection[1]), _MAX_PATH);
HWND hFileName = GetDlgItem(hWndFileDlg, edt1);
- TCHAR pszFileName[MAX_PATH];
+ char pszFileName[MAX_PATH];
SendMessage(hFileName, WM_GETTEXT, MAX_PATH, (LPARAM)pszFileName);
- if (_tcscmp(pstShare->pszSrvPath, szSelection) &&
- _tcscmp(pszFileName, pszShareDirStr)) {
+ if (strcmp(pstShare->pszSrvPath, szSelection) &&
+ strcmp(pszFileName, pszShareDirStr)) {
// a file was selected
// only reenable windows / set default values when a folder was selected before
- if (pstShare->pszSrvPath[_tcslen(pstShare->pszSrvPath)-1] == '/') {
+ if (pstShare->pszSrvPath[strlen(pstShare->pszSrvPath)-1] == '/') {
pNotify->lpOFN->Flags |= OFN_FILEMUSTEXIST;
EnableWindow(hFileName, TRUE);
EnableWindow(GetDlgItem(hDlg, IDC_MAX_DOWNLOADS), TRUE);
@@ -293,32 +300,32 @@ UINT_PTR CALLBACK ShareNewFileDialogHook(
} else {
// a directory was selected
pNotify->lpOFN->Flags &= ~OFN_FILEMUSTEXIST;
- _tcscpy(pNotify->lpOFN->lpstrFile, pszShareDirStr);
+ strcpy(pNotify->lpOFN->lpstrFile, pszShareDirStr);
CommDlg_OpenSave_SetControlText(hWndFileDlg, edt1, pszShareDirStr);
EnableWindow(hFileName, FALSE);
EnableWindow(GetDlgItem(hDlg, IDC_MAX_DOWNLOADS), FALSE);
SetDlgItemInt(hDlg, IDC_MAX_DOWNLOADS, (UINT)-1, true);
CommDlg_OpenSave_GetFolderPath(hWndFileDlg, szSelection, MAX_PATH);
- TCHAR* pszFolder = szSelection;
- TCHAR* pszTmp = szSelection;
+ char* pszFolder = szSelection;
+ char* pszTmp = szSelection;
while (*pszTmp != '\0') {
if (*pszTmp == '\\' && *(pszTmp + 1))
pszFolder = pszTmp + 1;
pszTmp++;
}
- pszTmp = _tcschr(szSelection, ':');
+ pszTmp = strchr(szSelection, ':');
if (pszTmp != NULL)
*pszTmp = '\0';
- memmove(&szSelection[1], pszFolder, _tcslen(pszFolder) + 1);
+ memmove(&szSelection[1], pszFolder, strlen(pszFolder) + 1);
szSelection[0] = '/';
- if (szSelection[_tcslen(szSelection)-1] != '/')
- _tcscat(szSelection, _T("/"));
+ if (szSelection[strlen(szSelection)-1] != '/')
+ strcat(szSelection, "/");
// only write to IDC_SHARE_NAME when a file / other folder was selected before
- if (!_tcscmp(szSelection, pstShare->pszSrvPath))
+ if (!strcmp(szSelection, pstShare->pszSrvPath))
return false;
}
@@ -334,7 +341,7 @@ UINT_PTR CALLBACK ShareNewFileDialogHook(
SetDlgItemText(hDlg, IDC_SHARE_NAME, szSelection);
}
- _tcscpy(pstShare->pszSrvPath, szSelection);
+ strcpy(pstShare->pszSrvPath, szSelection);
return false;
}
@@ -342,14 +349,14 @@ UINT_PTR CALLBACK ShareNewFileDialogHook(
case CDN_FILEOK: {
GetDlgItemText(hDlg, IDC_SHARE_NAME, pstShare->pszSrvPath, _MAX_PATH);
- TCHAR* pszTmp = _tcsstr(pstShare->pszRealPath, pszShareDirStr);
+ char* pszTmp = strstr(pstShare->pszRealPath, pszShareDirStr);
if (pszTmp) {
*pszTmp = '\0';
- if (pstShare->pszSrvPath[_tcslen(pstShare->pszSrvPath)-1] != '/')
- _tcscat(pstShare->pszSrvPath, _T("/"));
+ if (pstShare->pszSrvPath[strlen(pstShare->pszSrvPath)-1] != '/')
+ strcat(pstShare->pszSrvPath, "/");
} else {
- if (pstShare->pszSrvPath[_tcslen(pstShare->pszSrvPath)-1] == '/')
- pstShare->pszSrvPath[_tcslen(pstShare->pszSrvPath)-1] = '\0';
+ if (pstShare->pszSrvPath[strlen(pstShare->pszSrvPath)-1] == '/')
+ pstShare->pszSrvPath[strlen(pstShare->pszSrvPath)-1] = '\0';
}
BOOL bTranslated = false;
@@ -362,7 +369,7 @@ UINT_PTR CALLBACK ShareNewFileDialogHook(
//if( ! (pstShare->dwAllowedIP & pstShare->dwAllowedMask)
- if (!bTranslated || (_tcslen(pstShare->pszSrvPath) <= 0)) {
+ if (!bTranslated || (strlen(pstShare->pszSrvPath) <= 0)) {
SetWindowLongPtr(hDlg, DWLP_MSGRESULT, 1);
return true;
}
@@ -374,12 +381,12 @@ UINT_PTR CALLBACK ShareNewFileDialogHook(
case WM_DROPFILES: {
HDROP hDrop = (HDROP)wParam;
- TCHAR szDropedFile[MAX_PATH];
- int nLen = DragQueryFile(hDrop, 0, szDropedFile, SIZEOF(szDropedFile));
+ char szDropedFile[MAX_PATH];
+ int nLen = DragQueryFile(hDrop, 0, szDropedFile, sizeof(szDropedFile));
if (nLen > 0) {
- TCHAR * psz = _tcsrchr(szDropedFile, '\\');
+ char * psz = strrchr(szDropedFile, '\\');
if (psz) {
- TCHAR oldNext = psz[1];
+ char oldNext = psz[1];
psz[1] = '\0';
// Fill in the directory
SendMessage(GetParent(hDlg), CDM_SETCONTROLTEXT, edt1, (LPARAM)szDropedFile);
@@ -427,17 +434,17 @@ bool bShowShareNewFileDlg(HWND hwndOwner, STFileShareInfo * pstNewShare) {
OPENFILENAME ofn = {0};
ofn.lStructSize = sizeof(OPENFILENAME);
- TCHAR temp[MAX_PATH];
- mir_sntprintf(temp, SIZEOF(temp), _T("%s (*.*)%c*.*%c%c"), TranslateT("All files"), 0, 0, 0);
+ char temp[MAX_PATH];
+ mir_snprintf(temp, SIZEOF(temp), _T("%s (*.*)%c*.*%c%c"), Translate("All files"), 0, 0, 0);
ofn.lpstrFilter = temp;
ofn.lpstrFile = pstNewShare->pszRealPath;
ofn.nMaxFile = pstNewShare->dwMaxRealPath;
- TCHAR szInitialDir[MAX_PATH];
- if (ofn.lpstrFile[_tcslen(ofn.lpstrFile)-1] == '\\') {
+ char szInitialDir[MAX_PATH];
+ if (ofn.lpstrFile[strlen(ofn.lpstrFile)-1] == '\\') {
ofn.lpstrInitialDir = szInitialDir;
- _tcscpy(szInitialDir, ofn.lpstrFile);
+ strcpy(szInitialDir, ofn.lpstrFile);
*ofn.lpstrFile = '\0';
}
@@ -455,38 +462,38 @@ bool bShowShareNewFileDlg(HWND hwndOwner, STFileShareInfo * pstNewShare) {
if (!GetOpenFileName(&ofn)) {
DWORD dwError = CommDlgExtendedError();
if (dwError) {
- TCHAR szTemp[200];
- mir_sntprintf(szTemp, SIZEOF(szTemp), _T("Failed to create File Open dialog the error returned was %d"), dwError);
+ char szTemp[200];
+ mir_snprintf(szTemp, sizeof(szTemp), "Failed to create File Open dialog the error returned was %d", dwError);
MessageBox(NULL, szTemp, MSG_BOX_TITEL, MB_OK);
}
return false;
}
- if (_tcschr(pstNewShare->pszSrvPath, '"')) {
+ if (strchr(pstNewShare->pszSrvPath, '"')) {
// multiple files selected
// Serverpath: "file1" "file2" "file3"
// move one after the other to front of string (in place)
// terminate it with \0 append to realpath and add the share
- TCHAR *pszFileNamePos = pstNewShare->pszSrvPath;
- TCHAR *szRealDirectoryEnd =
- &pstNewShare->pszRealPath[_tcslen(pstNewShare->pszRealPath)];
+ char* pszFileNamePos = pstNewShare->pszSrvPath;
+ char* szRealDirectoryEnd =
+ &pstNewShare->pszRealPath[strlen(pstNewShare->pszRealPath)];
*szRealDirectoryEnd = '\\';
szRealDirectoryEnd++;
while (pszFileNamePos && *pszFileNamePos) {
- pszFileNamePos = _tcschr(pszFileNamePos, '"');
+ pszFileNamePos = strchr(pszFileNamePos, '"');
if (pszFileNamePos) {
pszFileNamePos++;
- TCHAR* start = pszFileNamePos;
- pszFileNamePos = _tcschr(pszFileNamePos, '"');
+ char* start = pszFileNamePos;
+ pszFileNamePos = strchr(pszFileNamePos, '"');
if (pszFileNamePos) {
- TCHAR* end = pszFileNamePos;
+ char* end = pszFileNamePos;
memmove(pstNewShare->pszSrvPath+1, start, end - start);
*(end - (start - (pstNewShare->pszSrvPath+1)) ) = '\0';
int realPathLen = szRealDirectoryEnd - pstNewShare->pszRealPath;
- _tcsncpy(szRealDirectoryEnd, pstNewShare->pszSrvPath+1,
+ strncpy(szRealDirectoryEnd, pstNewShare->pszSrvPath+1,
pstNewShare->dwMaxRealPath - realPathLen - 1);
pstNewShare->pszRealPath[pstNewShare->dwMaxRealPath] = '\0';
@@ -535,7 +542,7 @@ void UpdateStatisticView(HWND hwndDlg, bool bRefressUsersOnly = false) {
CLFileShareListAccess scCrit;
- TCHAR szTmp[50];
+ char szTmp[50];
in_addr stAddr;
bool bAutoRefress = false;
@@ -545,7 +552,7 @@ void UpdateStatisticView(HWND hwndDlg, bool bRefressUsersOnly = false) {
int nUserNr = 0;
for (CLFileShareNode * pclCur = pclFirstNode; pclCur ; pclCur = pclCur->pclNext) {
if (! bRefressUsersOnly &&
- (bShowHiddenShares || !_tcsstr(pclCur->st.pszRealPath, _T("\\@")))) {
+ (bShowHiddenShares || !strstr(pclCur->st.pszRealPath, "\\@"))) {
sItem.mask = LVIF_TEXT /*| LVIF_PARAM | LVIF_IMAGE*/;
sItem.iItem = nShareNr;
sItem.iSubItem = 0;
@@ -553,19 +560,19 @@ void UpdateStatisticView(HWND hwndDlg, bool bRefressUsersOnly = false) {
ListView_InsertItem(hShareList, &sItem);
- mir_sntprintf(szTmp, SIZEOF(szTmp), _T("%d"), pclCur->st.nMaxDownloads);
+ mir_snprintf(szTmp, sizeof(szTmp), "%d", pclCur->st.nMaxDownloads);
sItem.iSubItem = 1;
sItem.pszText = szTmp;
ListView_SetItem(hShareList, &sItem);
stAddr.S_un.S_addr = htonl(pclCur->st.dwAllowedIP);
sItem.iSubItem = 2;
- sItem.pszText = _A2T(inet_ntoa(stAddr));
+ sItem.pszText = inet_ntoa(stAddr);
ListView_SetItem(hShareList, &sItem);
stAddr.S_un.S_addr = htonl(pclCur->st.dwAllowedMask);
sItem.iSubItem = 3;
- sItem.pszText = _A2T(inet_ntoa(stAddr));
+ sItem.pszText = inet_ntoa(stAddr);
ListView_SetItem(hShareList, &sItem);
sItem.iSubItem = 4;
@@ -585,17 +592,17 @@ void UpdateStatisticView(HWND hwndDlg, bool bRefressUsersOnly = false) {
ListView_InsertItem(hUserList, &sItem);
sItem.iSubItem = 1;
- sItem.pszText = _A2T(inet_ntoa(pclCurUser->stAddr));
+ sItem.pszText = inet_ntoa(pclCurUser->stAddr);
ListView_SetItem(hUserList, &sItem);
sItem.iSubItem = 2;
- sItem.pszText = (TCHAR *)pclCurUser->pszCustomInfo();
+ sItem.pszText = (char*)pclCurUser->pszCustomInfo();
ListView_SetItem(hUserList, &sItem);
if (pclCurUser->dwTotalSize) {
- mir_sntprintf(szTmp, SIZEOF(szTmp), _T("%d %%"), (pclCurUser->dwCurrentDL * 100) / pclCurUser->dwTotalSize);
+ mir_snprintf(szTmp, sizeof(szTmp), "%d %%", (pclCurUser->dwCurrentDL * 100) / pclCurUser->dwTotalSize);
} else {
- _tcscpy(szTmp, _T("? %%"));
+ strcpy(szTmp, "? %%");
}
sItem.iSubItem = 3;
sItem.pszText = szTmp;
@@ -605,9 +612,9 @@ void UpdateStatisticView(HWND hwndDlg, bool bRefressUsersOnly = false) {
if (dwSpeed > 10000) {
dwSpeed += 512; // make sure we round ot down correctly.
dwSpeed /= 1024;
- mir_sntprintf(szTmp, SIZEOF(szTmp), _T("%d KB/Sec"), dwSpeed);
+ mir_snprintf(szTmp, sizeof(szTmp), "%d KB/Sec", dwSpeed);
} else {
- mir_sntprintf(szTmp, SIZEOF(szTmp), _T("%d B/Sec"), dwSpeed);
+ mir_snprintf(szTmp, sizeof(szTmp), "%d B/Sec", dwSpeed);
}
sItem.iSubItem = 4;
sItem.pszText = szTmp;
@@ -767,25 +774,25 @@ static INT_PTR CALLBACK DlgProcStatsticView(HWND hwndDlg, UINT msg, WPARAM wPara
case WM_DROPFILES: {
HDROP hDrop = (HDROP)wParam;
- TCHAR szDropedFile[MAX_PATH];
- TCHAR szServPath[MAX_PATH] = {0};
+ char szDropedFile[MAX_PATH];
+ char szServPath[MAX_PATH] = {0};
int nLen = DragQueryFile(hDrop, 0xFFFFFFFF, NULL, 0);
for (int i = 0; i < nLen; i++) {
- DragQueryFile(hDrop, i, szDropedFile, SIZEOF(szDropedFile));
+ DragQueryFile(hDrop, i, szDropedFile, sizeof(szDropedFile));
STFileShareInfo stNewShare = {0};
stNewShare.lStructSize = sizeof(STFileShareInfo);
stNewShare.nMaxDownloads = nDefaultDownloadLimit;
stNewShare.pszRealPath = szDropedFile;
- stNewShare.dwMaxRealPath = SIZEOF(szDropedFile);
+ stNewShare.dwMaxRealPath = sizeof(szDropedFile);
stNewShare.pszSrvPath = szServPath;
- stNewShare.dwMaxSrvPath = SIZEOF(szServPath);
+ stNewShare.dwMaxSrvPath = sizeof(szServPath);
szServPath[0] = '/';
- TCHAR* fileName = _tcsrchr(szDropedFile, '\\');
+ char* fileName = strrchr(szDropedFile, '\\');
if (fileName)
- _tcsncpy(&szServPath[1], fileName+1, MAX_PATH-2);
+ strncpy(&szServPath[1], fileName+1, MAX_PATH-2);
if (CallService(MS_HTTP_ADD_CHANGE_REMOVE, 0, (LPARAM)&stNewShare)) {
MessageBox(NULL, TranslateT("Failed to share new file"), MSG_BOX_TITEL, MB_OK);
@@ -845,11 +852,11 @@ static INT_PTR CALLBACK DlgProcStatsticView(HWND hwndDlg, UINT msg, WPARAM wPara
case WM_COMMAND: {
HWND hShareList = GetDlgItem(hwndDlg, IDC_CURRENT_SHARES);
- TCHAR szTmp[MAX_PATH];
+ char szTmp[MAX_PATH];
LVITEM sItem = { 0 };
sItem.mask = LVIF_TEXT;
sItem.pszText = szTmp;
- sItem.cchTextMax = SIZEOF(szTmp);
+ sItem.cchTextMax = sizeof(szTmp);
switch (LOWORD(wParam)) {
@@ -868,7 +875,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) {
@@ -876,9 +883,9 @@ static INT_PTR CALLBACK DlgProcStatsticView(HWND hwndDlg, UINT msg, WPARAM wPara
if (LOWORD(wParam) == ID_SHARELIST_REMOVESHARE) {
CallService(MS_HTTP_ADD_CHANGE_REMOVE, 0, (LPARAM)&stShareInfo);
} else {
- TCHAR szRealPath[MAX_PATH];
+ char szRealPath[MAX_PATH];
stShareInfo.pszRealPath = szRealPath;
- stShareInfo.dwMaxRealPath = SIZEOF(szRealPath);
+ stShareInfo.dwMaxRealPath = sizeof(szRealPath);
CallService(MS_HTTP_GET_SHARE, 0, (LPARAM)&stShareInfo);
bShowShareNewFileDlg(hwndDlg, &stShareInfo);
}
@@ -894,7 +901,7 @@ static INT_PTR CALLBACK DlgProcStatsticView(HWND hwndDlg, UINT msg, WPARAM wPara
sItem.iItem = ListView_GetNextItem(hShareList, -1, LVIS_SELECTED);
if (sItem.iItem != -1) {
if (ListView_GetItem(hShareList, &sItem)) {
- tstring sLink = sCreateLink(sItem.pszText);
+ string sLink = sCreateLink(sItem.pszText);
if (sLink.size() <= 0) {
MessageBox(hwndDlg, TranslateT("Selected link size is 0"), MSG_BOX_TITEL, MB_OK);
return TRUE;
@@ -913,19 +920,19 @@ static INT_PTR CALLBACK DlgProcStatsticView(HWND hwndDlg, UINT msg, WPARAM wPara
HGLOBAL hglbCopy = GlobalAlloc(GMEM_MOVEABLE, sLink.size() + 1);
// Lock the handle and copy the text to the buffer.
- TCHAR *lptstrCopy = (TCHAR *)GlobalLock(hglbCopy);
- _tcscpy(lptstrCopy, sLink.c_str());
+ char * lptstrCopy = (char *)GlobalLock(hglbCopy);
+ strcpy(lptstrCopy, sLink.c_str());
GlobalUnlock(hglbCopy);
// Place the handle on the clipboard.
- HANDLE hMyData = SetClipboardData(CF_TEXT, hglbCopy);
+ HANDLE hMyData = SetClipboardData(CF_UNICODETEXT, hglbCopy);
if (! hMyData)
MessageBox(hwndDlg, TranslateT("Failed to set clipboard data"), MSG_BOX_TITEL, MB_OK);
CloseClipboard();
} else {
- CallService(MS_UTILS_OPENURL, 0, (LPARAM)(const char*)sLink.c_str());
+ CallService(MS_UTILS_OPENURL, OUF_TCHAR, (LPARAM)sLink.c_str());
}
} else {
MessageBox(hwndDlg, TranslateT("ListView_GetItem failed"), MSG_BOX_TITEL, MB_OK);
@@ -986,10 +993,9 @@ static INT_PTR CALLBACK DlgProcStatsticView(HWND hwndDlg, UINT msg, WPARAM wPara
// Developer : Sérgio Rolanski
/////////////////////////////////////////////////////////////////////
-void SendLinkToUser(WPARAM wParam, TCHAR *pszSrvPath)
-{
- tstring sLink = sCreateLink(pszSrvPath);
- CallService(MS_MSG_SENDMESSAGE, (WPARAM)wParam, (LPARAM)sLink.c_str());
+void SendLinkToUser(WPARAM wParam, char *pszSrvPath) {
+ string sLink = sCreateLink(pszSrvPath);
+ CallService(MS_MSG_SENDMESSAGET, wParam, (LPARAM)sLink.c_str());
}
/////////////////////////////////////////////////////////////////////
@@ -1011,16 +1017,16 @@ static INT_PTR nShareNewFile(WPARAM hContact, LPARAM lParam)
{
// used to be _MAX_PATH
// changed it since selecting multiple files requires a bigger buffer
- TCHAR szNewFile[10000] = {0};
- TCHAR szSrvPath[10000] = {0};
+ char szNewFile[10000] = {0};
+ char szSrvPath[10000] = {0};
STFileShareInfo stNewShare = {0};
stNewShare.lStructSize = sizeof(STFileShareInfo);
stNewShare.nMaxDownloads = 1;
stNewShare.pszRealPath = szNewFile;
- stNewShare.dwMaxRealPath = SIZEOF(szNewFile);
+ stNewShare.dwMaxRealPath = sizeof(szNewFile);
stNewShare.pszSrvPath = szSrvPath;
- stNewShare.dwMaxSrvPath = SIZEOF(szSrvPath);
+ stNewShare.dwMaxSrvPath = sizeof(szSrvPath);
if (hContact) {
// Try to locate an IP address.
@@ -1093,7 +1099,7 @@ static INT_PTR nShowStatisticsView(WPARAM /*wParam*/, LPARAM /*lParam*/) {
static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
switch (msg) {
case WM_INITDIALOG: {
- tstring sDefExt = DBGetString(NULL, MODULE, "ExternalSrvName", szDefaultExternalSrvName);
+ string sDefExt = DBGetString(NULL, MODULE, "ExternalSrvName", szDefaultExternalSrvName);
SetDlgItemText(hwndDlg, IDC_EXTERNAL_SRV_NAME, sDefExt.c_str());
bool b = db_get_b(NULL, MODULE, "AddStatisticsMenuItem", 1) != 0;
@@ -1124,7 +1130,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP
{// Page keyword
SetDlgItemText(hwndDlg, IDC_PAGE_KEYWORD, sPageKeyword.c_str());
HWND hComboBox = GetDlgItem(hwndDlg, IDC_PAGE_KEYWORD);
- SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)_T(""));
+ SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)"");
SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)LPGENT("Current IP Address: "));
SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)LPGENT("Current Address: "));
SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)LPGENT("IP Adress: "));
@@ -1207,13 +1213,13 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP
return TRUE;
}
case IDC_TEST_EXTERNALIP: {
- TCHAR szUrl[500];
- TCHAR szKeyWord[1000];
- GetDlgItemText(hwndDlg, IDC_URL_ADDRESS, szUrl, SIZEOF(szUrl));
- GetDlgItemText(hwndDlg, IDC_PAGE_KEYWORD, szKeyWord, SIZEOF(szKeyWord));
- DWORD dwExternalIP = GetExternIP(_T2A(szUrl), _T2A(szKeyWord));
+ char szUrl[ 500 ];
+ char szKeyWord[ 1000 ];
+ GetDlgItemText(hwndDlg, IDC_URL_ADDRESS, szUrl, sizeof(szUrl));
+ GetDlgItemText(hwndDlg, IDC_PAGE_KEYWORD, szKeyWord, sizeof(szKeyWord));
+ DWORD dwExternalIP = GetExternIP(szUrl, szKeyWord);
- mir_sntprintf(szKeyWord, SIZEOF(szKeyWord), TranslateT("Your external IP was detected as %d.%d.%d.%d\r\nby: %s") ,
+ mir_snprintf(szKeyWord, sizeof(szKeyWord), Translate("Your external IP was detected as %d.%d.%d.%d\r\nby: %s") ,
SplitIpAddress(dwExternalIP) ,
szUrl);
MessageBox(hwndDlg, szKeyWord, MSG_BOX_TITEL, MB_OK);
@@ -1225,9 +1231,9 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP
NMHDR * p = ((LPNMHDR)lParam);
switch (p->code) {
case PSN_APPLY: {
- TCHAR szTemp[500];
- if (GetDlgItemText(hwndDlg, IDC_EXTERNAL_SRV_NAME, szTemp, SIZEOF(szTemp)))
- db_set_ts(NULL, MODULE, "ExternalSrvName", szTemp);
+ char szTemp[ 500 ];
+ if (GetDlgItemText(hwndDlg, IDC_EXTERNAL_SRV_NAME, szTemp, sizeof(szTemp)))
+ db_set_s(NULL, MODULE, "ExternalSrvName", szTemp);
bool b = db_get_b(NULL, MODULE, "AddStatisticsMenuItem", 1) != 0;
bool bNew = IsDlgButtonChecked(hwndDlg, IDC_ADD_STATISTICS_MENU_ITEM) == BST_CHECKED;
@@ -1249,13 +1255,13 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP
bShowPopups = IsDlgButtonChecked(hwndDlg, IDC_SHOW_POPUPS) == BST_CHECKED;
db_set_b(NULL, MODULE, "ShowPopups", bShowPopups);
- GetDlgItemText(hwndDlg, IDC_URL_ADDRESS, szTemp, SIZEOF(szTemp));
+ GetDlgItemText(hwndDlg, IDC_URL_ADDRESS, szTemp, sizeof(szTemp));
sUrlAddress = szTemp;
- db_set_ts(NULL, MODULE, "UrlAddress", sUrlAddress.c_str());
+ db_set_s(NULL, MODULE, "UrlAddress", sUrlAddress.c_str());
- GetDlgItemText(hwndDlg, IDC_PAGE_KEYWORD, szTemp, SIZEOF(szTemp));
+ GetDlgItemText(hwndDlg, IDC_PAGE_KEYWORD, szTemp, sizeof(szTemp));
sPageKeyword = szTemp;
- db_set_ts(NULL, MODULE, "PageKeyword", sPageKeyword.c_str());
+ db_set_s(NULL, MODULE, "PageKeyword", sPageKeyword.c_str());
dwExternalIpAddress = 0;
BOOL bTranslated = false;
@@ -1336,12 +1342,12 @@ int OptionsInitialize(WPARAM wParam, LPARAM /*lParam*/)
OPTIONSDIALOGPAGE odp = { sizeof(odp) };
odp.position = 900000000;
odp.hInstance = hInstance;
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_HTTP_SERVER);
- odp.flags = ODPF_BOLDGROUPS | ODPF_TCHAR;
+ odp.pszTemplate = MAKEINTRESOURCE(IDD_OPT_HTTP_SERVER);
+ odp.flags = ODPF_BOLDGROUPS|ODPF_TCHAR;
odp.ptszTitle = LPGENT("HTTP Server");
odp.ptszGroup = LPGENT("Network");
odp.pfnDlgProc = OptionsDlgProc;
- Options_AddPage(wParam, &odp);
+ Options_AddPage(wParam,&odp);
return 0;
}
@@ -1362,7 +1368,7 @@ int OptionsInitialize(WPARAM wParam, LPARAM /*lParam*/)
void CALLBACK MainThreadCallback(ULONG_PTR dwParam) {
POPUPDATAT *pclData = (POPUPDATAT*)dwParam;
if (db_get_b(NULL, MODULE, "WriteLogFile", 0) != 0) {
- LogEvent(pclData->lptzContactName, pclData->lptzText);
+ LogEvent(pclData->lpzContactName, pclData->lpzText);
}
PUAddPopupT(pclData);
delete pclData;
@@ -1427,15 +1433,15 @@ LRESULT CALLBACK PopupWindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM
// Developer : KN
/////////////////////////////////////////////////////////////////////
-void ShowPopupWindow(const TCHAR * pszName, const TCHAR * pszText, COLORREF ColorBack /*= 0*/) {
+void ShowPopupWindow(const char * pszName, const char * pszText, COLORREF ColorBack /*= 0*/) {
if (! bShowPopups)
return;
POPUPDATAT *pclData = new POPUPDATAT;
memset(pclData, 0, sizeof(POPUPDATAT));
pclData->lchIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_SHARE_NEW_FILE));
- _tcsncpy(pclData->lptzContactName, pszName, SIZEOF(pclData->lptzContactName) - 1); // -1 so that there aways will be a null termination !!
- _tcsncpy(pclData->lptzText, pszText, SIZEOF(pclData->lptzText) - 1);
+ strncpy(pclData->lpzContactName, pszName, sizeof(pclData->lpzContactName) - 1); // -1 so that there aways will be a null termination !!
+ strncpy(pclData->lpzText, pszText, sizeof(pclData->lpzText) - 1);
pclData->colorBack = ColorBack;
//ppd.colorText = colorText;
pclData->PluginWindowProc = PopupWindowProc;
@@ -1483,9 +1489,10 @@ void InitGuiElements() {
return;
}
- CLISTMENUITEM mi = { 0 };
+ CLISTMENUITEM mi;
+ ZeroMemory(&mi, sizeof(mi));
mi.cbSize = sizeof(mi);
- mi.flags = CMIF_TCHAR;
+ mi.flags = 0;
mi.pszContactOwner = NULL; //all contacts
mi.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_SHARE_NEW_FILE));
mi.position = -2000019955;
diff --git a/plugins/HTTPServer/src/GuiElements.h b/plugins/HTTPServer/src/GuiElements.h
index 654c3ff844..0ce1d11814 100644
--- a/plugins/HTTPServer/src/GuiElements.h
+++ b/plugins/HTTPServer/src/GuiElements.h
@@ -23,7 +23,7 @@
void InitGuiElements();
void UnInitGuiElements();
void UpdateStatisticsView();
-void ShowPopupWindow(const TCHAR *pszName, const TCHAR *pszText, COLORREF ColorBack = 0);
-void SendLinkToUser(WPARAM wParam, TCHAR *pszSrvPath); // Add By Sergio Vieira Rolanski
+void ShowPopupWindow(const char * pszName, const char * pszText, COLORREF ColorBack = 0);
+void SendLinkToUser(WPARAM wParam, char *pszSrvPath); // Add By Sergio Vieira Rolanski
#endif \ No newline at end of file
diff --git a/plugins/HTTPServer/src/HttpUser.cpp b/plugins/HTTPServer/src/HttpUser.cpp
index ad47914ba6..428a5cb087 100644
--- a/plugins/HTTPServer/src/HttpUser.cpp
+++ b/plugins/HTTPServer/src/HttpUser.cpp
@@ -51,14 +51,14 @@ void FileTimeToUnixTime(LPFILETIME pft, time_t* t) {
// Developer : KN
/////////////////////////////////////////////////////////////////////
-static int nUnescapedURI(TCHAR *pszURI) {
+static int nUnescapedURI(char * pszURI) {
if (! pszURI)
return 0;
- TCHAR *pszOrigURI = pszURI;
+ char * pszOrigURI = pszURI;
int sumb;
int more = -1;
- TCHAR *pszCurInsert = pszURI;
+ char* pszCurInsert = pszURI;
for (; *pszURI && pszURI[0] != ' ' ; pszURI++) {
int nNewChar;
@@ -67,7 +67,7 @@ static int nUnescapedURI(TCHAR *pszURI) {
if (pszURI[1] == NULL || pszURI[2] == NULL || pszURI[1] == ' ' || pszURI[2] == ' ')
break; // handles error like "%2 " or "%a"
- if (_stscanf(&pszURI[1], _T("%2X"), &nNewChar) != 1) {
+ if (sscanf(&pszURI[1], "%2X", &nNewChar) != 1) {
// can't convert to number
pszURI += 2;
continue; // we skip it !!!
@@ -172,7 +172,7 @@ CLHttpUser::~CLHttpUser() {
// Developer : KN
/////////////////////////////////////////////////////////////////////
-bool CLHttpUser::bReadGetParameters(TCHAR *pszRequest) {
+bool CLHttpUser::bReadGetParameters(char * pszRequest) {
bool bRet = true;
for (; *pszRequest ; pszRequest++) {
if (pszRequest[0] != '\n') {
@@ -183,16 +183,16 @@ bool CLHttpUser::bReadGetParameters(TCHAR *pszRequest) {
pszRequest[0] = 0;
pszRequest++;
for (int nCur = 0; nCur < eLastParam ; nCur++) {
- int nLen = (int)_tcslen(szParmStr[nCur]);
- if (_tcsncmp(pszRequest, szParmStr[nCur], nLen) == 0) {
+ int nLen = (int)strlen(szParmStr[nCur]);
+ if (strncmp(pszRequest, szParmStr[nCur], nLen) == 0) {
if (apszParam[nCur]) {
bRet = false;
// already set !!
} else {
pszRequest += nLen;
apszParam[nCur] = pszRequest;
- pszRequest += _tcscspn(pszRequest, _T("\r\n")) - 1;
- TCHAR *psz = pszRequest;
+ pszRequest += strcspn(pszRequest, "\r\n") - 1;
+ char * psz = pszRequest;
while (*psz == ' ') {
psz[0] = 0;// owerwrite ' ' or '\r' or '\n'
psz--;
@@ -221,39 +221,38 @@ bool CLHttpUser::bReadGetParameters(TCHAR *pszRequest) {
// Changed : 21 January 2006 by Vampik
/////////////////////////////////////////////////////////////////////
-void CLHttpUser::SendError(int iErrorCode, const TCHAR *pszError, const TCHAR *pszDescription)
-{
- TCHAR szCurTime[100];
+void CLHttpUser::SendError(int iErrorCode, const char * pszError, const char * pszDescription) {
+ char szCurTime[ 100 ];
time_t ltime;
time(&ltime);
- _tcsftime(szCurTime, SIZEOF(szCurTime), _T("%a, %d %b %Y %H:%M:%S GMT"), gmtime(&ltime));
+ strftime(szCurTime, sizeof(szCurTime), "%a, %d %b %Y %H:%M:%S GMT", gmtime(&ltime));
if (!pszDescription)
pszDescription = pszError;
- 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"),
+ 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",
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, _T2A(szBuf), dwBytesToWrite, 0);
+ Netlib_Send(hConnection, szBuf, dwBytesToWrite, 0);
}
/////////////////////////////////////////////////////////////////////
@@ -272,40 +271,39 @@ void CLHttpUser::SendError(int iErrorCode, const TCHAR *pszError, const TCHAR *p
// Developer : KN, Houdini, Vampik
/////////////////////////////////////////////////////////////////////
-void CLHttpUser::SendRedir(int iErrorCode, const TCHAR *pszError, const TCHAR *pszDescription, const TCHAR *pszRedirect)
-{
- TCHAR szCurrTime[100];
+void CLHttpUser::SendRedir(int iErrorCode, const char * pszError, const char * pszDescription, const char * pszRedirect) {
+ char szCurrTime[ 100 ];
time_t ltime;
time(&ltime);
- _tcsftime(szCurrTime, SIZEOF(szCurrTime), _T("%a, %d %b %Y %H:%M:%S GMT"), gmtime(&ltime));
+ strftime(szCurrTime, sizeof(szCurrTime), "%a, %d %b %Y %H:%M:%S GMT", gmtime(&ltime));
if (!pszDescription)
pszDescription = pszError;
- 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"),
+ 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",
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, _T2A(szBuff), dwBytesToWrite, 0);
+ Netlib_Send(hConnection, szBuff, dwBytesToWrite, 0);
}
/////////////////////////////////////////////////////////////////////
@@ -323,8 +321,7 @@ void CLHttpUser::SendRedir(int iErrorCode, const TCHAR *pszError, const TCHAR *p
// Developer : Houdini
/////////////////////////////////////////////////////////////////////
-static void _tcsmcat(TCHAR *pszDest, const TCHAR *pszSrc, int iMaxLength)
-{
+static void strmcat(char* pszDest, const char* pszSrc, int iMaxLength) {
int iLength = 0;
while (*pszDest != '\0') {
pszDest++;
@@ -358,7 +355,7 @@ static void _tcsmcat(TCHAR *pszDest, const TCHAR *pszSrc, int iMaxLength)
// Changed : 21 January 2006 by Vampik
/////////////////////////////////////////////////////////////////////
-bool CLHttpUser::bProcessGetRequest(TCHAR *pszRequest, bool bIsGetCommand) {
+bool CLHttpUser::bProcessGetRequest(char * pszRequest, bool bIsGetCommand) {
//LogEvent("Request", pszRequest);
int nUriLength = nUnescapedURI(pszRequest);
@@ -370,11 +367,11 @@ bool CLHttpUser::bProcessGetRequest(TCHAR *pszRequest, bool bIsGetCommand) {
if (bShutdownInProgress)
return false;
- static TCHAR szTempfile[MAX_PATH+1];
+ static char szTempfile[MAX_PATH+1];
szTempfile[0] = '\0';
if (!bReadGetParameters(pszRequest)) {
- SendError(400, _T("Bad Request"));
+ SendError(400, "Bad Request");
return false;
}
@@ -387,20 +384,20 @@ bool CLHttpUser::bProcessGetRequest(TCHAR *pszRequest, bool bIsGetCommand) {
continue; // not the right length, quickly move on to the next.
if (pclCur->bIsDirectory() ?
- (_tcsncmp(pclCur->st.pszSrvPath, pszRequest, pclCur->nGetSrvPathLen() - 1) == 0) :
- (_tcsncmp(pclCur->st.pszSrvPath, pszRequest, pclCur->nGetSrvPathLen()) == 0)) {
+ (strncmp(pclCur->st.pszSrvPath, pszRequest, pclCur->nGetSrvPathLen() - 1) == 0) :
+ (strncmp(pclCur->st.pszSrvPath, pszRequest, pclCur->nGetSrvPathLen()) == 0)) {
/*OutputDebugString( "Request for file OK : ");
OutputDebugString( pclCur->st.pszSrvPath );
OutputDebugString( "\n" );*/
- static TCHAR szSrvPath[MAX_PATH+1];
- static TCHAR szRealPath[MAX_PATH+1];
- TCHAR *pszSrvPath = pclCur->st.pszSrvPath;
- TCHAR *pszRealPath = pclCur->st.pszRealPath;
+ static char szSrvPath[MAX_PATH+1];
+ static char szRealPath[MAX_PATH+1];
+ char* pszSrvPath = pclCur->st.pszSrvPath;
+ char* pszRealPath = pclCur->st.pszRealPath;
if (pclCur->bIsDirectory()) {
- _tcscpy(szRealPath, pclCur->st.pszRealPath);
- _tcscpy(szSrvPath, pclCur->st.pszSrvPath);
+ strcpy(szRealPath, pclCur->st.pszRealPath);
+ strcpy(szSrvPath, pclCur->st.pszSrvPath);
pszRealPath = szRealPath;
pszSrvPath = szSrvPath;
@@ -410,42 +407,42 @@ bool CLHttpUser::bProcessGetRequest(TCHAR *pszRequest, bool bIsGetCommand) {
pszRequest[nUriLength] = '\0';
if (pclCur->nGetSrvPathLen() - nUriLength == 1) {
- SendRedir(302, _T("Found"), _T("The document has moved"), pszRequest);
+ SendRedir(302, "Found", "The document has moved", pszRequest);
return false;
} else {
- _tcsmcat(pszRealPath, &pszRequest[pclCur->nGetSrvPathLen()], MAX_PATH);
- _tcsmcat(pszSrvPath, &pszRequest[pclCur->nGetSrvPathLen()], MAX_PATH);
+ strmcat(pszRealPath, &pszRequest[pclCur->nGetSrvPathLen()], MAX_PATH);
+ strmcat(pszSrvPath, &pszRequest[pclCur->nGetSrvPathLen()], MAX_PATH);
}
pszRequest[nUriLength] = ' ';
// hacker protection - should be removed by the browser
- if (_tcsstr(pszRealPath, _T(".."))) {
- SendError(404, _T("Not Found"), _T("The requested URL was not found on this server."));
+ if (strstr(pszRealPath, "..")) {
+ SendError(404, "Not Found", "The requested URL was not found on this server.");
return false;
}
- TCHAR *pszTmp = pszRealPath;
- while (pszTmp = _tcschr(pszTmp, '/'))
+ char* pszTmp = pszRealPath;
+ while (pszTmp = strchr(pszTmp, '/'))
* pszTmp = '\\';
hFile = CreateFile(pszRealPath, GENERIC_READ ,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE) {
- if (pszSrvPath[_tcslen(pszSrvPath)-1] != '/') {
- _tcsmcat(pszRealPath, _T("\\"), MAX_PATH);
- _tcsmcat(pszSrvPath, _T("/"), MAX_PATH);
+ if (pszSrvPath[strlen(pszSrvPath)-1] != '/') {
+ strmcat(pszRealPath, "\\", MAX_PATH);
+ strmcat(pszSrvPath, "/", MAX_PATH);
}
// a directory with index.htm
- _tcsmcat(szRealPath, _T("index.htm"), MAX_PATH);
+ strmcat(szRealPath, "index.htm", MAX_PATH);
hFile = CreateFile(pszRealPath, GENERIC_READ ,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_HIDDEN, NULL);
if (hFile == INVALID_HANDLE_VALUE) {
// a directory with index.html
- _tcsmcat(szRealPath, _T("l"), MAX_PATH);
+ strmcat(szRealPath, "l", MAX_PATH);
hFile = CreateFile(pszRealPath, GENERIC_READ ,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_HIDDEN, NULL);
@@ -454,13 +451,13 @@ bool CLHttpUser::bProcessGetRequest(TCHAR *pszRequest, bool bIsGetCommand) {
// generate directory index in temporary file
if (*szTempfile == '\0') {
GetTempPath(MAX_PATH, szTempfile);
- _tcsmcat(szTempfile, _T("\\HttpServerTemp"), MAX_PATH);
- _tcsmcat(szTempfile, pszSrvPath, MAX_PATH);
- TCHAR *pszTmp = szTempfile;
- while (pszTmp = _tcschr(pszTmp, '/'))
+ strmcat(szTempfile, "\\HttpServerTemp", MAX_PATH);
+ strmcat(szTempfile, pszSrvPath, MAX_PATH);
+ char* pszTmp = szTempfile;
+ while (pszTmp = strchr(pszTmp, '/'))
* pszTmp = '~';
}
- pszRealPath[_tcslen(pszRealPath) - 10] = '\0';
+ pszRealPath[strlen(pszRealPath) - 10] = '\0';
// detecting browser function removed
// every browser should support it by now
@@ -475,23 +472,23 @@ bool CLHttpUser::bProcessGetRequest(TCHAR *pszRequest, bool bIsGetCommand) {
hFile = CreateFile(szTempfile, GENERIC_READ ,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
- _tcscpy(szRealPath, _T("a.xml")); // restore .xml for mime type
+ strcpy(szRealPath, "a.xml"); // restore .xml for mime type
} else if ((indexCreationMode == INDEX_CREATION_HTML ||
indexCreationMode == INDEX_CREATION_DETECT) &&
bCreateIndexHTML(pszRealPath, szTempfile, pszSrvPath, dwRemoteIP)) {
hFile = CreateFile(szTempfile, GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
- _tcscpy(szRealPath, _T("a.html")); // restore .html for mime type
+ strcpy(szRealPath, "a.html"); // restore .html for mime type
} else {
continue;
}
} else {
- _tcsmcat(pszSrvPath, _T("index.html"), MAX_PATH);
+ strmcat(pszSrvPath, "index.html", MAX_PATH);
szTempfile[0] = '\0';
}
} else {
- _tcsmcat(pszSrvPath, _T("index.htm"), MAX_PATH);
+ strmcat(pszSrvPath, "index.htm", MAX_PATH);
szTempfile[0] = '\0';
}
} else {
@@ -502,12 +499,12 @@ bool CLHttpUser::bProcessGetRequest(TCHAR *pszRequest, bool bIsGetCommand) {
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE) {
- SendError(404, _T("Not Found"), _T("HTTP server failed to open local file"));
+ SendError(404, "Not Found", "HTTP server failed to open local file");
return false;
}
}
- _tcscpy(this->szCurrentDLSrvPath, pszSrvPath);
+ strcpy(this->szCurrentDLSrvPath, pszSrvPath);
DWORD nDataSize = GetFileSize(hFile, NULL);
dwTotalSize = nDataSize;
@@ -515,31 +512,31 @@ bool CLHttpUser::bProcessGetRequest(TCHAR *pszRequest, bool bIsGetCommand) {
FILETIME stFileTime;
GetFileTime(hFile, NULL, NULL, &stFileTime);
- TCHAR szCurTime[100];
+ char szCurTime[ 100 ];
time_t ltime;
time(&ltime);
- _tcsftime(szCurTime, SIZEOF(szCurTime), _T("%a, %d %b %Y %H:%M:%S GMT"), gmtime(&ltime));
+ strftime(szCurTime, sizeof(szCurTime), "%a, %d %b %Y %H:%M:%S GMT", gmtime(&ltime));
- TCHAR szFileTime[100];
+ char szFileTime[ 100 ];
FileTimeToUnixTime(&stFileTime, &ltime);
- _tcsftime(szFileTime, SIZEOF(szFileTime), _T("%a, %d %b %Y %H:%M:%S GMT"), gmtime(&ltime));
+ strftime(szFileTime, sizeof(szFileTime), "%a, %d %b %Y %H:%M:%S GMT", gmtime(&ltime));
- if (apszParam[eIfModifiedSince] && _tcscmp(apszParam[eIfModifiedSince], szFileTime) == 0) {
- SendError(304, _T("Not Modified"));
+ if (apszParam[eIfModifiedSince] && strcmp(apszParam[eIfModifiedSince], szFileTime) == 0) {
+ SendError(304, "Not Modified" );
return true;
}
// we found match send file !!
if (bIsGetCommand) {
if (! pclCur->bAddUser(this)) {
- SendError(403, _T("Forbidden"), _T("Access has been denied because there are too many connections"));
+ SendError(403, "Forbidden", "Access has been denied because there are too many connections");
return false;
}
}
if (*(ULONG*)(&stAddr) != 0x0100007F && // do not show popup of 127.0.0.1
- _tcsstr(pszRealPath, _T("\\@")) == NULL) { // and of shares which start with an @
- ShowPopupWindow(_A2T(inet_ntoa(stAddr)), pszSrvPath);
+ strstr(pszRealPath, "\\@") == NULL) { // and of shares which start with an @
+ ShowPopupWindow(inet_ntoa(stAddr), pszSrvPath);
}
clCritSection.Unlock();
@@ -547,37 +544,37 @@ bool CLHttpUser::bProcessGetRequest(TCHAR *pszRequest, bool bIsGetCommand) {
DWORD dwFileStart = 0;
DWORD dwDataToSend = nDataSize;
- TCHAR szETag[50];
+ char szETag[ 50 ];
{
- int nETagLen = mir_sntprintf(szETag, SIZEOF(szETag), _T("\"%x-%x-%x\""),
+ int nETagLen = mir_snprintf(szETag, sizeof(szETag), "\"%x-%x-%x\"",
nDataSize, stFileTime.dwHighDateTime, stFileTime.dwLowDateTime);
- if (!apszParam[eIfRange] || (_tcsncmp(szETag, apszParam[eIfRange], nETagLen) == 0)) {
- TCHAR *pszRange = apszParam[eRange];
+ if (!apszParam[eIfRange] || (strncmp(szETag, apszParam[eIfRange], nETagLen) == 0)) {
+ char * pszRange = apszParam[eRange];
if (pszRange) {
- if (_tcsncmp(pszRange, _T("bytes="), _tcslen(_T("bytes="))) == 0) {
+ if (strncmp(pszRange, "bytes=", 6) == 0) {
pszRange += 6;
// Do resume !!!
- TCHAR *pszEnd;
+ char *pszEnd;
if (pszRange[0] == '-') {
// its a suffix-byte-range-spec
- DWORD dwLen = _tcstol(pszRange + 1, &pszEnd, 10);
+ DWORD dwLen = strtol(pszRange + 1, &pszEnd, 10);
if (dwLen < nDataSize)
dwFileStart = nDataSize - dwLen;
} else {
- DWORD dwLen = _tcstol(pszRange, &pszEnd, 10);
+ DWORD dwLen = strtol(pszRange, &pszEnd, 10);
if (*pszEnd == '-' && dwLen < nDataSize) {
dwFileStart = dwLen;
pszRange = pszEnd + 1;
if (*pszRange != 0) {
- dwLen = _tcstol(pszEnd + 1, &pszEnd, 10);
+ dwLen = strtol(pszEnd + 1, &pszEnd, 10);
if (dwLen > dwFileStart)
dwDataToSend = (dwLen + 1) - dwFileStart;
else
dwFileStart = 0;
}
} else {
- SendError(400, _T("Bad Request"));
+ SendError(400, "Bad Request");
return false;
}
}
@@ -599,27 +596,27 @@ 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.
- TCHAR szBuf[1460 * 4];
+ char szBuf[1460 * 4];
if (dwFileStart > 0 || dwDataToSend != nDataSize) {
if (SetFilePointer(hFile, dwFileStart, NULL, FILE_BEGIN) == INVALID_SET_FILE_POINTER) {
- SendError(416, _T("Requested Range Not Satisfiable"));
+ SendError(416, "Requested Range Not Satisfiable");
return true;
}
- 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,
+ 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,
szCurTime,
PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
szETag,
@@ -630,18 +627,18 @@ bool CLHttpUser::bProcessGetRequest(TCHAR *pszRequest, bool bIsGetCommand) {
nDataSize,
szFileTime);
} else {
- 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,
+ 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,
szCurTime,
PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
szETag,
@@ -650,7 +647,7 @@ bool CLHttpUser::bProcessGetRequest(TCHAR *pszRequest, bool bIsGetCommand) {
szFileTime);
}
- Netlib_Send(hConnection, _T2A(szBuf), dwBytesToWrite, 0);
+ Netlib_Send(hConnection, szBuf, dwBytesToWrite, 0);
if (bIsGetCommand) {
static int nThreadCount = 0;
@@ -688,9 +685,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 +701,7 @@ bool CLHttpUser::bProcessGetRequest(TCHAR *pszRequest, bool bIsGetCommand) {
if (bSpeedLimit)
nMaxBytesToSend -= dwBytesToWrite;
- DWORD dwSend = Netlib_Send(hConnection, _T2A(szBuf), dwBytesToWrite, MSG_NODUMP);
+ DWORD dwSend = Netlib_Send(hConnection, szBuf, dwBytesToWrite, MSG_NODUMP);
if (dwSend == SOCKET_ERROR)
break;
dwCurrentDL += dwSend;
@@ -753,7 +750,7 @@ bool CLHttpUser::bProcessGetRequest(TCHAR *pszRequest, bool bIsGetCommand) {
for (CLFileShareNode * pcl = pclFirstNode ; pcl ; pcl = pcl->pclNext) {
if (pcl == pclCur) {
*pclPrev = pclCur->pclNext;
- ShowPopupWindow(TranslateT("Share removed"), pclCur->st.pszSrvPath, RGB(255, 189, 189));
+ ShowPopupWindow(Translate("Share removed"), pclCur->st.pszSrvPath, RGB(255, 189, 189));
delete pclCur;
bNeedToWriteConfig = true;
break;
@@ -773,25 +770,24 @@ bool CLHttpUser::bProcessGetRequest(TCHAR *pszRequest, bool bIsGetCommand) {
#ifdef _DEBUG
- OutputDebugString(_T("########### Request Failed ###########\n"));
+ OutputDebugString("########### Request Failed ###########\n");
OutputDebugString(pszRequest);
#endif
pszRequest[nUriLength] = 0;
- if ((nUriLength != 12 || _tcsncmp(pszRequest, _T("/favicon.ico"), nUriLength)) && // do not show popup of favicon.ico
+ if ((nUriLength != 12 || strncmp(pszRequest, "/favicon.ico", nUriLength)) && // do not show popup of favicon.ico
*(ULONG*)(&stAddr) != 0x0100007F) { // do not show popup of 127.0.0.1
- ShowPopupWindow(_A2T(inet_ntoa(stAddr)), pszRequest, RGB(255, 189, 189));
+ ShowPopupWindow(inet_ntoa(stAddr), pszRequest, RGB(255, 189, 189));
}
- SendError(404, _T("Not Found"), _T("The requested URL was not found on this server."));
+ SendError(404, "Not Found", "The requested URL was not found on this server.");
return false;
}
-void CLHttpUser::HandleNewConnection()
-{
+void CLHttpUser::HandleNewConnection() {
/*
{
@@ -832,10 +828,10 @@ void CLHttpUser::HandleNewConnection()
}
*/
- TCHAR szBuf[1000];
+ char szBuf[1000];
int nCurPos = 0;
- while (SIZEOF(szBuf) - nCurPos > 10 && !bShutdownInProgress) {
- int nBytesRead = Netlib_Recv(hConnection, _T2A(&szBuf[nCurPos]), SIZEOF(szBuf) - nCurPos, 0);
+ while (sizeof(szBuf) - nCurPos > 10 && !bShutdownInProgress) {
+ int nBytesRead = Netlib_Recv(hConnection, &szBuf[nCurPos], sizeof(szBuf) - nCurPos, 0);
if (! nBytesRead) {
// socket closed gracefully
break;
@@ -850,9 +846,9 @@ void CLHttpUser::HandleNewConnection()
if (nCurPos <= 5)
continue;
- bool bIsGetCommand = _tcsncmp(szBuf, _T("GET "), _tcslen(_T("GET "))) == 0;
- if (!bIsGetCommand && _tcsncmp(szBuf, _T("HEAD "), _tcslen(_T("HEAD "))) != 0) {
- SendError(501, _T("Not Implemented"));
+ bool bIsGetCommand = memcmp(szBuf, "GET ", 4) == 0;
+ if (!bIsGetCommand && memcmp(szBuf, "HEAD ", 5) != 0) {
+ SendError(501, "Not Implemented");
break; // We only support GET and HEAD commands !!
}
diff --git a/plugins/HTTPServer/src/HttpUser.h b/plugins/HTTPServer/src/HttpUser.h
index d428391249..00b43a76eb 100644
--- a/plugins/HTTPServer/src/HttpUser.h
+++ b/plugins/HTTPServer/src/HttpUser.h
@@ -33,13 +33,13 @@ enum ENParamTypes {
eLastParam
};
-static TCHAR * szParmStr[eLastParam] = {
- _T("Range: "),
- _T("If-Range: "),
- _T("Unless-Modified-Since: "),
- _T("If-Modified-Since: "),
- _T("User-Agent: "),
- _T("Host: ")
+static char * szParmStr[eLastParam] = {
+ "Range: ",
+ "If-Range: ",
+ "Unless-Modified-Since: ",
+ "If-Modified-Since: ",
+ "User-Agent: ",
+ "Host: "
};
@@ -48,23 +48,23 @@ public:
CLHttpUser(HANDLE hCon, in_addr stAdd);
virtual ~CLHttpUser();
- bool bReadGetParameters(TCHAR *pszRequest);
+ bool bReadGetParameters(char * pszRequest);
//bool bSendFile( HANDLE hFile ,
bool bCloseTransfers() {
return true;
}
- bool bProcessGetRequest(TCHAR *pszRequest, bool bIsGetCommand);
- const TCHAR * pszCustomInfo() {
+ bool bProcessGetRequest(char * pszRequest, bool bIsGetCommand);
+ const char * pszCustomInfo() {
return apszParam[eUserAgent];
}
void HandleNewConnection();
private:
HANDLE hFile;
- TCHAR *apszParam[eLastParam];
+ char *apszParam[eLastParam];
- void SendError(int iErrorCode, const TCHAR *pszError, const TCHAR *pszDescription = NULL);
- void SendRedir(int iErrorCode, const TCHAR *pszError, const TCHAR *pszDescription = NULL, const TCHAR *pszRedirect = NULL);
+ void SendError(int iErrorCode, const char * pszError, const char * pszDescription = NULL);
+ void SendRedir(int iErrorCode, const char * pszError, const char * pszDescription = NULL, const char * pszRedirect = NULL);
};
#endif \ No newline at end of file
diff --git a/plugins/HTTPServer/src/IndexCreation.h b/plugins/HTTPServer/src/IndexCreation.h
index 5876595a46..c3892c4308 100644
--- a/plugins/HTTPServer/src/IndexCreation.h
+++ b/plugins/HTTPServer/src/IndexCreation.h
@@ -23,7 +23,7 @@
#include "m_HTTPServer.h"
#include "FileShareNode.h"
-const TCHAR szIndexHTMLTemplateFile[] = _T("HTTPServerIndex.html");
+const char szIndexHTMLTemplateFile[] = "HTTPServerIndex.html";
enum eIndexCreationMode {
INDEX_CREATION_DISABLE = 0,
@@ -34,8 +34,8 @@ enum eIndexCreationMode {
extern eIndexCreationMode indexCreationMode;
-bool bCreateIndexXML(const TCHAR *pszRealPath, const TCHAR *pszIndexPath, const TCHAR *pszSrvPath, DWORD dwRemoteIP);
-bool bCreateIndexHTML(const TCHAR *pszRealPath, const TCHAR *pszIndexPath, const TCHAR *pszSrvPath, DWORD dwRemoteIP);
+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);
void FreeIndexHTMLTemplate();
bool LoadIndexHTMLTemplate();
diff --git a/plugins/HTTPServer/src/IndexHTML.cpp b/plugins/HTTPServer/src/IndexHTML.cpp
index c8e6ccddc7..f1f15fbc44 100644
--- a/plugins/HTTPServer/src/IndexHTML.cpp
+++ b/plugins/HTTPServer/src/IndexHTML.cpp
@@ -19,7 +19,7 @@
eIndexCreationMode indexCreationMode;
-static TCHAR *szIndexHTMLTemplate = NULL;
+static char* szIndexHTMLTemplate = NULL;
static const int MAX_PARAM_LENGTH = 5;
// signs below 32 are not used anyway
@@ -56,27 +56,27 @@ bool LoadIndexHTMLTemplate() {
if (szIndexHTMLTemplate != NULL)
return true;
- TCHAR szBuf[10000];
- TCHAR *pszBuf = szBuf;
+ char szBuf[10000];
+ char* pszBuf = szBuf;
- TCHAR szDestBuf[10000];
- TCHAR *pszDestBuf = szDestBuf;
+ char szDestBuf[10000];
+ char* pszDestBuf = szDestBuf;
- _tccpy(pszBuf, szPluginPath);
- _tcscat(pszBuf, szIndexHTMLTemplateFile);
+ strcpy(pszBuf, szPluginPath);
+ strcat(pszBuf, szIndexHTMLTemplateFile);
HANDLE hFile = CreateFile(pszBuf, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE) {
- MessageBox(NULL, _T("HTTPServerIndex.html not found in Plugin Path"), MSG_BOX_TITEL, MB_OK);
+ MessageBox(NULL, "HTTPServerIndex.html not found in Plugin Path", MSG_BOX_TITEL, MB_OK);
return false;
}
DWORD dwBytesRead = 0;
- if (ReadFile(hFile, pszBuf, SIZEOF(szBuf), &dwBytesRead, NULL) || dwBytesRead <= 0) {
+ if (ReadFile(hFile, pszBuf, sizeof(szBuf), &dwBytesRead, NULL) || dwBytesRead <= 0) {
while (dwBytesRead > (DWORD)(pszBuf - szBuf)) {
if (*pszBuf == '[') {
- TCHAR* pszKeywordBegin = pszBuf + 1;
+ char* pszKeywordBegin = pszBuf + 1;
bool bHasParameters = false;
do {
@@ -93,21 +93,21 @@ bool LoadIndexHTMLTemplate() {
*pszDestBuf = '#';
// signs below 32 are not used anyway
- if (!_tcscmp(pszKeywordBegin, _T("End"))) *pszDestBuf = SY_END;
- else if (!_tcscmp(pszKeywordBegin, _T("ForDirectoriesDo"))) *pszDestBuf = SY_FOR_DIRS;
- else if (!_tcscmp(pszKeywordBegin, _T("DirectoryUrl"))) *pszDestBuf = SY_DIR_URL;
- else if (!_tcscmp(pszKeywordBegin, _T("DirectoryName"))) *pszDestBuf = SY_DIR_NAME;
- else if (!_tcscmp(pszKeywordBegin, _T("ForFilesDo"))) *pszDestBuf = SY_FOR_FILES;
- else if (!_tcscmp(pszKeywordBegin, _T("FileUrl"))) *pszDestBuf = SY_FILE_URL;
- else if (!_tcscmp(pszKeywordBegin, _T("FileName"))) *pszDestBuf = SY_FILE_NAME;
- else if (!_tcscmp(pszKeywordBegin, _T("FileSize"))) *pszDestBuf = SY_FILE_SIZE;
- else if (!_tcscmp(pszKeywordBegin, _T("FileCreated"))) *pszDestBuf = SY_FILE_CREATE_TIME;
- else if (!_tcscmp(pszKeywordBegin, _T("FileModified"))) *pszDestBuf = SY_FILE_MODIFY_TIME;
- else if (!_tcscmp(pszKeywordBegin, _T("IsEven"))) *pszDestBuf = SY_IS_EVEN;
- else if (!_tcscmp(pszKeywordBegin, _T("IsOdd"))) *pszDestBuf = SY_IS_ODD;
- else if (!_tcscmp(pszKeywordBegin, _T("IsFileType"))) *pszDestBuf = SY_IS_FILE_TYPE;
+ if (!strcmp(pszKeywordBegin, "End")) *pszDestBuf = SY_END;
+ else if (!strcmp(pszKeywordBegin, "ForDirectoriesDo")) *pszDestBuf = SY_FOR_DIRS;
+ else if (!strcmp(pszKeywordBegin, "DirectoryUrl")) *pszDestBuf = SY_DIR_URL;
+ else if (!strcmp(pszKeywordBegin, "DirectoryName")) *pszDestBuf = SY_DIR_NAME;
+ else if (!strcmp(pszKeywordBegin, "ForFilesDo")) *pszDestBuf = SY_FOR_FILES;
+ else if (!strcmp(pszKeywordBegin, "FileUrl")) *pszDestBuf = SY_FILE_URL;
+ else if (!strcmp(pszKeywordBegin, "FileName")) *pszDestBuf = SY_FILE_NAME;
+ else if (!strcmp(pszKeywordBegin, "FileSize")) *pszDestBuf = SY_FILE_SIZE;
+ else if (!strcmp(pszKeywordBegin, "FileCreated")) *pszDestBuf = SY_FILE_CREATE_TIME;
+ else if (!strcmp(pszKeywordBegin, "FileModified")) *pszDestBuf = SY_FILE_MODIFY_TIME;
+ else if (!strcmp(pszKeywordBegin, "IsEven")) *pszDestBuf = SY_IS_EVEN;
+ else if (!strcmp(pszKeywordBegin, "IsOdd")) *pszDestBuf = SY_IS_ODD;
+ else if (!strcmp(pszKeywordBegin, "IsFileType")) *pszDestBuf = SY_IS_FILE_TYPE;
else {
- LogEvent(_T("Error in index template"), _T("Unknown Tag"));
+ LogEvent("Error in index template", "Unknown Tag");
// unknown tag
}
@@ -133,13 +133,13 @@ bool LoadIndexHTMLTemplate() {
if (bHasParameters) {
// max MAX_PARAM_LENGTH chars per param (terminated with : when shorter than MAX_PARAM_LENGTH)
byte iParamCount = 1;
- TCHAR *pcParamCount = pszDestBuf++;
- TCHAR *pszParameterBegin = pszBuf + 1;
+ char* pcParamCount = (pszDestBuf++);
+ char* pszParameterBegin = pszBuf + 1;
do {
if (*pszBuf == ',') {
*pszBuf = ':';
- _tcsncpy(pszDestBuf, pszParameterBegin, MAX_PARAM_LENGTH);
+ strncpy(pszDestBuf, pszParameterBegin, MAX_PARAM_LENGTH);
pszDestBuf += MAX_PARAM_LENGTH;
pszParameterBegin = pszBuf + 1;
@@ -152,7 +152,7 @@ bool LoadIndexHTMLTemplate() {
break;
*pszBuf = ':';
- _tcsncpy(pszDestBuf, pszParameterBegin, MAX_PARAM_LENGTH);
+ strncpy(pszDestBuf, pszParameterBegin, MAX_PARAM_LENGTH);
pszDestBuf += MAX_PARAM_LENGTH;
*pcParamCount = iParamCount;
@@ -185,7 +185,7 @@ bool LoadIndexHTMLTemplate() {
// begin of iLevel - find End of iLevel
if (iLevel > 0) {
- TCHAR *pszLevelEnd = pszBuf + 2; // skip for address reserved bytes
+ char* pszLevelEnd = pszBuf + 2; // skip for address reserved bytes
// skip parameters of IsFileType
if (*(pszBuf - 1) == SY_IS_FILE_TYPE) {
@@ -219,7 +219,7 @@ bool LoadIndexHTMLTemplate() {
}
if (*pszLevelEnd == '\0') {
- LogEvent(_T("Error in index template"), _T("End is missing"));
+ LogEvent("Error in index template", "End is missing");
break; // Error - End missing
}
@@ -233,8 +233,8 @@ bool LoadIndexHTMLTemplate() {
//LogEvent("Template", szDestBuf);
- szIndexHTMLTemplate = new TCHAR[_tcslen(szDestBuf) + 1];
- _tcscpy(szIndexHTMLTemplate, szDestBuf);
+ szIndexHTMLTemplate = new char[strlen(szDestBuf)+1];
+ strcpy(szIndexHTMLTemplate, szDestBuf);
}
CloseHandle(hFile);
@@ -274,19 +274,19 @@ void FreeIndexHTMLTemplate() {
// Developer : Houdini
/////////////////////////////////////////////////////////////////////
-bool bCreateIndexHTML(const TCHAR *pszRealPath, const TCHAR *pszIndexPath, const TCHAR *pszSrvPath, DWORD /* dwRemoteIP */)
-{
+bool bCreateIndexHTML(const char * pszRealPath, const char * pszIndexPath,
+ const char * pszSrvPath, DWORD /* dwRemoteIP */) {
#define RelativeJump(begin) { pszPos += *((WORD*)(begin+1)) & 0x7FFF; }
if (szIndexHTMLTemplate == NULL)
return false;
// check if directory exists
- TCHAR szMask[MAX_PATH];
- _tcscpy(szMask, pszRealPath);
- _tcscat(szMask, _T("*"));
+ char szMask[MAX_PATH];
+ strcpy(szMask, pszRealPath);
+ strcat(szMask, "*");
- WIN32_FIND_DATA fdFindFileData;
+ WIN32_FIND_DATAA fdFindFileData;
HANDLE hFind = FindFirstFile(szMask, &fdFindFileData);
if (hFind == INVALID_HANDLE_VALUE)
@@ -301,35 +301,35 @@ bool bCreateIndexHTML(const TCHAR *pszRealPath, const TCHAR *pszIndexPath, const
if (hFile == INVALID_HANDLE_VALUE)
return FALSE;
- TCHAR szBuffer[10000];
- TCHAR *pszBuffer = szBuffer;
+ char szBuffer[10000];
+ char* pszBuffer = szBuffer;
DWORD dwBytesWritten = 0;
- TCHAR *pszPos = szIndexHTMLTemplate;
+ char* pszPos = szIndexHTMLTemplate;
byte iCurrentAction = 0;
- TCHAR *pszLevelBegin[50];
+ char* pszLevelBegin[50];
byte iLevel = 0;
- TCHAR szName[1000] = _T("");
- TCHAR szURL[1000] = _T("");
+ char szName[1000] = "";
+ char szURL[1000] = "";
int iFileSize = 0;
FILETIME ftFileCreateTime;
FILETIME ftFileModifyTime;
bool bEvenOdd = 0;
bool bKnownFileType = false;
- _tcscpy(szBuffer, pszSrvPath);
- TCHAR *pszTemp = _tcsrchr(szBuffer, '/');
+ strcpy(szBuffer, pszSrvPath);
+ char* pszTemp = strrchr(szBuffer, '/');
if (pszTemp)
*pszTemp = '\0';
- pszTemp = _tcsrchr(szBuffer, '/');
+ pszTemp = strrchr(szBuffer, '/');
if (pszTemp)
- _tcscpy(szName, pszTemp + 1);
+ strcpy(szName, pszTemp + 1);
if (szName[0] == '\0')
- _tcscpy(szName, _T("my Miranda Webserver"));
+ strcpy(szName, "my Miranda Webserver");
do {
switch (*pszPos) {
@@ -355,9 +355,9 @@ bool bCreateIndexHTML(const TCHAR *pszRealPath, const TCHAR *pszIndexPath, const
}
}
- while (!_tcscmp(fdFindFileData.cFileName, _T(".")) ||
- !_tcsncmp(fdFindFileData.cFileName, _T("@"), 1) ||
- (!_tcscmp(fdFindFileData.cFileName, _T("..")) && !_tcscmp(pszSrvPath, _T("/"))) || // hide .. in root
+ while (!strcmp(fdFindFileData.cFileName, ".") ||
+ !strncmp(fdFindFileData.cFileName, "@", 1) ||
+ (!strcmp(fdFindFileData.cFileName, "..") && !strcmp(pszSrvPath, "/")) || // hide .. in root
((*pszPos == 19) == ((fdFindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0))) {
if (!FindNextFile(hFind, &fdFindFileData)) {
FindClose(hFind);
@@ -369,14 +369,14 @@ bool bCreateIndexHTML(const TCHAR *pszRealPath, const TCHAR *pszIndexPath, const
}
if (hFind) {
- _tcscpy(szName, fdFindFileData.cFileName);
- _tcscpy(szURL, fdFindFileData.cFileName);
+ strcpy(szName, fdFindFileData.cFileName);
+ strcpy(szURL, fdFindFileData.cFileName);
/*char* pszTmp = szURL;
while(pszTmp = strchr(pszTmp, ' '))
*pszTmp = '+';*/
if (*pszPos == SY_FOR_DIRS) { // For Directories
- _tcscat(szURL, _T("/"));
+ strcat(szURL, "/");
} else { // For Files
iFileSize = fdFindFileData.nFileSizeLow;
ftFileCreateTime = fdFindFileData.ftCreationTime;
@@ -410,13 +410,13 @@ bool bCreateIndexHTML(const TCHAR *pszRealPath, const TCHAR *pszIndexPath, const
case SY_FILE_NAME:
case SY_DIR_NAME: {
- pszBuffer += mir_sntprintf(pszBuffer, 250, _T("%s"), szName);
+ pszBuffer += mir_snprintf(pszBuffer, 250, "%s", szName);
break;
}
case SY_DIR_URL: {
case SY_FILE_URL:
- pszBuffer += mir_sntprintf(pszBuffer, 250, _T("%s"), szURL);
+ pszBuffer += mir_snprintf(pszBuffer, 250, "%s", szURL);
break;
}
@@ -427,7 +427,7 @@ bool bCreateIndexHTML(const TCHAR *pszRealPath, const TCHAR *pszIndexPath, const
(*pszPos == SY_FILE_CREATE_TIME) ? &ftFileCreateTime : &ftFileModifyTime,
&systemTime);
- pszBuffer += mir_sntprintf(pszBuffer, 100, _T("%i/%02i/%02i %i:%02i:%02i"),
+ pszBuffer += mir_snprintf(pszBuffer, 100, "%i/%02i/%02i %i:%02i:%02i",
systemTime.wYear, systemTime.wMonth, systemTime.wDay, systemTime.wHour,
systemTime.wMinute, systemTime.wSecond);
break;
@@ -435,11 +435,11 @@ bool bCreateIndexHTML(const TCHAR *pszRealPath, const TCHAR *pszIndexPath, const
case SY_FILE_SIZE: {
if ((iFileSize >> 10) == 0)
- pszBuffer += mir_sntprintf(pszBuffer, 100, _T("%i Byte"), iFileSize);
+ pszBuffer += mir_snprintf(pszBuffer, 100, "%i Byte", iFileSize);
else if ((iFileSize >> 20) == 0)
- pszBuffer += mir_sntprintf(pszBuffer, 100, _T("%.1f KB"), (float)(iFileSize) / 1024.0f);
+ pszBuffer += mir_snprintf(pszBuffer, 100, "%.1f KB", (float)(iFileSize) / 1024.0f);
else
- pszBuffer += mir_sntprintf(pszBuffer, 100, _T("%.1f MB"), (float)(iFileSize) / (1024.0f * 1024.0f));
+ pszBuffer += mir_snprintf(pszBuffer, 100, "%.1f MB", (float)(iFileSize) / (1024.0f * 1024.0f));
break;
}
@@ -461,7 +461,7 @@ bool bCreateIndexHTML(const TCHAR *pszRealPath, const TCHAR *pszIndexPath, const
iCurrentAction = *pszPos;
byte iParamCount = *(pszPos + 3);
- TCHAR* pszParam = pszPos + 4;
+ char* pszParam = pszPos + 4;
bool bSkip = true;
if (bKnownFileType == false) {
@@ -469,16 +469,16 @@ bool bCreateIndexHTML(const TCHAR *pszRealPath, const TCHAR *pszIndexPath, const
bSkip = false;
} else {
for (byte i = 0; i < iParamCount; i++) {
- TCHAR szParam[MAX_PARAM_LENGTH+1];
- _tcsncpy(szParam, pszParam, MAX_PARAM_LENGTH);
+ char szParam[MAX_PARAM_LENGTH+1];
+ strncpy(szParam, pszParam, MAX_PARAM_LENGTH);
szParam[MAX_PARAM_LENGTH] = '\0';
- TCHAR *pszTmp = _tcschr(szParam, ':');
+ char* pszTmp = strchr(szParam, ':');
if (pszTmp)
*pszTmp = '\0';
- TCHAR *pszExt = _tcsrchr(szName, '.');
+ char* pszExt = strrchr(szName, '.');
- if (pszExt && !_tcsicmp(pszExt + 1, szParam)) {
+ if (pszExt && !_stricmp(pszExt + 1, szParam)) {
bSkip = false;
break;
}
diff --git a/plugins/HTTPServer/src/IndexXML.cpp b/plugins/HTTPServer/src/IndexXML.cpp
index 098725b9a8..942e572433 100644
--- a/plugins/HTTPServer/src/IndexXML.cpp
+++ b/plugins/HTTPServer/src/IndexXML.cpp
@@ -17,31 +17,31 @@
#include "Glob.h"
-static const char szXmlHeader1[] = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\r\n"
- "<?xml-stylesheet type=\"text/xsl\" href=\"";
+static const TCHAR szXmlHeader1[] = _T("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\r\n")
+ _T("<?xml-stylesheet type=\"text/xsl\" href=\"");
-static const char szXmlHeader2[] = "\"?>\r\n"
- "<config>\r\n";
+static const TCHAR szXmlHeader2[] = _T("\"?>\r\n")
+ _T("<config>\r\n");
-static const char szXmlTail[] = "</config>";
+static const TCHAR szXmlTail[] = _T("</config>");
-static void ReplaceSign(TCHAR *pszSrc, int MaxLength, const TCHAR pszReplace, const TCHAR *pszNew)
-{
- static TCHAR szBuffer[1024];
- TCHAR *pszSign = _tcschr(pszSrc, pszReplace);
+static void ReplaceSign(char* pszSrc, int MaxLength, const char pszReplace,
+ const char * pszNew) {
+ static char szBuffer[1024];
+ char* pszSign = strchr(pszSrc, pszReplace);
if (pszSign) {
- _tcscpy(szBuffer, pszSrc);
+ strcpy(szBuffer, pszSrc);
do {
- _tcscpy(szBuffer + (pszSign - pszSrc), pszNew);
- _tcscpy(szBuffer + (pszSign - pszSrc) + _tcslen(pszNew), pszSign + 1);
+ strcpy(szBuffer + (pszSign - pszSrc), pszNew);
+ strcpy(szBuffer + (pszSign - pszSrc) + strlen(pszNew), pszSign + 1);
*pszSign = ' ';
- } while (pszSign = _tcschr(pszSrc, pszReplace));
+ } while (pszSign = strchr(pszSrc, pszReplace));
- _tcsncpy(pszSrc, szBuffer, MaxLength);
+ strncpy(pszSrc, szBuffer, MaxLength);
pszSrc[MaxLength-1] = '\0';
}
@@ -61,13 +61,13 @@ static void ReplaceSign(TCHAR *pszSrc, int MaxLength, const TCHAR pszReplace, co
// Developer : Houdini
/////////////////////////////////////////////////////////////////////
-bool bCreateIndexXML(const TCHAR *pszRealPath, const TCHAR *pszIndexPath, const TCHAR *pszSrvPath, DWORD dwRemoteIP)
-{
- TCHAR szMask[MAX_PATH+1];
- _tcscpy(szMask, pszRealPath);
- _tcscat(szMask, _T("*"));
+bool bCreateIndexXML(const char * pszRealPath, const char * pszIndexPath,
+ const char * pszSrvPath, DWORD dwRemoteIP) {
+ char szMask[MAX_PATH+1];
+ strcpy(szMask, pszRealPath);
+ strcat(szMask, "*");
- WIN32_FIND_DATA fdFindFileData;
+ WIN32_FIND_DATAA fdFindFileData;
HANDLE hFind = FindFirstFile(szMask, &fdFindFileData);
if (hFind == INVALID_HANDLE_VALUE)
@@ -82,90 +82,90 @@ bool bCreateIndexXML(const TCHAR *pszRealPath, const TCHAR *pszIndexPath, const
}
const int BUFFER_SIZE = 1000;
- TCHAR szBuffer[BUFFER_SIZE+1];
- TCHAR *pszBuffer = szBuffer;
- TCHAR szFileName[MAX_PATH+1] = _T("");
- TCHAR* pszExt;
+ char szBuffer[BUFFER_SIZE+1];
+ char* pszBuffer = szBuffer;
+ char szFileName[MAX_PATH+1] = "";
+ char* pszExt;
DWORD dwBytesWritten = 0;
// Generate Dirname
- _tcscpy(szBuffer, pszSrvPath);
- TCHAR *pszTemp = _tcsrchr(szBuffer, '/');
+ strcpy(szBuffer, pszSrvPath);
+ char* pszTemp = strrchr(szBuffer, '/');
if (pszTemp)
*pszTemp = '\0';
- pszTemp = _tcsrchr(szBuffer, '/');
+ pszTemp = strrchr(szBuffer, '/');
if (pszTemp)
- _tcscpy(szFileName, pszTemp + 1);
+ strcpy(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);
- _tcscat(szMask, _T("index.xsl"));
+ strcpy(szMask, pszRealPath);
+ strcat(szMask, "index.xsl");
HANDLE hFileExists = CreateFile(szMask, GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, NULL);
if (hFileExists == INVALID_HANDLE_VALUE) {
- _tcscpy(szBuffer, _T("/index.xsl"));
+ strcpy(szBuffer, "/index.xsl");
} else {
CloseHandle(hFileExists);
- _tcscpy(szBuffer, _T("index.xsl"));
+ strcpy(szBuffer, "index.xsl");
}
- WriteFile(hFile, szBuffer, (DWORD)_tcslen(szBuffer), &dwBytesWritten, NULL);
+ WriteFile(hFile, szBuffer, (DWORD)strlen(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;"));
- pszBuffer += mir_sntprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
- _T(" <dirname>%s</dirname>\r\n"), szFileName);
+ ReplaceSign(szFileName, MAX_PATH, '&', "&amp;");
+ pszBuffer += mir_snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
+ " <dirname>%s</dirname>\r\n", szFileName);
WriteFile(hFile, szBuffer, pszBuffer - szBuffer, &dwBytesWritten, NULL);
// Find files and directories
do {
- if (_tcscmp(fdFindFileData.cFileName, _T(".")) &&
- _tcsncmp(fdFindFileData.cFileName, _T("@"), _tcslen(_T("@"))) &&
- (_tcscmp(fdFindFileData.cFileName, _T("..")) || _tcscmp(pszSrvPath, _T("/")))) { // hide .. in root
+ if (strcmp(fdFindFileData.cFileName, ".") &&
+ strncmp(fdFindFileData.cFileName, "@", 1) &&
+ (strcmp(fdFindFileData.cFileName, "..") || strcmp(pszSrvPath, "/"))) { // hide .. in root
pszBuffer = szBuffer;
- _tcscpy(szFileName, fdFindFileData.cFileName);
- ReplaceSign(szFileName, MAX_PATH, '&', _T("&amp;"));
+ strcpy(szFileName, fdFindFileData.cFileName);
+ ReplaceSign(szFileName, MAX_PATH, '&', "&amp;");
if (fdFindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
- pszBuffer += mir_sntprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
- _T(" <item name=\"%s\" isdir=\"true\"/>\r\n"), szFileName);
+ pszBuffer += mir_snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
+ " <item name=\"%s\" isdir=\"true\"/>\r\n", szFileName);
} else {
- pszExt = _tcsrchr(szFileName, '.');
+ pszExt = strrchr(szFileName, '.');
if (pszExt != NULL) {
*pszExt = '\0';
pszExt++;
}
- pszBuffer += mir_sntprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
- _T(" <item name=\"%s\" ext=\"%s\" size=\"%i\" "),
- szFileName, (pszExt == NULL) ? _T("") : pszExt, fdFindFileData.nFileSizeLow);
+ pszBuffer += mir_snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
+ " <item name=\"%s\" ext=\"%s\" size=\"%i\" ",
+ szFileName, (pszExt == NULL) ? "" : pszExt, fdFindFileData.nFileSizeLow);
SYSTEMTIME systemTime;
FileTimeToSystemTime(&fdFindFileData.ftCreationTime, &systemTime);
- pszBuffer += mir_sntprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
- _T("created=\"%i/%02i/%02i %i:%02i:%02i\" "),
+ pszBuffer += mir_snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
+ "created=\"%i/%02i/%02i %i:%02i:%02i\" ",
systemTime.wYear, systemTime.wMonth, systemTime.wDay, systemTime.wHour,
systemTime.wMinute, systemTime.wSecond);
FileTimeToSystemTime(&fdFindFileData.ftLastWriteTime, &systemTime);
- pszBuffer += mir_sntprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
- _T("modified=\"%i/%02i/%02i %i:%02i:%02i\" "),
+ pszBuffer += mir_snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
+ "modified=\"%i/%02i/%02i %i:%02i:%02i\" ",
systemTime.wYear, systemTime.wMonth, systemTime.wDay, systemTime.wHour,
systemTime.wMinute, systemTime.wSecond);
- pszBuffer += mir_sntprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
- _T("/>\r\n"));
+ pszBuffer += mir_snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
+ "/>\r\n");
}
if (!WriteFile(hFile, szBuffer, pszBuffer - szBuffer, &dwBytesWritten, NULL))
@@ -180,27 +180,27 @@ bool bCreateIndexXML(const TCHAR *pszRealPath, const TCHAR *pszIndexPath, const
// Add other shared files & directories
for (CLFileShareNode * pclCur = pclFirstNode; pclCur ; pclCur = pclCur->pclNext) {
if (!((pclCur->st.dwAllowedIP ^ dwRemoteIP) & pclCur->st.dwAllowedMask) && // hide inaccessible shares
- (size_t)(pclCur->nGetSrvPathLen()) > _tcslen(pszSrvPath) &&
- !_tcsstr(pclCur->st.pszRealPath, _T("\\@")) &&
- !_tcsncmp(pclCur->st.pszSrvPath, pszSrvPath, _tcslen(pszSrvPath))) {
+ (size_t)(pclCur->nGetSrvPathLen()) > strlen(pszSrvPath) &&
+ !strstr(pclCur->st.pszRealPath, "\\@") &&
+ !strncmp(pclCur->st.pszSrvPath, pszSrvPath, strlen(pszSrvPath))) {
pszBuffer = szBuffer;
- _tcscpy(szFileName, &pclCur->st.pszSrvPath[_tcslen(pszSrvPath)]);
- ReplaceSign(szFileName, MAX_PATH, '&', _T("&amp;"));
+ strcpy(szFileName, &pclCur->st.pszSrvPath[strlen(pszSrvPath)]);
+ ReplaceSign(szFileName, MAX_PATH, '&', "&amp;");
if (pclCur->bIsDirectory()) {
- szFileName[_tcslen(szFileName)-1] = '\0';
- if (!_tcschr(szFileName, '/')) { // only one level deeper
- pszBuffer += mir_sntprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
- _T(" <item name=\"%s\" isdir=\"true\"/>\r\n"), szFileName);
+ szFileName[strlen(szFileName)-1] = '\0';
+ if (!strchr(szFileName, '/')) { // only one level deeper
+ pszBuffer += mir_snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
+ " <item name=\"%s\" isdir=\"true\"/>\r\n", szFileName);
if (!WriteFile(hFile, szBuffer, pszBuffer - szBuffer, &dwBytesWritten, NULL))
break;
}
} else {
- if (!_tcschr(szFileName, '/') && // only one level deeper
- _tcsncmp(pszRealPath, pclCur->st.pszRealPath, _tcslen(pszRealPath))) { // no duplicates
- pszExt = _tcsrchr(szFileName, '.');
+ if (!strchr(szFileName, '/') && // only one level deeper
+ strncmp(pszRealPath, pclCur->st.pszRealPath, strlen(pszRealPath))) { // no duplicates
+ pszExt = strrchr(szFileName, '.');
if (pszExt != NULL) {
*pszExt = '\0';
@@ -219,25 +219,25 @@ bool bCreateIndexXML(const TCHAR *pszRealPath, const TCHAR *pszIndexPath, const
CloseHandle(hFileS);
}
- pszBuffer += mir_sntprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
- _T(" <item name=\"%s\" ext=\"%s\" size=\"%i\" "),
- szFileName, (pszExt == NULL) ? _T("") : pszExt, dwFileSize);
+ pszBuffer += mir_snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
+ " <item name=\"%s\" ext=\"%s\" size=\"%i\" ",
+ szFileName, (pszExt == NULL) ? "" : pszExt, dwFileSize);
SYSTEMTIME systemTime;
FileTimeToSystemTime(&ftFileCreateTime, &systemTime);
- pszBuffer += mir_sntprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
- _T("created=\"%i/%02i/%02i %i:%02i:%02i\" "),
+ pszBuffer += mir_snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
+ "created=\"%i/%02i/%02i %i:%02i:%02i\" ",
systemTime.wYear, systemTime.wMonth, systemTime.wDay, systemTime.wHour,
systemTime.wMinute, systemTime.wSecond);
FileTimeToSystemTime(&ftFileModifyTime, &systemTime);
- pszBuffer += mir_sntprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
- _T("modified=\"%i/%02i/%02i %i:%02i:%02i\" "),
+ pszBuffer += mir_snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
+ "modified=\"%i/%02i/%02i %i:%02i:%02i\" ",
systemTime.wYear, systemTime.wMonth, systemTime.wDay, systemTime.wHour,
systemTime.wMinute, systemTime.wSecond);
- pszBuffer += mir_sntprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
- _T("/>\r\n"));
+ pszBuffer += mir_snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
+ "/>\r\n");
if (!WriteFile(hFile, szBuffer, pszBuffer - szBuffer, &dwBytesWritten, NULL))
break;
@@ -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/MimeHandling.cpp b/plugins/HTTPServer/src/MimeHandling.cpp
index 8bce315b81..9656753056 100644
--- a/plugins/HTTPServer/src/MimeHandling.cpp
+++ b/plugins/HTTPServer/src/MimeHandling.cpp
@@ -3,53 +3,53 @@
/* MIME type/ext map */
ContentTypeDB MIME = NULL;
/* Default Mime type when recognition fails */
-TCHAR DefaultMime[] = _T("application/octet-stream");
+char DefaultMime[] = "application/octet-stream";
int bInitMimeHandling() {
FILE *mimeDB;
- TCHAR line[LINE_MAX_SIZE];
- TCHAR *tok = NULL;
+ char line[LINE_MAX_SIZE];
+ char *tok = NULL;
ContentType *pDBCell = NULL;
ContentTypeDB pDB = NULL;
ExtensionList extListCur = NULL;
ExtensionListCell *pExtCell = NULL;
- TCHAR szBuf[10000];
+ char szBuf[10000];
- _tcscpy(szBuf, szPluginPath);
- _tcscat(szBuf, szMimeTypeConfigFile);
- mimeDB = _tfopen(szBuf, _T("r"));
+ strcpy(szBuf, szPluginPath);
+ strcat(szBuf, szMimeTypeConfigFile);
+ mimeDB = fopen(szBuf, "r");
if (mimeDB != NULL) {
- while (_fgetts(line, LINE_MAX_SIZE, mimeDB)) {
+ while (fgets(line, LINE_MAX_SIZE, mimeDB)) {
/*filter junk lines assuming Mime type start with letter
(convention ?) */
if ((line[0] <= 'z' && line[0] >= 'a')
|| (line[0] <= 'Z' && line[0] >= 'A')) {
/*remove comments trailing comments*/
- tok = _tcsrchr(line, '#');
+ tok = strrchr(line, '#');
if (tok != NULL) {
*tok = '\0';
}
/* remove trailing \n */
- int lenght = (int)_tcslen(line);
+ int lenght = (int)strlen(line);
if (lenght > 0 && line[lenght - 1] == '\n')
line[lenght - 1] = '\0';
/* first token = mime type */
- tok = (TCHAR *)_tcstok(line, _T(" \t"));
+ tok = (char*)strtok(line, " \t");
/*create and fill a cell*/
pDBCell = (ContentType*)malloc(sizeof(ContentType));
- pDBCell->mimeType = (TCHAR *)malloc((_tcslen(tok) + 1) * sizeof(TCHAR));
- _tcscpy(pDBCell->mimeType, tok);
+ pDBCell->mimeType = (char*)malloc(strlen(tok) + 1);
+ strcpy(pDBCell->mimeType, tok);
pDBCell->extList = NULL;
pDBCell->next = NULL;
/* looking for extensions */
- tok = (TCHAR *)_tcstok(NULL, _T(" \t"));
+ tok = (char*)strtok(NULL, " \t");
while (tok != NULL) {
/*create and fill a cell*/
pExtCell = (ExtensionListCell*)malloc(sizeof(ExtensionListCell));
- pExtCell->ext = (TCHAR *)malloc((_tcslen(tok) + 1) * sizeof(TCHAR));
- _tcscpy(pExtCell->ext, tok);
+ pExtCell->ext = (char*)malloc(strlen(tok) + 1);
+ strcpy(pExtCell->ext, tok);
pExtCell->next = NULL;
/*link*/
if (pDBCell->extList == NULL) {
@@ -58,7 +58,7 @@ int bInitMimeHandling() {
extListCur->next = pExtCell;
}
extListCur = pExtCell;
- tok = (TCHAR *)_tcstok(NULL, _T(" \t"));
+ tok = (char*)strtok(NULL, " \t");
}
/* link */
if (pDBCell->extList != NULL) { /*extension(s) found*/
@@ -83,13 +83,12 @@ int bInitMimeHandling() {
return 1;
}
-const TCHAR *pszGetMimeType(const TCHAR *pszFileName)
-{
+const char * pszGetMimeType(const char * pszFileName) {
ContentTypeDB courMIME;
ExtensionList courEXT;
- const TCHAR *ext;
+ const char* ext;
- ext = _tcsrchr(pszFileName, '.');
+ ext = strrchr(pszFileName, '.');
if (ext != NULL) {
if (ext[1] == '\0') {
@@ -104,7 +103,7 @@ const TCHAR *pszGetMimeType(const TCHAR *pszFileName)
while (courMIME != NULL) {
courEXT = courMIME->extList;
while (courEXT != NULL) {
- if (!_tcsicmp(courEXT->ext, ext)) {
+ if (!_stricmp(courEXT->ext, ext)) {
return courMIME->mimeType;
}
courEXT = courEXT->next;
diff --git a/plugins/HTTPServer/src/MimeHandling.h b/plugins/HTTPServer/src/MimeHandling.h
index 80efcc1243..f40fdf94c8 100644
--- a/plugins/HTTPServer/src/MimeHandling.h
+++ b/plugins/HTTPServer/src/MimeHandling.h
@@ -4,7 +4,7 @@
extern "C" {
#endif
-#define szMimeTypeConfigFile _T("HTTPMimeTypes")
+#define szMimeTypeConfigFile "HTTPMimeTypes"
/* MIME DB Data structure
@@ -28,24 +28,24 @@ extern "C" {
*/
typedef struct _ExtensionListCell {
- TCHAR *ext;
- struct _ExtensionListCell *next;
- } ExtensionListCell;
+ char* ext;
+ struct _ExtensionListCell* next;
+ } ExtensionListCell ;
typedef struct _ContentType {
- TCHAR *mimeType;
- ExtensionListCell *extList;
- struct _ContentType *next;
- } ContentType;
+ char* mimeType;
+ ExtensionListCell* extList;
+ struct _ContentType* next;
+ } ContentType ;
- typedef ContentType *ContentTypeDB;
- typedef ExtensionListCell *ExtensionList;
+ typedef ContentType* ContentTypeDB;
+ typedef ExtensionListCell* ExtensionList;
extern int bInitMimeHandling();
- extern const TCHAR *pszGetMimeType(const TCHAR *pszFileName);
+ extern const char * pszGetMimeType(const char * pszFileName);
#ifdef __cplusplus
}
diff --git a/plugins/HTTPServer/src/main.cpp b/plugins/HTTPServer/src/main.cpp
index 405dcf1816..cd3062d859 100644
--- a/plugins/HTTPServer/src/main.cpp
+++ b/plugins/HTTPServer/src/main.cpp
@@ -18,27 +18,27 @@
#include "Glob.h"
-#define szConfigFile _T("HTTPServer.xml")
-
-const char szXmlHeader[] = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\r\n"
- "<?xml-stylesheet type=\"text/xsl\" href=\"HTTPServer.xsl\"?>\r\n"
- "<config>\r\n";
-
-const TCHAR szXmlData[] = _T("\t<share>\r\n")
- _T("\t\t<name>%s</name>\r\n")
- _T("\t\t<file>%s</file>\r\n")
- _T("\t\t<max_downloads>%d</max_downloads>\r\n")
- _T("\t\t<ip_address>%d.%d.%d.%d</ip_address>\r\n")
- _T("\t\t<ip_mask>%d.%d.%d.%d</ip_mask>\r\n")
- _T("\t</share>\r\n");
-
-const char szXmlTail[] = "</config>";
-
-const TCHAR* pszDefaultShares[] = {
- _T("htdocs\\@settings\\favicon.ico"), _T("/favicon.ico"),
- _T("htdocs\\@settings\\index.xsl"), _T("/index.xsl"),
- _T("htdocs\\@settings\\theme\\"), _T("/theme/"),
- _T("htdocs\\"), _T("/"),
+#define szConfigFile "HTTPServer.xml"
+
+const TCHAR szXmlHeader[] = _T("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\r\n")
+ _T("<?xml-stylesheet type=\"text/xsl\" href=\"HTTPServer.xsl\"?>\r\n")
+ _T("<config>\r\n");
+
+const char szXmlData[] = "\t<share>\r\n"
+ "\t\t<name>%s</name>\r\n"
+ "\t\t<file>%s</file>\r\n"
+ "\t\t<max_downloads>%d</max_downloads>\r\n"
+ "\t\t<ip_address>%d.%d.%d.%d</ip_address>\r\n"
+ "\t\t<ip_mask>%d.%d.%d.%d</ip_mask>\r\n"
+ "\t</share>\r\n";
+
+const TCHAR szXmlTail[] = _T("</config>");
+
+const char* pszDefaultShares[] = {
+ "htdocs\\@settings\\favicon.ico", "/favicon.ico",
+ "htdocs\\@settings\\index.xsl", "/index.xsl",
+ "htdocs\\@settings\\theme\\", "/theme/",
+ "htdocs\\", "/",
0, 0
};
@@ -50,7 +50,7 @@ HANDLE hDirectBoundPort;
HINSTANCE hInstance = NULL;
-tstring sLogFilePath;
+string sLogFilePath;
// static so they can not be used from other modules ( sourcefiles )
static HANDLE hEventSystemInit = 0;
@@ -63,7 +63,7 @@ static HANDLE hHttpGetAllShares = 0;
static HGENMENU hAcceptConnectionsMenuItem = 0;
-TCHAR szPluginPath[MAX_PATH] = {0};
+char szPluginPath[MAX_PATH] = {0};
int nPluginPathLen = 0;
DWORD dwLocalIpAddress = 0;
@@ -125,10 +125,9 @@ bool bOpenLogFile() {
}
-bool bWriteToFile(HANDLE hFile, const TCHAR *pszSrc, int nLen = -1)
-{
+bool bWriteToFile(HANDLE hFile, const char * pszSrc, int nLen = -1) {
if (nLen < 0)
- nLen = (int)_tcslen(pszSrc);
+ nLen = (int)strlen(pszSrc);
DWORD dwBytesWritten;
return WriteFile(hFile, pszSrc, nLen, &dwBytesWritten, NULL) && (dwBytesWritten == (DWORD)nLen);
}
@@ -148,8 +147,7 @@ bool bWriteToFile(HANDLE hFile, const TCHAR *pszSrc, int nLen = -1)
// Developer : KN
/////////////////////////////////////////////////////////////////////
-void LogEvent(const TCHAR *pszTitle, const TCHAR *pszLog)
-{
+void LogEvent(const TCHAR * pszTitle, const char * pszLog) {
HANDLE hFile = CreateFile(sLogFilePath.c_str(), GENERIC_WRITE, FILE_SHARE_READ, 0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE) {
MessageBox(NULL, TranslateT("Failed to open or create log file"), MSG_BOX_TITEL, MB_OK);
@@ -161,20 +159,20 @@ void LogEvent(const TCHAR *pszTitle, const TCHAR *pszLog)
return;
}
- TCHAR szTmp[128];
+ char szTmp[128];
time_t now;
time(&now);
- int nLen = (int)_tcsftime(szTmp, SIZEOF(szTmp), _T("%d-%m-%Y %H:%M:%S -- "), localtime(&now));
+ int nLen = (int)strftime(szTmp, sizeof(szTmp), "%d-%m-%Y %H:%M:%S -- ", localtime(&now));
- int nLogLen = (int)_tcslen(pszLog);
+ int nLogLen = (int)strlen(pszLog);
while (nLogLen > 0 && (pszLog[nLogLen-1] == '\r' || pszLog[nLogLen-1] == '\n'))
nLogLen--;
if (!bWriteToFile(hFile, szTmp, nLen) ||
!bWriteToFile(hFile, pszTitle) ||
- !bWriteToFile(hFile, _T(" : ")) ||
+ !bWriteToFile(hFile, " : ") ||
!bWriteToFile(hFile, pszLog, nLogLen) ||
- !bWriteToFile(hFile, _T("\r\n"))) {
+ !bWriteToFile(hFile, "\r\n")) {
MessageBox(NULL, TranslateT("Failed to write some part of the log file"), MSG_BOX_TITEL, MB_OK);
}
CloseHandle(hFile);
@@ -195,12 +193,11 @@ void LogEvent(const TCHAR *pszTitle, const TCHAR *pszLog)
// Developer : KN
/////////////////////////////////////////////////////////////////////
-DWORD dwReadIPAddress(TCHAR *pszStr, bool &bError)
-{
+DWORD dwReadIPAddress(char * pszStr, bool &bError) {
DWORD ip = 0;
- TCHAR *pszEnd;
+ char *pszEnd;
for (int n = 0 ; n < 4 ; n++) {
- int nVal = _tcstol(pszStr, &pszEnd, 10);
+ int nVal = strtol(pszStr, &pszEnd, 10);
if (pszEnd <= pszStr || (n != 3 && pszEnd[0] != '.') || (nVal < 0 || nVal > 255)) {
bError = true;
return 0;
@@ -224,21 +221,20 @@ DWORD dwReadIPAddress(TCHAR *pszStr, bool &bError)
// Developer : KN
/////////////////////////////////////////////////////////////////////
-bool bReadConfigurationFile()
-{
+bool bReadConfigurationFile() {
CLFileShareListAccess clCritSection;
CLFileShareNode * pclLastNode = NULL;
- TCHAR szBuf[1000];
- _tcscpy(szBuf, szPluginPath);
- _tcscat(szBuf, szConfigFile);
+ char szBuf[1000];
+ strcpy(szBuf, szPluginPath);
+ strcat(szBuf, szConfigFile);
HANDLE hFile = CreateFile(szBuf, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE)
return false;
- TCHAR *pszCurPos = szBuf;
+ char *pszCurPos = szBuf;
bool bEof = false;
while (!bEof) {
@@ -246,33 +242,33 @@ bool bReadConfigurationFile()
// move rest of buffer to front
if (pszCurPos && pszCurPos != szBuf) {
- dwBytesInBuffer = DWORD(SIZEOF(szBuf) - (pszCurPos - szBuf));
- memmove(szBuf, pszCurPos, dwBytesInBuffer);
+ dwBytesInBuffer = DWORD(sizeof(szBuf) - (pszCurPos - szBuf));
+ memmove(szBuf, pszCurPos, dwBytesInBuffer * sizeof(TCHAR));
}
// append data to buffer
DWORD dwBytesRead = 0;
- bEof = !ReadFile(hFile, &szBuf[dwBytesInBuffer], SIZEOF(szBuf) - dwBytesInBuffer,
+ bEof = !ReadFile(hFile, &szBuf[dwBytesInBuffer], sizeof(szBuf) - dwBytesInBuffer,
&dwBytesRead, NULL) || dwBytesRead <= 0;
pszCurPos = szBuf;
if (pszCurPos) {
- while (pszCurPos && (pszCurPos = _tcsstr(pszCurPos, _T("<share>"))) != NULL) {
+ while (pszCurPos && (pszCurPos = strstr(pszCurPos, "<share>")) != NULL) {
pszCurPos += 7;
- TCHAR *pszColData[5] = {NULL};
+ char * pszColData[5] = {NULL};
for (int n = 0 ; n < 5 ; n++) {
- pszColData[n] = _tcsstr(pszCurPos, _T(">"));
+ pszColData[n] = strstr(pszCurPos, ">");
if (!pszColData[n])
break;
pszColData[n] += 1;
- pszCurPos = _tcsstr(pszColData[n], _T("</"));
+ pszCurPos = strstr(pszColData[n], "</");
if (!pszCurPos)
break;
pszCurPos[0] = 0;// NULL terminate row data, we overwrite the '<'
- pszCurPos = _tcsstr(pszCurPos + 3, _T(">"));
+ pszCurPos = strstr(pszCurPos + 3, ">");
if (!pszCurPos)
break;
@@ -284,9 +280,9 @@ bool bReadConfigurationFile()
CLFileShareNode * pcl = new CLFileShareNode(pszColData[0], pszColData[1]);
bool bError = false;
- TCHAR * pszEnd;
+ char * pszEnd;
- pcl->st.nMaxDownloads = _tcstol(pszColData[2], &pszEnd, NULL);
+ pcl->st.nMaxDownloads = strtol(pszColData[2], &pszEnd, NULL);
if (!pszEnd || *pszEnd != NULL)
bError = true;
@@ -305,7 +301,7 @@ bool bReadConfigurationFile()
}
// refill buffer
- if (!bEof && pszCurPos - szBuf > SIZEOF(szBuf) / 2)
+ if (!bEof && pszCurPos - szBuf > sizeof(szBuf) / 2)
break;
}
}
@@ -328,29 +324,28 @@ bool bReadConfigurationFile()
// Developer : KN
/////////////////////////////////////////////////////////////////////
-bool bWriteConfigurationFile()
-{
+bool bWriteConfigurationFile() {
CLFileShareListAccess clCritSection;
- TCHAR szBuf[1000];
- _tcscpy(szBuf, szPluginPath);
- _tcscat(szBuf, szConfigFile);
+ char szBuf[1000];
+ strcpy(szBuf, szPluginPath);
+ strcat(szBuf, szConfigFile);
HANDLE hFile = CreateFile(szBuf, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE) {
TCHAR temp[200];
- mir_sntprintf(temp, SIZEOF(temp), _T("%s%s"), TranslateT("Failed to open or create file "), szConfigFile);
- MessageBox(NULL, temp, MSG_BOX_TITEL, MB_OK);
+ mir_sntprintf(temp, SIZEOF(temp), _T("%s%s"), TranslateT("Failed to open or create file "), _T(szConfigFile));
+ MessageBox(NULL, temp , MSG_BOX_TITEL, MB_OK);
return false;
}
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);
+ mir_sntprintf(temp, SIZEOF(temp), _T("%s%s"), TranslateT("Failed to write xml header to file "), _T(szConfigFile));
MessageBox(NULL, temp, MSG_BOX_TITEL, MB_OK);
} else {
CLFileShareNode * pclCur = pclFirstNode;
while (pclCur) {
- DWORD dwBytesToWrite = mir_sntprintf(szBuf, SIZEOF(szBuf), szXmlData,
+ DWORD dwBytesToWrite = mir_snprintf(szBuf, sizeof(szBuf), szXmlData ,
pclCur->st.pszSrvPath,
pclCur->pszOrigRealPath,
pclCur->st.nMaxDownloads,
@@ -359,16 +354,16 @@ bool bWriteConfigurationFile()
if (! WriteFile(hFile, szBuf, dwBytesToWrite, &dwBytesWriten, NULL)) {
TCHAR temp[200];
- mir_sntprintf(temp, SIZEOF(temp), _T("%s%s"), TranslateT("Failed to write xml data to file "), szConfigFile);
+ mir_sntprintf(temp, SIZEOF(temp), _T("%s%s"), TranslateT("Failed to write xml data to file "), _T(szConfigFile));
MessageBox(NULL, temp, MSG_BOX_TITEL, MB_OK);
break;
}
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);
+ mir_sntprintf(temp, SIZEOF(temp), _T("%s%s"), TranslateT("Failed to write xml tail to file "), _T(szConfigFile));
MessageBox(NULL, temp, MSG_BOX_TITEL, MB_OK);
}
}
@@ -399,9 +394,9 @@ static INT_PTR nAddChangeRemoveShare(WPARAM wParam, LPARAM lParam) {
STFileShareInfo * pclNew = (STFileShareInfo*)lParam;
// make the server path lowercase
- TCHAR *pszPos = pclNew->pszSrvPath;
+ char* pszPos = pclNew->pszSrvPath;
while (*pszPos) {
- *pszPos = tolower(*pszPos);
+ *pszPos = (char)tolower(*pszPos);
pszPos++;
}
@@ -409,7 +404,7 @@ static INT_PTR nAddChangeRemoveShare(WPARAM wParam, LPARAM lParam) {
return 1002;
CLFileShareListAccess clCritSection;
- bool bIsDirectory = (pclNew->pszSrvPath[_tcslen(pclNew->pszSrvPath)-1] == '/');
+ bool bIsDirectory = (pclNew->pszSrvPath[strlen(pclNew->pszSrvPath)-1] == '/');
CLFileShareNode **pclPrev = &pclFirstNode;
CLFileShareNode * pclCur = pclFirstNode;
@@ -423,7 +418,7 @@ static INT_PTR nAddChangeRemoveShare(WPARAM wParam, LPARAM lParam) {
}
while (pclCur) {
- if (_tcsicmp(pclCur->st.pszSrvPath, pclNew->pszSrvPath) == 0) {
+ if (_stricmp(pclCur->st.pszSrvPath, pclNew->pszSrvPath) == 0) {
if (pclCur->bAnyUsers()) {
// Some downloads are in progress we will try an terminate them !!
// we try for 5 sec.
@@ -489,10 +484,10 @@ static INT_PTR nGetShare(WPARAM /*wParam*/, LPARAM lParam) {
STFileShareInfo * pclShare = (STFileShareInfo*)lParam;
CLFileShareNode * pclCur = pclFirstNode;
while (pclCur) {
- if (_tcscmp(pclCur->st.pszSrvPath, pclShare->pszSrvPath) == 0) {
- if (pclShare->dwMaxRealPath <= _tcslen(pclCur->st.pszRealPath) + 1)
+ if (strcmp(pclCur->st.pszSrvPath, pclShare->pszSrvPath) == 0) {
+ if (pclShare->dwMaxRealPath <= strlen(pclCur->st.pszRealPath) + 1)
return 1003;
- _tcscpy(pclShare->pszRealPath, pclCur->st.pszRealPath);
+ strcpy(pclShare->pszRealPath, pclCur->st.pszRealPath);
pclShare->dwAllowedIP = pclCur->st.dwAllowedIP;
pclShare->dwAllowedMask = pclCur->st.dwAllowedMask;
pclShare->nMaxDownloads = pclCur->st.nMaxDownloads;
@@ -627,7 +622,7 @@ static int nProtoAck(WPARAM /*wParam*/, LPARAM lParam) {
INT_PTR nToggelAcceptConnections(WPARAM wparam, LPARAM /*lparam*/) {
CLISTMENUITEM mi = { sizeof(mi) };
- mi.flags = CMIF_TCHAR | CMIM_NAME | CMIM_ICON;
+ mi.flags = CMIM_NAME | CMIM_ICON;
if (!hDirectBoundPort) {
NETLIBUSERSETTINGS nus = { 0 };
@@ -648,8 +643,8 @@ INT_PTR nToggelAcceptConnections(WPARAM wparam, LPARAM /*lparam*/) {
hDirectBoundPort = (HANDLE) CallService(MS_NETLIB_BINDPORT, (WPARAM) hNetlibUser, (LPARAM) & nlb);
if (!hDirectBoundPort) {
TCHAR szTemp[200];
- mir_sntprintf(szTemp, SIZEOF(szTemp), TranslateT("Failed to bind to port %s\r\nThis is most likely because another program or service is using this port") ,
- nlb.wPort == 80 ? _T("80") : _A2T(nus.szIncomingPorts));
+ mir_snprintf(szTemp, SIZEOF(szTemp), TranslateT("Failed to bind to port %s\r\nThis is most likely because another program or service is using this port") ,
+ nlb.wPort == 80 ? "80" : nus.szIncomingPorts);
MessageBox(NULL, szTemp, MSG_BOX_TITEL, MB_OK);
return 1001;
}
@@ -658,13 +653,13 @@ INT_PTR nToggelAcceptConnections(WPARAM wparam, LPARAM /*lparam*/) {
mi.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_DISABLE_SERVER));
mi.ptszName = LPGENT("Disable HTTP server");
- Netlib_Logf(hNetlibUser, mi.pszName);
+ Netlib_LogfT(hNetlibUser, mi.ptszName);
} else if (hDirectBoundPort && wparam == 0) {
Netlib_CloseHandle(hDirectBoundPort);
hDirectBoundPort = 0;
mi.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_SHARE_NEW_FILE));
mi.ptszName = LPGENT("Enable HTTP server");
- Netlib_Logf(hNetlibUser, mi.pszName);
+ Netlib_LogfT(hNetlibUser, mi.ptszName);
} else {
return 0; // no changes;
}
@@ -721,24 +716,25 @@ int MainInit(WPARAM /*wparam*/, LPARAM /*lparam*/) {
if (! bReadConfigurationFile()) {
//MessageBox( NULL, "Failed to read configuration file : " szConfigFile, MSG_BOX_TITEL, MB_OK );
- TCHAR szRealPath[MAX_PATH];
- TCHAR szSrvPath[MAX_PATH] = {0};
- STFileShareInfo share = { 0 };
+ char szRealPath[MAX_PATH];
+ char szSrvPath[MAX_PATH] = {0};
+ STFileShareInfo share;
- const TCHAR** p = pszDefaultShares;
+ const char** p = pszDefaultShares;
while (*p) {
+ memset(&share, 0, sizeof(share));
share.lStructSize = sizeof(share);
share.dwAllowedIP = 0;
share.dwAllowedMask = 0;
share.nMaxDownloads = -1;
share.pszRealPath = szRealPath;
- share.dwMaxRealPath = SIZEOF(szRealPath);
- _tcscpy(share.pszRealPath, p[0]);
+ share.dwMaxRealPath = sizeof(szRealPath);
+ strcpy(share.pszRealPath, p[0]);
share.pszSrvPath = szSrvPath;
- share.dwMaxSrvPath = SIZEOF(szSrvPath);
- _tcscpy(share.pszSrvPath, p[1]);
+ share.dwMaxSrvPath = sizeof(szSrvPath);
+ strcpy(share.pszSrvPath, p[1]);
if (CallService(MS_HTTP_ADD_CHANGE_REMOVE, 0, (LPARAM)&share))
break;
@@ -902,26 +898,26 @@ int nSystemShutdown(WPARAM /*wparam*/, LPARAM /*lparam*/) {
return 1;
}
- if(CallService(MS_DB_GETPROFILEPATHT,MAX_PATH,(LPARAM)szPluginPath))
+ if(CallService(MS_DB_GETPROFILEPATH,MAX_PATH,(LPARAM)szPluginPath))
{
MessageBox(NULL, _T("Failed to retrieve plugin path."), MSG_BOX_TITEL, MB_OK);
return 1;
}
_tcsncat(szPluginPath,_T("\\HTTPServer\\"), MAX_PATH);
- int err = CreateDirectoryTreeT(szPluginPath);
+ int err = CreateDirectoryTree(szPluginPath);
if((err != 0) && (err != ERROR_ALREADY_EXISTS))
{
MessageBox(NULL, _T("Failed to create HTTPServer directory."), MSG_BOX_TITEL, MB_OK);
return 1;
}
- nPluginPathLen = (int)_tcslen(szPluginPath);
+ nPluginPathLen = (int)strlen(szPluginPath);
sLogFilePath = szPluginPath;
- sLogFilePath += _T("HTTPServer.log");
+ sLogFilePath += "HTTPServer.log";
- if (!bInitMimeHandling()) {
- MessageBox(NULL, _T("Failed to read configuration file : ") szMimeTypeConfigFile, MSG_BOX_TITEL, MB_OK);
+ if (! bInitMimeHandling()) {
+ MessageBox(NULL, "Failed to read configuration file : " szMimeTypeConfigFile, MSG_BOX_TITEL, MB_OK);
}
nMaxUploadSpeed = db_get_dw(NULL, MODULE, "MaxUploadSpeed", nMaxUploadSpeed);
@@ -936,7 +932,7 @@ int nSystemShutdown(WPARAM /*wparam*/, LPARAM /*lparam*/) {
mi.pszContactOwner = NULL; //all contacts
mi.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_SHARE_NEW_FILE));
mi.position = 1000085000;
- mi.ptszName = LPGENT("Enable HTTP server");
+ mi.pszName = LPGENT("Enable HTTP server");
mi.pszService = MS_HTTP_ACCEPT_CONNECTIONS;
hAcceptConnectionsMenuItem = Menu_AddMainMenuItem(&mi);
}