From 3942df7207beeb9f2fc08a6deb1d375badbe066a Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Sat, 14 Jun 2014 22:35:16 +0000 Subject: plugin unicoded git-svn-id: http://svn.miranda-ng.org/main/trunk@9488 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/HTTPServer/src/IndexXML.cpp | 138 ++++++++++++++++++------------------ 1 file changed, 69 insertions(+), 69 deletions(-) (limited to 'plugins/HTTPServer/src/IndexXML.cpp') 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[] = ""; -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), - " %s\r\n", szFileName); + ReplaceSign(szFileName, MAX_PATH, '&', _T("&")); + pszBuffer += mir_sntprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer), + _T(" %s\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), - " \r\n", szFileName); + pszBuffer += mir_sntprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer), + _T(" \r\n"), szFileName); } else { - pszExt = strrchr(szFileName, '.'); + pszExt = _tcsrchr(szFileName, '.'); if (pszExt != NULL) { *pszExt = '\0'; pszExt++; } - 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), - " \r\n", szFileName); + szFileName[_tcslen(szFileName)-1] = '\0'; + if (!_tcschr(szFileName, '/')) { // only one level deeper + pszBuffer += mir_sntprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer), + _T(" \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), - " \r\n"); + pszBuffer += mir_sntprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer), + _T("/>\r\n")); if (!WriteFile(hFile, szBuffer, pszBuffer - szBuffer, &dwBytesWritten, NULL)) break; -- cgit v1.2.3