diff options
author | mataes2007 <mataes2007@e753b5eb-9565-29b2-b5c5-2cc6f99dfbcb> | 2012-01-14 19:18:42 +0000 |
---|---|---|
committer | mataes2007 <mataes2007@e753b5eb-9565-29b2-b5c5-2cc6f99dfbcb> | 2012-01-14 19:18:42 +0000 |
commit | 0aafc6c4b2e485f5ee9bb0bdf3e687525859cb03 (patch) | |
tree | 73230de5fcc8ba7a89a8185f49dfb74313e02558 | |
parent | 03d88e9750c2d983318035dcd33da24875799b4c (diff) |
HTTPServer (patch from FREAK_THEMIGHTY):
code cleanup
header reorganisation
MM_INTERFACE support
new langpacks support
rather technical changes
git-svn-id: http://miranda-plugins.googlecode.com/svn/trunk@258 e753b5eb-9565-29b2-b5c5-2cc6f99dfbcb
-rw-r--r-- | HTTPServer/AggressiveOptimize.h | 66 | ||||
-rw-r--r-- | HTTPServer/FileShareNode.cpp | 12 | ||||
-rw-r--r-- | HTTPServer/FileShareNode.h | 2 | ||||
-rw-r--r-- | HTTPServer/Glob.h | 33 | ||||
-rw-r--r-- | HTTPServer/GuiElements.cpp | 158 | ||||
-rw-r--r-- | HTTPServer/GuiElements.h | 2 | ||||
-rw-r--r-- | HTTPServer/HTTPServer_10.vcxproj | 235 | ||||
-rw-r--r-- | HTTPServer/HTTPServer_10.vcxproj.filters | 82 | ||||
-rw-r--r-- | HTTPServer/HttpUser.cpp | 30 | ||||
-rw-r--r-- | HTTPServer/HttpUser.h | 2 | ||||
-rw-r--r-- | HTTPServer/IndexCreation.h | 2 | ||||
-rw-r--r-- | HTTPServer/IndexHTML.cpp | 28 | ||||
-rw-r--r-- | HTTPServer/IndexXML.cpp | 31 | ||||
-rw-r--r-- | HTTPServer/MimeHandling.cpp | 9 | ||||
-rw-r--r-- | HTTPServer/MimeHandling.h | 82 | ||||
-rw-r--r-- | HTTPServer/data/HTTPServerIndex.html | 117 | ||||
-rw-r--r-- | HTTPServer/data/htdocs/@settings/index.xsl | 297 | ||||
-rw-r--r-- | HTTPServer/main.cpp | 126 |
18 files changed, 781 insertions, 533 deletions
diff --git a/HTTPServer/AggressiveOptimize.h b/HTTPServer/AggressiveOptimize.h deleted file mode 100644 index fab80a1..0000000 --- a/HTTPServer/AggressiveOptimize.h +++ /dev/null @@ -1,66 +0,0 @@ -
-//////////////////////////////
-// Version 1.10
-// Jan 23rd, 2000
-// Version 1.00
-// May 20th, 1999
-// Todd C. Wilson, Fresh Ground Software
-// (todd@nopcode.com)
-// This header file will kick in settings for Visual C++ 5 and 6 that will (usually)
-// result in smaller exe's.
-// The "trick" is to tell the compiler to not pad out the function calls; this is done
-// by not using the /O1 or /O2 option - if you do, you implicitly use /Gy, which pads
-// out each and every function call. In one single 500k dll, I managed to cut out 120k
-// by this alone!
-// The other two "tricks" are telling the Linker to merge all data-type segments together
-// in the exe file. The relocation, read-only (constants) data, and code section (.text)
-// sections can almost always be merged. Each section merged can save 4k in exe space,
-// since each section is padded out to 4k chunks. This is very noticable with smaller
-// exes, since you could have only 700 bytes of data, 300 bytes of code, 94 bytes of
-// strings - padded out, this could be 12k of runtime, for 1094 bytes of stuff!
-// Note that if you're using MFC static or some other 3rd party libs, you may get poor
-// results with merging the readonly (.rdata) section - the exe may grow larger.
-// To use this feature, define _MERGE_DATA_ in your project or before this header is used.
-// With Visual C++ 5, the program uses a file alignement of 512 bytes, which results
-// in a small exe. Under VC6, the program instead uses 4k, which is the same as the
-// section size. The reason (from what I understand) is that 4k is the chunk size of
-// the virtual memory manager, and that WinAlign (an end-user tuning tool for Win98)
-// will re-align the programs on this boundary. The problem with this is that all of
-// Microsoft's system exes and dlls are not tuned like this, and using 4k causes serious
-// exe bloat. Very noticable for smaller programs.
-// The "trick" for this is to use the undocumented FILEALIGN linker parm to change the
-// padding from 4k to 1/2k, which results in a much smaller exe - anywhere from 20%-75%
-// depending on the size.
-
-
-#ifdef NDEBUG
-
-#if _MSC_VER <= 1200
-// /Og (global optimizations), /Os (favor small code), /Oy (no frame pointers)
-//#pragma optimize("gsy",on)
-#pragma optimize("g",on)
-#pragma optimize("s",on)
-#pragma optimize("y",on)
-
-#pragma comment(linker,"/RELEASE")
-
-
-// Note that merging the .rdata section will result in LARGER exe's if you using
-// MFC (esp. static link). If this is desirable, define _MERGE_RDATA_ in your project.
-#ifdef _MERGE_RDATA_
-#pragma comment(linker,"/merge:.rdata=.data")
-#endif // _MERGE_RDATA_
-
-#pragma comment(linker,"/merge:.text=.data")
-#pragma comment(linker,"/merge:.reloc=.data")
-
-
-#if _MSC_VER >= 1000
-// Only supported/needed with VC6; VC5 already does 0x200 for release builds.
-// Totally undocumented! And if you set it lower than 512 bytes, the program crashes.
-// Either leave at 0x200 or 0x1000
-#pragma comment(linker,"/FILEALIGN:0x200")
-#endif // _MSC_VER >= 1000
-#endif // _MSC_VER < 1200
-
-#endif // NDEBUG
diff --git a/HTTPServer/FileShareNode.cpp b/HTTPServer/FileShareNode.cpp index ede135a..e38cb39 100644 --- a/HTTPServer/FileShareNode.cpp +++ b/HTTPServer/FileShareNode.cpp @@ -15,21 +15,9 @@ //along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-#ifdef NDEBUG //release
-#include "AggressiveOptimize.h" //create small code
-#endif
-
#include "FileShareNode.h"
-#include "Glob.h"
#include "GuiElements.h"
-#include <stdio.h>
-
-#pragma warning( push, 3 )
-#include "newpluginapi.h"
-#include "m_netlib.h"
-#pragma warning( pop )
-
CLFileShareNode * pclFirstNode = NULL;
CRITICAL_SECTION csFileShareListAccess;
diff --git a/HTTPServer/FileShareNode.h b/HTTPServer/FileShareNode.h index 706a31f..634b4ef 100644 --- a/HTTPServer/FileShareNode.h +++ b/HTTPServer/FileShareNode.h @@ -18,7 +18,7 @@ #ifndef FILE_SHARE_NODE_H
#define FILE_SHARE_NODE_H
-#include <windows.h>
+#include "Glob.h"
#include "m_HTTPServer.h"
class CLShareUser {
diff --git a/HTTPServer/Glob.h b/HTTPServer/Glob.h index a3a1f71..8dc270c 100644 --- a/HTTPServer/Glob.h +++ b/HTTPServer/Glob.h @@ -19,21 +19,36 @@ #define HTTP_SERVER_GLOB_H
#include <windows.h>
-
-#ifndef INVALID_SET_FILE_POINTER
-#define INVALID_SET_FILE_POINTER (unsigned long)(-1)
-#endif
-
-#ifndef ULONG_PTR
-#define ULONG_PTR ULONG
-#endif
+#include <string>
+#include <process.h>
+#include <stdio.h>
+#include <commctrl.h>
+#include <time.h>
+#include <commctrl.h>
+#include <Winsock.h>
+
+#define MIRANDA_VER 0x0900
+#include "newpluginapi.h"
+#include "m_database.h"
+#include "m_clist.h"
+#include "m_clui.h"
+#include "m_skin.h"
+#include "m_langpack.h"
+#include "m_options.h"
+#include "m_system.h"
+#include "m_history.h"
+#include "m_userinfo.h"
+#include "m_netlib.h"
+#include "m_message.h"
+#include "m_popup.h"
+#include "m_protosvc.h"
#define SD_RECEIVE 0x00
#define SD_SEND 0x01
#define SD_BOTH 0x02
#define MODULE "HTTPServer"
-#define MSG_BOX_TITEL "Miranda (HTTPServer.dll)"
+#define MSG_BOX_TITEL _T("Miranda (HTTPServer.dll)")
#define SplitIpAddress( p ) (BYTE)(p>>24),(BYTE)(p>>16),(BYTE)(p>>8),(BYTE)(p)
diff --git a/HTTPServer/GuiElements.cpp b/HTTPServer/GuiElements.cpp index d05af16..3716be5 100644 --- a/HTTPServer/GuiElements.cpp +++ b/HTTPServer/GuiElements.cpp @@ -15,57 +15,15 @@ //along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-#ifdef NDEBUG //release
-#include "AggressiveOptimize.h" //create small code
-#endif
-
#include "GuiElements.h"
-#include <windows.h>
-#include <stdio.h>
-#include <commctrl.h>
-
-#pragma warning( push, 3 )
-#include <string>
using namespace std;
-#include "Glob.h"
#include "m_HTTPServer.h"
#include "FileShareNode.h"
#include "resource.h"
#include "IndexCreation.h"
-#include "newpluginapi.h"
-#include "m_database.h"
-#include "m_clist.h"
-#include "m_skin.h"
-#include "m_langpack.h"
-#include "m_options.h"
-#include "m_system.h"
-#include "m_history.h"
-#include "m_userinfo.h"
-#include "m_netlib.h"
-#include "m_message.h"
-#include "m_popup.h"
-#include "m_clui.h"
-
-#pragma warning( pop )
-
-struct NETLIBHTTPREQUEST_V032 {
- int cbSize;
- int requestType; //a REQUEST_
- DWORD flags;
- char *szUrl;
- NETLIBHTTPHEADER *headers; //If this is a POST request and headers
- //doesn't contain a Content-Length it'll be added automatically
- int headersCount;
- char *pData; //data to be sent in POST request.
- int dataLength; //must be 0 for REQUEST_GET/REQUEST_CONNECT
- int resultCode;
- char *szResultDescr;
-};
-
-
#define MS_SHARE_NEW_FILE "HTTPServer/ShareNewFile"
#define MS_SHOW_STATISTICS_VIEW "HTTPServer/ShowStatisticsView"
@@ -111,7 +69,7 @@ string sPageKeyword = szDefaultPageKeyword; void ReplaceAll(string &sSrc, const char * pszReplace, const string &sNew) {
string::size_type nCur = 0;
- int nRepalceLen = strlen(pszReplace);
+ size_t nRepalceLen = strlen(pszReplace);
while ((nCur = sSrc.find(pszReplace, nCur)) != sSrc.npos) {
sSrc.replace(nCur, nRepalceLen, sNew);
nCur += sNew.size();
@@ -205,10 +163,6 @@ unsigned long GetExternIP(const char *szURL, const char *szPattern) { externIP.s_addr = 0;
nlreply = (NETLIBHTTPREQUEST *) CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM) hNetlibUser, (LPARAM) & nlhr);
- if (nlreply == 0) {
- nlhr.cbSize = sizeof(NETLIBHTTPREQUEST_V032); // try with old size
- nlreply = (NETLIBHTTPREQUEST *) CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM) hNetlibUser, (LPARAM) & nlhr);
- }
if (nlreply) {
if (nlreply->resultCode >= 200 && nlreply->resultCode < 300) {
nlreply->pData[nlreply->dataLength] = 0;// make sure its null terminated
@@ -253,7 +207,7 @@ unsigned long GetExternIP(const char *szURL, const char *szPattern) { string sCreateLink(const char * pszSrvPath) {
char szTemp[30];
string sLink = DBGetString(NULL, MODULE, "ExternalSrvName", szDefaultExternalSrvName);
- _snprintf(szTemp, sizeof(szTemp), "%d.%d.%d.%d", SplitIpAddress(dwLocalIpAddress));
+ mir_snprintf(szTemp, sizeof(szTemp), "%d.%d.%d.%d", SplitIpAddress(dwLocalIpAddress));
ReplaceAll(sLink, "%LocalIP%", szTemp);
if (sLink.find("%ExternalIP%") != sLink.npos) {
@@ -266,11 +220,11 @@ string sCreateLink(const char * pszSrvPath) { dwExternalIpAddressGenerated = GetTickCount();
}
- _snprintf(szTemp, sizeof(szTemp), "%d.%d.%d.%d", SplitIpAddress(dwExternalIpAddress));
+ mir_snprintf(szTemp, sizeof(szTemp), "%d.%d.%d.%d", SplitIpAddress(dwExternalIpAddress));
ReplaceAll(sLink, "%ExternalIP%", szTemp);
}
- _snprintf(szTemp, sizeof(szTemp), "%d", dwLocalPortUsed, szTemp);
+ mir_snprintf(szTemp, sizeof(szTemp), "%d", dwLocalPortUsed, szTemp);
ReplaceAll(sLink, "%Port%", szTemp);
string sSrvPath = pszSrvPath;
@@ -295,7 +249,7 @@ string sCreateLink(const char * pszSrvPath) { // Developer : KN, Houdini
/////////////////////////////////////////////////////////////////////
-UINT CALLBACK ShareNewFileDialogHook(
+UINT_PTR CALLBACK ShareNewFileDialogHook(
HWND hDlg, // handle to child dialog box
UINT uiMsg, // message identifier
WPARAM wParam, // message parameter
@@ -305,11 +259,11 @@ UINT CALLBACK ShareNewFileDialogHook( static int nInit = 0;
- STFileShareInfo * pstShare = (STFileShareInfo *)GetWindowLong(hDlg, GWL_USERDATA);
+ STFileShareInfo * pstShare = (STFileShareInfo *)GetWindowLong(hDlg, GWLP_USERDATA);
switch (uiMsg) {
case WM_INITDIALOG: {
pstShare = (STFileShareInfo *)((OPENFILENAME *)lParam)->lCustData;
- SetWindowLong(hDlg, GWL_USERDATA, (LPARAM)pstShare);
+ SetWindowLong(hDlg, GWLP_USERDATA, (LPARAM)pstShare);
SetDlgItemInt(hDlg, IDC_MAX_DOWNLOADS, pstShare->nMaxDownloads, true);
SendMessage(GetDlgItem(hDlg, IDC_ALLOWED_IPADDRESS), IPM_SETADDRESS, 0, pstShare->dwAllowedIP);
@@ -422,7 +376,7 @@ UINT CALLBACK ShareNewFileDialogHook( //if( ! (pstShare->dwAllowedIP & pstShare->dwAllowedMask)
if (!bTranslated || (strlen(pstShare->pszSrvPath) <= 0)) {
- SetWindowLong(hDlg, DWL_MSGRESULT, 1);
+ SetWindowLong(hDlg, DWLP_MSGRESULT, 1);
return true;
}
return false;
@@ -485,7 +439,7 @@ UINT CALLBACK ShareNewFileDialogHook( bool bShowShareNewFileDlg(HWND hwndOwner, STFileShareInfo * pstNewShare) {
OPENFILENAME ofn = {0};
ofn.lStructSize = sizeof(OPENFILENAME);
- ofn.lpstrFilter = "All Files (*.*)\0*.*\0";
+ ofn.lpstrFilter = _T("All Files (*.*)\0*.*\0");
ofn.lpstrFile = pstNewShare->pszRealPath;
ofn.nMaxFile = pstNewShare->dwMaxRealPath;
@@ -503,7 +457,7 @@ bool bShowShareNewFileDlg(HWND hwndOwner, STFileShareInfo * pstNewShare) { | OFN_ALLOWMULTISELECT;
ofn.hwndOwner = hwndOwner;
ofn.hInstance = hInstance;
- ofn.lpstrTitle = Translate("Specify a file to share");
+ ofn.lpstrTitle = TranslateT("Specify a file to share");
ofn.lpTemplateName = MAKEINTRESOURCE(IDD_NEW_SHARE_PROPERTIES);
ofn.lpfnHook = ShareNewFileDialogHook;
ofn.lCustData = (LPARAM)pstNewShare;
@@ -511,8 +465,8 @@ bool bShowShareNewFileDlg(HWND hwndOwner, STFileShareInfo * pstNewShare) { if (!GetOpenFileName(&ofn)) {
DWORD dwError = CommDlgExtendedError();
if (dwError) {
- char szTemp[200];
- _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;
@@ -547,7 +501,7 @@ bool bShowShareNewFileDlg(HWND hwndOwner, STFileShareInfo * pstNewShare) { pstNewShare->pszRealPath[pstNewShare->dwMaxRealPath] = '\0';
if (CallService(MS_HTTP_ADD_CHANGE_REMOVE, 0, (LPARAM)pstNewShare)) {
- MessageBox(NULL, "Failed to share new file", MSG_BOX_TITEL, MB_OK);
+ MessageBox(NULL, _T("Failed to share new file"), MSG_BOX_TITEL, MB_OK);
return false;
}
pszFileNamePos++;
@@ -557,7 +511,7 @@ bool bShowShareNewFileDlg(HWND hwndOwner, STFileShareInfo * pstNewShare) { } else {
if (CallService(MS_HTTP_ADD_CHANGE_REMOVE, 0, (LPARAM)pstNewShare)) {
- MessageBox(NULL, "Failed to share new file", MSG_BOX_TITEL, MB_OK);
+ MessageBox(NULL, _T("Failed to share new file"), MSG_BOX_TITEL, MB_OK);
return false;
}
}
@@ -609,7 +563,7 @@ void UpdateStatisticView(HWND hwndDlg, bool bRefressUsersOnly = false) { ListView_InsertItem(hShareList, &sItem);
- _snprintf(szTmp, sizeof(szTmp), "%d", pclCur->st.nMaxDownloads);
+ mir_snprintf(szTmp, sizeof(szTmp), "%d", pclCur->st.nMaxDownloads);
sItem.iSubItem = 1;
sItem.pszText = szTmp;
ListView_SetItem(hShareList, &sItem);
@@ -649,7 +603,7 @@ void UpdateStatisticView(HWND hwndDlg, bool bRefressUsersOnly = false) { ListView_SetItem(hUserList, &sItem);
if (pclCurUser->dwTotalSize) {
- _snprintf(szTmp, sizeof(szTmp), "%d %%", (pclCurUser->dwCurrentDL * 100) / pclCurUser->dwTotalSize);
+ mir_snprintf(szTmp, sizeof(szTmp), "%d %%", (pclCurUser->dwCurrentDL * 100) / pclCurUser->dwTotalSize);
} else {
strcpy(szTmp, "? %%");
}
@@ -661,9 +615,9 @@ void UpdateStatisticView(HWND hwndDlg, bool bRefressUsersOnly = false) { if (dwSpeed > 10000) {
dwSpeed += 512; // make sure we round ot down correctly.
dwSpeed /= 1024;
- _snprintf(szTmp, sizeof(szTmp), "%d KB/Sec", dwSpeed);
+ mir_snprintf(szTmp, sizeof(szTmp), "%d KB/Sec", dwSpeed);
} else {
- _snprintf(szTmp, sizeof(szTmp), "%d B/Sec", dwSpeed);
+ mir_snprintf(szTmp, sizeof(szTmp), "%d B/Sec", dwSpeed);
}
sItem.iSubItem = 4;
sItem.pszText = szTmp;
@@ -733,7 +687,7 @@ void SetWindowsCtrls(HWND hwndDlg) { // Developer : KN, Houdini
/////////////////////////////////////////////////////////////////////
-static BOOL CALLBACK DlgProcStatsticView(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
+static INT_PTR CALLBACK DlgProcStatsticView(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
switch (msg) {
case WM_INITDIALOG: {
SendMessage(hwndDlg, WM_SETICON, ICON_BIG,
@@ -758,36 +712,36 @@ static BOOL CALLBACK DlgProcStatsticView(HWND hwndDlg, UINT msg, WPARAM wParam, LVCOLUMN cCol = { 0 };
cCol.mask = LVCF_TEXT | LVCF_WIDTH;
cCol.cx = DBGetContactSettingWord(NULL, MODULE, "StatWnd_cx1", 126);
- cCol.pszText = Translate("Share name");
+ cCol.pszText = TranslateT("Share name");
ListView_InsertColumn(hShareList, 0, &cCol);
cCol.cx = DBGetContactSettingWord(NULL, MODULE, "StatWnd_cx2", 48);
- cCol.pszText = Translate("Max Downloads");
+ cCol.pszText = TranslateT("Max Downloads");
ListView_InsertColumn(hShareList, 1, &cCol);
cCol.cx = DBGetContactSettingWord(NULL, MODULE, "StatWnd_cx3", 96);
- cCol.pszText = Translate("Allowed IP");
+ cCol.pszText = TranslateT("Allowed IP");
ListView_InsertColumn(hShareList, 2, &cCol);
cCol.cx = DBGetContactSettingWord(NULL, MODULE, "StatWnd_cx4", 104);
- cCol.pszText = Translate("Allowed Mask");
+ cCol.pszText = TranslateT("Allowed Mask");
ListView_InsertColumn(hShareList, 3, &cCol);
cCol.cx = DBGetContactSettingWord(NULL, MODULE, "StatWnd_cx5", 252);
- cCol.pszText = Translate("Real path");
+ cCol.pszText = TranslateT("Real path");
ListView_InsertColumn(hShareList, 4, &cCol);
cCol.mask = LVCF_TEXT | LVCF_WIDTH;
cCol.cx = DBGetContactSettingWord(NULL, MODULE, "StatWnd_cx6", 142);
- cCol.pszText = Translate("Share name");
+ cCol.pszText = TranslateT("Share name");
ListView_InsertColumn(hUserList, 0, &cCol);
cCol.cx = DBGetContactSettingWord(NULL, MODULE, "StatWnd_cx7", 111);
- cCol.pszText = Translate("User");
+ cCol.pszText = TranslateT("User");
ListView_InsertColumn(hUserList, 1, &cCol);
cCol.cx = DBGetContactSettingWord(NULL, MODULE, "StatWnd_cx8", 100);
- cCol.pszText = Translate("Agent");
+ cCol.pszText = TranslateT("Agent");
ListView_InsertColumn(hUserList, 2, &cCol);
cCol.cx = DBGetContactSettingWord(NULL, MODULE, "StatWnd_cx9", 100);
- cCol.pszText = Translate("Completed");
+ cCol.pszText = TranslateT("Completed");
ListView_InsertColumn(hUserList, 3, &cCol);
cCol.cx = DBGetContactSettingWord(NULL, MODULE, "StatWnd_cx10", 100);
- cCol.pszText = Translate("Speed");
+ cCol.pszText = TranslateT("Speed");
ListView_InsertColumn(hUserList, 4, &cCol);
bool b = DBGetContactSettingByte(NULL, MODULE, "StatWnd_ShowHidden", 0) != 0;
@@ -844,7 +798,7 @@ static BOOL CALLBACK DlgProcStatsticView(HWND hwndDlg, UINT msg, WPARAM wParam, strncpy(&szServPath[1], fileName+1, MAX_PATH-2);
if (CallService(MS_HTTP_ADD_CHANGE_REMOVE, 0, (LPARAM)&stNewShare)) {
- MessageBox(NULL, "Failed to share new file", MSG_BOX_TITEL, MB_OK);
+ MessageBox(NULL, _T("Failed to share new file"), MSG_BOX_TITEL, MB_OK);
return false;
}
}
@@ -952,18 +906,18 @@ static BOOL CALLBACK DlgProcStatsticView(HWND hwndDlg, UINT msg, WPARAM wParam, if (ListView_GetItem(hShareList, &sItem)) {
string sLink = sCreateLink(sItem.pszText);
if (sLink.size() <= 0) {
- MessageBox(hwndDlg, "Selected link size is 0", MSG_BOX_TITEL, MB_OK);
+ MessageBox(hwndDlg, _T("Selected link size is 0"), MSG_BOX_TITEL, MB_OK);
return TRUE;
}
if (LOWORD(wParam) == ID_SHARELIST_COPYLINK) {
if (!OpenClipboard(hwndDlg)) {
- MessageBox(hwndDlg, "Failed to get access to clipboard", MSG_BOX_TITEL, MB_OK);
+ MessageBox(hwndDlg, _T("Failed to get access to clipboard"), MSG_BOX_TITEL, MB_OK);
return TRUE;
}
if (!EmptyClipboard()) {
- MessageBox(hwndDlg, "Failed to get close the clipboard", MSG_BOX_TITEL, MB_OK);
+ MessageBox(hwndDlg, _T("Failed to get close the clipboard"), MSG_BOX_TITEL, MB_OK);
return TRUE;
}
@@ -977,14 +931,14 @@ static BOOL CALLBACK DlgProcStatsticView(HWND hwndDlg, UINT msg, WPARAM wParam, HANDLE hMyData = SetClipboardData(CF_TEXT, hglbCopy);
if (! hMyData)
- MessageBox(hwndDlg, "Failed to set clipboard data", MSG_BOX_TITEL, MB_OK);
+ MessageBox(hwndDlg, _T("Failed to set clipboard data"), MSG_BOX_TITEL, MB_OK);
CloseClipboard();
} else {
CallService(MS_UTILS_OPENURL, 0, (LPARAM)(const char*)sLink.c_str());
}
} else {
- MessageBox(hwndDlg, "ListView_GetItem failed", MSG_BOX_TITEL, MB_OK);
+ MessageBox(hwndDlg, _T("ListView_GetItem failed"), MSG_BOX_TITEL, MB_OK);
}
} else {
MessageBox(hwndDlg, Translate("No share selected"), MSG_BOX_TITEL, MB_OK);
@@ -1044,13 +998,7 @@ static BOOL CALLBACK DlgProcStatsticView(HWND hwndDlg, UINT msg, WPARAM wParam, void SendLinkToUser(WPARAM wParam, char *pszSrvPath) {
string sLink = sCreateLink(pszSrvPath);
-
- //NB: Current versions of the convers plugin use the name
- //"SRMsg/LaunchMessageWindow" instead. For compatibility you should call
- //both names and the correct one will work.
-
- CallService(MS_MSG_SENDMESSAGE, (WPARAM)wParam, (LPARAM)sLink.c_str());
- CallService("SRMsg/LaunchMessageWindow", (WPARAM)wParam, (LPARAM)sLink.c_str());
+ CallService(MS_MSG_SENDMESSAGE, wParam, (LPARAM)sLink.c_str());
}
/////////////////////////////////////////////////////////////////////
@@ -1068,7 +1016,7 @@ void SendLinkToUser(WPARAM wParam, char *pszSrvPath) { // Developer : KN, Houdini
/////////////////////////////////////////////////////////////////////
-static long nShareNewFile(WPARAM wParam, LPARAM lParam) {
+static INT_PTR nShareNewFile(WPARAM wParam, LPARAM lParam) {
HANDLE hContact = (HANDLE)wParam;
// used to be _MAX_PATH
@@ -1125,7 +1073,7 @@ static long nShareNewFile(WPARAM wParam, LPARAM lParam) { }
-static long nShowStatisticsView(WPARAM /*wParam*/, LPARAM /*lParam*/) {
+static INT_PTR nShowStatisticsView(WPARAM /*wParam*/, LPARAM /*lParam*/) {
if (hwndStatsticView) {
BringWindowToTop(hwndStatsticView);
return 0;
@@ -1152,7 +1100,7 @@ static long nShowStatisticsView(WPARAM /*wParam*/, LPARAM /*lParam*/) { // Developer : KN, Houdini
/////////////////////////////////////////////////////////////////////
-static BOOL CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, 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);
@@ -1275,7 +1223,7 @@ static BOOL CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA GetDlgItemText(hwndDlg, IDC_PAGE_KEYWORD, szKeyWord, sizeof(szKeyWord));
DWORD dwExternalIP = GetExternIP(szUrl, szKeyWord);
- _snprintf(szKeyWord, sizeof(szKeyWord), Translate("You external ip was detected as %d.%d.%d.%d\r\nby: %s") ,
+ mir_snprintf(szKeyWord, sizeof(szKeyWord), Translate("You external ip was detected as %d.%d.%d.%d\r\nby: %s") ,
SplitIpAddress(dwExternalIP) ,
szUrl);
MessageBox(hwndDlg, szKeyWord, MSG_BOX_TITEL, MB_OK);
@@ -1295,14 +1243,14 @@ static BOOL CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA bool bNew = IsDlgButtonChecked(hwndDlg, IDC_ADD_STATISTICS_MENU_ITEM) == BST_CHECKED;
if (b != bNew) {
DBWriteContactSettingByte(NULL, MODULE, "AddStatisticsMenuItem", bNew);
- MessageBox(hwndDlg, Translate("You need to restart miranda to change the main menu"), MSG_BOX_TITEL, MB_OK);
+ MessageBox(hwndDlg, TranslateT("You need to restart miranda to change the main menu"), MSG_BOX_TITEL, MB_OK);
}
b = DBGetContactSettingByte(NULL, MODULE, "AddAcceptConMenuItem", 1) != 0;
bNew = IsDlgButtonChecked(hwndDlg, IDC_ACCEPT_COM_MENU_ITEM) == BST_CHECKED;
if (b != bNew) {
DBWriteContactSettingByte(NULL, MODULE, "AddAcceptConMenuItem", bNew);
- MessageBox(hwndDlg, Translate("You need to restart miranda to change the main menu"), MSG_BOX_TITEL, MB_OK);
+ MessageBox(hwndDlg, TranslateT("You need to restart miranda to change the main menu"), MSG_BOX_TITEL, MB_OK);
}
bNew = IsDlgButtonChecked(hwndDlg, IDC_WRITE_LOG_FILE) == BST_CHECKED;
@@ -1404,9 +1352,9 @@ int OptionsInitialize(WPARAM wParam, LPARAM /*lParam*/) { odp.position = 900000000;
odp.hInstance = hInstance;
odp.pszTemplate = MAKEINTRESOURCE(IDD_OPT_HTTP_SERVER);
- odp.flags = ODPF_BOLDGROUPS;
- odp.pszTitle = Translate("HTTP Server");
- odp.pszGroup = Translate("Network");
+ odp.flags = ODPF_BOLDGROUPS|ODPF_TCHAR;
+ odp.ptszTitle = LPGENT("HTTP Server");
+ odp.ptszGroup = LPGENT("Network");
odp.pfnDlgProc = OptionsDlgProc;
CallService(MS_OPT_ADDPAGE, wParam, (LPARAM)&odp);
return 0;
@@ -1543,39 +1491,39 @@ void InitGuiElements() { hShareNewFileService = CreateServiceFunction(MS_SHARE_NEW_FILE, nShareNewFile);
if (! hShareNewFileService) {
- MessageBox(NULL, "Failed to CreateServiceFunction MS_SHARE_NEW_FILE", MSG_BOX_TITEL, MB_OK);
+ MessageBox(NULL, _T("Failed to CreateServiceFunction MS_SHARE_NEW_FILE"), MSG_BOX_TITEL, MB_OK);
return;
}
hShowStatisticsViewService = CreateServiceFunction(MS_SHOW_STATISTICS_VIEW, nShowStatisticsView);
if (! hShowStatisticsViewService) {
- MessageBox(NULL, "Failed to CreateServiceFunction MS_SHOW_STATISTICS_VIEW", MSG_BOX_TITEL, MB_OK);
+ MessageBox(NULL, _T("Failed to CreateServiceFunction MS_SHOW_STATISTICS_VIEW"), MSG_BOX_TITEL, MB_OK);
return;
}
CLISTMENUITEM mi;
ZeroMemory(&mi, sizeof(mi));
mi.cbSize = sizeof(mi);
- mi.flags = 0;
+ mi.flags = CMIF_TCHAR;
mi.pszContactOwner = NULL; //all contacts
mi.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_SHARE_NEW_FILE));
mi.position = -2000019955;
- mi.pszName = Translate("HTTP Share new file");
+ mi.ptszName = LPGENT("HTTP Share new file");
mi.pszService = MS_SHARE_NEW_FILE;
hShareNewFileMenuItem = (HANDLE)CallService(MS_CLIST_ADDCONTACTMENUITEM, 0, (LPARAM) & mi);
if (!hShareNewFileMenuItem) {
- MessageBox(NULL, "Failed to add contact menu item", MSG_BOX_TITEL, MB_OK);
+ MessageBox(NULL, _T("Failed to add contact menu item"), MSG_BOX_TITEL, MB_OK);
return;
}
if (DBGetContactSettingByte(NULL, MODULE, "AddStatisticsMenuItem", 1) != 0) {
mi.position = 1000085005;
- mi.flags = 0;
+ mi.flags = CMIF_TCHAR;
//mi.hIcon=LoadIcon(hInstance,MAKEINTRESOURCE(IDI_SHARE_NEW_FILE));
mi.pszContactOwner = NULL;
- mi.pszName = Translate("Show HTTP server statistics");
+ mi.ptszName = LPGENT("Show HTTP server statistics");
mi.pszService = MS_SHOW_STATISTICS_VIEW;
hShowStatisticsViewMenuItem = (HANDLE)CallService(MS_CLIST_ADDMAINMENUITEM, 0, (LPARAM) & mi);
}
@@ -1583,7 +1531,7 @@ void InitGuiElements() { hEventOptionsInitialize = HookEvent(ME_OPT_INITIALISE, OptionsInitialize);
if (!hEventOptionsInitialize)
- MessageBox(NULL, "Failed to HookEvent ME_OPT_INITIALISE", MSG_BOX_TITEL, MB_OK);
+ MessageBox(NULL, _T("Failed to HookEvent ME_OPT_INITIALISE"), MSG_BOX_TITEL, MB_OK);
bShowPopups = DBGetContactSettingByte(NULL, MODULE, "ShowPopups", bShowPopups) != 0;
/*
diff --git a/HTTPServer/GuiElements.h b/HTTPServer/GuiElements.h index 0ce1d11..c473d92 100644 --- a/HTTPServer/GuiElements.h +++ b/HTTPServer/GuiElements.h @@ -18,7 +18,7 @@ #ifndef GUI_ELEMENTS_H
#define GUI_ELEMENTS_H
-#include <windows.h>
+#include "Glob.h"
void InitGuiElements();
void UnInitGuiElements();
diff --git a/HTTPServer/HTTPServer_10.vcxproj b/HTTPServer/HTTPServer_10.vcxproj new file mode 100644 index 0000000..be05b38 --- /dev/null +++ b/HTTPServer/HTTPServer_10.vcxproj @@ -0,0 +1,235 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{F7A70398-AFA0-4A58-B645-85268F9517DE}</ProjectGuid>
+ <RootNamespace>HTTPServer</RootNamespace>
+ <ProjectName>HTTPServer</ProjectName>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC70.props" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC70.props" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC70.props" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC70.props" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>
+ <IgnoreImportLibrary Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</IgnoreImportLibrary>
+ <IgnoreImportLibrary Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</IgnoreImportLibrary>
+ <IgnoreImportLibrary Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</IgnoreImportLibrary>
+ <IgnoreImportLibrary Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</IgnoreImportLibrary>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)\$(Configuration)/Plugins\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)/Obj/$(ProjectName)\</IntDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)\$(Configuration)/Plugins\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)/Obj/$(ProjectName)\</IntDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)\$(Configuration)64/Plugins\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\</IntDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)\$(Configuration)64/Plugins\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\</IntDir>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Midl>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MkTypLibCompatible>true</MkTypLibCompatible>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <TargetEnvironment>Win32</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>../../include;../ExternalAPI</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_DEBUG;WIN32;_WINDOWS;_USRDLL;_WIN32_IE=0x0400;_WIN32_WINNT=0x0400;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ResourceCompile>
+ <Link>
+ <AdditionalDependencies>msvcrtd.lib;User32.lib;Kernel32.lib;Ws2_32.lib;Comdlg32.lib;comctl32.lib;libcpmtd.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
+ <SubSystem>Windows</SubSystem>
+ <BaseAddress>0x22500000</BaseAddress>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ </Link>
+ <PostBuildEvent />
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <Midl>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MkTypLibCompatible>true</MkTypLibCompatible>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ </Midl>
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>../../include;../ExternalAPI</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_DEBUG;WIN64;_WINDOWS;_USRDLL;_WIN32_IE=0x0400;_WIN32_WINNT=0x0400;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ResourceCompile>
+ <Link>
+ <AdditionalDependencies>msvcrtd.lib;User32.lib;Kernel32.lib;Ws2_32.lib;Comdlg32.lib;comctl32.lib;libcpmtd.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Windows</SubSystem>
+ <BaseAddress>0x22500000</BaseAddress>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
+ </Link>
+ <PostBuildEvent />
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Midl>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MkTypLibCompatible>true</MkTypLibCompatible>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <TargetEnvironment>Win32</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <Optimization>Full</Optimization>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <AdditionalIncludeDirectories>../../include;../ExternalAPI</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>NDEBUG;WIN32;_WINDOWS;_USRDLL;_WIN32_IE=0x0400;_WIN32_WINNT=0x0400;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ResourceCompile>
+ <Link>
+ <AdditionalDependencies>msvcrt.lib;User32.lib;Kernel32.lib;Ws2_32.lib;Comdlg32.lib;comctl32.lib;libcpmt.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
+ <SubSystem>Windows</SubSystem>
+ <BaseAddress>0x22500000</BaseAddress>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <Midl>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MkTypLibCompatible>true</MkTypLibCompatible>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ </Midl>
+ <ClCompile>
+ <Optimization>Full</Optimization>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <AdditionalIncludeDirectories>../../include;../ExternalAPI</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>NDEBUG;WIN64;_WINDOWS;_USRDLL;_WIN32_IE=0x0400;_WIN32_WINNT=0x0400;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ResourceCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
+ <BaseAddress>0x22500000</BaseAddress>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <AdditionalDependencies>msvcrt.lib;User32.lib;Kernel32.lib;Ws2_32.lib;Comdlg32.lib;comctl32.lib;libcpmt.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClInclude Include="AggressiveOptimize.h" />
+ <ClInclude Include="FileShareNode.h" />
+ <ClInclude Include="Glob.h" />
+ <ClInclude Include="GuiElements.h" />
+ <ClInclude Include="HttpUser.h" />
+ <ClInclude Include="IndexCreation.h" />
+ <ClInclude Include="m_HTTPServer.h" />
+ <ClInclude Include="MimeHandling.h" />
+ <ClInclude Include="resource.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="FileShareNode.cpp" />
+ <ClCompile Include="GuiElements.cpp" />
+ <ClCompile Include="HttpUser.cpp" />
+ <ClCompile Include="IndexHTML.cpp" />
+ <ClCompile Include="IndexXML.cpp" />
+ <ClCompile Include="main.cpp" />
+ <ClCompile Include="MimeHandling.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="dis_srv.ico" />
+ <None Include="share_ne.ico" />
+ <None Include="Changelog.txt" />
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="resource.rc" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
\ No newline at end of file diff --git a/HTTPServer/HTTPServer_10.vcxproj.filters b/HTTPServer/HTTPServer_10.vcxproj.filters new file mode 100644 index 0000000..fc3de3d --- /dev/null +++ b/HTTPServer/HTTPServer_10.vcxproj.filters @@ -0,0 +1,82 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <ClCompile Include="FileShareNode.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="GuiElements.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="HttpUser.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="IndexHTML.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="IndexXML.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="main.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="MimeHandling.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="AggressiveOptimize.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="FileShareNode.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="Glob.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="GuiElements.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="HttpUser.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="IndexCreation.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="m_HTTPServer.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="MimeHandling.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="resource.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="Changelog.txt">
+ <Filter>Resource Files</Filter>
+ </None>
+ <None Include="dis_srv.ico">
+ <Filter>Resource Files</Filter>
+ </None>
+ <None Include="share_ne.ico">
+ <Filter>Resource Files</Filter>
+ </None>
+ </ItemGroup>
+ <ItemGroup>
+ <Filter Include="Resource Files">
+ <UniqueIdentifier>{5e05f681-4ca1-4f05-8cf7-ad36d263563a}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{b7aa7d9f-57f6-4f53-bc69-a31070153186}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{c13934ba-ee0b-4ced-a1fc-0becf97da3db}</UniqueIdentifier>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="resource.rc">
+ <Filter>Resource Files</Filter>
+ </ResourceCompile>
+ </ItemGroup>
+</Project>
\ No newline at end of file diff --git a/HTTPServer/HttpUser.cpp b/HTTPServer/HttpUser.cpp index 2e10fc1..0dd9ad9 100644 --- a/HTTPServer/HttpUser.cpp +++ b/HTTPServer/HttpUser.cpp @@ -15,26 +15,12 @@ //along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-#ifdef NDEBUG //release
-#include "AggressiveOptimize.h" //create small code
-#endif
-
#include "HttpUser.h"
#include "MimeHandling.h"
#include "GuiElements.h"
#include "IndexCreation.h"
-#include "Glob.h"
-#include <stdio.h>
-#include <time.h>
-
-#pragma warning( push, 3 )
-
-#include "newpluginapi.h"
-#include "m_langpack.h"
-#include "m_netlib.h"
-#pragma warning( pop )
/////////////////////////////////////////////////////////////////////
@@ -251,7 +237,7 @@ void CLHttpUser::SendError(int iErrorCode, const char * pszError, const char * p pszDescription = pszError;
char szBuf[1000];
- DWORD dwBytesToWrite = _snprintf(szBuf, sizeof(szBuf) ,
+ DWORD dwBytesToWrite = mir_snprintf(szBuf, sizeof(szBuf) ,
"HTTP/1.1 %i %s\r\n"
"Date: %s\r\n"
"Server: MirandaWeb/%s\r\n"
@@ -301,7 +287,7 @@ void CLHttpUser::SendRedir(int iErrorCode, const char * pszError, const char * p pszDescription = pszError;
char szBuff[1000];
- DWORD dwBytesToWrite = _snprintf(szBuff, sizeof(szBuff) ,
+ DWORD dwBytesToWrite = mir_snprintf(szBuff, sizeof(szBuff) ,
"HTTP/1.1 %i %s\r\n"
"Date: %s\r\n"
"Server: MirandaWeb/%s\r\n"
@@ -566,7 +552,7 @@ bool CLHttpUser::bProcessGetRequest(char * pszRequest, bool bIsGetCommand) { char szETag[ 50 ];
{
- int nETagLen = _snprintf(szETag, sizeof(szETag), "\"%x-%x-%x\"",
+ int nETagLen = mir_snprintf(szETag, sizeof(szETag), "\"%x-%x-%x\"",
nDataSize, stFileTime.dwHighDateTime, stFileTime.dwLowDateTime);
if (!apszParam[eIfRange] || (strncmp(szETag, apszParam[eIfRange], nETagLen) == 0)) {
@@ -636,7 +622,7 @@ bool CLHttpUser::bProcessGetRequest(char * pszRequest, bool bIsGetCommand) { "Last-Modified: %s\r\n"
"\r\n";
- dwBytesToWrite = _snprintf(szBuf, sizeof(szBuf), szHttpPartial ,
+ dwBytesToWrite = mir_snprintf(szBuf, sizeof(szBuf), szHttpPartial ,
szCurTime ,
pszVersion,
szETag ,
@@ -658,7 +644,7 @@ bool CLHttpUser::bProcessGetRequest(char * pszRequest, bool bIsGetCommand) { "Last-Modified: %s\r\n"
"\r\n";
- dwBytesToWrite = _snprintf(szBuf, sizeof(szBuf), szHttpOk ,
+ dwBytesToWrite = mir_snprintf(szBuf, sizeof(szBuf), szHttpOk ,
szCurTime ,
pszVersion,
szETag ,
@@ -693,7 +679,7 @@ bool CLHttpUser::bProcessGetRequest(char * pszRequest, bool bIsGetCommand) { DWORD dwCurTick = GetTickCount();
if (dwCurTick - dwLastUpdate >= 1000) {/*
char szTmp[200];
- _snprintf( szTmp, sizeof( szTmp ), "Bytes tr %d Time %d Tick %d\n", dwCurrentDL - dwLastCurrentDL, dwCurTick - dwLastUpdate, dwCurTick );
+ mir_snprintf( szTmp, sizeof( szTmp ), "Bytes tr %d Time %d Tick %d\n", dwCurrentDL - dwLastCurrentDL, dwCurTick - dwLastUpdate, dwCurTick );
OutputDebugString( szTmp );
*/
dwSpeed = ((dwCurrentDL - dwLastCurrentDL) * 1000) / (dwCurTick - dwLastUpdate);
@@ -745,7 +731,7 @@ bool CLHttpUser::bProcessGetRequest(char * pszRequest, bool bIsGetCommand) { }
/*
char szTmp[200];
- _snprintf( szTmp, sizeof( szTmp ), "Current status : %d %% pos %d size %d\n", (dwCurrentDL * 100) / dwTotalSize, dwCurrentDL , dwTotalSize );
+ mir_snprintf( szTmp, sizeof( szTmp ), "Current status : %d %% pos %d size %d\n", (dwCurrentDL * 100) / dwTotalSize, dwCurrentDL , dwTotalSize );
OutputDebugString( szTmp );
*/
}
@@ -761,7 +747,7 @@ bool CLHttpUser::bProcessGetRequest(char * pszRequest, bool bIsGetCommand) { /*
{
char szBuf[200];
- _snprintf( szBuf, sizeof( szBuf ), "File Transfer stoped %d transfer complete %d\n", GetTickCount(), dwCurrentDL == nDataSize);
+ mir_snprintf( szBuf, sizeof( szBuf ), "File Transfer stoped %d transfer complete %d\n", GetTickCount(), dwCurrentDL == nDataSize);
OutputDebugString( szBuf );
}
*/
diff --git a/HTTPServer/HttpUser.h b/HTTPServer/HttpUser.h index 00b43a7..7f29070 100644 --- a/HTTPServer/HttpUser.h +++ b/HTTPServer/HttpUser.h @@ -18,7 +18,7 @@ #ifndef HTTP_USER_H
#define HTTP_USER_H
-#include <windows.h>
+#include "Glob.h"
#include "m_HTTPServer.h"
#include "FileShareNode.h"
diff --git a/HTTPServer/IndexCreation.h b/HTTPServer/IndexCreation.h index c3892c4..0411825 100644 --- a/HTTPServer/IndexCreation.h +++ b/HTTPServer/IndexCreation.h @@ -19,7 +19,7 @@ #ifndef HTTP_INDEXCREATION_H
#define HTTP_INDEXCREATION_H
-#include <windows.h>
+#include "Glob.h"
#include "m_HTTPServer.h"
#include "FileShareNode.h"
diff --git a/HTTPServer/IndexHTML.cpp b/HTTPServer/IndexHTML.cpp index 27a2760..1adae53 100644 --- a/HTTPServer/IndexHTML.cpp +++ b/HTTPServer/IndexHTML.cpp @@ -15,16 +15,10 @@ //along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-#ifdef NDEBUG //release
-#include "AggressiveOptimize.h" //create small code
-#endif
#include "HttpUser.h"
#include "MimeHandling.h"
#include "GuiElements.h"
-#include "Glob.h"
-#include <stdio.h>
-#include <time.h>
#include "IndexCreation.h"
eIndexCreationMode indexCreationMode;
@@ -78,7 +72,7 @@ bool LoadIndexHTMLTemplate() { 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;
}
@@ -300,7 +294,7 @@ bool bCreateIndexHTML(const char * pszRealPath, const char * pszIndexPath, strcpy(szMask, pszRealPath);
strcat(szMask, "*");
- WIN32_FIND_DATAA fdFindFileData;
+ WIN32_FIND_DATA fdFindFileData;
HANDLE hFind = FindFirstFile(szMask, &fdFindFileData);
if (hFind == INVALID_HANDLE_VALUE)
@@ -369,9 +363,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("..")) && !strcmp(pszSrvPath, "/")) || // hide .. in root
((*pszPos == 19) == ((fdFindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0))) {
if (!FindNextFile(hFind, &fdFindFileData)) {
FindClose(hFind);
@@ -424,13 +418,13 @@ bool bCreateIndexHTML(const char * pszRealPath, const char * pszIndexPath, case SY_FILE_NAME:
case SY_DIR_NAME: {
- pszBuffer += _snprintf(pszBuffer, 250, "%s", szName);
+ pszBuffer += mir_snprintf(pszBuffer, 250, "%s", szName);
break;
}
case SY_DIR_URL: {
case SY_FILE_URL:
- pszBuffer += _snprintf(pszBuffer, 250, "%s", szURL);
+ pszBuffer += mir_snprintf(pszBuffer, 250, "%s", szURL);
break;
}
@@ -441,7 +435,7 @@ bool bCreateIndexHTML(const char * pszRealPath, const char * pszIndexPath, (*pszPos == SY_FILE_CREATE_TIME) ? &ftFileCreateTime : &ftFileModifyTime,
&systemTime);
- pszBuffer += _snprintf(pszBuffer, 100, "%i/%02i/%02i %i:%02i:%02i",
+ pszBuffer += mir_snprintf(pszBuffer, 100, "%i/%02i/%02i %i:%02i:%02i",
systemTime.wYear, systemTime.wMonth, systemTime.wDay, systemTime.wHour,
systemTime.wMinute, systemTime.wSecond);
break;
@@ -449,11 +443,11 @@ bool bCreateIndexHTML(const char * pszRealPath, const char * pszIndexPath, case SY_FILE_SIZE: {
if ((iFileSize >> 10) == 0)
- pszBuffer += _snprintf(pszBuffer, 100, "%i Byte", iFileSize);
+ pszBuffer += mir_snprintf(pszBuffer, 100, "%i Byte", iFileSize);
else if ((iFileSize >> 20) == 0)
- pszBuffer += _snprintf(pszBuffer, 100, "%.1f KB", (float)(iFileSize) / 1024.0f);
+ pszBuffer += mir_snprintf(pszBuffer, 100, "%.1f KB", (float)(iFileSize) / 1024.0f);
else
- pszBuffer += _snprintf(pszBuffer, 100, "%.1f MB", (float)(iFileSize) / (1024.0f * 1024.0f));
+ pszBuffer += mir_snprintf(pszBuffer, 100, "%.1f MB", (float)(iFileSize) / (1024.0f * 1024.0f));
break;
}
diff --git a/HTTPServer/IndexXML.cpp b/HTTPServer/IndexXML.cpp index 6806670..634ce72 100644 --- a/HTTPServer/IndexXML.cpp +++ b/HTTPServer/IndexXML.cpp @@ -15,16 +15,9 @@ //along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-#ifdef NDEBUG //release
-#include "AggressiveOptimize.h" //create small code
-#endif
-
#include "HttpUser.h"
#include "MimeHandling.h"
#include "GuiElements.h"
-#include "Glob.h"
-#include <stdio.h>
-#include <time.h>
#include "IndexCreation.h"
@@ -78,7 +71,7 @@ bool bCreateIndexXML(const char * pszRealPath, const char * pszIndexPath, strcpy(szMask, pszRealPath);
strcat(szMask, "*");
- WIN32_FIND_DATAA fdFindFileData;
+ WIN32_FIND_DATA fdFindFileData;
HANDLE hFind = FindFirstFile(szMask, &fdFindFileData);
if (hFind == INVALID_HANDLE_VALUE)
@@ -133,7 +126,7 @@ bool bCreateIndexXML(const char * pszRealPath, const char * pszIndexPath, // Write dirname
ReplaceSign(szFileName, MAX_PATH, '&', "&");
- pszBuffer += _snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
+ pszBuffer += mir_snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
" <dirname>%s</dirname>\r\n", szFileName);
WriteFile(hFile, szBuffer, pszBuffer - szBuffer, &dwBytesWritten, NULL);
@@ -148,7 +141,7 @@ bool bCreateIndexXML(const char * pszRealPath, const char * pszIndexPath, ReplaceSign(szFileName, MAX_PATH, '&', "&");
if (fdFindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
- pszBuffer += _snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
+ pszBuffer += mir_snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
" <item name=\"%s\" isdir=\"true\"/>\r\n", szFileName);
} else {
pszExt = strrchr(szFileName, '.');
@@ -158,24 +151,24 @@ bool bCreateIndexXML(const char * pszRealPath, const char * pszIndexPath, pszExt++;
}
- pszBuffer += _snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
+ pszBuffer += mir_snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
" <item name=\"%s\" ext=\"%s\" size=\"%i\" ",
szFileName, (pszExt == NULL) ? "" : pszExt, fdFindFileData.nFileSizeLow);
SYSTEMTIME systemTime;
FileTimeToSystemTime(&fdFindFileData.ftCreationTime, &systemTime);
- pszBuffer += _snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
+ pszBuffer += mir_snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
"created=\"%i/%02i/%02i %i:%02i:%02i\" ",
systemTime.wYear, systemTime.wMonth, systemTime.wDay, systemTime.wHour,
systemTime.wMinute, systemTime.wSecond);
FileTimeToSystemTime(&fdFindFileData.ftLastWriteTime, &systemTime);
- pszBuffer += _snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
+ pszBuffer += mir_snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
"modified=\"%i/%02i/%02i %i:%02i:%02i\" ",
systemTime.wYear, systemTime.wMonth, systemTime.wDay, systemTime.wHour,
systemTime.wMinute, systemTime.wSecond);
- pszBuffer += _snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
+ pszBuffer += mir_snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
"/>\r\n");
}
@@ -202,7 +195,7 @@ bool bCreateIndexXML(const char * pszRealPath, const char * pszIndexPath, if (pclCur->bIsDirectory()) {
szFileName[strlen(szFileName)-1] = '\0';
if (!strchr(szFileName, '/')) { // only one level deeper
- pszBuffer += _snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
+ pszBuffer += mir_snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
" <item name=\"%s\" isdir=\"true\"/>\r\n", szFileName);
if (!WriteFile(hFile, szBuffer, pszBuffer - szBuffer, &dwBytesWritten, NULL))
@@ -230,24 +223,24 @@ bool bCreateIndexXML(const char * pszRealPath, const char * pszIndexPath, CloseHandle(hFileS);
}
- pszBuffer += _snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
+ pszBuffer += mir_snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
" <item name=\"%s\" ext=\"%s\" size=\"%i\" ",
szFileName, (pszExt == NULL) ? "" : pszExt, dwFileSize);
SYSTEMTIME systemTime;
FileTimeToSystemTime(&ftFileCreateTime, &systemTime);
- pszBuffer += _snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
+ pszBuffer += mir_snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
"created=\"%i/%02i/%02i %i:%02i:%02i\" ",
systemTime.wYear, systemTime.wMonth, systemTime.wDay, systemTime.wHour,
systemTime.wMinute, systemTime.wSecond);
FileTimeToSystemTime(&ftFileModifyTime, &systemTime);
- pszBuffer += _snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
+ pszBuffer += mir_snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
"modified=\"%i/%02i/%02i %i:%02i:%02i\" ",
systemTime.wYear, systemTime.wMonth, systemTime.wDay, systemTime.wHour,
systemTime.wMinute, systemTime.wSecond);
- pszBuffer += _snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
+ pszBuffer += mir_snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
"/>\r\n");
if (!WriteFile(hFile, szBuffer, pszBuffer - szBuffer, &dwBytesWritten, NULL))
diff --git a/HTTPServer/MimeHandling.cpp b/HTTPServer/MimeHandling.cpp index 339051e..2069f16 100644 --- a/HTTPServer/MimeHandling.cpp +++ b/HTTPServer/MimeHandling.cpp @@ -1,12 +1,5 @@ -#include <stdio.h>
-#include <stdlib.h>
-#include "MimeHandling.h"
-
-#ifndef TEST
#include "Glob.h"
-#else
-char szPluginPath[10] = "";
-#endif
+#include "MimeHandling.h"
/* MIME type/ext map */
diff --git a/HTTPServer/MimeHandling.h b/HTTPServer/MimeHandling.h index f40fdf9..8286ff4 100644 --- a/HTTPServer/MimeHandling.h +++ b/HTTPServer/MimeHandling.h @@ -9,44 +9,44 @@ extern "C" { /* MIME DB Data structure
---------- ----------
- | mimeType | | mimeType | - |----------| |----------| - ----| next -----------------| next | - |----------| |----------| - | extList --- | extList --- - ---------- | ---------- | - --|--- --|--- - | ext | | ext | - |------| |------| - | next | | next | - --|--- ------ - --|--- - | ext | - |------| - | next | - ------ - */ - - typedef struct _ExtensionListCell { - char* ext; - struct _ExtensionListCell* next; - } ExtensionListCell ; - - - typedef struct _ContentType { - char* mimeType; - ExtensionListCell* extList; - struct _ContentType* next; - } ContentType ; - - typedef ContentType* ContentTypeDB; - typedef ExtensionListCell* ExtensionList; - - - - extern int bInitMimeHandling(); - extern const char * pszGetMimeType(const char * pszFileName); - -#ifdef __cplusplus -} -#endif + | mimeType | | mimeType |
+ |----------| |----------|
+ ----| next -----------------| next |
+ |----------| |----------|
+ | extList --- | extList ---
+ ---------- | ---------- |
+ --|--- --|---
+ | ext | | ext |
+ |------| |------|
+ | next | | next |
+ --|--- ------
+ --|---
+ | ext |
+ |------|
+ | next |
+ ------
+ */
+
+ typedef struct _ExtensionListCell {
+ char* ext;
+ struct _ExtensionListCell* next;
+ } ExtensionListCell ;
+
+
+ typedef struct _ContentType {
+ char* mimeType;
+ ExtensionListCell* extList;
+ struct _ContentType* next;
+ } ContentType ;
+
+ typedef ContentType* ContentTypeDB;
+ typedef ExtensionListCell* ExtensionList;
+
+
+
+ extern int bInitMimeHandling();
+ extern const char * pszGetMimeType(const char * pszFileName);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/HTTPServer/data/HTTPServerIndex.html b/HTTPServer/data/HTTPServerIndex.html index 4fdc419..ef79114 100644 --- a/HTTPServer/data/HTTPServerIndex.html +++ b/HTTPServer/data/HTTPServerIndex.html @@ -1,34 +1,83 @@ -<html>
-<head>
-<title>Directory Listing of [DirectoryName]</title>
-<style type="text/css">
-td { font-size:14px; color:#000033;}
-a:link { text-decoration: none; color:#003366; }
-a:visited { text-decoration: none; color:#003366; }
-a:active { text-decoration: none; color:#FFAA33; }
-a:hover { text-decoration: underline; color:#FFAA33; }
-</style>
-</head>
-<body bgcolor=#B0B0CC>
-<font face='tahoma, arial'>
-
-<table cellspacing=1 cellpadding=2 width=700>
-<tr height=40 bgcolor=#EEEEFF><td colspan=3 align=center>
-<h3 style='margin:0px'><font color="#666688">Directory Listing of [DirectoryName]</font></h3>
-[ForDirectoriesDo]<tr [IsEven]bgcolor=#EEEEFF[End][IsOdd]bgcolor=#DDDDEE[End]><td colspan=3><img src="/icons/folder_gray.png"><img src="/placeholder.gif" width=5><a href="[DirectoryUrl]">[DirectoryName]</a></td></tr>[End]
-[ForFilesDo]<tr [IsEven]bgcolor=#EEEEFF[End][IsOdd]bgcolor=#DDDDEE[End]><td>
-[IsFileType=jpg,jpeg,gif,png,bmp]<img src="/icons/image2.png">[End]
-[IsFileType=zip,rar,ace,arj,lha,lhz,tar,gz]<img src="/icons/tar.png">[End]
-[IsFileType=rtf,doc]<img src="/icons/doc.png">[End]
-[IsFileType=txt,diz]<img src="/icons/txt.png">[End]
-[IsFileType=pdf]<img src="/icons/pdf.png">[End]
-[IsFileType=exe,bat]<img src="/icons/win_apps.png">[End]
-[IsFileType=html,htm,xml]<img src="/icons/www.png">[End]
-[IsFileType=avi,mpg]<img src="/icons/video.png">[End]
-[IsFileType=c,cpp,h]<img src="/icons/source.png">[End]
-[IsFileType=mp3,ogg,wav,mid,mod,xm]<img src="/icons/sound.png">[End]
-[IsFileType=*]<img src="/icons/empty.png">[End]<img src="/placeholder.gif" width=5><a href="[FileUrl]">[FileName]</a></td><td>[FileModified]</td><td align='right'>[FileSize]</td></tr>[End]
-</font>
-</body>
-
-</html>
\ No newline at end of file +<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
+ "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
+
+
+ <!--
+ * template for HTTPServer Plugin for Miranda IM by Houdini
+ http://addons.miranda-im.org/details.php?action=viewfile&id=2304
+
+ * the icons are taken from the 'Crystal Project' by Everaldo Coelho, licenced under LGPL
+ http://www.everaldo.com/
+
+ modded by FREAK_THEMIGHTY
+ + header bar
+ + tooltips on each field
+ + moved design to seperate CSS file
+ * proper support for "shortcut icon" aka "favicon" (with link tag)
+ * lots of code changes
+ * converted to XHTML 1.1
+ -->
+
+ <head>
+
+ <!-- title of the page -->
+ <title>Verzeichnis [DirectoryName]</title>
+
+ <!-- path to the FavIcon -->
+ <link rel="shortcut icon" type="image/vnd.microsoft.icon" href="/favicon.ico" />
+
+ <!-- path to the CSS file -->
+ <link rel="stylesheet" type="text/css" href="/icons/themes/simpleTheme.css" />
+ </head>
+ <body>
+ <table id="listing">
+ <caption id="dir_title">Verzeichnis [DirectoryName]</caption>
+ <tr id="header">
+ <th class="file">Name</th>
+ <th class="size">Grösse</th>
+ <th class="modified">Geändert</th>
+ <th class="created">Erstellt</th>
+ </tr>
+
+[ForDirectoriesDo]
+ <tr [IsEven]class="even"[End][IsOdd]class="odd"[End]>
+ <td title="Verzeichnis: [DirectoryName]" class="folder" colspan="4">
+ <a href="[DirectoryUrl]" title="[DirectoryName] (Verzeichnis)" class="folder">
+ <img src="/icons/folder_gray.png" alt="folder" />
+ [DirectoryName]
+ </a>
+ </td>
+ </tr>
+[End]
+
+[ForFilesDo]
+ <tr [IsEven]class="even"[End][IsOdd]class="odd"[End]>
+ <td title="Datei: [FileName]" class="file">
+ <a href="[FileUrl]" title="[FileName] ([FileSize])">
+[IsFileType=jpg,jpeg,gif,png,bmp]<img src="/icons/image2.png" alt="" />[End]
+[IsFileType=zip,rar,ace,arj,lha,lhz,tar,gz,7z]<img src="/icons/tar.png" alt="" />[End]
+[IsFileType=rtf,doc]<img src="/icons/doc.png" alt="" />[End]
+[IsFileType=txt,diz]<img src="/icons/txt.png" alt="" />[End]
+[IsFileType=pdf]<img src="/icons/pdf.png" alt="" />[End]
+[IsFileType=tex]<img src="/icons/tex.png" alt="" />[End]
+[IsFileType=java,jar]<img src="/icons/source_java.png" alt="" />[End]
+[IsFileType=exe,bat,dll]<img src="/icons/win_apps.png" alt="" />[End]
+[IsFileType=html,htm,xml,php,css]<img src="/icons/www.png" alt="" />[End]
+[IsFileType=avi,mpg,mpeg]<img src="/icons/video.png" alt="" />[End]
+[IsFileType=c,cpp,h]<img src="/icons/source.png" alt="" />[End]
+[IsFileType=mp3,ogg,wav,mid,mod,xm]<img src="/icons/sound.png" alt="" />[End]
+[IsFileType=*]<img src="/icons/empty.png" alt="" />[End]
+ [FileName]
+ </a>
+ </td>
+ <td class="size" title="Grösse: [FileSize]">[FileSize]</td>
+ <td class="modified" title="Geändert: [FileModified]">[FileModified]</td>
+ <td class="created" title="Erstellt: [FileCreated]">[FileCreated]</td>
+ </tr>
+[End]
+
+ </table>
+ </body>
+</html>
diff --git a/HTTPServer/data/htdocs/@settings/index.xsl b/HTTPServer/data/htdocs/@settings/index.xsl index d8e8f4e..e180baa 100644 --- a/HTTPServer/data/htdocs/@settings/index.xsl +++ b/HTTPServer/data/htdocs/@settings/index.xsl @@ -1,121 +1,204 @@ -<?xasml version="1.0" encoding="ISO-8859-1"?>
+<?xml version="1.0" encoding="ISO-8859-1" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- Icons by Everaldo Coelho (www.everaldo.com) -->
-<xsl:template match="/">
- <xsl:variable name="dirname">
- <xsl:choose>
- <xsl:when test="config/dirname=''">my Miranda Webserver</xsl:when>
- <xsl:otherwise><xsl:value-of select="config/dirname"/></xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
+ <!--
+ * template for HTTPServer Plugin for Miranda IM by Houdini
+ http://addons.miranda-im.org/details.php?action=viewfile&id=2304
-<html>
- <head>
- <title>Directory Listing of <xsl:value-of select="$dirname"/></title>
- <style type="text/css">
- td { font-family:tahoma, arial; font-size:14px; color:#000033;}
- a:link { text-decoration: none; color:#003366; }
- a:visited { text-decoration: none; color:#003366; }
- a:active { text-decoration: none; color:#FFAA33; }
- a:hover { text-decoration: underline; color:#FFAA33; }
- </style>
- </head>
+ * Template modded by FREAK_THEMIGHTY using Notepad++ v5.8.2
+ [+] header bar
+ [+] bottom bar with number of total files and total file size
+ [+] tooltips on each field (with real byte-size)
+ [+] moved design to seperate CSS file
+ [*] proper support for "shortcut icon" aka "favicon" (with link tag)
+ [*] lots of code changes
+ -->
- <body bgcolor='#B0B0CC'>
- <font face='tahoma, arial'>
- <table border='0' cellspacing='1' cellpadding='2' width='700'>
- <tr height='40' bgcolor='#EEEEFF'>
- <td colspan='3' align='center'>
- <h3 style='margin:0px'><font color="#666688">Directory Listing of <xsl:value-of select="$dirname"/></font></h3>
- </td>
- </tr>
- <xsl:for-each select="config/item">
- <xsl:sort select="@isdir" order="descending"/>
- <xsl:sort select="@name"/>
- <xsl:element name='tr'>
- <xsl:attribute name="bgcolor">
- <xsl:choose>
- <xsl:when test="position() mod 2 = 0">#EEEEFF</xsl:when>
- <xsl:otherwise>#DDDDEE</xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
- <xsl:element name='td'>
- <xsl:attribute name="colspan">
+
+ <!-- site properties -->
+ <xsl:output method="xml" version="1.1" doctype-public="-//W3C//DTD XHTML 1.1//EN"
+ doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" encoding="ISO-8859-1"
+ omit-xml-declaration="no" indent="yes" standalone="no" media-type="application/xhtml+xml" />
+
+ <xsl:template match="config">
+ <!-- title of the site -->
+ <xsl:variable name="title">
+ <xsl:choose>
+ <xsl:when test="dirname!=''">Verzeichnis <xsl:value-of select="dirname" /></xsl:when>
+ <xsl:otherwise>Miranda IM Webserver</xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <!-- total size (in bytes) of all files -->
+ <xsl:variable name="size" select="sum(item/@size)" />
+
+ <xsl:variable name="total-realsize">
+ <xsl:call-template name="convert">
+ <xsl:with-param name="bytes" select="$size" />
+ </xsl:call-template>
+ </xsl:variable>
+
+ <!--begin of the site -->
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de">
+ <head>
+ <!-- title of the page -->
+ <title><xsl:value-of select="$title" /></title>
+
+ <!-- path to the FavIcon -->
+ <link type="image/vnd.microsoft.icon" rel="shortcut icon" href="/favicon.ico" />
+
+ <!-- path to the CSS file -->
+ <link type="text/css" rel="stylesheet" href="/icons/themes/simpleTheme.css" />
+ </head>
+ <body>
+ <table id="listing" class="listing">
+ <caption id="tablecaption" class="tablecaption" title="{$title}"><xsl:value-of select="$title" /></caption>
+ <tr id="header" class="header">
+ <th id="fileheader" class="file">Name</th>
+ <th id="sizeheader" class="size">Grösse</th>
+ <th id="modifiedheader" class="modified">Geändert</th>
+ <th id="createdheader" class="created">Erstellt</th>
+ </tr>
+ <xsl:for-each select="child::item">
+ <!-- an item can have following attributes:
+ @name - name of the file /folder
+ @isdir - 'true' if the item represents a folder, missing for files
+ @ext - extension of the file (only for files)
+ @size - size of the file (number of bytes) (only for files)
+ @created - date the file was created (only for files)
+ @modified - date the file was last modified (only for files)
+ -->
+ <!--sorting order-->
+ <xsl:sort select="@isdir='true'" order="descending" />
+ <xsl:sort select="@ext" data-type="text" case-order="lower-first" order="ascending" /> <!-- sort by extension-->
+ <xsl:sort select="@name" data-type="text" case-order="lower-first" order="ascending" /> <!-- sort by name-->
+ <!--<xsl:sort select="@size" data-type="number" order="ascending" />--> <!-- sort by size-->
+
+ <tr id="item{position()}">
+ <xsl:attribute name="class">
+ <!-- either even or odd-->
<xsl:choose>
- <xsl:when test="@isdir='true'">3</xsl:when>
- <xsl:otherwise>1</xsl:otherwise>
+ <xsl:when test="(position() mod 2) = 0">even</xsl:when>
+ <xsl:otherwise>odd</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
- <xsl:variable name="ext">
- <xsl:value-of select="translate(@ext, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')"/>
- </xsl:variable>
- <xsl:variable name="icon">
- <xsl:choose>
- <xsl:when test="@isdir='true'">folder_gray.png</xsl:when>
- <xsl:when test="$ext='jpg' or $ext='jpeg' or $ext='gif' or $ext='png' or $ext='bmp'">image2.png</xsl:when>
- <xsl:when test="$ext='zip' or $ext='rar' or $ext='ace' or $ext='arj' or $ext='lha' or ext='lhz' or ext='tar' or ext='gz'">tar.png</xsl:when>
- <xsl:when test="$ext='rtf' or $ext='doc'">document2.png</xsl:when>
- <xsl:when test="$ext='txt' or $ext='diz'">txt.png</xsl:when>
- <xsl:when test="$ext='pdf'">pdf.png</xsl:when>
- <xsl:when test="$ext='exe' or $ext='bat'">win_apps.png</xsl:when>
- <xsl:when test="$ext='html' or $ext='htm' or $ext='xml'">www.png</xsl:when>
- <xsl:when test="$ext='avi' or $ext='mpg'">video.png</xsl:when>
- <xsl:when test="$ext='c' or $ext='cpp' or $ext='h'">source.png</xsl:when>
- <xsl:when test="$ext='mp3' or $ext='ogg' or $ext='wav' or $ext='mid' or $ext='mod' or $ext='xm'">sound.png</xsl:when>
- <xsl:otherwise>empty.png</xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:element name='img'>
- <xsl:attribute name="src">/icons/<xsl:value-of select="$icon"/></xsl:attribute>
- </xsl:element>
- <xsl:element name='img'>
- <xsl:attribute name="src">/placeholder.gif</xsl:attribute>
- <xsl:attribute name="width">5</xsl:attribute>
- </xsl:element>
- <xsl:element name="a">
- <xsl:attribute name="href">
- <xsl:value-of select="@name"/>
- <xsl:if test="@ext!=''">.<xsl:value-of select="@ext"/></xsl:if>
- <xsl:if test="@isdir='true'">/</xsl:if>
- </xsl:attribute>
- <xsl:value-of select="@name"/>
- <xsl:if test="@ext!=''">.<xsl:value-of select="@ext"/></xsl:if>
- </xsl:element>
- </xsl:element>
- <xsl:choose>
- <xsl:when test="@isdir='true'"></xsl:when>
- <xsl:otherwise>
- <td><xsl:value-of select="@modified"/></td>
- <!-- <td><xsl:value-of select="@created"/></td> -->
- <td width='100' align='right'>
- <xsl:choose>
- <xsl:when test="@size >= 1073741824">
- <xsl:value-of select="round(@size div 107374182.4) div 10"/><font size="-1"> GB</font>
- </xsl:when>
- <xsl:when test="@size >= 1048576">
- <xsl:value-of select="round(@size div 104857.6) div 10"/><font size="-1"> MB</font>
- </xsl:when>
- <xsl:when test="@size >= 1024">
- <xsl:value-of select="round(@size div 102.4) div 10"/><font size="-1"> KB</font>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="@size"/><font size="-1"> Byte</font>
- </xsl:otherwise>
- </xsl:choose>
- </td>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:element>
- </xsl:for-each>
- </table>
- </font>
- </body>
-</html>
+ <xsl:choose>
+ <xsl:when test="@isdir='true'">
+ <!-- this is a folder -->
+ <td class="folder" id="folder{position()}" colspan="4" title="Verzeichnis: {@name}">
+ <a href="{@name}/" class="folder" id="link{position()}" title="{@name} (Verzeichnis)">
+ <img src="/icons/folder_gray.png" alt="folder" />
+ <xsl:value-of select="@name" />
+ </a>
+ </td>
+ </xsl:when>
+ <xsl:otherwise>
+ <!-- this is a file -->
+
+ <!-- complete name of the file (with extension, if there is one)-->
+ <xsl:variable name="filename">
+ <xsl:value-of select="@name" /><xsl:if test="@ext!=''">.<xsl:value-of select="@ext" /></xsl:if>
+ </xsl:variable>
+
+ <!-- filesize with appropriate units-->
+ <xsl:variable name="realsize">
+ <xsl:call-template name="convert">
+ <xsl:with-param name="bytes" select="@size" />
+ </xsl:call-template>
+ </xsl:variable>
+
+ <!-- extension in lowercase -->
+ <xsl:variable name="l_ext" select="translate(@ext,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')" />
+
+ <td class="file" id="file{position()}" title="Datei: {$filename}">
+ <a href="{$filename}" class="{$l_ext}" id="link{position()}" title="{$filename} ({$realsize})">
+ <xsl:element name="img">
+ <xsl:attribute name="alt"><xsl:value-of select="@ext" /></xsl:attribute>
+ <xsl:attribute name="src">
+ <xsl:choose>
+ <!-- try to find appropriate icon (case-insensitive compare, as extensions are always case-insensitive in Windows) -->
+ <xsl:when test="$l_ext='jpg' or $l_ext='jpeg' or $l_ext='gif' or $l_ext='png' or $l_ext='bmp'">/icons/image2.png</xsl:when>
+ <xsl:when test="$l_ext='zip' or $l_ext='rar' or $l_ext='ace' or $l_ext='arj' or $l_ext='lha' or $l_ext='lhz' or $l_ext='tar' or $l_ext='gz' or $l_ext='7z'">/icons/tar.png</xsl:when>
+ <xsl:when test="$l_ext='rtf' or $l_ext='doc'">/icons/document2.png</xsl:when>
+ <xsl:when test="$l_ext='txt' or $l_ext='diz'">/icons/txt.png</xsl:when>
+ <xsl:when test="$l_ext='pdf'">/icons/pdf.png</xsl:when>
+ <xsl:when test="$l_ext='tex'">/icons/tex.png</xsl:when>
+ <xsl:when test="$l_ext='java' or $l_ext='jar'">/icons/source_java.png</xsl:when>
+ <xsl:when test="$l_ext='exe' or $l_ext='bat' or $l_ext='dll'">/icons/win_apps.png</xsl:when>
+ <xsl:when test="$l_ext='html' or $l_ext='htm' or $l_ext='xml' or $l_ext='php' or $l_ext='css'">/icons/www.png</xsl:when>
+ <xsl:when test="$l_ext='avi' or $l_ext='mpg' or $l_ext='mpeg'">/icons/video.png</xsl:when>
+ <xsl:when test="$l_ext='c' or $l_ext='cpp' or $l_ext='h'">/icons/source.png</xsl:when>
+ <xsl:when test="$l_ext='mp3' or $l_ext='ogg' or $l_ext='wav' or $l_ext='mid' or $l_ext='mod' or $l_ext='xm'">/icons/sound.png</xsl:when>
+ <xsl:otherwise>/icons/empty.png</xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute><!--src-->
+ </xsl:element><!--img-->
+ <xsl:value-of select="$filename" />
+ </a>
+ </td>
+
+ <!-- size -->
+ <td class="size" id="size{position()}" title="Grösse: {$realsize} ({format-number(@size,'###,###,###,###,### Byte')})" >
+ <xsl:value-of select="$realsize" />
+ </td>
+
+ <!-- modified -->
+ <td class="modified" id="modified{position()}" title="Geändert: {@modified}">
+ <xsl:value-of select="@modified" />
+ </td>
+
+ <!-- created -->
+ <td class="created" id="created{position()}" title="Erstellt: {@created}">
+ <xsl:value-of select="@created" />
+ </td>
+ </xsl:otherwise>
+ </xsl:choose>
+ </tr>
+ </xsl:for-each><!--item-->
+
+ <tr id="stats" class="stats">
+ <th id="filestats" class="file">
+ <xsl:value-of select="count(item[@isdir='true' and @name!='..'])" /> Verzeichnis(se), <xsl:value-of select="count(item[@isdir!='true'])" /> Datei(en)
+ </th>
+ <th id="sizestats" class="size" title="Gesamtgrösse: {$total-realsize} ({format-number($size,'###,###,###,###,### Byte')})">
+ <xsl:value-of select="$total-realsize" />
+ </th>
+ <th id="modifiedstats" class="modified">insgesamt</th>
+ <th id="createdstats" class="created"><a href="#header" id="uplink" title="An den Anfang der Liste">nach oben</a></th>
+ </tr>
+ </table>
+ </body>
+ </html>
+ </xsl:template> <!--config-->
+
+ <!-- converts byte sizes into human-readable text -->
+ <xsl:template name="convert">
+ <xsl:param name="bytes" />
+ <xsl:choose>
+ <xsl:when test="$bytes <= 0">
+ ...
+ </xsl:when>
+ <xsl:when test="$bytes < 1024">
+ <xsl:value-of select="format-number($bytes,'#,### Byte')" />
+ </xsl:when>
+ <xsl:when test="$bytes < 1048576">
+ <xsl:value-of select="format-number($bytes div 1024,'#,###.# KB')" />
+ </xsl:when>
+ <xsl:when test="$bytes < 1073741824">
+ <xsl:value-of select="format-number($bytes div 1048576,'#,###.# MB')" />
+ </xsl:when>
+ <xsl:when test="$bytes < 1099511627776">
+ <xsl:value-of select="format-number($bytes div 1073741824,'#,###.# GB')" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="format-number($bytes div 1099511627776,'#,###.# TB')" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
-</xsl:template>
</xsl:stylesheet>
diff --git a/HTTPServer/main.cpp b/HTTPServer/main.cpp index 0ff96f6..a8816d1 100644 --- a/HTTPServer/main.cpp +++ b/HTTPServer/main.cpp @@ -15,45 +15,14 @@ //along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-#ifdef NDEBUG //release
-#include "AggressiveOptimize.h" //create small code
-#endif
-
-#include <windows.h>
-#include <commctrl.h>
-#include <process.h>
-#include <time.h>
-#include <stdio.h>
-
-#pragma warning( push, 3 )
-
-#include <string>
+#include "Glob.h"
using namespace std;
-#include "newpluginapi.h"
-#include "m_database.h"
-#include "m_clist.h"
-#include "m_skin.h"
-#include "m_langpack.h"
-#include "m_options.h"
-#include "m_system.h"
-#include "m_history.h"
-#include "m_userinfo.h"
-#include "m_netlib.h"
-#include "m_message.h"
-#include "m_popup.h"
-#include "m_protosvc.h"
-
-#pragma warning( pop )
-
-//#include <Winsock2.h>
-//#include <sphelper.h>
#include "m_HTTPServer.h"
#include "FileShareNode.h"
#include "HttpUser.h"
#include "GuiElements.h"
#include "MimeHandling.h"
-#include "Glob.h"
#include "resource.h"
#include "IndexCreation.h"
@@ -90,6 +59,8 @@ HANDLE hDirectBoundPort; HINSTANCE hInstance = NULL;
PLUGINLINK *pluginLink;
+MM_INTERFACE mmi;
+int hLangpack = 0;
string sLogFilePath;
@@ -127,23 +98,6 @@ void (*MirandaFree)(void*); bool bShutdownInProgress = false;
-
-struct NETLIBUSERSETTINGS_V032 {
- int cbSize; //to be filled in before calling
- int useProxy; //1 or 0
- int proxyType; //a PROXYTYPE_
- char* szProxyServer; //can be NULL
- int wProxyPort; //host byte order
- int useProxyAuth; //1 or 0. Always 0 for SOCKS4
- char* szProxyAuthUser; //can be NULL, always used by SOCKS4
- char* szProxyAuthPassword; //can be NULL
- int useProxyAuthNtlm; //1 or 0, only used by HTTP, HTTPS
- int dnsThroughProxy; //1 or 0
- int specifyIncomingPorts; //1 or 0
- char* szIncomingPorts; //can be NULL. Of form "1024-1050,1060-1070,2000"
-} ;
-
-
char* pszVersion = "0.1.2.2";
PLUGININFOEX pluginInfo = {
@@ -156,7 +110,7 @@ PLUGININFOEX pluginInfo = { "",
"© 2003-2009 Kennet Nielsen, Vampik, Houdini",
"http://www.miranda-im.org/download/details.php?action=viewfile&id=2304",
- 0,
+ UNICODE_AWARE,
0,
// {67848B07-83D2-49e9-8844-7E3DE268E304}
{ 0x67848b07, 0x83d2, 0x49e9, { 0x88, 0x44, 0x7e, 0x3d, 0xe2, 0x68, 0xe3, 0x4 } }
@@ -253,12 +207,12 @@ bool bWriteToFile(HANDLE hFile, const char * pszSrc, int nLen = -1) { void LogEvent(const char * pszTitle, const char * pszLog) {
HANDLE hFile = CreateFile(sLogFilePath.c_str(), GENERIC_WRITE, FILE_SHARE_READ, 0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE) {
- MessageBox(NULL, "Failed to open or create log file", MSG_BOX_TITEL, MB_OK);
+ MessageBox(NULL, _T("Failed to open or create log file"), MSG_BOX_TITEL, MB_OK);
return;
}
if (SetFilePointer(hFile, 0, 0, FILE_END) == INVALID_SET_FILE_POINTER) {
CloseHandle(hFile);
- MessageBox(NULL, "Failed to move to the end of the log file", MSG_BOX_TITEL, MB_OK);
+ MessageBox(NULL, _T("Failed to move to the end of the log file"), MSG_BOX_TITEL, MB_OK);
return;
}
@@ -276,7 +230,7 @@ void LogEvent(const char * pszTitle, const char * pszLog) { !bWriteToFile(hFile, " : ") ||
!bWriteToFile(hFile, pszLog, nLogLen) ||
!bWriteToFile(hFile, "\r\n")) {
- MessageBox(NULL, "Failed to write some part of the log file", MSG_BOX_TITEL, MB_OK);
+ MessageBox(NULL, _T("Failed to write some part of the log file"), MSG_BOX_TITEL, MB_OK);
}
CloseHandle(hFile);
}
@@ -434,17 +388,17 @@ bool bWriteConfigurationFile() { strcat(szBuf, szConfigFile);
HANDLE hFile = CreateFile(szBuf, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE) {
- MessageBox(NULL, "Failed to open or create file " szConfigFile, MSG_BOX_TITEL, MB_OK);
+ MessageBox(NULL, _T("Failed to open or create file ") szConfigFile, MSG_BOX_TITEL, MB_OK);
return false;
}
DWORD dwBytesWriten = 0;
if (! WriteFile(hFile, szXmlHeader, sizeof(szXmlHeader) - 1, &dwBytesWriten, NULL)) {
- MessageBox(NULL, "Failed to write xml header to file " szConfigFile, MSG_BOX_TITEL, MB_OK);
+ MessageBox(NULL, _T("Failed to write xml header to file ") szConfigFile, MSG_BOX_TITEL, MB_OK);
} else {
CLFileShareNode * pclCur = pclFirstNode;
while (pclCur) {
- DWORD dwBytesToWrite = _snprintf(szBuf, sizeof(szBuf), szXmlData ,
+ DWORD dwBytesToWrite = mir_snprintf(szBuf, sizeof(szBuf), szXmlData ,
pclCur->st.pszSrvPath,
pclCur->pszOrigRealPath,
pclCur->st.nMaxDownloads,
@@ -452,14 +406,14 @@ bool bWriteConfigurationFile() { SplitIpAddress(pclCur->st.dwAllowedMask));
if (! WriteFile(hFile, szBuf, dwBytesToWrite, &dwBytesWriten, NULL)) {
- MessageBox(NULL, "Failed to write xml data to file " szConfigFile, MSG_BOX_TITEL, MB_OK);
+ MessageBox(NULL, _T("Failed to write xml data to file ") szConfigFile, MSG_BOX_TITEL, MB_OK);
break;
}
pclCur = pclCur->pclNext;
}
if (! WriteFile(hFile, szXmlTail, sizeof(szXmlTail) - 1, &dwBytesWriten, NULL)) {
- MessageBox(NULL, "Failed to write xml tail to file " szConfigFile, MSG_BOX_TITEL, MB_OK);
+ MessageBox(NULL, _T("Failed to write xml tail to file ") szConfigFile, MSG_BOX_TITEL, MB_OK);
}
}
SetEndOfFile(hFile);
@@ -482,7 +436,7 @@ bool bWriteConfigurationFile() { // Developer : KN, Houdini, changed By Sergio Vieira Rolanski
/////////////////////////////////////////////////////////////////////
-static long nAddChangeRemoveShare(WPARAM wParam, LPARAM lParam) {
+static INT_PTR nAddChangeRemoveShare(WPARAM wParam, LPARAM lParam) {
if (!lParam)
return 1001;
@@ -570,7 +524,7 @@ static long nAddChangeRemoveShare(WPARAM wParam, LPARAM lParam) { // Developer : KN
/////////////////////////////////////////////////////////////////////
-static long nGetShare(WPARAM /*wParam*/, LPARAM lParam) {
+static INT_PTR nGetShare(WPARAM /*wParam*/, LPARAM lParam) {
if (!lParam)
return 1001;
@@ -609,7 +563,7 @@ static long nGetShare(WPARAM /*wParam*/, LPARAM lParam) { // Developer : KN
/////////////////////////////////////////////////////////////////////
-static long nHttpGetAllShares(WPARAM /*wParam*/, LPARAM /*lParam*/) {/*
+static INT_PTR nHttpGetAllShares(WPARAM /*wParam*/, LPARAM /*lParam*/) {/*
STFileShareInfo ** pTarget = (STFileShareInfo**)lParam;
CLFileShareNode * pclCur;
@@ -700,7 +654,7 @@ static int nProtoAck(WPARAM /*wParam*/, LPARAM lParam) { bIsOnline = ((int)ack->lParam != ID_STATUS_AWAY && (int)ack->lParam != ID_STATUS_NA);
/*
char szTmp[200];
- _snprintf( szTmp, sizeof( szTmp ), "%s New status %d\n" ,ack->szModule, (int)bIsOnline);
+ mir_snprintf( szTmp, sizeof( szTmp ), "%s New status %d\n" ,ack->szModule, (int)bIsOnline);
OutputDebugString( szTmp );*/
return 0;
}
@@ -720,7 +674,7 @@ static int nProtoAck(WPARAM /*wParam*/, LPARAM lParam) { // Developer : KN
/////////////////////////////////////////////////////////////////////
-long nToggelAcceptConnections(WPARAM wparam, LPARAM /*lparam*/) {
+INT_PTR nToggelAcceptConnections(WPARAM wparam, LPARAM /*lparam*/) {
CLISTMENUITEM mi = { 0 };
mi.cbSize = sizeof(mi);
mi.flags = CMIM_NAME | CMIM_ICON;
@@ -729,10 +683,7 @@ long nToggelAcceptConnections(WPARAM wparam, LPARAM /*lparam*/) { NETLIBUSERSETTINGS nus = { 0 };
nus.cbSize = sizeof(nus);
if (! CallService(MS_NETLIB_GETUSERSETTINGS, (WPARAM) hNetlibUser, (LPARAM) &nus)) {
- nus.cbSize = sizeof(NETLIBUSERSETTINGS_V032);
- if (! CallService(MS_NETLIB_GETUSERSETTINGS, (WPARAM) hNetlibUser, (LPARAM) &nus)) {
- Netlib_Logf(hNetlibUser, "Failed to get NETLIBUSERSETTINGS using MS_NETLIB_GETUSERSETTINGS");
- }
+ Netlib_Logf(hNetlibUser, "Failed to get NETLIBUSERSETTINGS using MS_NETLIB_GETUSERSETTINGS");
}
NETLIBBIND nlb = { 0 };
@@ -741,13 +692,13 @@ long nToggelAcceptConnections(WPARAM wparam, LPARAM /*lparam*/) { if (nus.specifyIncomingPorts && nus.szIncomingPorts && nus.szIncomingPorts[0])
nlb.wPort = 0;
else {
- //MessageBox( NULL, "Debug message using default port!", MSG_BOX_TITEL, MB_OK );
+ //MessageBox( NULL, _T("Debug message using default port!"), MSG_BOX_TITEL, MB_OK );
nlb.wPort = 80;
}
hDirectBoundPort = (HANDLE) CallService(MS_NETLIB_BINDPORT, (WPARAM) hNetlibUser, (LPARAM) & nlb);
if (!hDirectBoundPort) {
char szTemp[200];
- _snprintf(szTemp, sizeof(szTemp), "Failed to bind to port %s\r\nThis is most likely because another program or service is using this port" ,
+ mir_snprintf(szTemp, sizeof(szTemp), "Failed to bind to port %s\r\nThis is most likely because another program or service is using this port" ,
nlb.wPort == 80 ? "80" : nus.szIncomingPorts);
MessageBox(NULL, szTemp, MSG_BOX_TITEL, MB_OK);
return 1001;
@@ -756,13 +707,13 @@ long nToggelAcceptConnections(WPARAM wparam, LPARAM /*lparam*/) { dwLocalIpAddress = nlb.dwInternalIP;
mi.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_DISABLE_SERVER));
- mi.pszName = Translate("Disable HTTP server");
+ mi.ptszName = LPGENT("Disable HTTP server");
Netlib_Logf(hNetlibUser, mi.pszName);
} else if (hDirectBoundPort && wparam == 0) {
Netlib_CloseHandle(hDirectBoundPort);
hDirectBoundPort = 0;
mi.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_SHARE_NEW_FILE));
- mi.pszName = Translate("Enable HTTP server");
+ mi.ptszName = LPGENT("Enable HTTP server");
Netlib_Logf(hNetlibUser, mi.pszName);
} else {
return 0; // no changes;
@@ -852,12 +803,12 @@ int MainInit(WPARAM /*wparam*/, LPARAM /*lparam*/) { NETLIBUSER nlu = { 0 };
nlu.cbSize = sizeof(nlu);
- nlu.flags = NUF_OUTGOING | NUF_INCOMING /*| NUF_HTTPCONNS*/;
+ nlu.flags = NUF_OUTGOING | NUF_INCOMING | NUF_TCHAR /*| NUF_HTTPCONNS*/;
nlu.szSettingsModule = MODULE;
- nlu.szDescriptiveName = "HTTP Server";
+ nlu.ptszDescriptiveName = LPGENT("HTTP Server");
hNetlibUser = (HANDLE) CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM) & nlu);
if (!hNetlibUser) {
- MessageBox(NULL, "Failed to register NetLib user", MSG_BOX_TITEL, MB_OK);
+ MessageBox(NULL, _T("Failed to register NetLib user"), MSG_BOX_TITEL, MB_OK);
return 0;
}
@@ -983,48 +934,45 @@ extern "C" { int __declspec(dllexport)Load(PLUGINLINK *link) {
pluginLink = link;
- /*
- MM_INTERFACE stMirandaMMI;
- CallService( MS_SYSTEM_GET_MMI, NULL, (LPARAM) &stMirandaMMI );
- MirandaMalloc = stMirandaMMI.malloc;
- MirandaFree = stMirandaMMI.free;
- */
+ mir_getMMI(&mmi);
+ mir_getLP(&pluginInfo);
+
InitializeCriticalSection(&csFileShareListAccess);
hHttpAcceptConnectionsService = CreateServiceFunction(MS_HTTP_ACCEPT_CONNECTIONS, nToggelAcceptConnections);
if (! hHttpAcceptConnectionsService) {
- MessageBox(NULL, "Failed to CreateServiceFunction MS_HTTP_ACCEPT_CONNECTIONS", MSG_BOX_TITEL, MB_OK);
+ MessageBox(NULL, _T("Failed to CreateServiceFunction MS_HTTP_ACCEPT_CONNECTIONS"), MSG_BOX_TITEL, MB_OK);
return 0;
}
hHttpAddChangeRemoveService = CreateServiceFunction(MS_HTTP_ADD_CHANGE_REMOVE, nAddChangeRemoveShare);
if (! hHttpAddChangeRemoveService) {
- MessageBox(NULL, "Failed to CreateServiceFunction MS_HTTP_ADD_CHANGE_REMOVE", MSG_BOX_TITEL, MB_OK);
+ MessageBox(NULL, _T("Failed to CreateServiceFunction MS_HTTP_ADD_CHANGE_REMOVE"), MSG_BOX_TITEL, MB_OK);
return 0;
}
hHttpGetShareService = CreateServiceFunction(MS_HTTP_GET_SHARE, nGetShare);
if (! hHttpGetShareService) {
- MessageBox(NULL, "Failed to CreateServiceFunction MS_HTTP_GET_SHARE", MSG_BOX_TITEL, MB_OK);
+ MessageBox(NULL, _T("Failed to CreateServiceFunction MS_HTTP_GET_SHARE"), MSG_BOX_TITEL, MB_OK);
return 0;
}
hHttpGetAllShares = CreateServiceFunction(MS_HTTP_GET_ALL_SHARES, nHttpGetAllShares);
if (! hHttpGetAllShares) {
- MessageBox(NULL, "Failed to CreateServiceFunction MS_HTTP_GET_ALL_SHARES", MSG_BOX_TITEL, MB_OK);
+ MessageBox(NULL, _T("Failed to CreateServiceFunction MS_HTTP_GET_ALL_SHARES"), MSG_BOX_TITEL, MB_OK);
return 0;
}
hEventSystemInit = HookEvent(ME_SYSTEM_MODULESLOADED, MainInit);
if (!hEventSystemInit) {
- MessageBox(NULL, "Failed to HookEvent ME_SYSTEM_MODULESLOADED", MSG_BOX_TITEL, MB_OK);
+ MessageBox(NULL, _T("Failed to HookEvent ME_SYSTEM_MODULESLOADED"), MSG_BOX_TITEL, MB_OK);
return 0;
}
hPreShutdown = HookEvent(ME_SYSTEM_PRESHUTDOWN, PreShutdown);
if (!hPreShutdown) {
- MessageBox(NULL, "Failed to HookEvent ME_SYSTEM_PRESHUTDOWN", MSG_BOX_TITEL, MB_OK);
+ MessageBox(NULL, _T("Failed to HookEvent ME_SYSTEM_PRESHUTDOWN"), MSG_BOX_TITEL, MB_OK);
return 0;
}
@@ -1041,7 +989,7 @@ extern "C" { sLogFilePath += "HTTPServer.log";
if (! bInitMimeHandling()) {
- MessageBox(NULL, "Failed to read configuration file : " szMimeTypeConfigFile, MSG_BOX_TITEL, MB_OK);
+ MessageBox(NULL, _T("Failed to read configuration file : ") szMimeTypeConfigFile, MSG_BOX_TITEL, MB_OK);
}
// Plugin sweeper support
@@ -1058,11 +1006,11 @@ extern "C" { CLISTMENUITEM mi;
ZeroMemory(&mi, sizeof(mi));
mi.cbSize = sizeof(mi);
- mi.flags = 0;
+ mi.flags = CMIF_TCHAR;
mi.pszContactOwner = NULL; //all contacts
mi.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_SHARE_NEW_FILE));
mi.position = 1000085000;
- mi.pszName = Translate("Enable HTTP server");
+ mi.ptszName = LPGENT("Enable HTTP server");
mi.pszService = MS_HTTP_ACCEPT_CONNECTIONS;
hAcceptConnectionsMenuItem = (HANDLE)CallService(MS_CLIST_ADDMAINMENUITEM, 0, (LPARAM) & mi);
}
|