diff options
Diffstat (limited to 'plugins/HTTPServer/src')
-rw-r--r-- | plugins/HTTPServer/src/FileShareNode.cpp | 25 | ||||
-rw-r--r-- | plugins/HTTPServer/src/FileShareNode.h | 14 | ||||
-rw-r--r-- | plugins/HTTPServer/src/Glob.h | 4 | ||||
-rw-r--r-- | plugins/HTTPServer/src/GuiElements.cpp | 243 | ||||
-rw-r--r-- | plugins/HTTPServer/src/GuiElements.h | 4 | ||||
-rw-r--r-- | plugins/HTTPServer/src/HttpUser.cpp | 158 | ||||
-rw-r--r-- | plugins/HTTPServer/src/HttpUser.h | 26 | ||||
-rw-r--r-- | plugins/HTTPServer/src/IndexCreation.h | 6 | ||||
-rw-r--r-- | plugins/HTTPServer/src/IndexHTML.cpp | 134 | ||||
-rw-r--r-- | plugins/HTTPServer/src/IndexXML.cpp | 138 | ||||
-rw-r--r-- | plugins/HTTPServer/src/MimeHandling.cpp | 43 | ||||
-rw-r--r-- | plugins/HTTPServer/src/MimeHandling.h | 22 | ||||
-rw-r--r-- | plugins/HTTPServer/src/main.cpp | 149 |
13 files changed, 490 insertions, 476 deletions
diff --git a/plugins/HTTPServer/src/FileShareNode.cpp b/plugins/HTTPServer/src/FileShareNode.cpp index a5b57ecc14..cb5c3144b9 100644 --- a/plugins/HTTPServer/src/FileShareNode.cpp +++ b/plugins/HTTPServer/src/FileShareNode.cpp @@ -124,7 +124,8 @@ DWORD CLShareUser::dwGetDownloadSpeed() { // Developer : KN
/////////////////////////////////////////////////////////////////////
-CLFileShareNode::CLFileShareNode(char * pszSrvPath, char * pszRealPath) {
+CLFileShareNode::CLFileShareNode(TCHAR *pszSrvPath, TCHAR *pszRealPath)
+{
memset(&st, 0, sizeof(STFileShareInfo));
st.lStructSize = sizeof(STFileShareInfo);
pclNext = NULL;
@@ -195,7 +196,8 @@ CLFileShareNode::~CLFileShareNode() { // Developer : KN
/////////////////////////////////////////////////////////////////////
-bool CLFileShareNode::bSetPaths(char * pszSrvPath, char * pszRealPath) {
+bool CLFileShareNode::bSetPaths(TCHAR *pszSrvPath, TCHAR *pszRealPath)
+{
/* This might be a problem !!
if( nDownloadsInProgress > 0 )
return false;
@@ -207,25 +209,25 @@ bool CLFileShareNode::bSetPaths(char * pszSrvPath, char * pszRealPath) { delete [] st.pszSrvPath;
delete [] st.pszRealPath;
- st.dwMaxSrvPath = (int)strlen(pszSrvPath) + 1;
- st.pszSrvPath = new char[ st.dwMaxSrvPath ];
- strcpy(st.pszSrvPath, pszSrvPath);
+ st.dwMaxSrvPath = (int)_tcslen(pszSrvPath) + 1;
+ st.pszSrvPath = new TCHAR[st.dwMaxSrvPath];
+ _tcscpy(st.pszSrvPath, pszSrvPath);
- int nRealLen = (int)strlen(pszRealPath);
+ int nRealLen = (int)_tcslen(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 char[ st.dwMaxRealPath ];
- strcpy(st.pszRealPath, szPluginPath);
+ st.pszRealPath = new TCHAR[st.dwMaxRealPath];
+ _tcscpy(st.pszRealPath, szPluginPath);
pszOrigRealPath = &st.pszRealPath[nPluginPathLen];
} else {
st.dwMaxRealPath = nRealLen + 1;
- st.pszRealPath = new char[ st.dwMaxRealPath ];
+ st.pszRealPath = new TCHAR[st.dwMaxRealPath];
pszOrigRealPath = st.pszRealPath;
}
- strcpy(pszOrigRealPath, pszRealPath);
+ _tcscpy(pszOrigRealPath, pszRealPath);
return true;
}
@@ -242,7 +244,8 @@ bool CLFileShareNode::bSetPaths(char * pszSrvPath, char * 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 706a31f093..304d463eb3 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;
- char szCurrentDLSrvPath[MAX_PATH];
+ TCHAR szCurrentDLSrvPath[MAX_PATH];
virtual DWORD dwGetDownloadSpeed();
virtual bool bCloseTransfers() = NULL;
- virtual const char * pszCustomInfo() = NULL;
+ virtual const TCHAR * pszCustomInfo() = NULL;
void CloseSocket();
protected:
HANDLE hConnection;
@@ -41,11 +41,11 @@ protected: class CLFileShareNode {
public://, DWORD dwAllowedIP, DWORD dwAllowedMask, int nMaxDownloads );
- CLFileShareNode(char * pszSrvPath, char * pszRealPath);
- CLFileShareNode(STFileShareInfo * pstInfo);
+ CLFileShareNode(TCHAR *pszSrvPath, TCHAR *pszRealPath);
+ CLFileShareNode(STFileShareInfo *pstInfo);
~CLFileShareNode();
- bool bSetPaths(char * pszSrvPath, char * pszRealPath);
- bool bSetInfo(STFileShareInfo * pstInfo);
+ bool bSetPaths(TCHAR *pszSrvPath, TCHAR *pszRealPath);
+ bool bSetInfo(STFileShareInfo *pstInfo);
int nGetSrvPathLen() {
return st.dwMaxSrvPath -1;
}
@@ -54,7 +54,7 @@ public://, DWORD dwAllowedIP, DWORD dwAllowedMask, int nMaxDownloads ); }
STFileShareInfo st;
- char *pszOrigRealPath;
+ TCHAR *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 f64d28d950..ce61f1dc1d 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 char * pszTitle, const char * pszLog);
+void LogEvent(const TCHAR * pszTitle, const TCHAR * pszLog);
bool bOpenLogFile();
-extern char szPluginPath[MAX_PATH];
+extern TCHAR szPluginPath[MAX_PATH];
extern int nPluginPathLen;
extern DWORD dwLocalIpAddress;
diff --git a/plugins/HTTPServer/src/GuiElements.cpp b/plugins/HTTPServer/src/GuiElements.cpp index 50ec7a21b0..244ec26e8c 100644 --- a/plugins/HTTPServer/src/GuiElements.cpp +++ b/plugins/HTTPServer/src/GuiElements.cpp @@ -37,13 +37,13 @@ HANDLE hMainThread; bool bShowPopups = true;
-#define szDefaultExternalSrvName "http://%ExternalIP%:%Port%%SrvPath%"
+#define szDefaultExternalSrvName _T("http://%ExternalIP%:%Port%%SrvPath%")
-#define szDefaultUrlAddress "http://checkip.dyndns.org"
-#define szDefaultPageKeyword "Current IP Address: "
+#define szDefaultUrlAddress _T("http://checkip.dyndns.org")
+#define szDefaultPageKeyword _T("Current IP Address: ")
-string sUrlAddress = szDefaultUrlAddress;
-string sPageKeyword = szDefaultPageKeyword;
+tstring sUrlAddress = szDefaultUrlAddress;
+tstring sPageKeyword = szDefaultPageKeyword;
/////////////////////////////////////////////////////////////////////
@@ -61,17 +61,17 @@ string sPageKeyword = szDefaultPageKeyword; // Developer : KN
/////////////////////////////////////////////////////////////////////
-void ReplaceAll(string &sSrc, const char * pszReplace, const string &sNew) {
- string::size_type nCur = 0;
- int nRepalceLen = (int)strlen(pszReplace);
+void ReplaceAll(tstring &sSrc, const TCHAR * pszReplace, const tstring &sNew) {
+ tstring::size_type nCur = 0;
+ int nRepalceLen = (int)_tcslen(pszReplace);
while ((nCur = sSrc.find(pszReplace, nCur)) != sSrc.npos) {
sSrc.replace(nCur, nRepalceLen, sNew);
nCur += sNew.size();
}
}
-void ReplaceAll(string &sSrc, const char * pszReplace, const char * pszNew) {
- string sNew = pszNew;
+void ReplaceAll(tstring &sSrc, const TCHAR * pszReplace, const TCHAR * pszNew) {
+ tstring sNew = pszNew;
ReplaceAll(sSrc, pszReplace, sNew);
}
@@ -92,15 +92,15 @@ void ReplaceAll(string &sSrc, const char * pszReplace, const char * pszNew) { // Developer : KN
/////////////////////////////////////////////////////////////////////
-string DBGetString(MCONTACT hContact, const char *szModule, const char *szSetting, const char * pszError) {
- string ret;
+tstring DBGetString(MCONTACT hContact, const char *szModule, const char *szSetting, const TCHAR * pszError) {
+ tstring ret;
DBVARIANT dbv = {0};
if (! db_get(hContact, szModule, szSetting, &dbv)) {
if (dbv.type != DBVT_ASCIIZ) {
- MessageBox(NULL, "DB: Attempt to get wrong type of value, string", MSG_BOX_TITEL, MB_OK);
+ MessageBox(NULL, _T("DB: Attempt to get wrong type of value, string"), MSG_BOX_TITEL, MB_OK);
ret = pszError;
} else {
- ret = dbv.pszVal;
+ ret = dbv.ptszVal;
}
} else
ret = pszError;
@@ -198,32 +198,32 @@ unsigned long GetExternIP(const char *szURL, const char *szPattern) { // Developer : KN
/////////////////////////////////////////////////////////////////////
-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);
+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);
- if (sLink.find("%ExternalIP%") != sLink.npos) {
+ if (sLink.find(_T("%ExternalIP%")) != sLink.npos) {
static DWORD dwExternalIpAddressGenerated = 0;
// Get the IP again after 10 minutes
if (! dwExternalIpAddress || GetTickCount() - dwExternalIpAddressGenerated > 10 * 60 * 1000) {
- dwExternalIpAddress = GetExternIP(sUrlAddress.c_str(), sPageKeyword.c_str());
+ dwExternalIpAddress = GetExternIP(_T2A(sUrlAddress.c_str()), _T2A(sPageKeyword.c_str()));
dwExternalIpAddressGenerated = GetTickCount();
}
- mir_snprintf(szTemp, sizeof(szTemp), "%d.%d.%d.%d", SplitIpAddress(dwExternalIpAddress));
- ReplaceAll(sLink, "%ExternalIP%", szTemp);
+ mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%d.%d.%d.%d"), SplitIpAddress(dwExternalIpAddress));
+ ReplaceAll(sLink, _T("%ExternalIP%"), szTemp);
}
- mir_snprintf(szTemp, sizeof(szTemp), "%d", dwLocalPortUsed, szTemp);
- ReplaceAll(sLink, "%Port%", szTemp);
+ mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%d"), dwLocalPortUsed);
+ ReplaceAll(sLink, _T("%Port%"), szTemp);
- string sSrvPath = pszSrvPath;
- ReplaceAll(sSrvPath, " ", "%20");
- ReplaceAll(sLink, "%SrvPath%", sSrvPath);
+ tstring sSrvPath = pszSrvPath;
+ ReplaceAll(sSrvPath, _T(" "), _T("%20"));
+ ReplaceAll(sLink, _T("%SrvPath%"), sSrvPath);
return sLink;
}
@@ -249,7 +249,7 @@ UINT_PTR CALLBACK ShareNewFileDialogHook( WPARAM wParam, // message parameter
LPARAM lParam // message parameter
) {
- static const char* pszShareDirStr = Translate("Share Current Directory");
+ static const TCHAR* pszShareDirStr = TranslateT("Share Current Directory");
static int nInit = 0;
@@ -276,22 +276,22 @@ UINT_PTR CALLBACK ShareNewFileDialogHook( switch (pNotify->hdr.code) {
case CDN_FOLDERCHANGE:
case CDN_SELCHANGE: {
- static char szSelection[MAX_PATH] = "";
+ static TCHAR szSelection[MAX_PATH] = _T("");
HWND hWndFileDlg = GetParent(hDlg);
*szSelection = '/';
CommDlg_OpenSave_GetSpec(hWndFileDlg, (LPARAM)(&szSelection[1]), _MAX_PATH);
HWND hFileName = GetDlgItem(hWndFileDlg, edt1);
- char pszFileName[MAX_PATH];
+ TCHAR pszFileName[MAX_PATH];
SendMessage(hFileName, WM_GETTEXT, MAX_PATH, (LPARAM)pszFileName);
- if (strcmp(pstShare->pszSrvPath, szSelection) &&
- strcmp(pszFileName, pszShareDirStr)) {
+ if (_tcscmp(pstShare->pszSrvPath, szSelection) &&
+ _tcscmp(pszFileName, pszShareDirStr)) {
// a file was selected
// only reenable windows / set default values when a folder was selected before
- if (pstShare->pszSrvPath[strlen(pstShare->pszSrvPath)-1] == '/') {
+ if (pstShare->pszSrvPath[_tcslen(pstShare->pszSrvPath)-1] == '/') {
pNotify->lpOFN->Flags |= OFN_FILEMUSTEXIST;
EnableWindow(hFileName, TRUE);
EnableWindow(GetDlgItem(hDlg, IDC_MAX_DOWNLOADS), TRUE);
@@ -300,32 +300,32 @@ UINT_PTR CALLBACK ShareNewFileDialogHook( } else {
// a directory was selected
pNotify->lpOFN->Flags &= ~OFN_FILEMUSTEXIST;
- strcpy(pNotify->lpOFN->lpstrFile, pszShareDirStr);
+ _tcscpy(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);
- char* pszFolder = szSelection;
- char* pszTmp = szSelection;
+ TCHAR* pszFolder = szSelection;
+ TCHAR* pszTmp = szSelection;
while (*pszTmp != '\0') {
if (*pszTmp == '\\' && *(pszTmp + 1))
pszFolder = pszTmp + 1;
pszTmp++;
}
- pszTmp = strchr(szSelection, ':');
+ pszTmp = _tcschr(szSelection, ':');
if (pszTmp != NULL)
*pszTmp = '\0';
- memmove(&szSelection[1], pszFolder, strlen(pszFolder) + 1);
+ memmove(&szSelection[1], pszFolder, _tcslen(pszFolder) + 1);
szSelection[0] = '/';
- if (szSelection[strlen(szSelection)-1] != '/')
- strcat(szSelection, "/");
+ if (szSelection[_tcslen(szSelection)-1] != '/')
+ _tcscat(szSelection, _T("/"));
// only write to IDC_SHARE_NAME when a file / other folder was selected before
- if (!strcmp(szSelection, pstShare->pszSrvPath))
+ if (!_tcscmp(szSelection, pstShare->pszSrvPath))
return false;
}
@@ -341,7 +341,7 @@ UINT_PTR CALLBACK ShareNewFileDialogHook( SetDlgItemText(hDlg, IDC_SHARE_NAME, szSelection);
}
- strcpy(pstShare->pszSrvPath, szSelection);
+ _tcscpy(pstShare->pszSrvPath, szSelection);
return false;
}
@@ -349,14 +349,14 @@ UINT_PTR CALLBACK ShareNewFileDialogHook( case CDN_FILEOK: {
GetDlgItemText(hDlg, IDC_SHARE_NAME, pstShare->pszSrvPath, _MAX_PATH);
- char* pszTmp = strstr(pstShare->pszRealPath, pszShareDirStr);
+ TCHAR* pszTmp = _tcsstr(pstShare->pszRealPath, pszShareDirStr);
if (pszTmp) {
*pszTmp = '\0';
- if (pstShare->pszSrvPath[strlen(pstShare->pszSrvPath)-1] != '/')
- strcat(pstShare->pszSrvPath, "/");
+ if (pstShare->pszSrvPath[_tcslen(pstShare->pszSrvPath)-1] != '/')
+ _tcscat(pstShare->pszSrvPath, _T("/"));
} else {
- if (pstShare->pszSrvPath[strlen(pstShare->pszSrvPath)-1] == '/')
- pstShare->pszSrvPath[strlen(pstShare->pszSrvPath)-1] = '\0';
+ if (pstShare->pszSrvPath[_tcslen(pstShare->pszSrvPath)-1] == '/')
+ pstShare->pszSrvPath[_tcslen(pstShare->pszSrvPath)-1] = '\0';
}
BOOL bTranslated = false;
@@ -369,7 +369,7 @@ UINT_PTR CALLBACK ShareNewFileDialogHook( //if( ! (pstShare->dwAllowedIP & pstShare->dwAllowedMask)
- if (!bTranslated || (strlen(pstShare->pszSrvPath) <= 0)) {
+ if (!bTranslated || (_tcslen(pstShare->pszSrvPath) <= 0)) {
SetWindowLongPtr(hDlg, DWLP_MSGRESULT, 1);
return true;
}
@@ -381,12 +381,12 @@ UINT_PTR CALLBACK ShareNewFileDialogHook( case WM_DROPFILES: {
HDROP hDrop = (HDROP)wParam;
- char szDropedFile[MAX_PATH];
- int nLen = DragQueryFile(hDrop, 0, szDropedFile, sizeof(szDropedFile));
+ TCHAR szDropedFile[MAX_PATH];
+ int nLen = DragQueryFile(hDrop, 0, szDropedFile, SIZEOF(szDropedFile));
if (nLen > 0) {
- char * psz = strrchr(szDropedFile, '\\');
+ TCHAR * psz = _tcsrchr(szDropedFile, '\\');
if (psz) {
- char oldNext = psz[1];
+ TCHAR oldNext = psz[1];
psz[1] = '\0';
// Fill in the directory
SendMessage(GetParent(hDlg), CDM_SETCONTROLTEXT, edt1, (LPARAM)szDropedFile);
@@ -434,17 +434,17 @@ bool bShowShareNewFileDlg(HWND hwndOwner, STFileShareInfo * pstNewShare) { OPENFILENAME ofn = {0};
ofn.lStructSize = sizeof(OPENFILENAME);
- char temp[MAX_PATH];
- mir_snprintf(temp, SIZEOF(temp), _T("%s (*.*)%c*.*%c%c"), Translate("All files"), 0, 0, 0);
+ TCHAR temp[MAX_PATH];
+ mir_sntprintf(temp, SIZEOF(temp), _T("%s (*.*)%c*.*%c%c"), TranslateT("All files"), 0, 0, 0);
ofn.lpstrFilter = temp;
ofn.lpstrFile = pstNewShare->pszRealPath;
ofn.nMaxFile = pstNewShare->dwMaxRealPath;
- char szInitialDir[MAX_PATH];
- if (ofn.lpstrFile[strlen(ofn.lpstrFile)-1] == '\\') {
+ TCHAR szInitialDir[MAX_PATH];
+ if (ofn.lpstrFile[_tcslen(ofn.lpstrFile)-1] == '\\') {
ofn.lpstrInitialDir = szInitialDir;
- strcpy(szInitialDir, ofn.lpstrFile);
+ _tcscpy(szInitialDir, ofn.lpstrFile);
*ofn.lpstrFile = '\0';
}
@@ -462,38 +462,38 @@ bool bShowShareNewFileDlg(HWND hwndOwner, STFileShareInfo * pstNewShare) { if (!GetOpenFileName(&ofn)) {
DWORD dwError = CommDlgExtendedError();
if (dwError) {
- char szTemp[200];
- mir_snprintf(szTemp, sizeof(szTemp), "Failed to create File Open dialog the error returned was %d", dwError);
+ TCHAR szTemp[200];
+ mir_sntprintf(szTemp, SIZEOF(szTemp), _T("Failed to create File Open dialog the error returned was %d"), dwError);
MessageBox(NULL, szTemp, MSG_BOX_TITEL, MB_OK);
}
return false;
}
- if (strchr(pstNewShare->pszSrvPath, '"')) {
+ if (_tcschr(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
- char* pszFileNamePos = pstNewShare->pszSrvPath;
- char* szRealDirectoryEnd =
- &pstNewShare->pszRealPath[strlen(pstNewShare->pszRealPath)];
+ TCHAR *pszFileNamePos = pstNewShare->pszSrvPath;
+ TCHAR *szRealDirectoryEnd =
+ &pstNewShare->pszRealPath[_tcslen(pstNewShare->pszRealPath)];
*szRealDirectoryEnd = '\\';
szRealDirectoryEnd++;
while (pszFileNamePos && *pszFileNamePos) {
- pszFileNamePos = strchr(pszFileNamePos, '"');
+ pszFileNamePos = _tcschr(pszFileNamePos, '"');
if (pszFileNamePos) {
pszFileNamePos++;
- char* start = pszFileNamePos;
- pszFileNamePos = strchr(pszFileNamePos, '"');
+ TCHAR* start = pszFileNamePos;
+ pszFileNamePos = _tcschr(pszFileNamePos, '"');
if (pszFileNamePos) {
- char* end = pszFileNamePos;
+ TCHAR* end = pszFileNamePos;
memmove(pstNewShare->pszSrvPath+1, start, end - start);
*(end - (start - (pstNewShare->pszSrvPath+1)) ) = '\0';
int realPathLen = szRealDirectoryEnd - pstNewShare->pszRealPath;
- strncpy(szRealDirectoryEnd, pstNewShare->pszSrvPath+1,
+ _tcsncpy(szRealDirectoryEnd, pstNewShare->pszSrvPath+1,
pstNewShare->dwMaxRealPath - realPathLen - 1);
pstNewShare->pszRealPath[pstNewShare->dwMaxRealPath] = '\0';
@@ -542,7 +542,7 @@ void UpdateStatisticView(HWND hwndDlg, bool bRefressUsersOnly = false) { CLFileShareListAccess scCrit;
- char szTmp[50];
+ TCHAR szTmp[50];
in_addr stAddr;
bool bAutoRefress = false;
@@ -552,7 +552,7 @@ void UpdateStatisticView(HWND hwndDlg, bool bRefressUsersOnly = false) { int nUserNr = 0;
for (CLFileShareNode * pclCur = pclFirstNode; pclCur ; pclCur = pclCur->pclNext) {
if (! bRefressUsersOnly &&
- (bShowHiddenShares || !strstr(pclCur->st.pszRealPath, "\\@"))) {
+ (bShowHiddenShares || !_tcsstr(pclCur->st.pszRealPath, _T("\\@")))) {
sItem.mask = LVIF_TEXT /*| LVIF_PARAM | LVIF_IMAGE*/;
sItem.iItem = nShareNr;
sItem.iSubItem = 0;
@@ -560,19 +560,19 @@ void UpdateStatisticView(HWND hwndDlg, bool bRefressUsersOnly = false) { ListView_InsertItem(hShareList, &sItem);
- mir_snprintf(szTmp, sizeof(szTmp), "%d", pclCur->st.nMaxDownloads);
+ mir_sntprintf(szTmp, SIZEOF(szTmp), _T("%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 = inet_ntoa(stAddr);
+ sItem.pszText = _A2T(inet_ntoa(stAddr));
ListView_SetItem(hShareList, &sItem);
stAddr.S_un.S_addr = htonl(pclCur->st.dwAllowedMask);
sItem.iSubItem = 3;
- sItem.pszText = inet_ntoa(stAddr);
+ sItem.pszText = _A2T(inet_ntoa(stAddr));
ListView_SetItem(hShareList, &sItem);
sItem.iSubItem = 4;
@@ -592,17 +592,17 @@ void UpdateStatisticView(HWND hwndDlg, bool bRefressUsersOnly = false) { ListView_InsertItem(hUserList, &sItem);
sItem.iSubItem = 1;
- sItem.pszText = inet_ntoa(pclCurUser->stAddr);
+ sItem.pszText = _A2T(inet_ntoa(pclCurUser->stAddr));
ListView_SetItem(hUserList, &sItem);
sItem.iSubItem = 2;
- sItem.pszText = (char*)pclCurUser->pszCustomInfo();
+ sItem.pszText = (TCHAR *)pclCurUser->pszCustomInfo();
ListView_SetItem(hUserList, &sItem);
if (pclCurUser->dwTotalSize) {
- mir_snprintf(szTmp, sizeof(szTmp), "%d %%", (pclCurUser->dwCurrentDL * 100) / pclCurUser->dwTotalSize);
+ mir_sntprintf(szTmp, SIZEOF(szTmp), _T("%d %%"), (pclCurUser->dwCurrentDL * 100) / pclCurUser->dwTotalSize);
} else {
- strcpy(szTmp, "? %%");
+ _tcscpy(szTmp, _T("? %%"));
}
sItem.iSubItem = 3;
sItem.pszText = szTmp;
@@ -612,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_snprintf(szTmp, sizeof(szTmp), "%d KB/Sec", dwSpeed);
+ mir_sntprintf(szTmp, SIZEOF(szTmp), _T("%d KB/Sec"), dwSpeed);
} else {
- mir_snprintf(szTmp, sizeof(szTmp), "%d B/Sec", dwSpeed);
+ mir_sntprintf(szTmp, SIZEOF(szTmp), _T("%d B/Sec"), dwSpeed);
}
sItem.iSubItem = 4;
sItem.pszText = szTmp;
@@ -774,25 +774,25 @@ static INT_PTR CALLBACK DlgProcStatsticView(HWND hwndDlg, UINT msg, WPARAM wPara case WM_DROPFILES: {
HDROP hDrop = (HDROP)wParam;
- char szDropedFile[MAX_PATH];
- char szServPath[MAX_PATH] = {0};
+ TCHAR szDropedFile[MAX_PATH];
+ TCHAR 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] = '/';
- char* fileName = strrchr(szDropedFile, '\\');
+ TCHAR* fileName = _tcsrchr(szDropedFile, '\\');
if (fileName)
- strncpy(&szServPath[1], fileName+1, MAX_PATH-2);
+ _tcsncpy(&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);
@@ -852,11 +852,11 @@ static INT_PTR CALLBACK DlgProcStatsticView(HWND hwndDlg, UINT msg, WPARAM wPara case WM_COMMAND: {
HWND hShareList = GetDlgItem(hwndDlg, IDC_CURRENT_SHARES);
- char szTmp[MAX_PATH];
+ TCHAR szTmp[MAX_PATH];
LVITEM sItem = { 0 };
sItem.mask = LVIF_TEXT;
sItem.pszText = szTmp;
- sItem.cchTextMax = sizeof(szTmp);
+ sItem.cchTextMax = SIZEOF(szTmp);
switch (LOWORD(wParam)) {
@@ -883,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 {
- char szRealPath[MAX_PATH];
+ TCHAR 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);
}
@@ -901,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)) {
- string sLink = sCreateLink(sItem.pszText);
+ tstring sLink = sCreateLink(sItem.pszText);
if (sLink.size() <= 0) {
MessageBox(hwndDlg, TranslateT("Selected link size is 0"), MSG_BOX_TITEL, MB_OK);
return TRUE;
@@ -920,8 +920,8 @@ 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.
- char * lptstrCopy = (char *)GlobalLock(hglbCopy);
- strcpy(lptstrCopy, sLink.c_str());
+ TCHAR *lptstrCopy = (TCHAR *)GlobalLock(hglbCopy);
+ _tcscpy(lptstrCopy, sLink.c_str());
GlobalUnlock(hglbCopy);
// Place the handle on the clipboard.
@@ -993,8 +993,9 @@ static INT_PTR CALLBACK DlgProcStatsticView(HWND hwndDlg, UINT msg, WPARAM wPara // Developer : Sérgio Rolanski
/////////////////////////////////////////////////////////////////////
-void SendLinkToUser(WPARAM wParam, char *pszSrvPath) {
- string sLink = sCreateLink(pszSrvPath);
+void SendLinkToUser(WPARAM wParam, TCHAR *pszSrvPath)
+{
+ tstring sLink = sCreateLink(pszSrvPath);
CallService(MS_MSG_SENDMESSAGE, (WPARAM)wParam, (LPARAM)sLink.c_str());
}
@@ -1017,16 +1018,16 @@ static INT_PTR nShareNewFile(WPARAM hContact, LPARAM lParam) {
// used to be _MAX_PATH
// changed it since selecting multiple files requires a bigger buffer
- char szNewFile[10000] = {0};
- char szSrvPath[10000] = {0};
+ TCHAR szNewFile[10000] = {0};
+ TCHAR 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.
@@ -1099,7 +1100,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: {
- string sDefExt = DBGetString(NULL, MODULE, "ExternalSrvName", szDefaultExternalSrvName);
+ tstring 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;
@@ -1213,13 +1214,13 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP return TRUE;
}
case IDC_TEST_EXTERNALIP: {
- 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);
+ 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));
- mir_snprintf(szKeyWord, sizeof(szKeyWord), Translate("Your external IP was detected as %d.%d.%d.%d\r\nby: %s") ,
+ mir_sntprintf(szKeyWord, SIZEOF(szKeyWord), TranslateT("Your external IP was detected as %d.%d.%d.%d\r\nby: %s") ,
SplitIpAddress(dwExternalIP) ,
szUrl);
MessageBox(hwndDlg, szKeyWord, MSG_BOX_TITEL, MB_OK);
@@ -1231,9 +1232,9 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP NMHDR * p = ((LPNMHDR)lParam);
switch (p->code) {
case PSN_APPLY: {
- char szTemp[ 500 ];
- if (GetDlgItemText(hwndDlg, IDC_EXTERNAL_SRV_NAME, szTemp, sizeof(szTemp)))
- db_set_s(NULL, MODULE, "ExternalSrvName", szTemp);
+ TCHAR szTemp[500];
+ if (GetDlgItemText(hwndDlg, IDC_EXTERNAL_SRV_NAME, szTemp, SIZEOF(szTemp)))
+ db_set_ts(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;
@@ -1255,13 +1256,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_s(NULL, MODULE, "UrlAddress", sUrlAddress.c_str());
+ db_set_ts(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_s(NULL, MODULE, "PageKeyword", sPageKeyword.c_str());
+ db_set_ts(NULL, MODULE, "PageKeyword", sPageKeyword.c_str());
dwExternalIpAddress = 0;
BOOL bTranslated = false;
@@ -1342,12 +1343,12 @@ int OptionsInitialize(WPARAM wParam, LPARAM /*lParam*/) OPTIONSDIALOGPAGE odp = { sizeof(odp) };
odp.position = 900000000;
odp.hInstance = hInstance;
- odp.pszTemplate = MAKEINTRESOURCE(IDD_OPT_HTTP_SERVER);
- odp.flags = ODPF_BOLDGROUPS|ODPF_TCHAR;
+ odp.pszTemplate = MAKEINTRESOURCEA(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;
}
@@ -1368,7 +1369,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->lpzContactName, pclData->lpzText);
+ LogEvent(pclData->lptzContactName, pclData->lptzText);
}
PUAddPopupT(pclData);
delete pclData;
@@ -1433,15 +1434,15 @@ LRESULT CALLBACK PopupWindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM // Developer : KN
/////////////////////////////////////////////////////////////////////
-void ShowPopupWindow(const char * pszName, const char * pszText, COLORREF ColorBack /*= 0*/) {
+void ShowPopupWindow(const TCHAR * pszName, const TCHAR * 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));
- 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);
+ _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);
pclData->colorBack = ColorBack;
//ppd.colorText = colorText;
pclData->PluginWindowProc = PopupWindowProc;
diff --git a/plugins/HTTPServer/src/GuiElements.h b/plugins/HTTPServer/src/GuiElements.h index 0ce1d11814..654c3ff844 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 char * pszName, const char * pszText, COLORREF ColorBack = 0);
-void SendLinkToUser(WPARAM wParam, char *pszSrvPath); // Add By Sergio Vieira Rolanski
+void ShowPopupWindow(const TCHAR *pszName, const TCHAR *pszText, COLORREF ColorBack = 0);
+void SendLinkToUser(WPARAM wParam, TCHAR *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 428a5cb087..d84826cc8c 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(char * pszURI) {
+static int nUnescapedURI(TCHAR *pszURI) {
if (! pszURI)
return 0;
- char * pszOrigURI = pszURI;
+ TCHAR *pszOrigURI = pszURI;
int sumb;
int more = -1;
- char* pszCurInsert = pszURI;
+ TCHAR *pszCurInsert = pszURI;
for (; *pszURI && pszURI[0] != ' ' ; pszURI++) {
int nNewChar;
@@ -67,7 +67,7 @@ static int nUnescapedURI(char * pszURI) { if (pszURI[1] == NULL || pszURI[2] == NULL || pszURI[1] == ' ' || pszURI[2] == ' ')
break; // handles error like "%2 " or "%a"
- if (sscanf(&pszURI[1], "%2X", &nNewChar) != 1) {
+ if (_stscanf(&pszURI[1], _T("%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(char * pszRequest) {
+bool CLHttpUser::bReadGetParameters(TCHAR *pszRequest) {
bool bRet = true;
for (; *pszRequest ; pszRequest++) {
if (pszRequest[0] != '\n') {
@@ -183,16 +183,16 @@ bool CLHttpUser::bReadGetParameters(char * pszRequest) { pszRequest[0] = 0;
pszRequest++;
for (int nCur = 0; nCur < eLastParam ; nCur++) {
- int nLen = (int)strlen(szParmStr[nCur]);
- if (strncmp(pszRequest, szParmStr[nCur], nLen) == 0) {
+ int nLen = (int)_tcslen(szParmStr[nCur]);
+ if (_tcsncmp(pszRequest, szParmStr[nCur], nLen) == 0) {
if (apszParam[nCur]) {
bRet = false;
// already set !!
} else {
pszRequest += nLen;
apszParam[nCur] = pszRequest;
- pszRequest += strcspn(pszRequest, "\r\n") - 1;
- char * psz = pszRequest;
+ pszRequest += _tcscspn(pszRequest, _T("\r\n")) - 1;
+ TCHAR *psz = pszRequest;
while (*psz == ' ') {
psz[0] = 0;// owerwrite ' ' or '\r' or '\n'
psz--;
@@ -221,7 +221,8 @@ bool CLHttpUser::bReadGetParameters(char * pszRequest) { // Changed : 21 January 2006 by Vampik
/////////////////////////////////////////////////////////////////////
-void CLHttpUser::SendError(int iErrorCode, const char * pszError, const char * pszDescription) {
+void CLHttpUser::SendError(int iErrorCode, const TCHAR *pszError, const TCHAR *pszDescription)
+{
char szCurTime[ 100 ];
time_t ltime;
time(<ime);
@@ -271,7 +272,8 @@ void CLHttpUser::SendError(int iErrorCode, const char * pszError, const char * p // Developer : KN, Houdini, Vampik
/////////////////////////////////////////////////////////////////////
-void CLHttpUser::SendRedir(int iErrorCode, const char * pszError, const char * pszDescription, const char * pszRedirect) {
+void CLHttpUser::SendRedir(int iErrorCode, const TCHAR *pszError, const TCHAR *pszDescription, const TCHAR *pszRedirect)
+{
char szCurrTime[ 100 ];
time_t ltime;
time(<ime);
@@ -321,7 +323,8 @@ void CLHttpUser::SendRedir(int iErrorCode, const char * pszError, const char * p // Developer : Houdini
/////////////////////////////////////////////////////////////////////
-static void strmcat(char* pszDest, const char* pszSrc, int iMaxLength) {
+static void _tcsmcat(TCHAR *pszDest, const TCHAR *pszSrc, int iMaxLength)
+{
int iLength = 0;
while (*pszDest != '\0') {
pszDest++;
@@ -355,7 +358,7 @@ static void strmcat(char* pszDest, const char* pszSrc, int iMaxLength) { // Changed : 21 January 2006 by Vampik
/////////////////////////////////////////////////////////////////////
-bool CLHttpUser::bProcessGetRequest(char * pszRequest, bool bIsGetCommand) {
+bool CLHttpUser::bProcessGetRequest(TCHAR *pszRequest, bool bIsGetCommand) {
//LogEvent("Request", pszRequest);
int nUriLength = nUnescapedURI(pszRequest);
@@ -367,11 +370,11 @@ bool CLHttpUser::bProcessGetRequest(char * pszRequest, bool bIsGetCommand) { if (bShutdownInProgress)
return false;
- static char szTempfile[MAX_PATH+1];
+ static TCHAR szTempfile[MAX_PATH+1];
szTempfile[0] = '\0';
if (!bReadGetParameters(pszRequest)) {
- SendError(400, "Bad Request");
+ SendError(400, _T("Bad Request"));
return false;
}
@@ -384,20 +387,20 @@ bool CLHttpUser::bProcessGetRequest(char * pszRequest, bool bIsGetCommand) { continue; // not the right length, quickly move on to the next.
if (pclCur->bIsDirectory() ?
- (strncmp(pclCur->st.pszSrvPath, pszRequest, pclCur->nGetSrvPathLen() - 1) == 0) :
- (strncmp(pclCur->st.pszSrvPath, pszRequest, pclCur->nGetSrvPathLen()) == 0)) {
+ (_tcsncmp(pclCur->st.pszSrvPath, pszRequest, pclCur->nGetSrvPathLen() - 1) == 0) :
+ (_tcsncmp(pclCur->st.pszSrvPath, pszRequest, pclCur->nGetSrvPathLen()) == 0)) {
/*OutputDebugString( "Request for file OK : ");
OutputDebugString( pclCur->st.pszSrvPath );
OutputDebugString( "\n" );*/
- static char szSrvPath[MAX_PATH+1];
- static char szRealPath[MAX_PATH+1];
- char* pszSrvPath = pclCur->st.pszSrvPath;
- char* pszRealPath = pclCur->st.pszRealPath;
+ static TCHAR szSrvPath[MAX_PATH+1];
+ static TCHAR szRealPath[MAX_PATH+1];
+ TCHAR *pszSrvPath = pclCur->st.pszSrvPath;
+ TCHAR *pszRealPath = pclCur->st.pszRealPath;
if (pclCur->bIsDirectory()) {
- strcpy(szRealPath, pclCur->st.pszRealPath);
- strcpy(szSrvPath, pclCur->st.pszSrvPath);
+ _tcscpy(szRealPath, pclCur->st.pszRealPath);
+ _tcscpy(szSrvPath, pclCur->st.pszSrvPath);
pszRealPath = szRealPath;
pszSrvPath = szSrvPath;
@@ -407,42 +410,42 @@ bool CLHttpUser::bProcessGetRequest(char * pszRequest, bool bIsGetCommand) { pszRequest[nUriLength] = '\0';
if (pclCur->nGetSrvPathLen() - nUriLength == 1) {
- SendRedir(302, "Found", "The document has moved", pszRequest);
+ SendRedir(302, _T("Found"), _T("The document has moved"), pszRequest);
return false;
} else {
- strmcat(pszRealPath, &pszRequest[pclCur->nGetSrvPathLen()], MAX_PATH);
- strmcat(pszSrvPath, &pszRequest[pclCur->nGetSrvPathLen()], MAX_PATH);
+ _tcsmcat(pszRealPath, &pszRequest[pclCur->nGetSrvPathLen()], MAX_PATH);
+ _tcsmcat(pszSrvPath, &pszRequest[pclCur->nGetSrvPathLen()], MAX_PATH);
}
pszRequest[nUriLength] = ' ';
// hacker protection - should be removed by the browser
- if (strstr(pszRealPath, "..")) {
- SendError(404, "Not Found", "The requested URL was not found on this server.");
+ if (_tcsstr(pszRealPath, _T(".."))) {
+ SendError(404, _T("Not Found"), _T("The requested URL was not found on this server."));
return false;
}
- char* pszTmp = pszRealPath;
- while (pszTmp = strchr(pszTmp, '/'))
+ TCHAR *pszTmp = pszRealPath;
+ while (pszTmp = _tcschr(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[strlen(pszSrvPath)-1] != '/') {
- strmcat(pszRealPath, "\\", MAX_PATH);
- strmcat(pszSrvPath, "/", MAX_PATH);
+ if (pszSrvPath[_tcslen(pszSrvPath)-1] != '/') {
+ _tcsmcat(pszRealPath, _T("\\"), MAX_PATH);
+ _tcsmcat(pszSrvPath, _T("/"), MAX_PATH);
}
// a directory with index.htm
- strmcat(szRealPath, "index.htm", MAX_PATH);
+ _tcsmcat(szRealPath, _T("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
- strmcat(szRealPath, "l", MAX_PATH);
+ _tcsmcat(szRealPath, _T("l"), MAX_PATH);
hFile = CreateFile(pszRealPath, GENERIC_READ ,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_HIDDEN, NULL);
@@ -451,13 +454,13 @@ bool CLHttpUser::bProcessGetRequest(char * pszRequest, bool bIsGetCommand) { // generate directory index in temporary file
if (*szTempfile == '\0') {
GetTempPath(MAX_PATH, szTempfile);
- strmcat(szTempfile, "\\HttpServerTemp", MAX_PATH);
- strmcat(szTempfile, pszSrvPath, MAX_PATH);
- char* pszTmp = szTempfile;
- while (pszTmp = strchr(pszTmp, '/'))
+ _tcsmcat(szTempfile, _T("\\HttpServerTemp"), MAX_PATH);
+ _tcsmcat(szTempfile, pszSrvPath, MAX_PATH);
+ TCHAR *pszTmp = szTempfile;
+ while (pszTmp = _tcschr(pszTmp, '/'))
* pszTmp = '~';
}
- pszRealPath[strlen(pszRealPath) - 10] = '\0';
+ pszRealPath[_tcslen(pszRealPath) - 10] = '\0';
// detecting browser function removed
// every browser should support it by now
@@ -472,23 +475,23 @@ bool CLHttpUser::bProcessGetRequest(char * pszRequest, bool bIsGetCommand) { hFile = CreateFile(szTempfile, GENERIC_READ ,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
- strcpy(szRealPath, "a.xml"); // restore .xml for mime type
+ _tcscpy(szRealPath, _T("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);
- strcpy(szRealPath, "a.html"); // restore .html for mime type
+ _tcscpy(szRealPath, _T("a.html")); // restore .html for mime type
} else {
continue;
}
} else {
- strmcat(pszSrvPath, "index.html", MAX_PATH);
+ _tcsmcat(pszSrvPath, _T("index.html"), MAX_PATH);
szTempfile[0] = '\0';
}
} else {
- strmcat(pszSrvPath, "index.htm", MAX_PATH);
+ _tcsmcat(pszSrvPath, _T("index.htm"), MAX_PATH);
szTempfile[0] = '\0';
}
} else {
@@ -499,12 +502,12 @@ bool CLHttpUser::bProcessGetRequest(char * pszRequest, bool bIsGetCommand) { FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE) {
- SendError(404, "Not Found", "HTTP server failed to open local file");
+ SendError(404, _T("Not Found"), _T("HTTP server failed to open local file"));
return false;
}
}
- strcpy(this->szCurrentDLSrvPath, pszSrvPath);
+ _tcscpy(this->szCurrentDLSrvPath, pszSrvPath);
DWORD nDataSize = GetFileSize(hFile, NULL);
dwTotalSize = nDataSize;
@@ -517,26 +520,26 @@ bool CLHttpUser::bProcessGetRequest(char * pszRequest, bool bIsGetCommand) { time(<ime);
strftime(szCurTime, sizeof(szCurTime), "%a, %d %b %Y %H:%M:%S GMT", gmtime(<ime));
- char szFileTime[ 100 ];
+ TCHAR szFileTime[100];
FileTimeToUnixTime(&stFileTime, <ime);
- strftime(szFileTime, sizeof(szFileTime), "%a, %d %b %Y %H:%M:%S GMT", gmtime(<ime));
+ _tcsftime(szFileTime, SIZEOF(szFileTime), _T("%a, %d %b %Y %H:%M:%S GMT"), gmtime(<ime));
- if (apszParam[eIfModifiedSince] && strcmp(apszParam[eIfModifiedSince], szFileTime) == 0) {
- SendError(304, "Not Modified" );
+ if (apszParam[eIfModifiedSince] && _tcscmp(apszParam[eIfModifiedSince], szFileTime) == 0) {
+ SendError(304, _T("Not Modified"));
return true;
}
// we found match send file !!
if (bIsGetCommand) {
if (! pclCur->bAddUser(this)) {
- SendError(403, "Forbidden", "Access has been denied because there are too many connections");
+ SendError(403, _T("Forbidden"), _T("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
- strstr(pszRealPath, "\\@") == NULL) { // and of shares which start with an @
- ShowPopupWindow(inet_ntoa(stAddr), pszSrvPath);
+ _tcsstr(pszRealPath, _T("\\@")) == NULL) { // and of shares which start with an @
+ ShowPopupWindow(_A2T(inet_ntoa(stAddr)), pszSrvPath);
}
clCritSection.Unlock();
@@ -544,37 +547,37 @@ bool CLHttpUser::bProcessGetRequest(char * pszRequest, bool bIsGetCommand) { DWORD dwFileStart = 0;
DWORD dwDataToSend = nDataSize;
- char szETag[ 50 ];
+ TCHAR szETag[50];
{
- int nETagLen = mir_snprintf(szETag, sizeof(szETag), "\"%x-%x-%x\"",
+ int nETagLen = mir_sntprintf(szETag, SIZEOF(szETag), _T("\"%x-%x-%x\""),
nDataSize, stFileTime.dwHighDateTime, stFileTime.dwLowDateTime);
- if (!apszParam[eIfRange] || (strncmp(szETag, apszParam[eIfRange], nETagLen) == 0)) {
- char * pszRange = apszParam[eRange];
+ if (!apszParam[eIfRange] || (_tcsncmp(szETag, apszParam[eIfRange], nETagLen) == 0)) {
+ TCHAR *pszRange = apszParam[eRange];
if (pszRange) {
- if (strncmp(pszRange, "bytes=", 6) == 0) {
+ if (_tcsncmp(pszRange, _T("bytes="), _tcslen(_T("bytes="))) == 0) {
pszRange += 6;
// Do resume !!!
- char *pszEnd;
+ TCHAR *pszEnd;
if (pszRange[0] == '-') {
// its a suffix-byte-range-spec
- DWORD dwLen = strtol(pszRange + 1, &pszEnd, 10);
+ DWORD dwLen = _tcstol(pszRange + 1, &pszEnd, 10);
if (dwLen < nDataSize)
dwFileStart = nDataSize - dwLen;
} else {
- DWORD dwLen = strtol(pszRange, &pszEnd, 10);
+ DWORD dwLen = _tcstol(pszRange, &pszEnd, 10);
if (*pszEnd == '-' && dwLen < nDataSize) {
dwFileStart = dwLen;
pszRange = pszEnd + 1;
if (*pszRange != 0) {
- dwLen = strtol(pszEnd + 1, &pszEnd, 10);
+ dwLen = _tcstol(pszEnd + 1, &pszEnd, 10);
if (dwLen > dwFileStart)
dwDataToSend = (dwLen + 1) - dwFileStart;
else
dwFileStart = 0;
}
} else {
- SendError(400, "Bad Request");
+ SendError(400, _T("Bad Request"));
return false;
}
}
@@ -600,7 +603,7 @@ bool CLHttpUser::bProcessGetRequest(char * pszRequest, bool bIsGetCommand) { if (dwFileStart > 0 || dwDataToSend != nDataSize) {
if (SetFilePointer(hFile, dwFileStart, NULL, FILE_BEGIN) == INVALID_SET_FILE_POINTER) {
- SendError(416, "Requested Range Not Satisfiable");
+ SendError(416, _T("Requested Range Not Satisfiable"));
return true;
}
@@ -621,7 +624,7 @@ bool CLHttpUser::bProcessGetRequest(char * pszRequest, bool bIsGetCommand) { PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
szETag,
dwDataToSend,
- pszGetMimeType(pszRealPath),
+ _T2A(pszGetMimeType(pszRealPath)),
dwFileStart,
(dwFileStart + dwDataToSend - 1),
nDataSize,
@@ -750,7 +753,7 @@ bool CLHttpUser::bProcessGetRequest(char * pszRequest, bool bIsGetCommand) { for (CLFileShareNode * pcl = pclFirstNode ; pcl ; pcl = pcl->pclNext) {
if (pcl == pclCur) {
*pclPrev = pclCur->pclNext;
- ShowPopupWindow(Translate("Share removed"), pclCur->st.pszSrvPath, RGB(255, 189, 189));
+ ShowPopupWindow(TranslateT("Share removed"), pclCur->st.pszSrvPath, RGB(255, 189, 189));
delete pclCur;
bNeedToWriteConfig = true;
break;
@@ -770,24 +773,25 @@ bool CLHttpUser::bProcessGetRequest(char * pszRequest, bool bIsGetCommand) { #ifdef _DEBUG
- OutputDebugString("########### Request Failed ###########\n");
+ OutputDebugString(_T("########### Request Failed ###########\n"));
OutputDebugString(pszRequest);
#endif
pszRequest[nUriLength] = 0;
- if ((nUriLength != 12 || strncmp(pszRequest, "/favicon.ico", nUriLength)) && // do not show popup of favicon.ico
+ if ((nUriLength != 12 || _tcsncmp(pszRequest, _T("/favicon.ico"), nUriLength)) && // do not show popup of favicon.ico
*(ULONG*)(&stAddr) != 0x0100007F) { // do not show popup of 127.0.0.1
- ShowPopupWindow(inet_ntoa(stAddr), pszRequest, RGB(255, 189, 189));
+ ShowPopupWindow(_A2T(inet_ntoa(stAddr)), pszRequest, RGB(255, 189, 189));
}
- SendError(404, "Not Found", "The requested URL was not found on this server.");
+ SendError(404, _T("Not Found"), _T("The requested URL was not found on this server."));
return false;
}
-void CLHttpUser::HandleNewConnection() {
+void CLHttpUser::HandleNewConnection()
+{
/*
{
@@ -828,10 +832,10 @@ void CLHttpUser::HandleNewConnection() { }
*/
- char szBuf[1000];
+ TCHAR szBuf[1000];
int nCurPos = 0;
- while (sizeof(szBuf) - nCurPos > 10 && !bShutdownInProgress) {
- int nBytesRead = Netlib_Recv(hConnection, &szBuf[nCurPos], sizeof(szBuf) - nCurPos, 0);
+ while (SIZEOF(szBuf) - nCurPos > 10 && !bShutdownInProgress) {
+ int nBytesRead = Netlib_Recv(hConnection, _T2A(&szBuf[nCurPos]), SIZEOF(szBuf) - nCurPos, 0);
if (! nBytesRead) {
// socket closed gracefully
break;
@@ -846,9 +850,9 @@ void CLHttpUser::HandleNewConnection() { if (nCurPos <= 5)
continue;
- bool bIsGetCommand = memcmp(szBuf, "GET ", 4) == 0;
- if (!bIsGetCommand && memcmp(szBuf, "HEAD ", 5) != 0) {
- SendError(501, "Not Implemented");
+ 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"));
break; // We only support GET and HEAD commands !!
}
diff --git a/plugins/HTTPServer/src/HttpUser.h b/plugins/HTTPServer/src/HttpUser.h index 00b43a76eb..d428391249 100644 --- a/plugins/HTTPServer/src/HttpUser.h +++ b/plugins/HTTPServer/src/HttpUser.h @@ -33,13 +33,13 @@ enum ENParamTypes { eLastParam
};
-static char * szParmStr[eLastParam] = {
- "Range: ",
- "If-Range: ",
- "Unless-Modified-Since: ",
- "If-Modified-Since: ",
- "User-Agent: ",
- "Host: "
+static TCHAR * szParmStr[eLastParam] = {
+ _T("Range: "),
+ _T("If-Range: "),
+ _T("Unless-Modified-Since: "),
+ _T("If-Modified-Since: "),
+ _T("User-Agent: "),
+ _T("Host: ")
};
@@ -48,23 +48,23 @@ public: CLHttpUser(HANDLE hCon, in_addr stAdd);
virtual ~CLHttpUser();
- bool bReadGetParameters(char * pszRequest);
+ bool bReadGetParameters(TCHAR *pszRequest);
//bool bSendFile( HANDLE hFile ,
bool bCloseTransfers() {
return true;
}
- bool bProcessGetRequest(char * pszRequest, bool bIsGetCommand);
- const char * pszCustomInfo() {
+ bool bProcessGetRequest(TCHAR *pszRequest, bool bIsGetCommand);
+ const TCHAR * pszCustomInfo() {
return apszParam[eUserAgent];
}
void HandleNewConnection();
private:
HANDLE hFile;
- char *apszParam[eLastParam];
+ TCHAR *apszParam[eLastParam];
- 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);
+ 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);
};
#endif
\ No newline at end of file diff --git a/plugins/HTTPServer/src/IndexCreation.h b/plugins/HTTPServer/src/IndexCreation.h index c3892c4308..5876595a46 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 char szIndexHTMLTemplateFile[] = "HTTPServerIndex.html";
+const TCHAR szIndexHTMLTemplateFile[] = _T("HTTPServerIndex.html");
enum eIndexCreationMode {
INDEX_CREATION_DISABLE = 0,
@@ -34,8 +34,8 @@ enum eIndexCreationMode { extern eIndexCreationMode indexCreationMode;
-bool bCreateIndexXML(const char * pszRealPath, const char * pszIndexPath, const char * pszSrvPath, DWORD dwRemoteIP);
-bool bCreateIndexHTML(const char * pszRealPath, const char * pszIndexPath, const char * pszSrvPath, DWORD dwRemoteIP);
+bool bCreateIndexXML(const TCHAR *pszRealPath, const TCHAR *pszIndexPath, const TCHAR *pszSrvPath, DWORD dwRemoteIP);
+bool bCreateIndexHTML(const TCHAR *pszRealPath, const TCHAR *pszIndexPath, const TCHAR *pszSrvPath, DWORD dwRemoteIP);
void FreeIndexHTMLTemplate();
bool LoadIndexHTMLTemplate();
diff --git a/plugins/HTTPServer/src/IndexHTML.cpp b/plugins/HTTPServer/src/IndexHTML.cpp index f1f15fbc44..c8e6ccddc7 100644 --- a/plugins/HTTPServer/src/IndexHTML.cpp +++ b/plugins/HTTPServer/src/IndexHTML.cpp @@ -19,7 +19,7 @@ eIndexCreationMode indexCreationMode;
-static char* szIndexHTMLTemplate = NULL;
+static TCHAR *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;
- char szBuf[10000];
- char* pszBuf = szBuf;
+ TCHAR szBuf[10000];
+ TCHAR *pszBuf = szBuf;
- char szDestBuf[10000];
- char* pszDestBuf = szDestBuf;
+ TCHAR szDestBuf[10000];
+ TCHAR *pszDestBuf = szDestBuf;
- strcpy(pszBuf, szPluginPath);
- strcat(pszBuf, szIndexHTMLTemplateFile);
+ _tccpy(pszBuf, szPluginPath);
+ _tcscat(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, "HTTPServerIndex.html not found in Plugin Path", MSG_BOX_TITEL, MB_OK);
+ MessageBox(NULL, _T("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 == '[') {
- char* pszKeywordBegin = pszBuf + 1;
+ TCHAR* pszKeywordBegin = pszBuf + 1;
bool bHasParameters = false;
do {
@@ -93,21 +93,21 @@ bool LoadIndexHTMLTemplate() { *pszDestBuf = '#';
// signs below 32 are not used anyway
- 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;
+ 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;
else {
- LogEvent("Error in index template", "Unknown Tag");
+ LogEvent(_T("Error in index template"), _T("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;
- char* pcParamCount = (pszDestBuf++);
- char* pszParameterBegin = pszBuf + 1;
+ TCHAR *pcParamCount = pszDestBuf++;
+ TCHAR *pszParameterBegin = pszBuf + 1;
do {
if (*pszBuf == ',') {
*pszBuf = ':';
- strncpy(pszDestBuf, pszParameterBegin, MAX_PARAM_LENGTH);
+ _tcsncpy(pszDestBuf, pszParameterBegin, MAX_PARAM_LENGTH);
pszDestBuf += MAX_PARAM_LENGTH;
pszParameterBegin = pszBuf + 1;
@@ -152,7 +152,7 @@ bool LoadIndexHTMLTemplate() { break;
*pszBuf = ':';
- strncpy(pszDestBuf, pszParameterBegin, MAX_PARAM_LENGTH);
+ _tcsncpy(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) {
- char* pszLevelEnd = pszBuf + 2; // skip for address reserved bytes
+ TCHAR *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("Error in index template", "End is missing");
+ LogEvent(_T("Error in index template"), _T("End is missing"));
break; // Error - End missing
}
@@ -233,8 +233,8 @@ bool LoadIndexHTMLTemplate() { //LogEvent("Template", szDestBuf);
- szIndexHTMLTemplate = new char[strlen(szDestBuf)+1];
- strcpy(szIndexHTMLTemplate, szDestBuf);
+ szIndexHTMLTemplate = new TCHAR[_tcslen(szDestBuf) + 1];
+ _tcscpy(szIndexHTMLTemplate, szDestBuf);
}
CloseHandle(hFile);
@@ -274,19 +274,19 @@ void FreeIndexHTMLTemplate() { // Developer : Houdini
/////////////////////////////////////////////////////////////////////
-bool bCreateIndexHTML(const char * pszRealPath, const char * pszIndexPath,
- const char * pszSrvPath, DWORD /* dwRemoteIP */) {
+bool bCreateIndexHTML(const TCHAR *pszRealPath, const TCHAR *pszIndexPath, const TCHAR *pszSrvPath, DWORD /* dwRemoteIP */)
+{
#define RelativeJump(begin) { pszPos += *((WORD*)(begin+1)) & 0x7FFF; }
if (szIndexHTMLTemplate == NULL)
return false;
// check if directory exists
- char szMask[MAX_PATH];
- strcpy(szMask, pszRealPath);
- strcat(szMask, "*");
+ TCHAR szMask[MAX_PATH];
+ _tcscpy(szMask, pszRealPath);
+ _tcscat(szMask, _T("*"));
- WIN32_FIND_DATAA fdFindFileData;
+ WIN32_FIND_DATA fdFindFileData;
HANDLE hFind = FindFirstFile(szMask, &fdFindFileData);
if (hFind == INVALID_HANDLE_VALUE)
@@ -301,35 +301,35 @@ bool bCreateIndexHTML(const char * pszRealPath, const char * pszIndexPath, if (hFile == INVALID_HANDLE_VALUE)
return FALSE;
- char szBuffer[10000];
- char* pszBuffer = szBuffer;
+ TCHAR szBuffer[10000];
+ TCHAR *pszBuffer = szBuffer;
DWORD dwBytesWritten = 0;
- char* pszPos = szIndexHTMLTemplate;
+ TCHAR *pszPos = szIndexHTMLTemplate;
byte iCurrentAction = 0;
- char* pszLevelBegin[50];
+ TCHAR *pszLevelBegin[50];
byte iLevel = 0;
- char szName[1000] = "";
- char szURL[1000] = "";
+ TCHAR szName[1000] = _T("");
+ TCHAR szURL[1000] = _T("");
int iFileSize = 0;
FILETIME ftFileCreateTime;
FILETIME ftFileModifyTime;
bool bEvenOdd = 0;
bool bKnownFileType = false;
- strcpy(szBuffer, pszSrvPath);
- char* pszTemp = strrchr(szBuffer, '/');
+ _tcscpy(szBuffer, pszSrvPath);
+ TCHAR *pszTemp = _tcsrchr(szBuffer, '/');
if (pszTemp)
*pszTemp = '\0';
- pszTemp = strrchr(szBuffer, '/');
+ pszTemp = _tcsrchr(szBuffer, '/');
if (pszTemp)
- strcpy(szName, pszTemp + 1);
+ _tcscpy(szName, pszTemp + 1);
if (szName[0] == '\0')
- strcpy(szName, "my Miranda Webserver");
+ _tcscpy(szName, _T("my Miranda Webserver"));
do {
switch (*pszPos) {
@@ -355,9 +355,9 @@ bool bCreateIndexHTML(const char * pszRealPath, const char * pszIndexPath, }
}
- while (!strcmp(fdFindFileData.cFileName, ".") ||
- !strncmp(fdFindFileData.cFileName, "@", 1) ||
- (!strcmp(fdFindFileData.cFileName, "..") && !strcmp(pszSrvPath, "/")) || // hide .. in root
+ while (!_tcscmp(fdFindFileData.cFileName, _T(".")) ||
+ !_tcsncmp(fdFindFileData.cFileName, _T("@"), 1) ||
+ (!_tcscmp(fdFindFileData.cFileName, _T("..")) && !_tcscmp(pszSrvPath, _T("/"))) || // hide .. in root
((*pszPos == 19) == ((fdFindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0))) {
if (!FindNextFile(hFind, &fdFindFileData)) {
FindClose(hFind);
@@ -369,14 +369,14 @@ bool bCreateIndexHTML(const char * pszRealPath, const char * pszIndexPath, }
if (hFind) {
- strcpy(szName, fdFindFileData.cFileName);
- strcpy(szURL, fdFindFileData.cFileName);
+ _tcscpy(szName, fdFindFileData.cFileName);
+ _tcscpy(szURL, fdFindFileData.cFileName);
/*char* pszTmp = szURL;
while(pszTmp = strchr(pszTmp, ' '))
*pszTmp = '+';*/
if (*pszPos == SY_FOR_DIRS) { // For Directories
- strcat(szURL, "/");
+ _tcscat(szURL, _T("/"));
} else { // For Files
iFileSize = fdFindFileData.nFileSizeLow;
ftFileCreateTime = fdFindFileData.ftCreationTime;
@@ -410,13 +410,13 @@ bool bCreateIndexHTML(const char * pszRealPath, const char * pszIndexPath, case SY_FILE_NAME:
case SY_DIR_NAME: {
- pszBuffer += mir_snprintf(pszBuffer, 250, "%s", szName);
+ pszBuffer += mir_sntprintf(pszBuffer, 250, _T("%s"), szName);
break;
}
case SY_DIR_URL: {
case SY_FILE_URL:
- pszBuffer += mir_snprintf(pszBuffer, 250, "%s", szURL);
+ pszBuffer += mir_sntprintf(pszBuffer, 250, _T("%s"), szURL);
break;
}
@@ -427,7 +427,7 @@ bool bCreateIndexHTML(const char * pszRealPath, const char * pszIndexPath, (*pszPos == SY_FILE_CREATE_TIME) ? &ftFileCreateTime : &ftFileModifyTime,
&systemTime);
- pszBuffer += mir_snprintf(pszBuffer, 100, "%i/%02i/%02i %i:%02i:%02i",
+ pszBuffer += mir_sntprintf(pszBuffer, 100, _T("%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 char * pszRealPath, const char * pszIndexPath, case SY_FILE_SIZE: {
if ((iFileSize >> 10) == 0)
- pszBuffer += mir_snprintf(pszBuffer, 100, "%i Byte", iFileSize);
+ pszBuffer += mir_sntprintf(pszBuffer, 100, _T("%i Byte"), iFileSize);
else if ((iFileSize >> 20) == 0)
- pszBuffer += mir_snprintf(pszBuffer, 100, "%.1f KB", (float)(iFileSize) / 1024.0f);
+ pszBuffer += mir_sntprintf(pszBuffer, 100, _T("%.1f KB"), (float)(iFileSize) / 1024.0f);
else
- pszBuffer += mir_snprintf(pszBuffer, 100, "%.1f MB", (float)(iFileSize) / (1024.0f * 1024.0f));
+ pszBuffer += mir_sntprintf(pszBuffer, 100, _T("%.1f MB"), (float)(iFileSize) / (1024.0f * 1024.0f));
break;
}
@@ -461,7 +461,7 @@ bool bCreateIndexHTML(const char * pszRealPath, const char * pszIndexPath, iCurrentAction = *pszPos;
byte iParamCount = *(pszPos + 3);
- char* pszParam = pszPos + 4;
+ TCHAR* pszParam = pszPos + 4;
bool bSkip = true;
if (bKnownFileType == false) {
@@ -469,16 +469,16 @@ bool bCreateIndexHTML(const char * pszRealPath, const char * pszIndexPath, bSkip = false;
} else {
for (byte i = 0; i < iParamCount; i++) {
- char szParam[MAX_PARAM_LENGTH+1];
- strncpy(szParam, pszParam, MAX_PARAM_LENGTH);
+ TCHAR szParam[MAX_PARAM_LENGTH+1];
+ _tcsncpy(szParam, pszParam, MAX_PARAM_LENGTH);
szParam[MAX_PARAM_LENGTH] = '\0';
- char* pszTmp = strchr(szParam, ':');
+ TCHAR *pszTmp = _tcschr(szParam, ':');
if (pszTmp)
*pszTmp = '\0';
- char* pszExt = strrchr(szName, '.');
+ TCHAR *pszExt = _tcsrchr(szName, '.');
- if (pszExt && !_stricmp(pszExt + 1, szParam)) {
+ if (pszExt && !_tcsicmp(pszExt + 1, szParam)) {
bSkip = false;
break;
}
diff --git a/plugins/HTTPServer/src/IndexXML.cpp b/plugins/HTTPServer/src/IndexXML.cpp index f05efe472a..b34ef3c5b0 100644 --- a/plugins/HTTPServer/src/IndexXML.cpp +++ b/plugins/HTTPServer/src/IndexXML.cpp @@ -26,22 +26,22 @@ static const char szXmlHeader2[] = "\"?>\r\n" static const char szXmlTail[] = "</config>";
-static void ReplaceSign(char* pszSrc, int MaxLength, const char pszReplace,
- const char * pszNew) {
- static char szBuffer[1024];
- char* pszSign = strchr(pszSrc, pszReplace);
+static void ReplaceSign(TCHAR *pszSrc, int MaxLength, const TCHAR pszReplace, const TCHAR *pszNew)
+{
+ static TCHAR szBuffer[1024];
+ TCHAR *pszSign = _tcschr(pszSrc, pszReplace);
if (pszSign) {
- strcpy(szBuffer, pszSrc);
+ _tcscpy(szBuffer, pszSrc);
do {
- strcpy(szBuffer + (pszSign - pszSrc), pszNew);
- strcpy(szBuffer + (pszSign - pszSrc) + strlen(pszNew), pszSign + 1);
+ _tcscpy(szBuffer + (pszSign - pszSrc), pszNew);
+ _tcscpy(szBuffer + (pszSign - pszSrc) + _tcslen(pszNew), pszSign + 1);
*pszSign = ' ';
- } while (pszSign = strchr(pszSrc, pszReplace));
+ } while (pszSign = _tcschr(pszSrc, pszReplace));
- strncpy(pszSrc, szBuffer, MaxLength);
+ _tcsncpy(pszSrc, szBuffer, MaxLength);
pszSrc[MaxLength-1] = '\0';
}
@@ -61,13 +61,13 @@ static void ReplaceSign(char* pszSrc, int MaxLength, const char pszReplace, // Developer : Houdini
/////////////////////////////////////////////////////////////////////
-bool bCreateIndexXML(const char * pszRealPath, const char * pszIndexPath,
- const char * pszSrvPath, DWORD dwRemoteIP) {
- char szMask[MAX_PATH+1];
- strcpy(szMask, pszRealPath);
- strcat(szMask, "*");
+bool bCreateIndexXML(const TCHAR *pszRealPath, const TCHAR *pszIndexPath, const TCHAR *pszSrvPath, DWORD dwRemoteIP)
+{
+ TCHAR szMask[MAX_PATH+1];
+ _tcscpy(szMask, pszRealPath);
+ _tcscat(szMask, _T("*"));
- WIN32_FIND_DATAA fdFindFileData;
+ WIN32_FIND_DATA fdFindFileData;
HANDLE hFind = FindFirstFile(szMask, &fdFindFileData);
if (hFind == INVALID_HANDLE_VALUE)
@@ -82,90 +82,90 @@ bool bCreateIndexXML(const char * pszRealPath, const char * pszIndexPath, }
const int BUFFER_SIZE = 1000;
- char szBuffer[BUFFER_SIZE+1];
- char* pszBuffer = szBuffer;
- char szFileName[MAX_PATH+1] = "";
- char* pszExt;
+ TCHAR szBuffer[BUFFER_SIZE+1];
+ TCHAR *pszBuffer = szBuffer;
+ TCHAR szFileName[MAX_PATH+1] = _T("");
+ TCHAR* pszExt;
DWORD dwBytesWritten = 0;
// Generate Dirname
- strcpy(szBuffer, pszSrvPath);
- char* pszTemp = strrchr(szBuffer, '/');
+ _tcscpy(szBuffer, pszSrvPath);
+ TCHAR *pszTemp = _tcsrchr(szBuffer, '/');
if (pszTemp)
*pszTemp = '\0';
- pszTemp = strrchr(szBuffer, '/');
+ pszTemp = _tcsrchr(szBuffer, '/');
if (pszTemp)
- strcpy(szFileName, pszTemp + 1);
+ _tcscpy(szFileName, pszTemp + 1);
// Write Header
WriteFile(hFile, szXmlHeader1, sizeof(szXmlHeader1) - 1, &dwBytesWritten, NULL);
// check if a index.xsl exists in the same directory otherwise use the global
- strcpy(szMask, pszRealPath);
- strcat(szMask, "index.xsl");
+ _tcscpy(szMask, pszRealPath);
+ _tcscat(szMask, _T("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) {
- strcpy(szBuffer, "/index.xsl");
+ _tcscpy(szBuffer, _T("/index.xsl"));
} else {
CloseHandle(hFileExists);
- strcpy(szBuffer, "index.xsl");
+ _tcscpy(szBuffer, _T("index.xsl"));
}
- WriteFile(hFile, szBuffer, (DWORD)strlen(szBuffer), &dwBytesWritten, NULL);
+ WriteFile(hFile, szBuffer, (DWORD)_tcslen(szBuffer), &dwBytesWritten, NULL);
WriteFile(hFile, szXmlHeader2, sizeof(szXmlHeader2) - 1, &dwBytesWritten, NULL);
// Write dirname
- ReplaceSign(szFileName, MAX_PATH, '&', "&");
- pszBuffer += mir_snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
- " <dirname>%s</dirname>\r\n", szFileName);
+ ReplaceSign(szFileName, MAX_PATH, '&', _T("&"));
+ pszBuffer += mir_sntprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
+ _T(" <dirname>%s</dirname>\r\n"), szFileName);
WriteFile(hFile, szBuffer, pszBuffer - szBuffer, &dwBytesWritten, NULL);
// Find files and directories
do {
- if (strcmp(fdFindFileData.cFileName, ".") &&
- strncmp(fdFindFileData.cFileName, "@", 1) &&
- (strcmp(fdFindFileData.cFileName, "..") || strcmp(pszSrvPath, "/"))) { // hide .. in root
+ if (_tcscmp(fdFindFileData.cFileName, _T(".")) &&
+ _tcsncmp(fdFindFileData.cFileName, _T("@"), _tcslen(_T("@"))) &&
+ (_tcscmp(fdFindFileData.cFileName, _T("..")) || _tcscmp(pszSrvPath, _T("/")))) { // hide .. in root
pszBuffer = szBuffer;
- strcpy(szFileName, fdFindFileData.cFileName);
- ReplaceSign(szFileName, MAX_PATH, '&', "&");
+ _tcscpy(szFileName, fdFindFileData.cFileName);
+ ReplaceSign(szFileName, MAX_PATH, '&', _T("&"));
if (fdFindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
- pszBuffer += mir_snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
- " <item name=\"%s\" isdir=\"true\"/>\r\n", szFileName);
+ pszBuffer += mir_sntprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
+ _T(" <item name=\"%s\" isdir=\"true\"/>\r\n"), szFileName);
} else {
- pszExt = strrchr(szFileName, '.');
+ pszExt = _tcsrchr(szFileName, '.');
if (pszExt != NULL) {
*pszExt = '\0';
pszExt++;
}
- pszBuffer += mir_snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
- " <item name=\"%s\" ext=\"%s\" size=\"%i\" ",
- szFileName, (pszExt == NULL) ? "" : pszExt, fdFindFileData.nFileSizeLow);
+ pszBuffer += mir_sntprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
+ _T(" <item name=\"%s\" ext=\"%s\" size=\"%i\" "),
+ szFileName, (pszExt == NULL) ? _T("") : pszExt, fdFindFileData.nFileSizeLow);
SYSTEMTIME systemTime;
FileTimeToSystemTime(&fdFindFileData.ftCreationTime, &systemTime);
- pszBuffer += mir_snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
- "created=\"%i/%02i/%02i %i:%02i:%02i\" ",
+ pszBuffer += mir_sntprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
+ _T("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_snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
- "modified=\"%i/%02i/%02i %i:%02i:%02i\" ",
+ pszBuffer += mir_sntprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
+ _T("modified=\"%i/%02i/%02i %i:%02i:%02i\" "),
systemTime.wYear, systemTime.wMonth, systemTime.wDay, systemTime.wHour,
systemTime.wMinute, systemTime.wSecond);
- pszBuffer += mir_snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
- "/>\r\n");
+ pszBuffer += mir_sntprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
+ _T("/>\r\n"));
}
if (!WriteFile(hFile, szBuffer, pszBuffer - szBuffer, &dwBytesWritten, NULL))
@@ -180,27 +180,27 @@ bool bCreateIndexXML(const char * pszRealPath, const char * pszIndexPath, // 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()) > strlen(pszSrvPath) &&
- !strstr(pclCur->st.pszRealPath, "\\@") &&
- !strncmp(pclCur->st.pszSrvPath, pszSrvPath, strlen(pszSrvPath))) {
+ (size_t)(pclCur->nGetSrvPathLen()) > _tcslen(pszSrvPath) &&
+ !_tcsstr(pclCur->st.pszRealPath, _T("\\@")) &&
+ !_tcsncmp(pclCur->st.pszSrvPath, pszSrvPath, _tcslen(pszSrvPath))) {
pszBuffer = szBuffer;
- strcpy(szFileName, &pclCur->st.pszSrvPath[strlen(pszSrvPath)]);
- ReplaceSign(szFileName, MAX_PATH, '&', "&");
+ _tcscpy(szFileName, &pclCur->st.pszSrvPath[_tcslen(pszSrvPath)]);
+ ReplaceSign(szFileName, MAX_PATH, '&', _T("&"));
if (pclCur->bIsDirectory()) {
- 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);
+ 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);
if (!WriteFile(hFile, szBuffer, pszBuffer - szBuffer, &dwBytesWritten, NULL))
break;
}
} else {
- if (!strchr(szFileName, '/') && // only one level deeper
- strncmp(pszRealPath, pclCur->st.pszRealPath, strlen(pszRealPath))) { // no duplicates
- pszExt = strrchr(szFileName, '.');
+ if (!_tcschr(szFileName, '/') && // only one level deeper
+ _tcsncmp(pszRealPath, pclCur->st.pszRealPath, _tcslen(pszRealPath))) { // no duplicates
+ pszExt = _tcsrchr(szFileName, '.');
if (pszExt != NULL) {
*pszExt = '\0';
@@ -219,25 +219,25 @@ bool bCreateIndexXML(const char * pszRealPath, const char * pszIndexPath, CloseHandle(hFileS);
}
- pszBuffer += mir_snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
- " <item name=\"%s\" ext=\"%s\" size=\"%i\" ",
- szFileName, (pszExt == NULL) ? "" : pszExt, dwFileSize);
+ pszBuffer += mir_sntprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
+ _T(" <item name=\"%s\" ext=\"%s\" size=\"%i\" "),
+ szFileName, (pszExt == NULL) ? _T("") : pszExt, dwFileSize);
SYSTEMTIME systemTime;
FileTimeToSystemTime(&ftFileCreateTime, &systemTime);
- pszBuffer += mir_snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
- "created=\"%i/%02i/%02i %i:%02i:%02i\" ",
+ pszBuffer += mir_sntprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
+ _T("created=\"%i/%02i/%02i %i:%02i:%02i\" "),
systemTime.wYear, systemTime.wMonth, systemTime.wDay, systemTime.wHour,
systemTime.wMinute, systemTime.wSecond);
FileTimeToSystemTime(&ftFileModifyTime, &systemTime);
- pszBuffer += mir_snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
- "modified=\"%i/%02i/%02i %i:%02i:%02i\" ",
+ pszBuffer += mir_sntprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
+ _T("modified=\"%i/%02i/%02i %i:%02i:%02i\" "),
systemTime.wYear, systemTime.wMonth, systemTime.wDay, systemTime.wHour,
systemTime.wMinute, systemTime.wSecond);
- pszBuffer += mir_snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
- "/>\r\n");
+ pszBuffer += mir_sntprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
+ _T("/>\r\n"));
if (!WriteFile(hFile, szBuffer, pszBuffer - szBuffer, &dwBytesWritten, NULL))
break;
diff --git a/plugins/HTTPServer/src/MimeHandling.cpp b/plugins/HTTPServer/src/MimeHandling.cpp index 9656753056..8bce315b81 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 */
-char DefaultMime[] = "application/octet-stream";
+TCHAR DefaultMime[] = _T("application/octet-stream");
int bInitMimeHandling() {
FILE *mimeDB;
- char line[LINE_MAX_SIZE];
- char *tok = NULL;
+ TCHAR line[LINE_MAX_SIZE];
+ TCHAR *tok = NULL;
ContentType *pDBCell = NULL;
ContentTypeDB pDB = NULL;
ExtensionList extListCur = NULL;
ExtensionListCell *pExtCell = NULL;
- char szBuf[10000];
+ TCHAR szBuf[10000];
- strcpy(szBuf, szPluginPath);
- strcat(szBuf, szMimeTypeConfigFile);
- mimeDB = fopen(szBuf, "r");
+ _tcscpy(szBuf, szPluginPath);
+ _tcscat(szBuf, szMimeTypeConfigFile);
+ mimeDB = _tfopen(szBuf, _T("r"));
if (mimeDB != NULL) {
- while (fgets(line, LINE_MAX_SIZE, mimeDB)) {
+ while (_fgetts(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 = strrchr(line, '#');
+ tok = _tcsrchr(line, '#');
if (tok != NULL) {
*tok = '\0';
}
/* remove trailing \n */
- int lenght = (int)strlen(line);
+ int lenght = (int)_tcslen(line);
if (lenght > 0 && line[lenght - 1] == '\n')
line[lenght - 1] = '\0';
/* first token = mime type */
- tok = (char*)strtok(line, " \t");
+ tok = (TCHAR *)_tcstok(line, _T(" \t"));
/*create and fill a cell*/
pDBCell = (ContentType*)malloc(sizeof(ContentType));
- pDBCell->mimeType = (char*)malloc(strlen(tok) + 1);
- strcpy(pDBCell->mimeType, tok);
+ pDBCell->mimeType = (TCHAR *)malloc((_tcslen(tok) + 1) * sizeof(TCHAR));
+ _tcscpy(pDBCell->mimeType, tok);
pDBCell->extList = NULL;
pDBCell->next = NULL;
/* looking for extensions */
- tok = (char*)strtok(NULL, " \t");
+ tok = (TCHAR *)_tcstok(NULL, _T(" \t"));
while (tok != NULL) {
/*create and fill a cell*/
pExtCell = (ExtensionListCell*)malloc(sizeof(ExtensionListCell));
- pExtCell->ext = (char*)malloc(strlen(tok) + 1);
- strcpy(pExtCell->ext, tok);
+ pExtCell->ext = (TCHAR *)malloc((_tcslen(tok) + 1) * sizeof(TCHAR));
+ _tcscpy(pExtCell->ext, tok);
pExtCell->next = NULL;
/*link*/
if (pDBCell->extList == NULL) {
@@ -58,7 +58,7 @@ int bInitMimeHandling() { extListCur->next = pExtCell;
}
extListCur = pExtCell;
- tok = (char*)strtok(NULL, " \t");
+ tok = (TCHAR *)_tcstok(NULL, _T(" \t"));
}
/* link */
if (pDBCell->extList != NULL) { /*extension(s) found*/
@@ -83,12 +83,13 @@ int bInitMimeHandling() { return 1;
}
-const char * pszGetMimeType(const char * pszFileName) {
+const TCHAR *pszGetMimeType(const TCHAR *pszFileName)
+{
ContentTypeDB courMIME;
ExtensionList courEXT;
- const char* ext;
+ const TCHAR *ext;
- ext = strrchr(pszFileName, '.');
+ ext = _tcsrchr(pszFileName, '.');
if (ext != NULL) {
if (ext[1] == '\0') {
@@ -103,7 +104,7 @@ const char * pszGetMimeType(const char * pszFileName) { while (courMIME != NULL) {
courEXT = courMIME->extList;
while (courEXT != NULL) {
- if (!_stricmp(courEXT->ext, ext)) {
+ if (!_tcsicmp(courEXT->ext, ext)) {
return courMIME->mimeType;
}
courEXT = courEXT->next;
diff --git a/plugins/HTTPServer/src/MimeHandling.h b/plugins/HTTPServer/src/MimeHandling.h index f40fdf94c8..80efcc1243 100644 --- a/plugins/HTTPServer/src/MimeHandling.h +++ b/plugins/HTTPServer/src/MimeHandling.h @@ -4,7 +4,7 @@ extern "C" {
#endif
-#define szMimeTypeConfigFile "HTTPMimeTypes"
+#define szMimeTypeConfigFile _T("HTTPMimeTypes")
/* MIME DB Data structure
@@ -28,24 +28,24 @@ extern "C" { */ typedef struct _ExtensionListCell { - char* ext; - struct _ExtensionListCell* next; - } ExtensionListCell ; + TCHAR *ext; + struct _ExtensionListCell *next; + } ExtensionListCell; typedef struct _ContentType { - char* mimeType; - ExtensionListCell* extList; - struct _ContentType* next; - } ContentType ; + TCHAR *mimeType; + ExtensionListCell *extList; + struct _ContentType *next; + } ContentType; - typedef ContentType* ContentTypeDB; - typedef ExtensionListCell* ExtensionList; + typedef ContentType *ContentTypeDB; + typedef ExtensionListCell *ExtensionList; extern int bInitMimeHandling(); - extern const char * pszGetMimeType(const char * pszFileName); + extern const TCHAR *pszGetMimeType(const TCHAR *pszFileName); #ifdef __cplusplus } diff --git a/plugins/HTTPServer/src/main.cpp b/plugins/HTTPServer/src/main.cpp index f2b57ce946..7f0099609a 100644 --- a/plugins/HTTPServer/src/main.cpp +++ b/plugins/HTTPServer/src/main.cpp @@ -18,27 +18,27 @@ #include "Glob.h"
-#define szConfigFile "HTTPServer.xml"
+#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 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 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 char* pszDefaultShares[] = {
- "htdocs\\@settings\\favicon.ico", "/favicon.ico",
- "htdocs\\@settings\\index.xsl", "/index.xsl",
- "htdocs\\@settings\\theme\\", "/theme/",
- "htdocs\\", "/",
+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("/"),
0, 0
};
@@ -50,7 +50,7 @@ HANDLE hDirectBoundPort; HINSTANCE hInstance = NULL;
-string sLogFilePath;
+tstring 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;
-char szPluginPath[MAX_PATH] = {0};
+TCHAR szPluginPath[MAX_PATH] = {0};
int nPluginPathLen = 0;
DWORD dwLocalIpAddress = 0;
@@ -125,9 +125,10 @@ bool bOpenLogFile() { }
-bool bWriteToFile(HANDLE hFile, const char * pszSrc, int nLen = -1) {
+bool bWriteToFile(HANDLE hFile, const TCHAR *pszSrc, int nLen = -1)
+{
if (nLen < 0)
- nLen = (int)strlen(pszSrc);
+ nLen = (int)_tcslen(pszSrc);
DWORD dwBytesWritten;
return WriteFile(hFile, pszSrc, nLen, &dwBytesWritten, NULL) && (dwBytesWritten == (DWORD)nLen);
}
@@ -147,7 +148,8 @@ bool bWriteToFile(HANDLE hFile, const char * pszSrc, int nLen = -1) { // Developer : KN
/////////////////////////////////////////////////////////////////////
-void LogEvent(const TCHAR * pszTitle, const char * pszLog) {
+void LogEvent(const TCHAR *pszTitle, const TCHAR *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);
@@ -159,20 +161,20 @@ void LogEvent(const TCHAR * pszTitle, const char * pszLog) { return;
}
- char szTmp[128];
+ TCHAR szTmp[128];
time_t now;
time(&now);
- int nLen = (int)strftime(szTmp, sizeof(szTmp), "%d-%m-%Y %H:%M:%S -- ", localtime(&now));
+ int nLen = (int)_tcsftime(szTmp, SIZEOF(szTmp), _T("%d-%m-%Y %H:%M:%S -- "), localtime(&now));
- int nLogLen = (int)strlen(pszLog);
+ int nLogLen = (int)_tcslen(pszLog);
while (nLogLen > 0 && (pszLog[nLogLen-1] == '\r' || pszLog[nLogLen-1] == '\n'))
nLogLen--;
if (!bWriteToFile(hFile, szTmp, nLen) ||
!bWriteToFile(hFile, pszTitle) ||
- !bWriteToFile(hFile, " : ") ||
+ !bWriteToFile(hFile, _T(" : ")) ||
!bWriteToFile(hFile, pszLog, nLogLen) ||
- !bWriteToFile(hFile, "\r\n")) {
+ !bWriteToFile(hFile, _T("\r\n"))) {
MessageBox(NULL, TranslateT("Failed to write some part of the log file"), MSG_BOX_TITEL, MB_OK);
}
CloseHandle(hFile);
@@ -193,11 +195,12 @@ void LogEvent(const TCHAR * pszTitle, const char * pszLog) { // Developer : KN
/////////////////////////////////////////////////////////////////////
-DWORD dwReadIPAddress(char * pszStr, bool &bError) {
+DWORD dwReadIPAddress(TCHAR *pszStr, bool &bError)
+{
DWORD ip = 0;
- char *pszEnd;
+ TCHAR *pszEnd;
for (int n = 0 ; n < 4 ; n++) {
- int nVal = strtol(pszStr, &pszEnd, 10);
+ int nVal = _tcstol(pszStr, &pszEnd, 10);
if (pszEnd <= pszStr || (n != 3 && pszEnd[0] != '.') || (nVal < 0 || nVal > 255)) {
bError = true;
return 0;
@@ -221,20 +224,21 @@ DWORD dwReadIPAddress(char * pszStr, bool &bError) { // Developer : KN
/////////////////////////////////////////////////////////////////////
-bool bReadConfigurationFile() {
+bool bReadConfigurationFile()
+{
CLFileShareListAccess clCritSection;
CLFileShareNode * pclLastNode = NULL;
- char szBuf[1000];
- strcpy(szBuf, szPluginPath);
- strcat(szBuf, szConfigFile);
+ TCHAR szBuf[1000];
+ _tcscpy(szBuf, szPluginPath);
+ _tcscat(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;
- char *pszCurPos = szBuf;
+ TCHAR *pszCurPos = szBuf;
bool bEof = false;
while (!bEof) {
@@ -242,33 +246,33 @@ bool bReadConfigurationFile() { // move rest of buffer to front
if (pszCurPos && pszCurPos != szBuf) {
- dwBytesInBuffer = DWORD(sizeof(szBuf) - (pszCurPos - szBuf));
+ dwBytesInBuffer = DWORD(SIZEOF(szBuf) - (pszCurPos - szBuf));
memmove(szBuf, pszCurPos, dwBytesInBuffer);
}
// 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 = strstr(pszCurPos, "<share>")) != NULL) {
+ while (pszCurPos && (pszCurPos = _tcsstr(pszCurPos, _T("<share>"))) != NULL) {
pszCurPos += 7;
- char * pszColData[5] = {NULL};
+ TCHAR *pszColData[5] = {NULL};
for (int n = 0 ; n < 5 ; n++) {
- pszColData[n] = strstr(pszCurPos, ">");
+ pszColData[n] = _tcsstr(pszCurPos, _T(">"));
if (!pszColData[n])
break;
pszColData[n] += 1;
- pszCurPos = strstr(pszColData[n], "</");
+ pszCurPos = _tcsstr(pszColData[n], _T("</"));
if (!pszCurPos)
break;
pszCurPos[0] = 0;// NULL terminate row data, we overwrite the '<'
- pszCurPos = strstr(pszCurPos + 3, ">");
+ pszCurPos = _tcsstr(pszCurPos + 3, _T(">"));
if (!pszCurPos)
break;
@@ -280,9 +284,9 @@ bool bReadConfigurationFile() { CLFileShareNode * pcl = new CLFileShareNode(pszColData[0], pszColData[1]);
bool bError = false;
- char * pszEnd;
+ TCHAR * pszEnd;
- pcl->st.nMaxDownloads = strtol(pszColData[2], &pszEnd, NULL);
+ pcl->st.nMaxDownloads = _tcstol(pszColData[2], &pszEnd, NULL);
if (!pszEnd || *pszEnd != NULL)
bError = true;
@@ -324,28 +328,29 @@ bool bReadConfigurationFile() { // Developer : KN
/////////////////////////////////////////////////////////////////////
-bool bWriteConfigurationFile() {
+bool bWriteConfigurationFile()
+{
CLFileShareListAccess clCritSection;
- char szBuf[1000];
- strcpy(szBuf, szPluginPath);
- strcat(szBuf, szConfigFile);
+ TCHAR szBuf[1000];
+ _tcscpy(szBuf, szPluginPath);
+ _tcscat(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 "), _T(szConfigFile));
- MessageBox(NULL, temp , MSG_BOX_TITEL, MB_OK);
+ mir_sntprintf(temp, SIZEOF(temp), _T("%s%s"), TranslateT("Failed to open or create file "), szConfigFile);
+ MessageBox(NULL, temp, MSG_BOX_TITEL, MB_OK);
return false;
}
DWORD dwBytesWriten = 0;
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 "), _T(szConfigFile));
+ mir_sntprintf(temp, SIZEOF(temp), _T("%s%s"), TranslateT("Failed to write xml header to file "), szConfigFile);
MessageBox(NULL, temp, MSG_BOX_TITEL, MB_OK);
} else {
CLFileShareNode * pclCur = pclFirstNode;
while (pclCur) {
- DWORD dwBytesToWrite = mir_snprintf(szBuf, sizeof(szBuf), szXmlData ,
+ DWORD dwBytesToWrite = mir_sntprintf(szBuf, SIZEOF(szBuf), szXmlData,
pclCur->st.pszSrvPath,
pclCur->pszOrigRealPath,
pclCur->st.nMaxDownloads,
@@ -354,7 +359,7 @@ 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 "), _T(szConfigFile));
+ mir_sntprintf(temp, SIZEOF(temp), _T("%s%s"), TranslateT("Failed to write xml data to file "), szConfigFile);
MessageBox(NULL, temp, MSG_BOX_TITEL, MB_OK);
break;
}
@@ -363,7 +368,7 @@ bool bWriteConfigurationFile() { 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 "), _T(szConfigFile));
+ mir_sntprintf(temp, SIZEOF(temp), _T("%s%s"), TranslateT("Failed to write xml tail to file "), szConfigFile);
MessageBox(NULL, temp, MSG_BOX_TITEL, MB_OK);
}
}
@@ -394,9 +399,9 @@ static INT_PTR nAddChangeRemoveShare(WPARAM wParam, LPARAM lParam) { STFileShareInfo * pclNew = (STFileShareInfo*)lParam;
// make the server path lowercase
- char* pszPos = pclNew->pszSrvPath;
+ TCHAR *pszPos = pclNew->pszSrvPath;
while (*pszPos) {
- *pszPos = (char)tolower(*pszPos);
+ *pszPos = tolower(*pszPos);
pszPos++;
}
@@ -404,7 +409,7 @@ static INT_PTR nAddChangeRemoveShare(WPARAM wParam, LPARAM lParam) { return 1002;
CLFileShareListAccess clCritSection;
- bool bIsDirectory = (pclNew->pszSrvPath[strlen(pclNew->pszSrvPath)-1] == '/');
+ bool bIsDirectory = (pclNew->pszSrvPath[_tcslen(pclNew->pszSrvPath)-1] == '/');
CLFileShareNode **pclPrev = &pclFirstNode;
CLFileShareNode * pclCur = pclFirstNode;
@@ -418,7 +423,7 @@ static INT_PTR nAddChangeRemoveShare(WPARAM wParam, LPARAM lParam) { }
while (pclCur) {
- if (_stricmp(pclCur->st.pszSrvPath, pclNew->pszSrvPath) == 0) {
+ if (_tcsicmp(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.
@@ -484,10 +489,10 @@ static INT_PTR nGetShare(WPARAM /*wParam*/, LPARAM lParam) { STFileShareInfo * pclShare = (STFileShareInfo*)lParam;
CLFileShareNode * pclCur = pclFirstNode;
while (pclCur) {
- if (strcmp(pclCur->st.pszSrvPath, pclShare->pszSrvPath) == 0) {
- if (pclShare->dwMaxRealPath <= strlen(pclCur->st.pszRealPath) + 1)
+ if (_tcscmp(pclCur->st.pszSrvPath, pclShare->pszSrvPath) == 0) {
+ if (pclShare->dwMaxRealPath <= _tcslen(pclCur->st.pszRealPath) + 1)
return 1003;
- strcpy(pclShare->pszRealPath, pclCur->st.pszRealPath);
+ _tcscpy(pclShare->pszRealPath, pclCur->st.pszRealPath);
pclShare->dwAllowedIP = pclCur->st.dwAllowedIP;
pclShare->dwAllowedMask = pclCur->st.dwAllowedMask;
pclShare->nMaxDownloads = pclCur->st.nMaxDownloads;
@@ -643,8 +648,8 @@ INT_PTR nToggelAcceptConnections(WPARAM wparam, LPARAM /*lparam*/) { hDirectBoundPort = (HANDLE) CallService(MS_NETLIB_BINDPORT, (WPARAM) hNetlibUser, (LPARAM) & nlb);
if (!hDirectBoundPort) {
TCHAR szTemp[200];
- 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);
+ 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));
MessageBox(NULL, szTemp, MSG_BOX_TITEL, MB_OK);
return 1001;
}
@@ -716,11 +721,11 @@ int MainInit(WPARAM /*wparam*/, LPARAM /*lparam*/) { if (! bReadConfigurationFile()) {
//MessageBox( NULL, "Failed to read configuration file : " szConfigFile, MSG_BOX_TITEL, MB_OK );
- char szRealPath[MAX_PATH];
- char szSrvPath[MAX_PATH] = {0};
+ TCHAR szRealPath[MAX_PATH];
+ TCHAR szSrvPath[MAX_PATH] = {0};
STFileShareInfo share;
- const char** p = pszDefaultShares;
+ const TCHAR** p = pszDefaultShares;
while (*p) {
memset(&share, 0, sizeof(share));
share.lStructSize = sizeof(share);
@@ -729,12 +734,12 @@ int MainInit(WPARAM /*wparam*/, LPARAM /*lparam*/) { share.nMaxDownloads = -1;
share.pszRealPath = szRealPath;
- share.dwMaxRealPath = sizeof(szRealPath);
- strcpy(share.pszRealPath, p[0]);
+ share.dwMaxRealPath = SIZEOF(szRealPath);
+ _tcscpy(share.pszRealPath, p[0]);
share.pszSrvPath = szSrvPath;
- share.dwMaxSrvPath = sizeof(szSrvPath);
- strcpy(share.pszSrvPath, p[1]);
+ share.dwMaxSrvPath = SIZEOF(szSrvPath);
+ _tcscpy(share.pszSrvPath, p[1]);
if (CallService(MS_HTTP_ADD_CHANGE_REMOVE, 0, (LPARAM)&share))
break;
@@ -904,20 +909,20 @@ int nSystemShutdown(WPARAM /*wparam*/, LPARAM /*lparam*/) { return 1;
}
_tcsncat(szPluginPath,_T("\\HTTPServer\\"), MAX_PATH);
- int err = CreateDirectoryTree(szPluginPath);
+ int err = CreateDirectoryTreeT(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)strlen(szPluginPath);
+ nPluginPathLen = (int)_tcslen(szPluginPath);
sLogFilePath = szPluginPath;
- sLogFilePath += "HTTPServer.log";
+ sLogFilePath += _T("HTTPServer.log");
- if (! bInitMimeHandling()) {
- MessageBox(NULL, "Failed to read configuration file : " szMimeTypeConfigFile, MSG_BOX_TITEL, MB_OK);
+ if (!bInitMimeHandling()) {
+ MessageBox(NULL, _T("Failed to read configuration file : ") szMimeTypeConfigFile, MSG_BOX_TITEL, MB_OK);
}
nMaxUploadSpeed = db_get_dw(NULL, MODULE, "MaxUploadSpeed", nMaxUploadSpeed);
@@ -932,7 +937,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.pszName = LPGENT("Enable HTTP server");
+ mi.ptszName = LPGENT("Enable HTTP server");
mi.pszService = MS_HTTP_ACCEPT_CONNECTIONS;
hAcceptConnectionsMenuItem = Menu_AddMainMenuItem(&mi);
}
|