diff options
author | Kirill Volinsky <mataes2007@gmail.com> | 2014-06-14 22:35:16 +0000 |
---|---|---|
committer | Kirill Volinsky <mataes2007@gmail.com> | 2014-06-14 22:35:16 +0000 |
commit | 3942df7207beeb9f2fc08a6deb1d375badbe066a (patch) | |
tree | 10cff5e3f6b525410e00207d05578b30025c7d9f /plugins/HTTPServer/src/IndexHTML.cpp | |
parent | c5fb4140e75fe56e24caa98fda1f13b14955efe9 (diff) |
plugin unicoded
git-svn-id: http://svn.miranda-ng.org/main/trunk@9488 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/HTTPServer/src/IndexHTML.cpp')
-rw-r--r-- | plugins/HTTPServer/src/IndexHTML.cpp | 134 |
1 files changed, 67 insertions, 67 deletions
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;
}
|