summaryrefslogtreecommitdiff
path: root/plugins/HTTPServer
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-08-30 20:18:34 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-08-30 20:18:34 +0000
commit2f1ac5fc48cf9de50fe4380ea22d88840945728c (patch)
tree78045cb7ab1492812d6bf513e244cc6226851282 /plugins/HTTPServer
parent1279b591a7b8faf4c5dbb088b0432d19ef85726d (diff)
code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@15121 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/HTTPServer')
-rw-r--r--plugins/HTTPServer/src/FileShareNode.cpp63
-rw-r--r--plugins/HTTPServer/src/GuiElements.cpp854
-rw-r--r--plugins/HTTPServer/src/HttpUser.cpp371
-rw-r--r--plugins/HTTPServer/src/IndexHTML.cpp334
-rw-r--r--plugins/HTTPServer/src/IndexXML.cpp90
-rw-r--r--plugins/HTTPServer/src/MimeHandling.cpp30
-rw-r--r--plugins/HTTPServer/src/main.cpp146
7 files changed, 955 insertions, 933 deletions
diff --git a/plugins/HTTPServer/src/FileShareNode.cpp b/plugins/HTTPServer/src/FileShareNode.cpp
index a0307cad11..8584df5111 100644
--- a/plugins/HTTPServer/src/FileShareNode.cpp
+++ b/plugins/HTTPServer/src/FileShareNode.cpp
@@ -36,7 +36,8 @@ mir_cs csFileShareListAccess;
// Developer : KN
/////////////////////////////////////////////////////////////////////
-CLShareUser::CLShareUser(HANDLE hCon, in_addr stAdd) {
+CLShareUser::CLShareUser(HANDLE hCon, in_addr stAdd)
+{
hConnection = hCon;
stAddr = stAdd;
pclNext = NULL;
@@ -58,7 +59,8 @@ CLShareUser::CLShareUser(HANDLE hCon, in_addr stAdd) {
// Developer : KN
/////////////////////////////////////////////////////////////////////
-CLShareUser::~CLShareUser() {
+CLShareUser::~CLShareUser()
+{
if (hConnection) {
CloseSocket();
Netlib_CloseHandle(hConnection);
@@ -79,8 +81,9 @@ CLShareUser::~CLShareUser() {
// Developer : KN
/////////////////////////////////////////////////////////////////////
-void CLShareUser::CloseSocket() {
- SOCKET s = CallService(MS_NETLIB_GETSOCKET, (WPARAM) hConnection, 0);
+void CLShareUser::CloseSocket()
+{
+ SOCKET s = CallService(MS_NETLIB_GETSOCKET, (WPARAM)hConnection, 0);
if (s != INVALID_SOCKET) {
shutdown(s, SD_SEND);
int nBytesRead;
@@ -105,7 +108,8 @@ void CLShareUser::CloseSocket() {
// Developer : KN
/////////////////////////////////////////////////////////////////////
-DWORD CLShareUser::dwGetDownloadSpeed() {
+DWORD CLShareUser::dwGetDownloadSpeed()
+{
return dwSpeed;
}
@@ -124,7 +128,8 @@ DWORD CLShareUser::dwGetDownloadSpeed() {
// Developer : KN
/////////////////////////////////////////////////////////////////////
-CLFileShareNode::CLFileShareNode(char * pszSrvPath, char * pszRealPath) {
+CLFileShareNode::CLFileShareNode(char * pszSrvPath, char * pszRealPath)
+{
memset(&st, 0, sizeof(STFileShareInfo));
st.lStructSize = sizeof(STFileShareInfo);
pclNext = NULL;
@@ -146,7 +151,8 @@ CLFileShareNode::CLFileShareNode(char * pszSrvPath, char * pszRealPath) {
// Developer : KN
/////////////////////////////////////////////////////////////////////
-CLFileShareNode::CLFileShareNode(STFileShareInfo * pstInfo) {
+CLFileShareNode::CLFileShareNode(STFileShareInfo * pstInfo)
+{
memset(&st, 0, sizeof(STFileShareInfo));
st.lStructSize = sizeof(STFileShareInfo);
pclNext = NULL;
@@ -168,9 +174,10 @@ CLFileShareNode::CLFileShareNode(STFileShareInfo * pstInfo) {
// Developer : KN
/////////////////////////////////////////////////////////////////////
-CLFileShareNode::~CLFileShareNode() {
- delete [] st.pszSrvPath;
- delete [] st.pszRealPath;
+CLFileShareNode::~CLFileShareNode()
+{
+ delete[] st.pszSrvPath;
+ delete[] st.pszRealPath;
CLShareUser * pclCur = pclCurrentUsers;
while (pclCur) {
@@ -195,7 +202,8 @@ CLFileShareNode::~CLFileShareNode() {
// Developer : KN
/////////////////////////////////////////////////////////////////////
-bool CLFileShareNode::bSetPaths(char * pszSrvPath, char * pszRealPath) {
+bool CLFileShareNode::bSetPaths(char * pszSrvPath, char * pszRealPath)
+{
/* This might be a problem !!
if( nDownloadsInProgress > 0 )
return false;
@@ -204,25 +212,26 @@ bool CLFileShareNode::bSetPaths(char * pszSrvPath, char * pszRealPath) {
if (!pszSrvPath || !pszRealPath)
return false;
- delete [] st.pszSrvPath;
- delete [] st.pszRealPath;
+ delete[] st.pszSrvPath;
+ delete[] st.pszRealPath;
st.dwMaxSrvPath = (int)mir_strlen(pszSrvPath) + 1;
- st.pszSrvPath = new char[ st.dwMaxSrvPath ];
+ st.pszSrvPath = new char[st.dwMaxSrvPath];
mir_strcpy(st.pszSrvPath, pszSrvPath);
int nRealLen = (int)mir_strlen(pszRealPath);
if (nRealLen <= 2 || !(pszRealPath[1] == ':' ||
- (pszRealPath[0] == '\\' && pszRealPath[1] == '\\'))) {
+ (pszRealPath[0] == '\\' && pszRealPath[1] == '\\'))) {
// Relative path
// we will prepend plugin path to avoid problems
- st.dwMaxRealPath = nPluginPathLen + nRealLen + 1;
- st.pszRealPath = new char[ st.dwMaxRealPath ];
+ st.dwMaxRealPath = nPluginPathLen + nRealLen + 1;
+ st.pszRealPath = new char[st.dwMaxRealPath];
mir_strcpy(st.pszRealPath, szPluginPath);
pszOrigRealPath = &st.pszRealPath[nPluginPathLen];
- } else {
+ }
+ else {
st.dwMaxRealPath = nRealLen + 1;
- st.pszRealPath = new char[ st.dwMaxRealPath ];
+ st.pszRealPath = new char[st.dwMaxRealPath];
pszOrigRealPath = st.pszRealPath;
}
mir_strcpy(pszOrigRealPath, pszRealPath);
@@ -242,8 +251,9 @@ bool CLFileShareNode::bSetPaths(char * pszSrvPath, char * pszRealPath) {
// Developer : KN
/////////////////////////////////////////////////////////////////////
-bool CLFileShareNode::bSetInfo(STFileShareInfo * pstInfo) {
- if (! bSetPaths(pstInfo->pszSrvPath, pstInfo->pszRealPath))
+bool CLFileShareNode::bSetInfo(STFileShareInfo * pstInfo)
+{
+ if (!bSetPaths(pstInfo->pszSrvPath, pstInfo->pszRealPath))
return false;
if (pstInfo->nMaxDownloads < -1)
return false;
@@ -287,7 +297,8 @@ CLHttpUser * CLFileShareNode::pclAddHttpUser( HANDLE hConnection, in_addr stAddr
}
*/
-bool CLFileShareNode::bAddUser(CLShareUser * pclUser) {
+bool CLFileShareNode::bAddUser(CLShareUser * pclUser)
+{
// deny access
if (bIsOnline || !bLimitOnlyWhenOnline) {
int nConnectionCount = 0;
@@ -338,7 +349,8 @@ bool CLFileShareNode::bAddUser(CLShareUser * pclUser) {
// Developer : KN
/////////////////////////////////////////////////////////////////////
-bool CLFileShareNode::bRemoveUser(CLShareUser * pclUser) {
+bool CLFileShareNode::bRemoveUser(CLShareUser * pclUser)
+{
CLShareUser **pclPrev = &pclCurrentUsers;
CLShareUser * pclCur = pclCurrentUsers;
while (pclCur) {
@@ -366,10 +378,11 @@ bool CLFileShareNode::bRemoveUser(CLShareUser * pclUser) {
// Developer : KN
/////////////////////////////////////////////////////////////////////
-void CLFileShareNode::CloseAllTransfers() {
+void CLFileShareNode::CloseAllTransfers()
+{
CLShareUser * pclCur = pclCurrentUsers;
while (pclCur) {
pclCur->CloseSocket();
pclCur = pclCur->pclNext;
}
-} \ No newline at end of file
+}
diff --git a/plugins/HTTPServer/src/GuiElements.cpp b/plugins/HTTPServer/src/GuiElements.cpp
index 065d6c1b25..b1ab0de56e 100644
--- a/plugins/HTTPServer/src/GuiElements.cpp
+++ b/plugins/HTTPServer/src/GuiElements.cpp
@@ -60,7 +60,8 @@ string sPageKeyword = szDefaultPageKeyword;
// Developer : KN
/////////////////////////////////////////////////////////////////////
-void ReplaceAll(string &sSrc, const char * pszReplace, const string &sNew) {
+void ReplaceAll(string &sSrc, const char * pszReplace, const string &sNew)
+{
string::size_type nCur = 0;
int nRepalceLen = (int)mir_strlen(pszReplace);
while ((nCur = sSrc.find(pszReplace, nCur)) != sSrc.npos) {
@@ -69,7 +70,8 @@ void ReplaceAll(string &sSrc, const char * pszReplace, const string &sNew) {
}
}
-void ReplaceAll(string &sSrc, const char * pszReplace, const char * pszNew) {
+void ReplaceAll(string &sSrc, const char * pszReplace, const char * pszNew)
+{
string sNew = pszNew;
ReplaceAll(sSrc, pszReplace, sNew);
}
@@ -91,18 +93,19 @@ void ReplaceAll(string &sSrc, const char * pszReplace, const char * pszNew) {
// Developer : KN
/////////////////////////////////////////////////////////////////////
-string DBGetString(MCONTACT hContact, const char *szModule, const char *szSetting, const char * pszError) {
+string DBGetString(MCONTACT hContact, const char *szModule, const char *szSetting, const char * pszError)
+{
string ret;
- DBVARIANT dbv = {0};
- if (! db_get(hContact, szModule, szSetting, &dbv)) {
+ DBVARIANT dbv = { 0 };
+ if (!db_get(hContact, szModule, szSetting, &dbv)) {
if (dbv.type != DBVT_ASCIIZ) {
MessageBox(NULL, "DB: Attempt to get wrong type of value, string", MSG_BOX_TITEL, MB_OK);
ret = pszError;
- } else {
- ret = dbv.pszVal;
}
- } else
- ret = pszError;
+ else ret = dbv.pszVal;
+ }
+ else ret = pszError;
+
db_free(&dbv);
return ret;
}
@@ -121,13 +124,12 @@ string DBGetString(MCONTACT hContact, const char *szModule, const char *szSettin
// Developer : KN
/////////////////////////////////////////////////////////////////////
-void UpdateStatisticsView() {
- if (hwndStatsticView) {
+void UpdateStatisticsView()
+{
+ if (hwndStatsticView)
PostMessage(hwndStatsticView, WM_RELOAD_STATISTICS, 0, 0);
- }
}
-
/////////////////////////////////////////////////////////////////////
// Member Function : GetExternIP
// Type : Global
@@ -142,7 +144,8 @@ void UpdateStatisticsView() {
// Developer : KN
/////////////////////////////////////////////////////////////////////
-unsigned long GetExternIP(const char *szURL, const char *szPattern) {
+unsigned long GetExternIP(const char *szURL, const char *szPattern)
+{
HCURSOR hPrevCursor = ::SetCursor(::LoadCursor(0, IDC_WAIT));
NETLIBHTTPREQUEST nlhr;
@@ -155,7 +158,7 @@ unsigned long GetExternIP(const char *szURL, const char *szPattern) {
IN_ADDR externIP;
externIP.s_addr = 0;
- NETLIBHTTPREQUEST *nlreply = (NETLIBHTTPREQUEST *) CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM) hNetlibUser, (LPARAM) & nlhr);
+ NETLIBHTTPREQUEST *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
@@ -175,14 +178,12 @@ unsigned long GetExternIP(const char *szURL, const char *szPattern) {
if ((externIP.s_addr = inet_addr(pszIp)) == INADDR_NONE)
externIP.s_addr = 0;
}
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM) nlreply);
+ CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlreply);
}
::SetCursor(hPrevCursor);
return ntohl(externIP.s_addr);
}
-
-
/////////////////////////////////////////////////////////////////////
// Member Function : sCreateLink
// Type : Global
@@ -197,7 +198,8 @@ unsigned long GetExternIP(const char *szURL, const char *szPattern) {
// Developer : KN
/////////////////////////////////////////////////////////////////////
-string sCreateLink(const char * pszSrvPath) {
+string sCreateLink(const char * pszSrvPath)
+{
char szTemp[30];
string sLink = DBGetString(NULL, MODULE, "ExternalSrvName", szDefaultExternalSrvName);
mir_snprintf(szTemp, "%d.%d.%d.%d", SplitIpAddress(dwLocalIpAddress));
@@ -207,9 +209,8 @@ string sCreateLink(const char * pszSrvPath) {
static DWORD dwExternalIpAddressGenerated = 0;
// Get the IP again after 10 minutes
- if (! dwExternalIpAddress || GetTickCount() - dwExternalIpAddressGenerated > 10 * 60 * 1000) {
+ if (!dwExternalIpAddress || GetTickCount() - dwExternalIpAddressGenerated > 10 * 60 * 1000) {
dwExternalIpAddress = GetExternIP(sUrlAddress.c_str(), sPageKeyword.c_str());
-
dwExternalIpAddressGenerated = GetTickCount();
}
@@ -243,38 +244,40 @@ string sCreateLink(const char * pszSrvPath) {
/////////////////////////////////////////////////////////////////////
UINT_PTR CALLBACK ShareNewFileDialogHook(
- HWND hDlg, // handle to child dialog box
- UINT uiMsg, // message identifier
- WPARAM wParam, // message parameter
- LPARAM lParam // message parameter
-) {
+ HWND hDlg, // handle to child dialog box
+ UINT uiMsg, // message identifier
+ WPARAM wParam, // message parameter
+ LPARAM lParam // message parameter
+ )
+{
static const char* pszShareDirStr = Translate("Share Current Directory");
static int nInit = 0;
STFileShareInfo * pstShare = (STFileShareInfo *)GetWindowLongPtr(hDlg, GWLP_USERDATA);
switch (uiMsg) {
- case WM_INITDIALOG: {
- pstShare = (STFileShareInfo *)((OPENFILENAME *)lParam)->lCustData;
- SetWindowLongPtr(hDlg, GWLP_USERDATA, (LONG_PTR)pstShare);
+ case WM_INITDIALOG:
+ pstShare = (STFileShareInfo *)((OPENFILENAME *)lParam)->lCustData;
+ SetWindowLongPtr(hDlg, GWLP_USERDATA, (LONG_PTR)pstShare);
- SetDlgItemInt(hDlg, IDC_MAX_DOWNLOADS, pstShare->nMaxDownloads, TRUE);
- SendDlgItemMessage(hDlg, IDC_ALLOWED_IPADDRESS, IPM_SETADDRESS, 0, pstShare->dwAllowedIP);
- SendDlgItemMessage(hDlg, IDC_ALLOWED_IP_MASK, IPM_SETADDRESS, 0, pstShare->dwAllowedMask);
+ SetDlgItemInt(hDlg, IDC_MAX_DOWNLOADS, pstShare->nMaxDownloads, TRUE);
+ SendDlgItemMessage(hDlg, IDC_ALLOWED_IPADDRESS, IPM_SETADDRESS, 0, pstShare->dwAllowedIP);
+ SendDlgItemMessage(hDlg, IDC_ALLOWED_IP_MASK, IPM_SETADDRESS, 0, pstShare->dwAllowedMask);
- if (*pstShare->pszSrvPath)
- nInit = 2;
- else
- nInit = 1;
+ if (*pstShare->pszSrvPath)
+ nInit = 2;
+ else
+ nInit = 1;
- return false;
- }
+ return false;
- case WM_NOTIFY: {
+ case WM_NOTIFY:
+ {
OFNOTIFY * pNotify = (OFNOTIFY*)lParam;
switch (pNotify->hdr.code) {
- case CDN_FOLDERCHANGE:
- case CDN_SELCHANGE: {
+ case CDN_FOLDERCHANGE:
+ case CDN_SELCHANGE:
+ {
static char szSelection[MAX_PATH] = "";
HWND hWndFileDlg = GetParent(hDlg);
@@ -286,28 +289,29 @@ UINT_PTR CALLBACK ShareNewFileDialogHook(
GetWindowText(hFileName, pszFileName, _countof(pszFileName));
if (mir_strcmp(pstShare->pszSrvPath, szSelection) &&
- mir_strcmp(pszFileName, pszShareDirStr)) {
+ mir_strcmp(pszFileName, pszShareDirStr)) {
// a file was selected
// only reenable windows / set default values when a folder was selected before
- if (pstShare->pszSrvPath[mir_strlen(pstShare->pszSrvPath)-1] == '/') {
+ if (pstShare->pszSrvPath[mir_strlen(pstShare->pszSrvPath) - 1] == '/') {
pNotify->lpOFN->Flags |= OFN_FILEMUSTEXIST;
EnableWindow(hFileName, TRUE);
EnableWindow(GetDlgItem(hDlg, IDC_MAX_DOWNLOADS), TRUE);
- SetDlgItemInt(hDlg, IDC_MAX_DOWNLOADS, nDefaultDownloadLimit, true);
+ SetDlgItemInt(hDlg, IDC_MAX_DOWNLOADS, nDefaultDownloadLimit, true);
}
- } else {
+ }
+ else {
// a directory was selected
pNotify->lpOFN->Flags &= ~OFN_FILEMUSTEXIST;
mir_strcpy(pNotify->lpOFN->lpstrFile, pszShareDirStr);
CommDlg_OpenSave_SetControlText(hWndFileDlg, edt1, pszShareDirStr);
EnableWindow(hFileName, FALSE);
EnableWindow(GetDlgItem(hDlg, IDC_MAX_DOWNLOADS), FALSE);
- SetDlgItemInt(hDlg, IDC_MAX_DOWNLOADS, (UINT)-1, true);
+ SetDlgItemInt(hDlg, IDC_MAX_DOWNLOADS, (UINT)-1, true);
CommDlg_OpenSave_GetFolderPath(hWndFileDlg, szSelection, MAX_PATH);
char* pszFolder = szSelection;
- char* pszTmp = szSelection;
+ char* pszTmp = szSelection;
while (*pszTmp != '\0') {
if (*pszTmp == '\\' && *(pszTmp + 1))
pszFolder = pszTmp + 1;
@@ -320,7 +324,7 @@ UINT_PTR CALLBACK ShareNewFileDialogHook(
memmove(&szSelection[1], pszFolder, mir_strlen(pszFolder) + 1);
szSelection[0] = '/';
- if (szSelection[mir_strlen(szSelection)-1] != '/')
+ if (szSelection[mir_strlen(szSelection) - 1] != '/')
mir_strcat(szSelection, "/");
// only write to IDC_SHARE_NAME when a file / other folder was selected before
@@ -336,7 +340,8 @@ UINT_PTR CALLBACK ShareNewFileDialogHook(
SetDlgItemText(hDlg, IDC_SHARE_NAME, pstShare->pszSrvPath);
nInit--;
- } else {
+ }
+ else {
SetDlgItemText(hDlg, IDC_SHARE_NAME, szSelection);
}
@@ -345,17 +350,19 @@ UINT_PTR CALLBACK ShareNewFileDialogHook(
return false;
}
- case CDN_FILEOK: {
+ case CDN_FILEOK:
+ {
GetDlgItemText(hDlg, IDC_SHARE_NAME, pstShare->pszSrvPath, _MAX_PATH);
char* pszTmp = strstr(pstShare->pszRealPath, pszShareDirStr);
if (pszTmp) {
*pszTmp = '\0';
- if (pstShare->pszSrvPath[mir_strlen(pstShare->pszSrvPath)-1] != '/')
+ if (pstShare->pszSrvPath[mir_strlen(pstShare->pszSrvPath) - 1] != '/')
mir_strcat(pstShare->pszSrvPath, "/");
- } else {
- if (pstShare->pszSrvPath[mir_strlen(pstShare->pszSrvPath)-1] == '/')
- pstShare->pszSrvPath[mir_strlen(pstShare->pszSrvPath)-1] = '\0';
+ }
+ else {
+ if (pstShare->pszSrvPath[mir_strlen(pstShare->pszSrvPath) - 1] == '/')
+ pstShare->pszSrvPath[mir_strlen(pstShare->pszSrvPath) - 1] = '\0';
}
BOOL bTranslated = false;
@@ -378,7 +385,8 @@ UINT_PTR CALLBACK ShareNewFileDialogHook(
break;
}
- case WM_DROPFILES: {
+ case WM_DROPFILES:
+ {
HDROP hDrop = (HDROP)wParam;
char szDropedFile[MAX_PATH];
int nLen = DragQueryFile(hDrop, 0, szDropedFile, sizeof(szDropedFile));
@@ -401,14 +409,14 @@ UINT_PTR CALLBACK ShareNewFileDialogHook(
return 0;
}
- case WM_COMMAND: {
- switch (LOWORD(wParam)) {
- case IDC_TOGGLE_MASK: {
- DWORD dwCur;
- SendDlgItemMessage(hDlg, IDC_ALLOWED_IP_MASK, IPM_GETADDRESS, 0, (LPARAM)&dwCur);
- SendDlgItemMessage(hDlg, IDC_ALLOWED_IP_MASK, IPM_SETADDRESS, 0, (LPARAM) dwCur == 0xFFFFFFFF ? 0 : 0xFFFFFFFF);
- return TRUE;
- }
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDC_TOGGLE_MASK:
+ {
+ DWORD dwCur;
+ SendDlgItemMessage(hDlg, IDC_ALLOWED_IP_MASK, IPM_GETADDRESS, 0, (LPARAM)&dwCur);
+ SendDlgItemMessage(hDlg, IDC_ALLOWED_IP_MASK, IPM_SETADDRESS, 0, (LPARAM)dwCur == 0xFFFFFFFF ? 0 : 0xFFFFFFFF);
+ return TRUE;
}
}
}
@@ -429,8 +437,9 @@ UINT_PTR CALLBACK ShareNewFileDialogHook(
// Developer : KN, Houdini
/////////////////////////////////////////////////////////////////////
-bool bShowShareNewFileDlg(HWND hwndOwner, STFileShareInfo * pstNewShare) {
- OPENFILENAME ofn = {0};
+bool bShowShareNewFileDlg(HWND hwndOwner, STFileShareInfo * pstNewShare)
+{
+ OPENFILENAME ofn = { 0 };
ofn.lStructSize = sizeof(OPENFILENAME);
char temp[MAX_PATH];
@@ -441,20 +450,20 @@ bool bShowShareNewFileDlg(HWND hwndOwner, STFileShareInfo * pstNewShare) {
ofn.nMaxFile = pstNewShare->dwMaxRealPath;
char szInitialDir[MAX_PATH];
- if (ofn.lpstrFile[mir_strlen(ofn.lpstrFile)-1] == '\\') {
+ if (ofn.lpstrFile[mir_strlen(ofn.lpstrFile) - 1] == '\\') {
ofn.lpstrInitialDir = szInitialDir;
mir_strcpy(szInitialDir, ofn.lpstrFile);
*ofn.lpstrFile = '\0';
}
-
- ofn.Flags = /*OFN_DONTADDTORECENT |*/ OFN_NOREADONLYRETURN
- | OFN_ENABLEHOOK | OFN_ENABLETEMPLATE | OFN_EXPLORER | OFN_ENABLESIZING
- | OFN_ALLOWMULTISELECT;
+
+ ofn.Flags = /*OFN_DONTADDTORECENT |*/ OFN_NOREADONLYRETURN
+ | OFN_ENABLEHOOK | OFN_ENABLETEMPLATE | OFN_EXPLORER | OFN_ENABLESIZING
+ | OFN_ALLOWMULTISELECT;
ofn.hwndOwner = hwndOwner;
ofn.hInstance = hInstance;
ofn.lpstrTitle = TranslateT("Specify a file to share");
- ofn.lpTemplateName = MAKEINTRESOURCE(IDD_NEW_SHARE_PROPERTIES);
+ ofn.lpTemplateName = MAKEINTRESOURCE(IDD_NEW_SHARE_PROPERTIES);
ofn.lpfnHook = ShareNewFileDialogHook;
ofn.lCustData = (LPARAM)pstNewShare;
@@ -474,25 +483,24 @@ bool bShowShareNewFileDlg(HWND hwndOwner, STFileShareInfo * pstNewShare) {
// move one after the other to front of string (in place)
// terminate it with \0 append to realpath and add the share
char* pszFileNamePos = pstNewShare->pszSrvPath;
- char* szRealDirectoryEnd =
- &pstNewShare->pszRealPath[mir_strlen(pstNewShare->pszRealPath)];
+ char* szRealDirectoryEnd = &pstNewShare->pszRealPath[mir_strlen(pstNewShare->pszRealPath)];
*szRealDirectoryEnd = '\\';
szRealDirectoryEnd++;
-
- while (pszFileNamePos && *pszFileNamePos) {
+
+ while (pszFileNamePos && *pszFileNamePos) {
pszFileNamePos = strchr(pszFileNamePos, '"');
if (pszFileNamePos) {
pszFileNamePos++;
char* start = pszFileNamePos;
pszFileNamePos = strchr(pszFileNamePos, '"');
- if (pszFileNamePos) {
+ if (pszFileNamePos) {
char* end = pszFileNamePos;
- memmove(pstNewShare->pszSrvPath+1, start, end - start);
- *(end - (start - (pstNewShare->pszSrvPath+1)) ) = '\0';
-
+ memmove(pstNewShare->pszSrvPath + 1, start, end - start);
+ *(end - (start - (pstNewShare->pszSrvPath + 1))) = '\0';
+
int realPathLen = szRealDirectoryEnd - pstNewShare->pszRealPath;
- strncpy(szRealDirectoryEnd, pstNewShare->pszSrvPath+1,
+ strncpy(szRealDirectoryEnd, pstNewShare->pszSrvPath + 1,
pstNewShare->dwMaxRealPath - realPathLen - 1);
pstNewShare->pszRealPath[pstNewShare->dwMaxRealPath] = '\0';
@@ -501,11 +509,12 @@ bool bShowShareNewFileDlg(HWND hwndOwner, STFileShareInfo * pstNewShare) {
return false;
}
pszFileNamePos++;
- }
+ }
}
}
- } else {
+ }
+ else {
if (CallService(MS_HTTP_ADD_CHANGE_REMOVE, 0, (LPARAM)pstNewShare)) {
MessageBox(NULL, TranslateT("Failed to share new file"), MSG_BOX_TITEL, MB_OK);
return false;
@@ -530,12 +539,13 @@ bool bShowShareNewFileDlg(HWND hwndOwner, STFileShareInfo * pstNewShare) {
// Developer : KN, Houdini
/////////////////////////////////////////////////////////////////////
-void UpdateStatisticView(HWND hwndDlg, bool bRefressUsersOnly = false) {
+void UpdateStatisticView(HWND hwndDlg, bool bRefressUsersOnly = false)
+{
HWND hShareList = GetDlgItem(hwndDlg, IDC_CURRENT_SHARES);
HWND hUserList = GetDlgItem(hwndDlg, IDC_CURRENT_USERS);
bool bShowHiddenShares = IsDlgButtonChecked(hwndDlg, IDC_SHOWHIDDENSHARES) == BST_CHECKED;
- if (! bRefressUsersOnly)
+ if (!bRefressUsersOnly)
ListView_DeleteAllItems(hShareList);
ListView_DeleteAllItems(hUserList);
@@ -549,9 +559,9 @@ void UpdateStatisticView(HWND hwndDlg, bool bRefressUsersOnly = false) {
LVITEM sItem = { 0 };
int nShareNr = 0;
int nUserNr = 0;
- for (CLFileShareNode * pclCur = pclFirstNode; pclCur ; pclCur = pclCur->pclNext) {
- if (! bRefressUsersOnly &&
- (bShowHiddenShares || !strstr(pclCur->st.pszRealPath, "\\@"))) {
+ for (CLFileShareNode * pclCur = pclFirstNode; pclCur; pclCur = pclCur->pclNext) {
+ if (!bRefressUsersOnly &&
+ (bShowHiddenShares || !strstr(pclCur->st.pszRealPath, "\\@"))) {
sItem.mask = LVIF_TEXT /*| LVIF_PARAM | LVIF_IMAGE*/;
sItem.iItem = nShareNr;
sItem.iSubItem = 0;
@@ -581,7 +591,7 @@ void UpdateStatisticView(HWND hwndDlg, bool bRefressUsersOnly = false) {
nShareNr++;
}
- for (CLShareUser * pclCurUser = pclCur->pclGetUsers() ; pclCurUser ; pclCurUser = pclCurUser->pclNext) {
+ for (CLShareUser * pclCurUser = pclCur->pclGetUsers(); pclCurUser; pclCurUser = pclCurUser->pclNext) {
bAutoRefress = true;
sItem.mask = LVIF_TEXT /*| LVIF_PARAM | LVIF_IMAGE*/;
@@ -600,7 +610,8 @@ void UpdateStatisticView(HWND hwndDlg, bool bRefressUsersOnly = false) {
if (pclCurUser->dwTotalSize) {
mir_snprintf(szTmp, "%d %%", (pclCurUser->dwCurrentDL * 100) / pclCurUser->dwTotalSize);
- } else {
+ }
+ else {
mir_strcpy(szTmp, "? %%");
}
sItem.iSubItem = 3;
@@ -612,9 +623,9 @@ void UpdateStatisticView(HWND hwndDlg, bool bRefressUsersOnly = false) {
dwSpeed += 512; // make sure we round ot down correctly.
dwSpeed /= 1024;
mir_snprintf(szTmp, "%d KB/Sec", dwSpeed);
- } else {
- mir_snprintf(szTmp, "%d B/Sec", dwSpeed);
}
+ else mir_snprintf(szTmp, "%d B/Sec", dwSpeed);
+
sItem.iSubItem = 4;
sItem.pszText = szTmp;
ListView_SetItem(hUserList, &sItem);
@@ -623,7 +634,7 @@ void UpdateStatisticView(HWND hwndDlg, bool bRefressUsersOnly = false) {
}
}
- if (bLastAutoRefress != bAutoRefress) {
+ if (bLastAutoRefress != bAutoRefress) {
if (bAutoRefress)
SetTimer(hwndDlg, 0, 1000, NULL);
else
@@ -645,26 +656,27 @@ void UpdateStatisticView(HWND hwndDlg, bool bRefressUsersOnly = false) {
// Developer : KN
/////////////////////////////////////////////////////////////////////
-void SetWindowsCtrls(HWND hwndDlg) {
+void SetWindowsCtrls(HWND hwndDlg)
+{
RECT rNewSize;
GetClientRect(hwndDlg, &rNewSize);
const int nSpacing = 8;
int nCtrlHight = (rNewSize.bottom - (nSpacing * 3)) / 3 - 20;
- SetWindowPos(GetDlgItem(hwndDlg, IDC_CURRENT_SHARES), 0 ,
- nSpacing,
- 35,
- rNewSize.right - (nSpacing * 2) ,
- nCtrlHight*2,
- SWP_NOZORDER);
-
- SetWindowPos(GetDlgItem(hwndDlg, IDC_CURRENT_USERS), 0 ,
- nSpacing ,
- (nSpacing * 2) + nCtrlHight*2 + 25,
- rNewSize.right - (nSpacing * 2) ,
- nCtrlHight + 35,
- SWP_NOZORDER);
+ SetWindowPos(GetDlgItem(hwndDlg, IDC_CURRENT_SHARES), 0,
+ nSpacing,
+ 35,
+ rNewSize.right - (nSpacing * 2),
+ nCtrlHight * 2,
+ SWP_NOZORDER);
+
+ SetWindowPos(GetDlgItem(hwndDlg, IDC_CURRENT_USERS), 0,
+ nSpacing,
+ (nSpacing * 2) + nCtrlHight * 2 + 25,
+ rNewSize.right - (nSpacing * 2),
+ nCtrlHight + 35,
+ SWP_NOZORDER);
}
/////////////////////////////////////////////////////////////////////
@@ -683,11 +695,13 @@ void SetWindowsCtrls(HWND hwndDlg) {
// Developer : KN, Houdini
/////////////////////////////////////////////////////////////////////
-static INT_PTR 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: {
+ case WM_INITDIALOG:
+ {
SendMessage(hwndDlg, WM_SETICON, ICON_BIG,
- (LPARAM)LoadIcon(hInstance, MAKEINTRESOURCE(IDI_SHARE_NEW_FILE)));
+ (LPARAM)LoadIcon(hInstance, MAKEINTRESOURCE(IDI_SHARE_NEW_FILE)));
TranslateDialogDefault(hwndDlg);
@@ -747,40 +761,37 @@ static INT_PTR CALLBACK DlgProcStatsticView(HWND hwndDlg, UINT msg, WPARAM wPara
UpdateStatisticView(hwndDlg);
Utils_RestoreWindowPosition(hwndDlg, 0, MODULE, "StatWnd_");
SetWindowsCtrls(hwndDlg);
- return TRUE;
}
+ return TRUE;
- case WM_SIZE:
- case WM_SIZING: {
- SetWindowsCtrls(hwndDlg);
- return TRUE;
- }
+ case WM_SIZE:
+ case WM_SIZING:
+ SetWindowsCtrls(hwndDlg);
+ return TRUE;
- case WM_TIMER: {
- UpdateStatisticView(hwndDlg, true);
- return TRUE;
- }
+ case WM_TIMER:
+ UpdateStatisticView(hwndDlg, true);
+ return TRUE;
- case WM_RELOAD_STATISTICS: {
- UpdateStatisticView(hwndDlg);
- return TRUE;
- }
+ case WM_RELOAD_STATISTICS:
+ UpdateStatisticView(hwndDlg);
+ return TRUE;
- case WM_DESTROY: {
- hwndStatsticView = NULL;
- return 0;
- }
+ case WM_DESTROY:
+ hwndStatsticView = NULL;
+ return 0;
- case WM_DROPFILES: {
+ case WM_DROPFILES:
+ {
HDROP hDrop = (HDROP)wParam;
char szDropedFile[MAX_PATH];
- char szServPath[MAX_PATH] = {0};
+ char szServPath[MAX_PATH] = { 0 };
int nLen = DragQueryFile(hDrop, 0xFFFFFFFF, NULL, 0);
for (int i = 0; i < nLen; i++) {
DragQueryFile(hDrop, i, szDropedFile, sizeof(szDropedFile));
- STFileShareInfo stNewShare = {0};
+ STFileShareInfo stNewShare = { 0 };
stNewShare.lStructSize = sizeof(STFileShareInfo);
stNewShare.nMaxDownloads = nDefaultDownloadLimit;
stNewShare.pszRealPath = szDropedFile;
@@ -791,12 +802,12 @@ static INT_PTR CALLBACK DlgProcStatsticView(HWND hwndDlg, UINT msg, WPARAM wPara
szServPath[0] = '/';
char* fileName = strrchr(szDropedFile, '\\');
if (fileName)
- strncpy(&szServPath[1], fileName+1, MAX_PATH-2);
+ strncpy(&szServPath[1], fileName + 1, MAX_PATH - 2);
if (CallService(MS_HTTP_ADD_CHANGE_REMOVE, 0, (LPARAM)&stNewShare)) {
MessageBox(NULL, TranslateT("Failed to share new file"), MSG_BOX_TITEL, MB_OK);
return false;
- }
+ }
}
UpdateStatisticsView();
@@ -804,12 +815,13 @@ static INT_PTR CALLBACK DlgProcStatsticView(HWND hwndDlg, UINT msg, WPARAM wPara
return 0;
}
- case WM_CONTEXTMENU: {
+ case WM_CONTEXTMENU:
+ {
if (wParam != (WPARAM)GetDlgItem(hwndDlg, IDC_CURRENT_SHARES))
return FALSE;
HWND hShareList = GetDlgItem(hwndDlg, IDC_CURRENT_SHARES);
- if (ListView_GetNextItem(hShareList, -1, LVIS_SELECTED) == -1)
+ if (ListView_GetNextItem(hShareList, -1, LVIS_SELECTED) == -1)
return FALSE;
HMENU hMainMenu = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_MENU1));
@@ -839,7 +851,7 @@ static INT_PTR CALLBACK DlgProcStatsticView(HWND hwndDlg, UINT msg, WPARAM wPara
}
TranslateMenu(hMenu);
- TrackPopupMenu(hMenu, TPM_TOPALIGN | TPM_LEFTALIGN | TPM_RIGHTBUTTON,
+ TrackPopupMenu(hMenu, TPM_TOPALIGN | TPM_LEFTALIGN | TPM_RIGHTBUTTON,
pt.x, pt.y, 0, hwndDlg, NULL);
DestroyMenu(hMainMenu);
@@ -847,7 +859,8 @@ static INT_PTR CALLBACK DlgProcStatsticView(HWND hwndDlg, UINT msg, WPARAM wPara
return TRUE;
}
- case WM_COMMAND: {
+ case WM_COMMAND:
+ {
HWND hShareList = GetDlgItem(hwndDlg, IDC_CURRENT_SHARES);
char szTmp[MAX_PATH];
LVITEM sItem = { 0 };
@@ -856,19 +869,22 @@ static INT_PTR CALLBACK DlgProcStatsticView(HWND hwndDlg, UINT msg, WPARAM wPara
sItem.cchTextMax = _countof(szTmp);
switch (LOWORD(wParam)) {
- case IDC_SHOWHIDDENSHARES: {
+ case IDC_SHOWHIDDENSHARES:
+ {
UpdateStatisticView(hwndDlg);
return TRUE;
}
- case ID_SHARELIST_NEWSHARE: {
+ case ID_SHARELIST_NEWSHARE:
+ {
CallService(MS_SHARE_NEW_FILE, 0, (LPARAM)hwndDlg);
return TRUE;
}
- case ID_SHARELIST_EDITSHARE:
- case ID_SHARELIST_REMOVESHARE: {
- STFileShareInfo stShareInfo = {0};
+ case ID_SHARELIST_EDITSHARE:
+ case ID_SHARELIST_REMOVESHARE:
+ {
+ STFileShareInfo stShareInfo = { 0 };
stShareInfo.lStructSize = sizeof(STFileShareInfo);
stShareInfo.pszSrvPath = szTmp;
stShareInfo.dwMaxSrvPath = sizeof(szTmp);
@@ -876,9 +892,9 @@ static INT_PTR CALLBACK DlgProcStatsticView(HWND hwndDlg, UINT msg, WPARAM wPara
sItem.iItem = ListView_GetNextItem(hShareList, -1, LVIS_SELECTED);
while (sItem.iItem != -1) {
if (ListView_GetItem(hShareList, &sItem)) {
- if (LOWORD(wParam) == ID_SHARELIST_REMOVESHARE) {
+ if (LOWORD(wParam) == ID_SHARELIST_REMOVESHARE)
CallService(MS_HTTP_ADD_CHANGE_REMOVE, 0, (LPARAM)&stShareInfo);
- } else {
+ else {
char szRealPath[MAX_PATH];
stShareInfo.pszRealPath = szRealPath;
stShareInfo.dwMaxRealPath = sizeof(szRealPath);
@@ -892,82 +908,78 @@ static INT_PTR CALLBACK DlgProcStatsticView(HWND hwndDlg, UINT msg, WPARAM wPara
return TRUE;
}
- case ID_SHARELIST_OPEN:
- case ID_SHARELIST_COPYLINK: {
- sItem.iItem = ListView_GetNextItem(hShareList, -1, LVIS_SELECTED);
- if (sItem.iItem != -1) {
- if (ListView_GetItem(hShareList, &sItem)) {
- string sLink = sCreateLink(sItem.pszText);
- if (sLink.size() <= 0) {
- MessageBox(hwndDlg, TranslateT("Selected link size is 0"), MSG_BOX_TITEL, MB_OK);
+ case ID_SHARELIST_OPEN:
+ case ID_SHARELIST_COPYLINK:
+ sItem.iItem = ListView_GetNextItem(hShareList, -1, LVIS_SELECTED);
+ if (sItem.iItem != -1) {
+ if (ListView_GetItem(hShareList, &sItem)) {
+ string sLink = sCreateLink(sItem.pszText);
+ if (sLink.size() <= 0) {
+ MessageBox(hwndDlg, TranslateT("Selected link size is 0"), MSG_BOX_TITEL, MB_OK);
+ return TRUE;
+ }
+
+ if (LOWORD(wParam) == ID_SHARELIST_COPYLINK) {
+ if (!OpenClipboard(hwndDlg)) {
+ MessageBox(hwndDlg, TranslateT("Failed to get access to clipboard"), MSG_BOX_TITEL, MB_OK);
return TRUE;
}
- if (LOWORD(wParam) == ID_SHARELIST_COPYLINK) {
- if (!OpenClipboard(hwndDlg)) {
- MessageBox(hwndDlg, TranslateT("Failed to get access to clipboard"), MSG_BOX_TITEL, MB_OK);
- return TRUE;
- }
-
- if (!EmptyClipboard()) {
- MessageBox(hwndDlg, TranslateT("Failed to get close the clipboard"), MSG_BOX_TITEL, MB_OK);
- return TRUE;
- }
+ if (!EmptyClipboard()) {
+ MessageBox(hwndDlg, TranslateT("Failed to get close the clipboard"), MSG_BOX_TITEL, MB_OK);
+ return TRUE;
+ }
- HGLOBAL hglbCopy = GlobalAlloc(GMEM_MOVEABLE, sLink.size() + 1);
- // Lock the handle and copy the text to the buffer.
- char * lptstrCopy = (char *)GlobalLock(hglbCopy);
- mir_strcpy(lptstrCopy, sLink.c_str());
- GlobalUnlock(hglbCopy);
+ HGLOBAL hglbCopy = GlobalAlloc(GMEM_MOVEABLE, sLink.size() + 1);
+ // Lock the handle and copy the text to the buffer.
+ char * lptstrCopy = (char *)GlobalLock(hglbCopy);
+ mir_strcpy(lptstrCopy, sLink.c_str());
+ GlobalUnlock(hglbCopy);
- // Place the handle on the clipboard.
+ // Place the handle on the clipboard.
- HANDLE hMyData = SetClipboardData(CF_TEXT, hglbCopy);
- if (! hMyData)
- MessageBox(hwndDlg, TranslateT("Failed to set clipboard data"), MSG_BOX_TITEL, MB_OK);
+ HANDLE hMyData = SetClipboardData(CF_TEXT, hglbCopy);
+ if (!hMyData)
+ MessageBox(hwndDlg, TranslateT("Failed to set clipboard data"), MSG_BOX_TITEL, MB_OK);
- CloseClipboard();
- }
- else Utils_OpenUrl(sLink.c_str());
+ CloseClipboard();
}
- else MessageBox(hwndDlg, TranslateT("ListView_GetItem failed"), MSG_BOX_TITEL, MB_OK);
+ else Utils_OpenUrl(sLink.c_str());
}
- else MessageBox(hwndDlg, TranslateT("No share selected"), MSG_BOX_TITEL, MB_OK);
-
- return TRUE;
+ else MessageBox(hwndDlg, TranslateT("ListView_GetItem failed"), MSG_BOX_TITEL, MB_OK);
}
+ else MessageBox(hwndDlg, TranslateT("No share selected"), MSG_BOX_TITEL, MB_OK);
+
+ return TRUE;
}
break;
}
- case WM_CLOSE: {
- HWND hShareList = GetDlgItem(hwndDlg, IDC_CURRENT_SHARES);
- HWND hUserList = GetDlgItem(hwndDlg, IDC_CURRENT_USERS);
-
- db_set_w(NULL, MODULE, "StatWnd_cx1", (WORD)ListView_GetColumnWidth(hShareList, 0));
- db_set_w(NULL, MODULE, "StatWnd_cx2", (WORD)ListView_GetColumnWidth(hShareList, 1));
- db_set_w(NULL, MODULE, "StatWnd_cx3", (WORD)ListView_GetColumnWidth(hShareList, 2));
- db_set_w(NULL, MODULE, "StatWnd_cx4", (WORD)ListView_GetColumnWidth(hShareList, 3));
- db_set_w(NULL, MODULE, "StatWnd_cx5", (WORD)ListView_GetColumnWidth(hShareList, 4));
- db_set_w(NULL, MODULE, "StatWnd_cx6", (WORD)ListView_GetColumnWidth(hUserList, 0));
- db_set_w(NULL, MODULE, "StatWnd_cx7", (WORD)ListView_GetColumnWidth(hUserList, 1));
- db_set_w(NULL, MODULE, "StatWnd_cx8", (WORD)ListView_GetColumnWidth(hUserList, 2));
- db_set_w(NULL, MODULE, "StatWnd_cx9", (WORD)ListView_GetColumnWidth(hUserList, 3));
- db_set_w(NULL, MODULE, "StatWnd_cx10", (WORD)ListView_GetColumnWidth(hUserList, 4));
-
- bool b = IsDlgButtonChecked(hwndDlg, IDC_SHOWHIDDENSHARES) == BST_CHECKED;
- db_set_b(NULL, MODULE, "StatWnd_ShowHidden", b);
-
- Utils_SaveWindowPosition(hwndDlg, 0, MODULE, "StatWnd_");
- DestroyWindow(hwndDlg);
- return TRUE;
- }
+ case WM_CLOSE:
+ HWND hShareList = GetDlgItem(hwndDlg, IDC_CURRENT_SHARES);
+ HWND hUserList = GetDlgItem(hwndDlg, IDC_CURRENT_USERS);
+
+ db_set_w(NULL, MODULE, "StatWnd_cx1", (WORD)ListView_GetColumnWidth(hShareList, 0));
+ db_set_w(NULL, MODULE, "StatWnd_cx2", (WORD)ListView_GetColumnWidth(hShareList, 1));
+ db_set_w(NULL, MODULE, "StatWnd_cx3", (WORD)ListView_GetColumnWidth(hShareList, 2));
+ db_set_w(NULL, MODULE, "StatWnd_cx4", (WORD)ListView_GetColumnWidth(hShareList, 3));
+ db_set_w(NULL, MODULE, "StatWnd_cx5", (WORD)ListView_GetColumnWidth(hShareList, 4));
+ db_set_w(NULL, MODULE, "StatWnd_cx6", (WORD)ListView_GetColumnWidth(hUserList, 0));
+ db_set_w(NULL, MODULE, "StatWnd_cx7", (WORD)ListView_GetColumnWidth(hUserList, 1));
+ db_set_w(NULL, MODULE, "StatWnd_cx8", (WORD)ListView_GetColumnWidth(hUserList, 2));
+ db_set_w(NULL, MODULE, "StatWnd_cx9", (WORD)ListView_GetColumnWidth(hUserList, 3));
+ db_set_w(NULL, MODULE, "StatWnd_cx10", (WORD)ListView_GetColumnWidth(hUserList, 4));
+
+ bool b = IsDlgButtonChecked(hwndDlg, IDC_SHOWHIDDENSHARES) == BST_CHECKED;
+ db_set_b(NULL, MODULE, "StatWnd_ShowHidden", b);
+
+ Utils_SaveWindowPosition(hwndDlg, 0, MODULE, "StatWnd_");
+ DestroyWindow(hwndDlg);
+ return TRUE;
}
return FALSE;
- //return DefDlgProc( hwndDlg, msg, wParam, lParam );
}
-
/////////////////////////////////////////////////////////////////////
// Member Function : SendLinkToUser
// Type : Global
@@ -982,7 +994,8 @@ static INT_PTR CALLBACK DlgProcStatsticView(HWND hwndDlg, UINT msg, WPARAM wPara
// Developer : Sérgio Rolanski
/////////////////////////////////////////////////////////////////////
-void SendLinkToUser(WPARAM wParam, char *pszSrvPath) {
+void SendLinkToUser(WPARAM wParam, char *pszSrvPath)
+{
string sLink = sCreateLink(pszSrvPath);
CallService(MS_MSG_SENDMESSAGET, wParam, (LPARAM)sLink.c_str());
}
@@ -1006,10 +1019,10 @@ static INT_PTR nShareNewFile(WPARAM hContact, LPARAM lParam)
{
// used to be _MAX_PATH
// changed it since selecting multiple files requires a bigger buffer
- char szNewFile[10000] = {0};
- char szSrvPath[10000] = {0};
+ char szNewFile[10000] = { 0 };
+ char szSrvPath[10000] = { 0 };
- STFileShareInfo stNewShare = {0};
+ STFileShareInfo stNewShare = { 0 };
stNewShare.lStructSize = sizeof(STFileShareInfo);
stNewShare.nMaxDownloads = 1;
stNewShare.pszRealPath = szNewFile;
@@ -1019,13 +1032,13 @@ static INT_PTR nShareNewFile(WPARAM hContact, LPARAM lParam)
if (hContact) {
// Try to locate an IP address.
- DBVARIANT dbv = {0};
- if (! db_get(hContact, "Protocol", "p", &dbv)) {
+ DBVARIANT dbv = { 0 };
+ if (!db_get(hContact, "Protocol", "p", &dbv)) {
if (dbv.type == DBVT_ASCIIZ) {
stNewShare.dwAllowedIP = db_get_dw(hContact, dbv.pszVal, "IP", 0);
- if (! stNewShare.dwAllowedIP)
+ if (!stNewShare.dwAllowedIP)
stNewShare.dwAllowedIP = db_get_dw(hContact, dbv.pszVal, "RealIP", 0);
- if (! stNewShare.dwAllowedIP)
+ if (!stNewShare.dwAllowedIP)
stNewShare.dwAllowedIP = db_get_dw(hContact, MODULE, "LastUsedIP", 0);
}
}
@@ -1033,7 +1046,8 @@ static INT_PTR nShareNewFile(WPARAM hContact, LPARAM lParam)
stNewShare.dwAllowedMask = db_get_dw(hContact, MODULE, "LastUsedMask", 0);
}
- if (! stNewShare.dwAllowedMask) {
+
+ if (!stNewShare.dwAllowedMask) {
if (stNewShare.dwAllowedIP)
stNewShare.dwAllowedMask = 0xFFFFFFFF;
else
@@ -1057,8 +1071,8 @@ static INT_PTR nShareNewFile(WPARAM hContact, LPARAM lParam)
return 0;
}
-
-static INT_PTR nShowStatisticsView(WPARAM /*wParam*/, LPARAM /*lParam*/) {
+static INT_PTR nShowStatisticsView(WPARAM /*wParam*/, LPARAM /*lParam*/)
+{
if (hwndStatsticView) {
BringWindowToTop(hwndStatsticView);
return 0;
@@ -1068,7 +1082,6 @@ static INT_PTR nShowStatisticsView(WPARAM /*wParam*/, LPARAM /*lParam*/) {
return 0;
}
-
/////////////////////////////////////////////////////////////////////
// Member Function : OptionsDlgProc
// Type : Global
@@ -1085,233 +1098,230 @@ static INT_PTR nShowStatisticsView(WPARAM /*wParam*/, LPARAM /*lParam*/) {
// Developer : KN, Houdini
/////////////////////////////////////////////////////////////////////
-static INT_PTR 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);
- SetDlgItemText(hwndDlg, IDC_EXTERNAL_SRV_NAME, sDefExt.c_str());
-
- bool b = db_get_b(NULL, MODULE, "AddStatisticsMenuItem", 1) != 0;
- CheckDlgButton(hwndDlg, IDC_ADD_STATISTICS_MENU_ITEM, b ? BST_CHECKED : BST_UNCHECKED);
+ case WM_INITDIALOG:
+ {
+ string sDefExt = DBGetString(NULL, MODULE, "ExternalSrvName", szDefaultExternalSrvName);
+ SetDlgItemText(hwndDlg, IDC_EXTERNAL_SRV_NAME, sDefExt.c_str());
+
+ bool b = db_get_b(NULL, MODULE, "AddStatisticsMenuItem", 1) != 0;
+ CheckDlgButton(hwndDlg, IDC_ADD_STATISTICS_MENU_ITEM, b ? BST_CHECKED : BST_UNCHECKED);
+
+ b = db_get_b(NULL, MODULE, "AddAcceptConMenuItem", 1) != 0;
+ CheckDlgButton(hwndDlg, IDC_ACCEPT_COM_MENU_ITEM, b ? BST_CHECKED : BST_UNCHECKED);
+
+ b = db_get_b(NULL, MODULE, "WriteLogFile", 0) != 0;
+ CheckDlgButton(hwndDlg, IDC_WRITE_LOG_FILE, b ? BST_CHECKED : BST_UNCHECKED);
+
+ CheckDlgButton(hwndDlg, IDC_SHOW_POPUPS, bShowPopups ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_LIMIT_ONLY_WHEN_ONLINE, bLimitOnlyWhenOnline ? BST_CHECKED : BST_UNCHECKED);
+
+
+ {// Url Address
+ SetDlgItemText(hwndDlg, IDC_URL_ADDRESS, sUrlAddress.c_str());
+ HWND hComboBox = GetDlgItem(hwndDlg, IDC_URL_ADDRESS);
+ SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)_T("http://checkip.dyndns.org"));
+ SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)_T("http://checkip.dyndns.org:8245/"));
+ SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)_T("http://dynamic.zoneedit.com/checkip.html"));
+ SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)_T("http://ipdetect.dnspark.com/"));
+ SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)_T("http://update.dynu.com/basic/ipcheck.asp"));
+ SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)_T("http://www.dnsart.com/myip.php"));
+ SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)_T("http://www.dnsart.com:7777/myip.php"));
+ }
- b = db_get_b(NULL, MODULE, "AddAcceptConMenuItem", 1) != 0;
- CheckDlgButton(hwndDlg, IDC_ACCEPT_COM_MENU_ITEM, b ? BST_CHECKED : BST_UNCHECKED);
+ {// Page keyword
+ SetDlgItemText(hwndDlg, IDC_PAGE_KEYWORD, sPageKeyword.c_str());
+ HWND hComboBox = GetDlgItem(hwndDlg, IDC_PAGE_KEYWORD);
+ SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)"");
+ SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)LPGENT("Current IP Address: "));
+ SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)LPGENT("Current Address: "));
+ SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)LPGENT("IP Address: "));
+ SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)LPGENT("You are browsing from"));
+ SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)_T("<HTML><BODY>"));
+ }
- b = db_get_b(NULL, MODULE, "WriteLogFile", 0) != 0;
- CheckDlgButton(hwndDlg, IDC_WRITE_LOG_FILE, b ? BST_CHECKED : BST_UNCHECKED);
+ SetDlgItemInt(hwndDlg, IDC_MAX_SPEED, nMaxUploadSpeed >> 10, true);
+ SetDlgItemInt(hwndDlg, IDC_MAX_CONN_TOTAL, nMaxConnectionsTotal, true);
+ SetDlgItemInt(hwndDlg, IDC_MAX_CONN_PER_USER, nMaxConnectionsPerUser, true);
+ SetDlgItemInt(hwndDlg, IDC_DEFAULT_DOWNLOAD_LIMIT, nDefaultDownloadLimit, true);
- CheckDlgButton(hwndDlg, IDC_SHOW_POPUPS, bShowPopups ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_LIMIT_ONLY_WHEN_ONLINE, bLimitOnlyWhenOnline ? BST_CHECKED : BST_UNCHECKED);
+ indexCreationMode =
+ (eIndexCreationMode)db_get_b(NULL, MODULE, "IndexCreationMode", 3);
+ switch (indexCreationMode) {
+ case INDEX_CREATION_HTML:
+ CheckRadioButton(hwndDlg, IDC_INDEX_OFF, IDC_INDEX_DETECT, IDC_INDEX_HTML);
+ break;
+ case INDEX_CREATION_XML:
+ CheckRadioButton(hwndDlg, IDC_INDEX_OFF, IDC_INDEX_DETECT, IDC_INDEX_XML);
+ break;
+ case INDEX_CREATION_DETECT:
+ CheckRadioButton(hwndDlg, IDC_INDEX_OFF, IDC_INDEX_DETECT, IDC_INDEX_DETECT);
+ break;
+ default: // INDEX_CREATION_DISABLE
+ CheckRadioButton(hwndDlg, IDC_INDEX_OFF, IDC_INDEX_DETECT, IDC_INDEX_OFF);
+ break;
+ }
- {// Url Address
- SetDlgItemText(hwndDlg, IDC_URL_ADDRESS, sUrlAddress.c_str());
- HWND hComboBox = GetDlgItem(hwndDlg, IDC_URL_ADDRESS);
- SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)_T("http://checkip.dyndns.org"));
- SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)_T("http://checkip.dyndns.org:8245/"));
- SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)_T("http://dynamic.zoneedit.com/checkip.html"));
- SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)_T("http://ipdetect.dnspark.com/"));
- SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)_T("http://update.dynu.com/basic/ipcheck.asp"));
- SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)_T("http://www.dnsart.com/myip.php"));
- SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)_T("http://www.dnsart.com:7777/myip.php"));
- }
+ TranslateDialogDefault(hwndDlg);
+ }
+ return TRUE;
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDC_MAX_SPEED:
+ case IDC_MAX_CONN_PER_USER:
+ case IDC_MAX_CONN_TOTAL:
+ case IDC_EXTERNAL_SRV_NAME:
+ if (HIWORD(wParam) == EN_CHANGE)
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ return TRUE;
- {// Page keyword
- SetDlgItemText(hwndDlg, IDC_PAGE_KEYWORD, sPageKeyword.c_str());
- HWND hComboBox = GetDlgItem(hwndDlg, IDC_PAGE_KEYWORD);
- SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)"");
- SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)LPGENT("Current IP Address: "));
- SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)LPGENT("Current Address: "));
- SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)LPGENT("IP Address: "));
- SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)LPGENT("You are browsing from"));
- SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)_T("<HTML><BODY>"));
- }
+ case IDC_URL_ADDRESS:
+ case IDC_PAGE_KEYWORD:
+ if (HIWORD(wParam) == CBN_EDITUPDATE || HIWORD(wParam) == CBN_SELCHANGE)
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ return TRUE;
- SetDlgItemInt(hwndDlg, IDC_MAX_SPEED, nMaxUploadSpeed >> 10, true);
- SetDlgItemInt(hwndDlg, IDC_MAX_CONN_TOTAL, nMaxConnectionsTotal, true);
- SetDlgItemInt(hwndDlg, IDC_MAX_CONN_PER_USER, nMaxConnectionsPerUser, true);
- SetDlgItemInt(hwndDlg, IDC_DEFAULT_DOWNLOAD_LIMIT, nDefaultDownloadLimit, true);
-
- indexCreationMode =
- (eIndexCreationMode)db_get_b(NULL, MODULE, "IndexCreationMode", 3);
-
- switch (indexCreationMode) {
- case INDEX_CREATION_HTML:
- CheckRadioButton(hwndDlg, IDC_INDEX_OFF, IDC_INDEX_DETECT, IDC_INDEX_HTML);
- break;
- case INDEX_CREATION_XML:
- CheckRadioButton(hwndDlg, IDC_INDEX_OFF, IDC_INDEX_DETECT, IDC_INDEX_XML);
- break;
- case INDEX_CREATION_DETECT:
- CheckRadioButton(hwndDlg, IDC_INDEX_OFF, IDC_INDEX_DETECT, IDC_INDEX_DETECT);
- break;
- default: // INDEX_CREATION_DISABLE
- CheckRadioButton(hwndDlg, IDC_INDEX_OFF, IDC_INDEX_DETECT, IDC_INDEX_OFF);
- break;
- }
+ case IDC_INDEX_HTML:
+ case IDC_INDEX_OFF:
+ case IDC_INDEX_XML:
+ case IDC_INDEX_DETECT:
+ case IDC_LIMIT_ONLY_WHEN_ONLINE:
+ case IDC_SHOW_POPUPS:
+ case IDC_WRITE_LOG_FILE:
+ case IDC_ADD_STATISTICS_MENU_ITEM:
+ case IDC_ACCEPT_COM_MENU_ITEM:
+ if (HIWORD(wParam) == BN_CLICKED)
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ return TRUE;
- TranslateDialogDefault(hwndDlg);
- return TRUE;
+ case IDC_EXTERNAL_SRV_DEFAULT:
+ if (HIWORD(wParam) == BN_CLICKED) {
+ SetDlgItemText(hwndDlg, IDC_EXTERNAL_SRV_NAME, szDefaultExternalSrvName);
+ SetDlgItemText(hwndDlg, IDC_URL_ADDRESS, szDefaultUrlAddress);
+ SetDlgItemText(hwndDlg, IDC_PAGE_KEYWORD, szDefaultPageKeyword);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
- case WM_COMMAND: {
- switch (LOWORD(wParam)) {
- case IDC_MAX_SPEED:
- case IDC_MAX_CONN_PER_USER:
- case IDC_MAX_CONN_TOTAL:
- case IDC_EXTERNAL_SRV_NAME: {
- if (HIWORD(wParam) == EN_CHANGE)
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- return TRUE;
- }
- case IDC_URL_ADDRESS:
- case IDC_PAGE_KEYWORD: {
- /*if( !bWindowTextSet )
- return TRUE;*/
+ return TRUE;
- if (HIWORD(wParam) == CBN_EDITUPDATE || HIWORD(wParam) == CBN_SELCHANGE) {
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- }
- return TRUE;
- }
+ case IDC_OPEN_LOG:
+ bOpenLogFile();
+ return TRUE;
- case IDC_INDEX_HTML:
- case IDC_INDEX_OFF:
- case IDC_INDEX_XML:
- case IDC_INDEX_DETECT:
- case IDC_LIMIT_ONLY_WHEN_ONLINE:
- case IDC_SHOW_POPUPS:
- case IDC_WRITE_LOG_FILE:
- case IDC_ADD_STATISTICS_MENU_ITEM:
- case IDC_ACCEPT_COM_MENU_ITEM: {
- if (HIWORD(wParam) == BN_CLICKED) {
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- }
- return TRUE;
- }
- case IDC_EXTERNAL_SRV_DEFAULT: {
- if (HIWORD(wParam) == BN_CLICKED) {
- SetDlgItemText(hwndDlg, IDC_EXTERNAL_SRV_NAME, szDefaultExternalSrvName);
- SetDlgItemText(hwndDlg, IDC_URL_ADDRESS, szDefaultUrlAddress);
- SetDlgItemText(hwndDlg, IDC_PAGE_KEYWORD, szDefaultPageKeyword);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- }
- return TRUE;
- }
- case IDC_OPEN_LOG: {
- bOpenLogFile();
- return TRUE;
- }
- case IDC_TEST_EXTERNALIP: {
- char szUrl[ 500 ];
- char szKeyWord[ 1000 ];
- GetDlgItemText(hwndDlg, IDC_URL_ADDRESS, szUrl, _countof(szUrl));
- GetDlgItemText(hwndDlg, IDC_PAGE_KEYWORD, szKeyWord, _countof(szKeyWord));
- DWORD dwExternalIP = GetExternIP(szUrl, szKeyWord);
-
- mir_snprintf(szKeyWord, Translate("Your external IP was detected as %d.%d.%d.%d\r\nby: %s") ,
- SplitIpAddress(dwExternalIP) ,
- szUrl);
- MessageBox(hwndDlg, szKeyWord, MSG_BOX_TITEL, MB_OK);
- }
+ case IDC_TEST_EXTERNALIP:
+ char szUrl[500];
+ char szKeyWord[1000];
+ GetDlgItemText(hwndDlg, IDC_URL_ADDRESS, szUrl, _countof(szUrl));
+ GetDlgItemText(hwndDlg, IDC_PAGE_KEYWORD, szKeyWord, _countof(szKeyWord));
+ DWORD dwExternalIP = GetExternIP(szUrl, szKeyWord);
+
+ mir_snprintf(szKeyWord, Translate("Your external IP was detected as %d.%d.%d.%d\r\nby: %s"),
+ SplitIpAddress(dwExternalIP),
+ szUrl);
+ MessageBox(hwndDlg, szKeyWord, MSG_BOX_TITEL, MB_OK);
+ }
+ break;
+
+ case WM_NOTIFY:
+ NMHDR * p = ((LPNMHDR)lParam);
+ switch (p->code) {
+ case PSN_APPLY:
+ {
+ char szTemp[500];
+ if (GetDlgItemText(hwndDlg, IDC_EXTERNAL_SRV_NAME, szTemp, _countof(szTemp)))
+ db_set_s(NULL, MODULE, "ExternalSrvName", szTemp);
+
+ bool b = db_get_b(NULL, MODULE, "AddStatisticsMenuItem", 1) != 0;
+ bool bNew = IsDlgButtonChecked(hwndDlg, IDC_ADD_STATISTICS_MENU_ITEM) == BST_CHECKED;
+ if (b != bNew) {
+ db_set_b(NULL, MODULE, "AddStatisticsMenuItem", bNew);
+ MessageBox(hwndDlg, TranslateT("You need to restart Miranda to change the main menu"), MSG_BOX_TITEL, MB_OK);
}
- break;
- }
- case WM_NOTIFY: {
- NMHDR * p = ((LPNMHDR)lParam);
- switch (p->code) {
- case PSN_APPLY: {
- char szTemp[ 500 ];
- if (GetDlgItemText(hwndDlg, IDC_EXTERNAL_SRV_NAME, szTemp, _countof(szTemp)))
- db_set_s(NULL, MODULE, "ExternalSrvName", szTemp);
-
- bool b = db_get_b(NULL, MODULE, "AddStatisticsMenuItem", 1) != 0;
- bool bNew = IsDlgButtonChecked(hwndDlg, IDC_ADD_STATISTICS_MENU_ITEM) == BST_CHECKED;
- if (b != bNew) {
- db_set_b(NULL, MODULE, "AddStatisticsMenuItem", bNew);
- MessageBox(hwndDlg, TranslateT("You need to restart Miranda to change the main menu"), MSG_BOX_TITEL, MB_OK);
- }
- b = db_get_b(NULL, MODULE, "AddAcceptConMenuItem", 1) != 0;
- bNew = IsDlgButtonChecked(hwndDlg, IDC_ACCEPT_COM_MENU_ITEM) == BST_CHECKED;
- if (b != bNew) {
- db_set_b(NULL, MODULE, "AddAcceptConMenuItem", bNew);
- MessageBox(hwndDlg, TranslateT("You need to restart Miranda to change the main menu"), MSG_BOX_TITEL, MB_OK);
- }
+ b = db_get_b(NULL, MODULE, "AddAcceptConMenuItem", 1) != 0;
+ bNew = IsDlgButtonChecked(hwndDlg, IDC_ACCEPT_COM_MENU_ITEM) == BST_CHECKED;
+ if (b != bNew) {
+ db_set_b(NULL, MODULE, "AddAcceptConMenuItem", bNew);
+ 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;
- db_set_b(NULL, MODULE, "WriteLogFile", bNew);
+ bNew = IsDlgButtonChecked(hwndDlg, IDC_WRITE_LOG_FILE) == BST_CHECKED;
+ db_set_b(NULL, MODULE, "WriteLogFile", bNew);
- bShowPopups = IsDlgButtonChecked(hwndDlg, IDC_SHOW_POPUPS) == BST_CHECKED;
- db_set_b(NULL, MODULE, "ShowPopups", bShowPopups);
+ bShowPopups = IsDlgButtonChecked(hwndDlg, IDC_SHOW_POPUPS) == BST_CHECKED;
+ db_set_b(NULL, MODULE, "ShowPopups", bShowPopups);
- GetDlgItemText(hwndDlg, IDC_URL_ADDRESS, szTemp, _countof(szTemp));
- sUrlAddress = szTemp;
- db_set_s(NULL, MODULE, "UrlAddress", sUrlAddress.c_str());
+ GetDlgItemText(hwndDlg, IDC_URL_ADDRESS, szTemp, _countof(szTemp));
+ sUrlAddress = szTemp;
+ db_set_s(NULL, MODULE, "UrlAddress", sUrlAddress.c_str());
- GetDlgItemText(hwndDlg, IDC_PAGE_KEYWORD, szTemp, _countof(szTemp));
- sPageKeyword = szTemp;
- db_set_s(NULL, MODULE, "PageKeyword", sPageKeyword.c_str());
- dwExternalIpAddress = 0;
+ GetDlgItemText(hwndDlg, IDC_PAGE_KEYWORD, szTemp, _countof(szTemp));
+ sPageKeyword = szTemp;
+ db_set_s(NULL, MODULE, "PageKeyword", sPageKeyword.c_str());
+ dwExternalIpAddress = 0;
- BOOL bTranslated = false;
- int nTemp = GetDlgItemInt(hwndDlg, IDC_MAX_SPEED, &bTranslated, true);
- if (bTranslated) {
- nMaxUploadSpeed = nTemp << 10;
- db_set_dw(NULL, MODULE, "MaxUploadSpeed", nMaxUploadSpeed);
- }
+ BOOL bTranslated = false;
+ int nTemp = GetDlgItemInt(hwndDlg, IDC_MAX_SPEED, &bTranslated, true);
+ if (bTranslated) {
+ nMaxUploadSpeed = nTemp << 10;
+ db_set_dw(NULL, MODULE, "MaxUploadSpeed", nMaxUploadSpeed);
+ }
- nTemp = GetDlgItemInt(hwndDlg, IDC_MAX_CONN_TOTAL, &bTranslated, true);
- if (bTranslated) {
- nMaxConnectionsTotal = nTemp;
- db_set_dw(NULL, MODULE, "MaxConnectionsTotal", nMaxConnectionsTotal);
- }
+ nTemp = GetDlgItemInt(hwndDlg, IDC_MAX_CONN_TOTAL, &bTranslated, true);
+ if (bTranslated) {
+ nMaxConnectionsTotal = nTemp;
+ db_set_dw(NULL, MODULE, "MaxConnectionsTotal", nMaxConnectionsTotal);
+ }
- nTemp = GetDlgItemInt(hwndDlg, IDC_MAX_CONN_PER_USER, &bTranslated, true);
- if (bTranslated) {
- nMaxConnectionsPerUser = nTemp;
- db_set_dw(NULL, MODULE, "MaxConnectionsPerUser", nMaxConnectionsPerUser);
- }
+ nTemp = GetDlgItemInt(hwndDlg, IDC_MAX_CONN_PER_USER, &bTranslated, true);
+ if (bTranslated) {
+ nMaxConnectionsPerUser = nTemp;
+ db_set_dw(NULL, MODULE, "MaxConnectionsPerUser", nMaxConnectionsPerUser);
+ }
- nTemp = GetDlgItemInt(hwndDlg, IDC_DEFAULT_DOWNLOAD_LIMIT, &bTranslated, true);
- if (bTranslated) {
- nDefaultDownloadLimit = nTemp;
- db_set_dw(NULL, MODULE, "DefaultDownloadLimit", nDefaultDownloadLimit);
- }
+ nTemp = GetDlgItemInt(hwndDlg, IDC_DEFAULT_DOWNLOAD_LIMIT, &bTranslated, true);
+ if (bTranslated) {
+ nDefaultDownloadLimit = nTemp;
+ db_set_dw(NULL, MODULE, "DefaultDownloadLimit", nDefaultDownloadLimit);
+ }
- bLimitOnlyWhenOnline = IsDlgButtonChecked(hwndDlg, IDC_LIMIT_ONLY_WHEN_ONLINE) == BST_CHECKED;
- db_set_b(NULL, MODULE, "LimitOnlyWhenOnline", bLimitOnlyWhenOnline);
-
- if (IsDlgButtonChecked(hwndDlg, IDC_INDEX_HTML) == BST_CHECKED ||
- IsDlgButtonChecked(hwndDlg, IDC_INDEX_DETECT) == BST_CHECKED) {
- if (IsDlgButtonChecked(hwndDlg, IDC_INDEX_HTML) == BST_CHECKED)
- indexCreationMode = INDEX_CREATION_HTML;
- else
- indexCreationMode = INDEX_CREATION_DETECT;
-
- if (!LoadIndexHTMLTemplate()) {
- CheckRadioButton(hwndDlg, IDC_INDEX_OFF, IDC_INDEX_XML, IDC_INDEX_OFF);
- indexCreationMode = INDEX_CREATION_DISABLE;
- }
- } else if (IsDlgButtonChecked(hwndDlg, IDC_INDEX_XML) == BST_CHECKED) {
- FreeIndexHTMLTemplate();
- indexCreationMode = INDEX_CREATION_XML;
- } else {
- FreeIndexHTMLTemplate();
- indexCreationMode = INDEX_CREATION_DISABLE;
- }
+ bLimitOnlyWhenOnline = IsDlgButtonChecked(hwndDlg, IDC_LIMIT_ONLY_WHEN_ONLINE) == BST_CHECKED;
+ db_set_b(NULL, MODULE, "LimitOnlyWhenOnline", bLimitOnlyWhenOnline);
- db_set_b(NULL, MODULE, "IndexCreationMode", (BYTE)indexCreationMode);
+ if (IsDlgButtonChecked(hwndDlg, IDC_INDEX_HTML) == BST_CHECKED ||
+ IsDlgButtonChecked(hwndDlg, IDC_INDEX_DETECT) == BST_CHECKED) {
+ if (IsDlgButtonChecked(hwndDlg, IDC_INDEX_HTML) == BST_CHECKED)
+ indexCreationMode = INDEX_CREATION_HTML;
+ else
+ indexCreationMode = INDEX_CREATION_DETECT;
- return TRUE;
- }
+ if (!LoadIndexHTMLTemplate()) {
+ CheckRadioButton(hwndDlg, IDC_INDEX_OFF, IDC_INDEX_XML, IDC_INDEX_OFF);
+ indexCreationMode = INDEX_CREATION_DISABLE;
+ }
}
- break;
+ else if (IsDlgButtonChecked(hwndDlg, IDC_INDEX_XML) == BST_CHECKED) {
+ FreeIndexHTMLTemplate();
+ indexCreationMode = INDEX_CREATION_XML;
+ }
+ else {
+ FreeIndexHTMLTemplate();
+ indexCreationMode = INDEX_CREATION_DISABLE;
+ }
+
+ db_set_b(NULL, MODULE, "IndexCreationMode", (BYTE)indexCreationMode);
+
+ return TRUE;
}
+ break;
+ }
}
return FALSE;
}
-
/////////////////////////////////////////////////////////////////////
// Member Function : OptionsInitialize
// Type : Global
@@ -1332,11 +1342,11 @@ int OptionsInitialize(WPARAM wParam, LPARAM /*lParam*/)
odp.position = 900000000;
odp.hInstance = hInstance;
odp.pszTemplate = MAKEINTRESOURCE(IDD_OPT_HTTP_SERVER);
- odp.flags = ODPF_BOLDGROUPS|ODPF_TCHAR;
+ odp.flags = ODPF_BOLDGROUPS | ODPF_TCHAR;
odp.ptszTitle = LPGENT("HTTP Server");
odp.ptszGroup = LPGENT("Network");
odp.pfnDlgProc = OptionsDlgProc;
- Options_AddPage(wParam,&odp);
+ Options_AddPage(wParam, &odp);
return 0;
}
@@ -1354,11 +1364,12 @@ int OptionsInitialize(WPARAM wParam, LPARAM /*lParam*/)
// Developer : KN
/////////////////////////////////////////////////////////////////////
-void CALLBACK MainThreadCallback(ULONG_PTR dwParam) {
+void CALLBACK MainThreadCallback(ULONG_PTR dwParam)
+{
POPUPDATAT *pclData = (POPUPDATAT*)dwParam;
- if (db_get_b(NULL, MODULE, "WriteLogFile", 0) != 0) {
+ if (db_get_b(NULL, MODULE, "WriteLogFile", 0) != 0)
LogEvent(pclData->lpzContactName, pclData->lpzText);
- }
+
PUAddPopupT(pclData);
delete pclData;
}
@@ -1379,7 +1390,8 @@ void CALLBACK MainThreadCallback(ULONG_PTR dwParam) {
// Developer : KN, Houdini
/////////////////////////////////////////////////////////////////////
-void CALLBACK OpenStatisticViewFromPopupProc(ULONG_PTR /* dwParam */) {
+void CALLBACK OpenStatisticViewFromPopupProc(ULONG_PTR /* dwParam */)
+{
nShowStatisticsView(0, 0);
}
@@ -1390,17 +1402,16 @@ LRESULT CALLBACK PopupWindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM
switch (message) {
case WM_LBUTTONDOWN:
QueueUserAPC(OpenStatisticViewFromPopupProc, hMainThread, 0);
- PUDeletePopup( hWnd );
+ PUDeletePopup(hWnd);
return 0;
case WM_CONTEXTMENU:
- PUDeletePopup( hWnd );
+ PUDeletePopup(hWnd);
return 0;
}
return DefWindowProc(hWnd, message, wParam, lParam);
}
-
/////////////////////////////////////////////////////////////////////
// Member Function : ShowPopupWindow
// Type : Global
@@ -1414,13 +1425,14 @@ LRESULT CALLBACK PopupWindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM
// Developer : KN
/////////////////////////////////////////////////////////////////////
-void ShowPopupWindow(const char * pszName, const char * pszText, COLORREF ColorBack /*= 0*/) {
- if (! bShowPopups)
+void ShowPopupWindow(const char * pszName, const char * pszText, COLORREF ColorBack /*= 0*/)
+{
+ if (!bShowPopups)
return;
POPUPDATAT *pclData = new POPUPDATAT;
memset(pclData, 0, sizeof(POPUPDATAT));
- pclData->lchIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_SHARE_NEW_FILE));
+ pclData->lchIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_SHARE_NEW_FILE));
strncpy(pclData->lpzContactName, pszName, sizeof(pclData->lpzContactName) - 1); // -1 so that there aways will be a null termination !!
strncpy(pclData->lpzText, pszText, sizeof(pclData->lpzText) - 1);
pclData->colorBack = ColorBack;
diff --git a/plugins/HTTPServer/src/HttpUser.cpp b/plugins/HTTPServer/src/HttpUser.cpp
index b31694142a..99c8113042 100644
--- a/plugins/HTTPServer/src/HttpUser.cpp
+++ b/plugins/HTTPServer/src/HttpUser.cpp
@@ -31,7 +31,8 @@
// Developer : KN
/////////////////////////////////////////////////////////////////////
-void FileTimeToUnixTime(LPFILETIME pft, time_t* t) {
+void FileTimeToUnixTime(LPFILETIME pft, time_t* t)
+{
LONGLONG ll = ((LONGLONG)pft->dwHighDateTime) << 32;
ll = ll + pft->dwLowDateTime - 116444736000000000;
*t = (time_t)(ll / 10000000);
@@ -51,8 +52,9 @@ void FileTimeToUnixTime(LPFILETIME pft, time_t* t) {
// Developer : KN
/////////////////////////////////////////////////////////////////////
-static int nUnescapedURI(char * pszURI) {
- if (! pszURI)
+static int nUnescapedURI(char * pszURI)
+{
+ if (!pszURI)
return 0;
char * pszOrigURI = pszURI;
@@ -60,7 +62,7 @@ static int nUnescapedURI(char * pszURI) {
int more = -1;
char* pszCurInsert = pszURI;
- for (; *pszURI && pszURI[0] != ' ' ; pszURI++) {
+ for (; *pszURI && pszURI[0] != ' '; pszURI++) {
int nNewChar;
if (pszURI[0] == '%') {
// we need to unescape the char
@@ -92,25 +94,30 @@ static int nUnescapedURI(char * pszURI) {
}
if ((nNewChar & 0xc0) == 0x80) { // 10xxxxxx (continuation byte)
- sumb = (sumb << 6) | (nNewChar & 0x3f) ; // Add 6 bits to sumb
+ sumb = (sumb << 6) | (nNewChar & 0x3f); // Add 6 bits to sumb
more--;
if (more == 0) {
*pszCurInsert = (char)sumb; // here we just throw away all the fine UTF-8 encoding
pszCurInsert++;
}
- } else if ((nNewChar & 0xe0) == 0xc0) { // 110xxxxx (yields 5 bits)
+ }
+ else if ((nNewChar & 0xe0) == 0xc0) { // 110xxxxx (yields 5 bits)
sumb = nNewChar & 0x1f;
more = 1; // Expect 1 more byte
- } else if ((nNewChar & 0xf0) == 0xe0) { // 1110xxxx (yields 4 bits)
+ }
+ else if ((nNewChar & 0xf0) == 0xe0) { // 1110xxxx (yields 4 bits)
sumb = nNewChar & 0x0f;
more = 2; // Expect 2 more bytes
- } else if ((nNewChar & 0xf8) == 0xf0) { // 11110xxx (yields 3 bits)
+ }
+ else if ((nNewChar & 0xf8) == 0xf0) { // 11110xxx (yields 3 bits)
sumb = nNewChar & 0x07;
more = 3; // Expect 3 more bytes
- } else if ((nNewChar & 0xfc) == 0xf8) { // 111110xx (yields 2 bits)
+ }
+ else if ((nNewChar & 0xfc) == 0xf8) { // 111110xx (yields 2 bits)
sumb = nNewChar & 0x03;
more = 4; // Expect 4 more bytes
- } else /*if ((nNewChar & 0xfe) == 0xfc)*/
+ }
+ else /*if ((nNewChar & 0xfe) == 0xfc)*/
{ // 1111110x (yields 1 bit)
sumb = nNewChar & 0x01;
more = 5; // Expect 5 more bytes
@@ -135,7 +142,8 @@ static int nUnescapedURI(char * pszURI) {
// Developer : KN
/////////////////////////////////////////////////////////////////////
-CLHttpUser::CLHttpUser(HANDLE hCon, in_addr stAdd) : CLShareUser(hCon, stAdd) {
+CLHttpUser::CLHttpUser(HANDLE hCon, in_addr stAdd) : CLShareUser(hCon, stAdd)
+{
memset(apszParam, 0, sizeof(apszParam));
hFile = INVALID_HANDLE_VALUE;
}
@@ -154,7 +162,8 @@ CLHttpUser::CLHttpUser(HANDLE hCon, in_addr stAdd) : CLShareUser(hCon, stAdd) {
// Developer : KN
/////////////////////////////////////////////////////////////////////
-CLHttpUser::~CLHttpUser() {
+CLHttpUser::~CLHttpUser()
+{
if (hFile != INVALID_HANDLE_VALUE)
CloseHandle(hFile);
}
@@ -172,9 +181,10 @@ CLHttpUser::~CLHttpUser() {
// Developer : KN
/////////////////////////////////////////////////////////////////////
-bool CLHttpUser::bReadGetParameters(char * pszRequest) {
+bool CLHttpUser::bReadGetParameters(char * pszRequest)
+{
bool bRet = true;
- for (; *pszRequest ; pszRequest++) {
+ for (; *pszRequest; pszRequest++) {
if (pszRequest[0] != '\n') {
if (pszRequest[0] == '\r')
pszRequest[0] = 0;
@@ -182,13 +192,14 @@ bool CLHttpUser::bReadGetParameters(char * pszRequest) {
}
pszRequest[0] = 0;
pszRequest++;
- for (int nCur = 0; nCur < eLastParam ; nCur++) {
+ for (int nCur = 0; nCur < eLastParam; nCur++) {
int nLen = (int)mir_strlen(szParmStr[nCur]);
if (strncmp(pszRequest, szParmStr[nCur], nLen) == 0) {
if (apszParam[nCur]) {
bRet = false;
// already set !!
- } else {
+ }
+ else {
pszRequest += nLen;
apszParam[nCur] = pszRequest;
pszRequest += strcspn(pszRequest, "\r\n") - 1;
@@ -221,8 +232,9 @@ bool CLHttpUser::bReadGetParameters(char * pszRequest) {
// Changed : 21 January 2006 by Vampik
/////////////////////////////////////////////////////////////////////
-void CLHttpUser::SendError(int iErrorCode, const char * pszError, const char * pszDescription) {
- char szCurTime[ 100 ];
+void CLHttpUser::SendError(int iErrorCode, const char * pszError, const char * pszDescription)
+{
+ char szCurTime[100];
time_t ltime;
time(&ltime);
strftime(szCurTime, sizeof(szCurTime), "%a, %d %b %Y %H:%M:%S GMT", gmtime(&ltime));
@@ -232,25 +244,25 @@ void CLHttpUser::SendError(int iErrorCode, const char * pszError, const char * p
char szBuf[1000];
DWORD dwBytesToWrite = mir_snprintf(szBuf,
- "HTTP/1.1 %i %s\r\n"
- "Date: %s\r\n"
- "Server: MirandaWeb/%s\r\n"
- "Transfer-Encoding: chunked\r\n"
- "Content-Type: text/html; charset=iso-8859-1\r\n"
- "\r\n"
- "10f\r\n"
- "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n"
- "<HTML><HEAD>\n"
- "<TITLE>%i %s</TITLE>\n"
- "</HEAD><BODY>\n"
- "<H1>%s</H1>\n"
- "%s<P>\n"
- "<HR>\n"
- "<ADDRESS>MirandaWeb/%s</ADDRESS>\n"
- "</BODY></HTML>\n"
- "\r\n"
- "\r\n",
- iErrorCode, pszError, szCurTime, PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM), iErrorCode, pszError, pszError, pszDescription, PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM));
+ "HTTP/1.1 %i %s\r\n"
+ "Date: %s\r\n"
+ "Server: MirandaWeb/%s\r\n"
+ "Transfer-Encoding: chunked\r\n"
+ "Content-Type: text/html; charset=iso-8859-1\r\n"
+ "\r\n"
+ "10f\r\n"
+ "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n"
+ "<HTML><HEAD>\n"
+ "<TITLE>%i %s</TITLE>\n"
+ "</HEAD><BODY>\n"
+ "<H1>%s</H1>\n"
+ "%s<P>\n"
+ "<HR>\n"
+ "<ADDRESS>MirandaWeb/%s</ADDRESS>\n"
+ "</BODY></HTML>\n"
+ "\r\n"
+ "\r\n",
+ iErrorCode, pszError, szCurTime, __VERSION_STRING_DOTS, iErrorCode, pszError, pszError, pszDescription, __VERSION_STRING_DOTS);
Netlib_Send(hConnection, szBuf, dwBytesToWrite, 0);
}
@@ -271,8 +283,9 @@ void CLHttpUser::SendError(int iErrorCode, const char * pszError, const char * p
// Developer : KN, Houdini, Vampik
/////////////////////////////////////////////////////////////////////
-void CLHttpUser::SendRedir(int iErrorCode, const char * pszError, const char * pszDescription, const char * pszRedirect) {
- char szCurrTime[ 100 ];
+void CLHttpUser::SendRedir(int iErrorCode, const char * pszError, const char * pszDescription, const char * pszRedirect)
+{
+ char szCurrTime[100];
time_t ltime;
time(&ltime);
strftime(szCurrTime, sizeof(szCurrTime), "%a, %d %b %Y %H:%M:%S GMT", gmtime(&ltime));
@@ -282,26 +295,26 @@ void CLHttpUser::SendRedir(int iErrorCode, const char * pszError, const char * p
char szBuff[1000];
DWORD dwBytesToWrite = mir_snprintf(szBuff,
- "HTTP/1.1 %i %s\r\n"
- "Date: %s\r\n"
- "Server: MirandaWeb/%s\r\n"
- "Location: %s/\r\n"
- "Transfer-Encoding: chunked\r\n"
- "Content-Type: text/html; charset=iso-8859-1\r\n"
- "\r\n"
- "10f\r\n"
- "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n"
- "<HTML><HEAD>\n"
- "<TITLE>%i %s</TITLE>\n"
- "</HEAD><BODY>\n"
- "<H1>%s</H1>\n"
- "%s<P>\n"
- "<HR>\n"
- "<ADDRESS>MirandaWeb/%s</ADDRESS>\n"
- "</BODY></HTML>\n"
- "\r\n"
- "\r\n",
- iErrorCode, pszError, szCurrTime, PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM), pszRedirect, iErrorCode, pszError, pszError, pszDescription, PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM));
+ "HTTP/1.1 %i %s\r\n"
+ "Date: %s\r\n"
+ "Server: MirandaWeb/%s\r\n"
+ "Location: %s/\r\n"
+ "Transfer-Encoding: chunked\r\n"
+ "Content-Type: text/html; charset=iso-8859-1\r\n"
+ "\r\n"
+ "10f\r\n"
+ "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n"
+ "<HTML><HEAD>\n"
+ "<TITLE>%i %s</TITLE>\n"
+ "</HEAD><BODY>\n"
+ "<H1>%s</H1>\n"
+ "%s<P>\n"
+ "<HR>\n"
+ "<ADDRESS>MirandaWeb/%s</ADDRESS>\n"
+ "</BODY></HTML>\n"
+ "\r\n"
+ "\r\n",
+ iErrorCode, pszError, szCurrTime, PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM), pszRedirect, iErrorCode, pszError, pszError, pszDescription, PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM));
Netlib_Send(hConnection, szBuff, dwBytesToWrite, 0);
}
@@ -321,7 +334,8 @@ void CLHttpUser::SendRedir(int iErrorCode, const char * pszError, const char * p
// Developer : Houdini
/////////////////////////////////////////////////////////////////////
-static void strmcat(char* pszDest, const char* pszSrc, int iMaxLength) {
+static void strmcat(char* pszDest, const char* pszSrc, int iMaxLength)
+{
int iLength = 0;
while (*pszDest != '\0') {
pszDest++;
@@ -355,7 +369,8 @@ static void strmcat(char* pszDest, const char* pszSrc, int iMaxLength) {
// Changed : 21 January 2006 by Vampik
/////////////////////////////////////////////////////////////////////
-bool CLHttpUser::bProcessGetRequest(char * pszRequest, bool bIsGetCommand) {
+bool CLHttpUser::bProcessGetRequest(char * pszRequest, bool bIsGetCommand)
+{
//LogEvent("Request", pszRequest);
int nUriLength = nUnescapedURI(pszRequest);
@@ -367,7 +382,7 @@ bool CLHttpUser::bProcessGetRequest(char * pszRequest, bool bIsGetCommand) {
if (bShutdownInProgress)
return false;
- static char szTempfile[MAX_PATH+1];
+ static char szTempfile[MAX_PATH + 1];
szTempfile[0] = '\0';
if (!bReadGetParameters(pszRequest)) {
@@ -376,7 +391,7 @@ bool CLHttpUser::bProcessGetRequest(char * pszRequest, bool bIsGetCommand) {
}
DWORD dwRemoteIP = ntohl(stAddr.S_un.S_addr);
- for (CLFileShareNode * pclCur = pclFirstNode; pclCur ; pclCur = pclCur->pclNext) {
+ for (CLFileShareNode * pclCur = pclFirstNode; pclCur; pclCur = pclCur->pclNext) {
if ((pclCur->st.dwAllowedIP ^ dwRemoteIP) & pclCur->st.dwAllowedMask)
continue; // Not an allowed IP address
@@ -384,15 +399,15 @@ bool CLHttpUser::bProcessGetRequest(char * pszRequest, bool bIsGetCommand) {
continue; // not the right length, quickly move on to the next.
if (pclCur->bIsDirectory() ?
- (strncmp(pclCur->st.pszSrvPath, pszRequest, pclCur->nGetSrvPathLen() - 1) == 0) :
- (strncmp(pclCur->st.pszSrvPath, pszRequest, pclCur->nGetSrvPathLen()) == 0)) {
+ (strncmp(pclCur->st.pszSrvPath, pszRequest, pclCur->nGetSrvPathLen() - 1) == 0) :
+ (strncmp(pclCur->st.pszSrvPath, pszRequest, pclCur->nGetSrvPathLen()) == 0)) {
/*OutputDebugString( "Request for file OK : ");
OutputDebugString( pclCur->st.pszSrvPath );
OutputDebugString( "\n" );*/
- static char szSrvPath[MAX_PATH+1];
- static char szRealPath[MAX_PATH+1];
- char* pszSrvPath = pclCur->st.pszSrvPath;
+ static char szSrvPath[MAX_PATH + 1];
+ static char szRealPath[MAX_PATH + 1];
+ char* pszSrvPath = pclCur->st.pszSrvPath;
char* pszRealPath = pclCur->st.pszRealPath;
if (pclCur->bIsDirectory()) {
@@ -409,9 +424,10 @@ bool CLHttpUser::bProcessGetRequest(char * pszRequest, bool bIsGetCommand) {
if (pclCur->nGetSrvPathLen() - nUriLength == 1) {
SendRedir(302, "Found", "The document has moved", pszRequest);
return false;
- } else {
+ }
+ else {
strmcat(pszRealPath, &pszRequest[pclCur->nGetSrvPathLen()], MAX_PATH);
- strmcat(pszSrvPath, &pszRequest[pclCur->nGetSrvPathLen()], MAX_PATH);
+ strmcat(pszSrvPath, &pszRequest[pclCur->nGetSrvPathLen()], MAX_PATH);
}
pszRequest[nUriLength] = ' ';
@@ -425,27 +441,27 @@ bool CLHttpUser::bProcessGetRequest(char * pszRequest, bool bIsGetCommand) {
while (pszTmp = strchr(pszTmp, '/'))
* pszTmp = '\\';
- hFile = CreateFile(pszRealPath, GENERIC_READ ,
- FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ hFile = CreateFile(pszRealPath, GENERIC_READ,
+ FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE) {
- if (pszSrvPath[mir_strlen(pszSrvPath)-1] != '/') {
+ if (pszSrvPath[mir_strlen(pszSrvPath) - 1] != '/') {
strmcat(pszRealPath, "\\", MAX_PATH);
- strmcat(pszSrvPath, "/", MAX_PATH);
+ strmcat(pszSrvPath, "/", MAX_PATH);
}
// a directory with index.htm
strmcat(szRealPath, "index.htm", MAX_PATH);
- hFile = CreateFile(pszRealPath, GENERIC_READ ,
- FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_HIDDEN, NULL);
+ hFile = CreateFile(pszRealPath, GENERIC_READ,
+ FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_HIDDEN, NULL);
if (hFile == INVALID_HANDLE_VALUE) {
// a directory with index.html
strmcat(szRealPath, "l", MAX_PATH);
- hFile = CreateFile(pszRealPath, GENERIC_READ ,
- FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_HIDDEN, NULL);
+ hFile = CreateFile(pszRealPath, GENERIC_READ,
+ FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_HIDDEN, NULL);
if (hFile == INVALID_HANDLE_VALUE) {
// generate directory index in temporary file
@@ -461,42 +477,48 @@ bool CLHttpUser::bProcessGetRequest(char * pszRequest, bool bIsGetCommand) {
// detecting browser function removed
// every browser should support it by now
- bool BrowserSupportsXML = true;
- //(apszParam[eUserAgent] != NULL) &&
- // (strstr(apszParam[eUserAgent], "Firefox") ||
- // (strstr(apszParam[eUserAgent], "MSIE") && !strstr(apszParam[eUserAgent], "Opera")));
+ bool BrowserSupportsXML = true;
+ //(apszParam[eUserAgent] != NULL) &&
+ // (strstr(apszParam[eUserAgent], "Firefox") ||
+ // (strstr(apszParam[eUserAgent], "MSIE") && !strstr(apszParam[eUserAgent], "Opera")));
if ((indexCreationMode == INDEX_CREATION_XML ||
- (indexCreationMode == INDEX_CREATION_DETECT && BrowserSupportsXML)) &&
- bCreateIndexXML(pszRealPath, szTempfile, pszSrvPath, dwRemoteIP)) {
- hFile = CreateFile(szTempfile, GENERIC_READ ,
- FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ (indexCreationMode == INDEX_CREATION_DETECT && BrowserSupportsXML)) &&
+ bCreateIndexXML(pszRealPath, szTempfile, pszSrvPath, dwRemoteIP)) {
+ hFile = CreateFile(szTempfile, GENERIC_READ,
+ FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
mir_strcpy(szRealPath, "a.xml"); // restore .xml for mime type
- } else if ((indexCreationMode == INDEX_CREATION_HTML ||
- indexCreationMode == INDEX_CREATION_DETECT) &&
- bCreateIndexHTML(pszRealPath, szTempfile, pszSrvPath, dwRemoteIP)) {
+ }
+ else if ((indexCreationMode == INDEX_CREATION_HTML ||
+ indexCreationMode == INDEX_CREATION_DETECT) &&
+ bCreateIndexHTML(pszRealPath, szTempfile, pszSrvPath, dwRemoteIP)) {
hFile = CreateFile(szTempfile, GENERIC_READ,
- FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
mir_strcpy(szRealPath, "a.html"); // restore .html for mime type
- } else {
+ }
+ else {
continue;
}
- } else {
+ }
+ else {
strmcat(pszSrvPath, "index.html", MAX_PATH);
szTempfile[0] = '\0';
}
- } else {
+ }
+ else {
strmcat(pszSrvPath, "index.htm", MAX_PATH);
szTempfile[0] = '\0';
}
- } else {
+ }
+ else {
szTempfile[0] = '\0';
}
- } else {
- hFile = CreateFile(pszRealPath, GENERIC_READ ,
- FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ }
+ else {
+ hFile = CreateFile(pszRealPath, GENERIC_READ,
+ FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE) {
SendError(404, "Not Found", "HTTP server failed to open local file");
@@ -512,30 +534,30 @@ bool CLHttpUser::bProcessGetRequest(char * pszRequest, bool bIsGetCommand) {
FILETIME stFileTime;
GetFileTime(hFile, NULL, NULL, &stFileTime);
- char szCurTime[ 100 ];
+ char szCurTime[100];
time_t ltime;
time(&ltime);
strftime(szCurTime, sizeof(szCurTime), "%a, %d %b %Y %H:%M:%S GMT", gmtime(&ltime));
- char szFileTime[ 100 ];
+ char szFileTime[100];
FileTimeToUnixTime(&stFileTime, &ltime);
strftime(szFileTime, sizeof(szFileTime), "%a, %d %b %Y %H:%M:%S GMT", gmtime(&ltime));
-
+
if (apszParam[eIfModifiedSince] && mir_strcmp(apszParam[eIfModifiedSince], szFileTime) == 0) {
- SendError(304, "Not Modified" );
+ SendError(304, "Not Modified");
return true;
}
-
+
// we found match send file !!
if (bIsGetCommand) {
- if (! pclCur->bAddUser(this)) {
+ if (!pclCur->bAddUser(this)) {
SendError(403, "Forbidden", "Access has been denied because there are too many connections");
return false;
}
}
if (*(ULONG*)(&stAddr) != 0x0100007F && // do not show popup of 127.0.0.1
- strstr(pszRealPath, "\\@") == NULL) { // and of shares which start with an @
+ strstr(pszRealPath, "\\@") == NULL) { // and of shares which start with an @
ShowPopupWindow(inet_ntoa(stAddr), pszSrvPath);
}
@@ -544,10 +566,10 @@ bool CLHttpUser::bProcessGetRequest(char * pszRequest, bool bIsGetCommand) {
DWORD dwFileStart = 0;
DWORD dwDataToSend = nDataSize;
- char szETag[ 50 ];
+ char szETag[50];
{
int nETagLen = mir_snprintf(szETag, "\"%x-%x-%x\"",
- nDataSize, stFileTime.dwHighDateTime, stFileTime.dwLowDateTime);
+ nDataSize, stFileTime.dwHighDateTime, stFileTime.dwLowDateTime);
if (!apszParam[eIfRange] || (strncmp(szETag, apszParam[eIfRange], nETagLen) == 0)) {
char * pszRange = apszParam[eRange];
@@ -561,7 +583,8 @@ bool CLHttpUser::bProcessGetRequest(char * pszRequest, bool bIsGetCommand) {
DWORD dwLen = strtol(pszRange + 1, &pszEnd, 10);
if (dwLen < nDataSize)
dwFileStart = nDataSize - dwLen;
- } else {
+ }
+ else {
DWORD dwLen = strtol(pszRange, &pszEnd, 10);
if (*pszEnd == '-' && dwLen < nDataSize) {
dwFileStart = dwLen;
@@ -573,7 +596,8 @@ bool CLHttpUser::bProcessGetRequest(char * pszRequest, bool bIsGetCommand) {
else
dwFileStart = 0;
}
- } else {
+ }
+ else {
SendError(400, "Bad Request");
return false;
}
@@ -605,46 +629,47 @@ bool CLHttpUser::bProcessGetRequest(char * pszRequest, bool bIsGetCommand) {
}
const char szHttpPartial[] = "HTTP/1.1 206 Partial Content\r\n"
- "Connection: Keep-Alive\r\n"
- "Date: %s\r\n"
- "Server: MirandaWeb/%s\r\n"
- "Accept-Ranges: bytes\r\n"
- "ETag: %s\r\n"
- "Content-Length: %d\r\n"
- "Content-Type: %s\r\n"
- "Content-Range: bytes %d-%d/%d\r\n"
- "Last-Modified: %s\r\n"
- "\r\n";
+ "Connection: Keep-Alive\r\n"
+ "Date: %s\r\n"
+ "Server: MirandaWeb/%s\r\n"
+ "Accept-Ranges: bytes\r\n"
+ "ETag: %s\r\n"
+ "Content-Length: %d\r\n"
+ "Content-Type: %s\r\n"
+ "Content-Range: bytes %d-%d/%d\r\n"
+ "Last-Modified: %s\r\n"
+ "\r\n";
dwBytesToWrite = mir_snprintf(szBuf, szHttpPartial,
- szCurTime,
- PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
- szETag,
- dwDataToSend,
- pszGetMimeType(pszRealPath),
- dwFileStart,
- (dwFileStart + dwDataToSend - 1),
- nDataSize,
- szFileTime);
- } else {
+ szCurTime,
+ PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
+ szETag,
+ dwDataToSend,
+ pszGetMimeType(pszRealPath),
+ dwFileStart,
+ (dwFileStart + dwDataToSend - 1),
+ nDataSize,
+ szFileTime);
+ }
+ else {
const char szHttpOk[] = "HTTP/1.1 200 OK\r\n"
- "Connection: Keep-Alive\r\n"
- "Date: %s\r\n"
- "Server: MirandaWeb/%s\r\n"
- "Accept-Ranges: bytes\r\n"
- "ETag: %s\r\n"
- "Content-Length: %d\r\n"
- "Content-Type: %s\r\n"
- "Last-Modified: %s\r\n"
- "\r\n";
+ "Connection: Keep-Alive\r\n"
+ "Date: %s\r\n"
+ "Server: MirandaWeb/%s\r\n"
+ "Accept-Ranges: bytes\r\n"
+ "ETag: %s\r\n"
+ "Content-Length: %d\r\n"
+ "Content-Type: %s\r\n"
+ "Last-Modified: %s\r\n"
+ "\r\n";
dwBytesToWrite = mir_snprintf(szBuf, szHttpOk,
- szCurTime,
- PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
- szETag,
- nDataSize,
- pszGetMimeType(pszRealPath),
- szFileTime);
+ szCurTime,
+ PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
+ szETag,
+ nDataSize,
+ pszGetMimeType(pszRealPath),
+ szFileTime);
}
Netlib_Send(hConnection, szBuf, dwBytesToWrite, 0);
@@ -747,7 +772,7 @@ bool CLHttpUser::bProcessGetRequest(char * pszRequest, bool bIsGetCommand) {
// Therefore we test it even if we did'en decreese it
if (pclCur->st.nMaxDownloads == 0 && !pclCur->bAnyUsers()) {
CLFileShareNode **pclPrev = &pclFirstNode;
- for (CLFileShareNode * pcl = pclFirstNode ; pcl ; pcl = pcl->pclNext) {
+ for (CLFileShareNode * pcl = pclFirstNode; pcl; pcl = pcl->pclNext) {
if (pcl == pclCur) {
*pclPrev = pclCur->pclNext;
ShowPopupWindow(Translate("Share removed"), pclCur->st.pszSrvPath, RGB(255, 189, 189));
@@ -768,71 +793,29 @@ bool CLHttpUser::bProcessGetRequest(char * pszRequest, bool bIsGetCommand) {
}
}
-
-#ifdef _DEBUG
+ #ifdef _DEBUG
OutputDebugString("########### Request Failed ###########\n");
OutputDebugString(pszRequest);
-#endif
+ #endif
pszRequest[nUriLength] = 0;
if ((nUriLength != 12 || strncmp(pszRequest, "/favicon.ico", nUriLength)) && // do not show popup of favicon.ico
- *(ULONG*)(&stAddr) != 0x0100007F) { // do not show popup of 127.0.0.1
+ *(ULONG*)(&stAddr) != 0x0100007F) { // do not show popup of 127.0.0.1
ShowPopupWindow(inet_ntoa(stAddr), pszRequest, RGB(255, 189, 189));
}
SendError(404, "Not Found", "The requested URL was not found on this server.");
-
return false;
}
-
-void CLHttpUser::HandleNewConnection() {
-
-/*
- {
- SOCKET s = CallService(MS_NETLIB_GETSOCKET, (WPARAM) hConnection, 0);
- sockaddr_in MyAddr;
- int nSize = sizeof( MyAddr );
- getsockname( s, (sockaddr*)&MyAddr, &nSize );
- ShowPopupWindow( "My IP address", inet_ntoa( MyAddr.sin_addr ) );
- //OutputDebugString( );
- }*/
- /*
- {
- LINGER li;
- int nLenght = sizeof( li );
- int ret = getsockopt( s, IPPROTO_TCP, SO_LINGER, (char *)&li, &nLenght );
- if( ret )
- {
- DWORD error = WSAGetLastError();
- if( error
- WSANOTINITIALISED
- WSAENETDOWN The network subsystem has failed.
- WSAEFAULT One of the optval or the optlen parameters is not a valid part of the user address space, or the optlen parameter is too small.
- WSAEINPROGRESS A blocking Windows Sockets 1.1 call is in progress, or the service provider is still processing a callback function.
- WSAEINVAL The level parameter is unknown or invalid.
- WSAENOPROTOOPT The option is unknown or unsupported by the indicated protocol family.
- WSAENOTSOCK
- }
- nLenght = sizeof( li );
- li.l_onoff = 1;
- li.l_linger = 0;// time is default
- ret = setsockopt( s, IPPROTO_TCP, SO_LINGER, (const char *)&li, nLenght );
- if( ret )
- {
- // error
- }
- int nLenght = sizeof( li );
- int ret = getsockopt( s, IPPROTO_TCP, SO_LINGER, (char *)&li, &nLenght );
- }
- */
-
+void CLHttpUser::HandleNewConnection()
+{
char szBuf[1000];
int nCurPos = 0;
while (sizeof(szBuf) - nCurPos > 10 && !bShutdownInProgress) {
int nBytesRead = Netlib_Recv(hConnection, &szBuf[nCurPos], sizeof(szBuf) - nCurPos, 0);
- if (! nBytesRead) {
+ if (!nBytesRead) {
// socket closed gracefully
break;
}
@@ -857,10 +840,10 @@ void CLHttpUser::HandleNewConnection() {
bool bBreakWhile = false;
for (; nOldCurPos < nCurPos; nOldCurPos++) {
- if (szBuf[nOldCurPos-2] == '\n' && szBuf[nOldCurPos-1] == '\r' && szBuf[nOldCurPos] == '\n') {
+ if (szBuf[nOldCurPos - 2] == '\n' && szBuf[nOldCurPos - 1] == '\r' && szBuf[nOldCurPos] == '\n') {
// we have a walid request !!! scan to see if we have this file
szBuf[nOldCurPos] = NULL;
- bProcessGetRequest(&szBuf[bIsGetCommand?4:5], bIsGetCommand);
+ bProcessGetRequest(&szBuf[bIsGetCommand ? 4 : 5], bIsGetCommand);
bBreakWhile = true;
break;
diff --git a/plugins/HTTPServer/src/IndexHTML.cpp b/plugins/HTTPServer/src/IndexHTML.cpp
index 6bf65357ac..cd7687330c 100644
--- a/plugins/HTTPServer/src/IndexHTML.cpp
+++ b/plugins/HTTPServer/src/IndexHTML.cpp
@@ -23,7 +23,8 @@ static char* szIndexHTMLTemplate = NULL;
static const int MAX_PARAM_LENGTH = 5;
// signs below 32 are not used anyway
-enum Symbol {
+enum Symbol
+{
SY_END = 15,
SY_FOR_DIRS,
SY_DIR_URL,
@@ -52,7 +53,8 @@ enum Symbol {
// Developer : Houdini
/////////////////////////////////////////////////////////////////////
-bool LoadIndexHTMLTemplate() {
+bool LoadIndexHTMLTemplate()
+{
if (szIndexHTMLTemplate != NULL)
return true;
@@ -65,7 +67,7 @@ bool LoadIndexHTMLTemplate() {
mir_snprintf(szBuf, "%s%s", szPluginPath, szIndexHTMLTemplateFile);
HANDLE hFile = CreateFile(pszBuf, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
- NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ 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);
return false;
@@ -119,14 +121,15 @@ bool LoadIndexHTMLTemplate() {
// these tags require an End - reserve space for relative jump address (2 byte)
switch (*(pszDestBuf - 1)) {
- case SY_FOR_DIRS:
- case SY_FOR_FILES:
- case SY_IS_EVEN:
- case SY_IS_ODD:
- case SY_IS_FILE_TYPE: {
- *((WORD*)(pszDestBuf)) = 0x7070;
- pszDestBuf += 2;
- }
+ case SY_FOR_DIRS:
+ case SY_FOR_FILES:
+ case SY_IS_EVEN:
+ case SY_IS_ODD:
+ case SY_IS_FILE_TYPE:
+ {
+ *((WORD*)(pszDestBuf)) = 0x7070;
+ pszDestBuf += 2;
+ }
}
if (bHasParameters) {
@@ -156,7 +159,8 @@ bool LoadIndexHTMLTemplate() {
*pcParamCount = iParamCount;
}
- } else {
+ }
+ else {
*(pszDestBuf++) = *pszBuf;
}
@@ -170,14 +174,14 @@ bool LoadIndexHTMLTemplate() {
while (*pszBuf != '\0') {
byte iLevel = 0;
switch (*pszBuf) {
- // these tags require an End - precalculate address of End
- case SY_FOR_DIRS:
- case SY_FOR_FILES:
- case SY_IS_EVEN:
- case SY_IS_ODD:
- case SY_IS_FILE_TYPE:
- iLevel++;
- break;
+ // these tags require an End - precalculate address of End
+ case SY_FOR_DIRS:
+ case SY_FOR_FILES:
+ case SY_IS_EVEN:
+ case SY_IS_ODD:
+ case SY_IS_FILE_TYPE:
+ iLevel++;
+ break;
}
pszBuf++;
@@ -194,24 +198,24 @@ bool LoadIndexHTMLTemplate() {
while (*pszLevelEnd != '\0' && iLevel > 0) {
switch (*pszLevelEnd) {
- case SY_FOR_DIRS:
- case SY_FOR_FILES:
- case SY_IS_EVEN:
- case SY_IS_ODD:
- iLevel++;
- pszLevelEnd += 2;
- break;
-
- case SY_IS_FILE_TYPE:
- iLevel++;
- pszLevelEnd += 2;
- pszLevelEnd += 1;
- pszLevelEnd += *(pszLevelEnd) * MAX_PARAM_LENGTH;
- break;
-
- case SY_END:
- iLevel--;
- break;
+ case SY_FOR_DIRS:
+ case SY_FOR_FILES:
+ case SY_IS_EVEN:
+ case SY_IS_ODD:
+ iLevel++;
+ pszLevelEnd += 2;
+ break;
+
+ case SY_IS_FILE_TYPE:
+ iLevel++;
+ pszLevelEnd += 2;
+ pszLevelEnd += 1;
+ pszLevelEnd += *(pszLevelEnd)* MAX_PARAM_LENGTH;
+ break;
+
+ case SY_END:
+ iLevel--;
+ break;
}
pszLevelEnd++;
@@ -232,7 +236,7 @@ bool LoadIndexHTMLTemplate() {
//LogEvent("Template", szDestBuf);
- szIndexHTMLTemplate = new char[mir_strlen(szDestBuf)+1];
+ szIndexHTMLTemplate = new char[mir_strlen(szDestBuf) + 1];
mir_strcpy(szIndexHTMLTemplate, szDestBuf);
}
@@ -253,7 +257,8 @@ bool LoadIndexHTMLTemplate() {
// Developer : Houdini
/////////////////////////////////////////////////////////////////////
-void FreeIndexHTMLTemplate() {
+void FreeIndexHTMLTemplate()
+{
if (szIndexHTMLTemplate != NULL) {
delete[] szIndexHTMLTemplate;
szIndexHTMLTemplate = NULL;
@@ -274,8 +279,9 @@ void FreeIndexHTMLTemplate() {
/////////////////////////////////////////////////////////////////////
bool bCreateIndexHTML(const char * pszRealPath, const char * pszIndexPath,
- const char * pszSrvPath, DWORD /* dwRemoteIP */) {
-#define RelativeJump(begin) { pszPos += *((WORD*)(begin+1)) & 0x7FFF; }
+ const char * pszSrvPath, DWORD /* dwRemoteIP */)
+{
+ #define RelativeJump(begin) { pszPos += *((WORD*)(begin+1)) & 0x7FFF; }
if (szIndexHTMLTemplate == NULL)
return false;
@@ -293,8 +299,8 @@ bool bCreateIndexHTML(const char * pszRealPath, const char * pszIndexPath,
FindClose(hFind);
hFind = 0;
- HANDLE hFile = CreateFile(pszIndexPath, GENERIC_WRITE, FILE_SHARE_READ ,
- NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_TEMPORARY, NULL);
+ HANDLE hFile = CreateFile(pszIndexPath, GENERIC_WRITE, FILE_SHARE_READ,
+ NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_TEMPORARY, NULL);
if (hFile == INVALID_HANDLE_VALUE)
return FALSE;
@@ -317,157 +323,149 @@ bool bCreateIndexHTML(const char * pszRealPath, const char * pszIndexPath,
bool bEvenOdd = 0;
bool bKnownFileType = false;
- strncpy(szBuffer, pszSrvPath, _countof(szBuffer)-1);
- char* pszTemp = strrchr(szBuffer, '/');
+ strncpy(szBuffer, pszSrvPath, _countof(szBuffer) - 1);
+ char *pszTemp = strrchr(szBuffer, '/');
if (pszTemp)
*pszTemp = '\0';
pszTemp = strrchr(szBuffer, '/');
if (pszTemp)
- strncpy(szName, pszTemp + 1, _countof(szName)-1);
+ strncpy(szName, pszTemp + 1, _countof(szName) - 1);
if (szName[0] == '\0')
mir_strcpy(szName, "my Miranda Webserver");
do {
switch (*pszPos) {
- case SY_FOR_FILES:
- case SY_FOR_DIRS: {
- if (hFind == 0) {
- pszLevelBegin[iLevel++] = pszPos;
- iCurrentAction = *pszPos;
-
- hFind = FindFirstFile(szMask, &fdFindFileData);
- if (hFind == 0) {
- iCurrentAction = 0;
- RelativeJump(pszLevelBegin[iLevel-1]);
- break;
- }
- } else {
- if (!FindNextFile(hFind, &fdFindFileData)) {
- FindClose(hFind);
- hFind = 0;
- iCurrentAction = 0;
- RelativeJump(pszLevelBegin[iLevel-1]);
- break;
- }
- }
-
- while (!mir_strcmp(fdFindFileData.cFileName, ".") ||
- !strncmp(fdFindFileData.cFileName, "@", 1) ||
- (!mir_strcmp(fdFindFileData.cFileName, "..") && !mir_strcmp(pszSrvPath, "/")) || // hide .. in root
- ((*pszPos == 19) == ((fdFindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0))) {
- if (!FindNextFile(hFind, &fdFindFileData)) {
- FindClose(hFind);
- hFind = 0;
- iCurrentAction = 0;
- RelativeJump(pszLevelBegin[iLevel-1]);
- break;
- }
- }
-
- if (hFind) {
- mir_strcpy(szName, fdFindFileData.cFileName);
- mir_strcpy(szURL, fdFindFileData.cFileName);
- /*char* pszTmp = szURL;
- while(pszTmp = strchr(pszTmp, ' '))
- *pszTmp = '+';*/
-
- if (*pszPos == SY_FOR_DIRS) { // For Directories
- mir_strcat(szURL, "/");
- } else { // For Files
- iFileSize = fdFindFileData.nFileSizeLow;
- ftFileCreateTime = fdFindFileData.ftCreationTime;
- ftFileModifyTime = fdFindFileData.ftLastWriteTime;
- }
+ case SY_FOR_FILES:
+ case SY_FOR_DIRS:
+ if (hFind == 0) {
+ pszLevelBegin[iLevel++] = pszPos;
+ iCurrentAction = *pszPos;
- bKnownFileType = false;
- bEvenOdd = !bEvenOdd;
- pszPos += 2;
+ hFind = FindFirstFile(szMask, &fdFindFileData);
+ if (hFind == 0) {
+ iCurrentAction = 0;
+ RelativeJump(pszLevelBegin[iLevel - 1]);
+ break;
}
-
- break;
}
-
- case SY_END: { // End
- if (iLevel <= 0)
- break; // Error
-
- if (iCurrentAction == SY_FOR_DIRS || iCurrentAction == SY_FOR_FILES) { // For loops
- pszPos = pszLevelBegin[iLevel-1] - 1; // jump to begin
- } else {
- iLevel--;
- if (iLevel > 0)
- iCurrentAction = *pszLevelBegin[iLevel-1];
- else
- iCurrentAction = 0;
+ else {
+ if (!FindNextFile(hFind, &fdFindFileData)) {
+ FindClose(hFind);
+ hFind = 0;
+ iCurrentAction = 0;
+ RelativeJump(pszLevelBegin[iLevel - 1]);
+ break;
}
-
- break;
}
- case SY_FILE_NAME:
- case SY_DIR_NAME: {
- pszBuffer += mir_snprintf(pszBuffer, 250, "%s", szName);
- break;
+ while (!mir_strcmp(fdFindFileData.cFileName, ".") ||
+ !strncmp(fdFindFileData.cFileName, "@", 1) ||
+ (!mir_strcmp(fdFindFileData.cFileName, "..") && !mir_strcmp(pszSrvPath, "/")) || // hide .. in root
+ ((*pszPos == 19) == ((fdFindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0))) {
+ if (!FindNextFile(hFind, &fdFindFileData)) {
+ FindClose(hFind);
+ hFind = 0;
+ iCurrentAction = 0;
+ RelativeJump(pszLevelBegin[iLevel - 1]);
+ break;
+ }
}
- case SY_DIR_URL: {
- case SY_FILE_URL:
- pszBuffer += mir_snprintf(pszBuffer, 250, "%s", szURL);
- break;
- }
+ if (hFind) {
+ mir_strcpy(szName, fdFindFileData.cFileName);
+ mir_strcpy(szURL, fdFindFileData.cFileName);
+ /*char* pszTmp = szURL;
+ while(pszTmp = strchr(pszTmp, ' '))
+ *pszTmp = '+';*/
- case SY_FILE_CREATE_TIME:
- case SY_FILE_MODIFY_TIME: {
- SYSTEMTIME systemTime;
- FileTimeToSystemTime(
- (*pszPos == SY_FILE_CREATE_TIME) ? &ftFileCreateTime : &ftFileModifyTime,
- &systemTime);
+ if (*pszPos == SY_FOR_DIRS) { // For Directories
+ mir_strcat(szURL, "/");
+ }
+ else { // For Files
+ iFileSize = fdFindFileData.nFileSizeLow;
+ ftFileCreateTime = fdFindFileData.ftCreationTime;
+ ftFileModifyTime = fdFindFileData.ftLastWriteTime;
+ }
- pszBuffer += mir_snprintf(pszBuffer, 100, "%i/%02i/%02i %i:%02i:%02i",
- systemTime.wYear, systemTime.wMonth, systemTime.wDay, systemTime.wHour,
- systemTime.wMinute, systemTime.wSecond);
- break;
+ bKnownFileType = false;
+ bEvenOdd = !bEvenOdd;
+ pszPos += 2;
}
-
- case SY_FILE_SIZE: {
- if ((iFileSize >> 10) == 0)
- pszBuffer += mir_snprintf(pszBuffer, 100, "%i Byte", iFileSize);
- else if ((iFileSize >> 20) == 0)
- pszBuffer += mir_snprintf(pszBuffer, 100, "%.1f KB", (float)(iFileSize) / 1024.0f);
+ break;
+
+ case SY_END:
+ // End
+ if (iLevel <= 0)
+ break; // Error
+
+ if (iCurrentAction == SY_FOR_DIRS || iCurrentAction == SY_FOR_FILES) // For loops
+ pszPos = pszLevelBegin[iLevel - 1] - 1; // jump to begin
+ else {
+ iLevel--;
+ if (iLevel > 0)
+ iCurrentAction = *pszLevelBegin[iLevel - 1];
else
- pszBuffer += mir_snprintf(pszBuffer, 100, "%.1f MB", (float)(iFileSize) / (1024.0f * 1024.0f));
- break;
+ iCurrentAction = 0;
}
- case SY_IS_EVEN:
- case SY_IS_ODD: {
- pszLevelBegin[iLevel++] = pszPos;
- iCurrentAction = *pszPos;
-
- if (bEvenOdd != (*pszPos - SY_IS_EVEN == 1)) { // SY_IS_EVEN+1 == SY_IS_ODD
- RelativeJump(pszLevelBegin[iLevel-1]);
- } else {
- pszPos += 2;
- }
- break;
+ break;
+
+ case SY_FILE_NAME:
+ case SY_DIR_NAME:
+ pszBuffer += mir_snprintf(pszBuffer, 250, "%s", szName);
+ break;
+
+ case SY_DIR_URL:
+ case SY_FILE_URL:
+ pszBuffer += mir_snprintf(pszBuffer, 250, "%s", szURL);
+ break;
+
+ case SY_FILE_CREATE_TIME:
+ case SY_FILE_MODIFY_TIME:
+ SYSTEMTIME systemTime;
+ FileTimeToSystemTime((*pszPos == SY_FILE_CREATE_TIME) ? &ftFileCreateTime : &ftFileModifyTime, &systemTime);
+
+ pszBuffer += mir_snprintf(pszBuffer, 100, "%i/%02i/%02i %i:%02i:%02i",
+ systemTime.wYear, systemTime.wMonth, systemTime.wDay, systemTime.wHour,
+ systemTime.wMinute, systemTime.wSecond);
+ break;
+
+ case SY_FILE_SIZE:
+ if ((iFileSize >> 10) == 0)
+ pszBuffer += mir_snprintf(pszBuffer, 100, "%i Byte", iFileSize);
+ else if ((iFileSize >> 20) == 0)
+ pszBuffer += mir_snprintf(pszBuffer, 100, "%.1f KB", (float)(iFileSize) / 1024.0f);
+ else
+ pszBuffer += mir_snprintf(pszBuffer, 100, "%.1f MB", (float)(iFileSize) / (1024.0f * 1024.0f));
+ break;
+
+ case SY_IS_EVEN:
+ case SY_IS_ODD:
+ pszLevelBegin[iLevel++] = pszPos;
+ iCurrentAction = *pszPos;
+
+ if (bEvenOdd != (*pszPos - SY_IS_EVEN == 1)) { // SY_IS_EVEN+1 == SY_IS_ODD
+ RelativeJump(pszLevelBegin[iLevel - 1]);
}
+ else pszPos += 2;
+ break;
- case SY_IS_FILE_TYPE: {
- pszLevelBegin[iLevel++] = pszPos;
- iCurrentAction = *pszPos;
-
+ case SY_IS_FILE_TYPE:
+ pszLevelBegin[iLevel++] = pszPos;
+ iCurrentAction = *pszPos;
+ {
byte iParamCount = *(pszPos + 3);
char* pszParam = pszPos + 4;
bool bSkip = true;
if (bKnownFileType == false) {
- if (*pszParam == '*') {
+ if (*pszParam == '*')
bSkip = false;
- } else {
+ else {
for (byte i = 0; i < iParamCount; i++) {
- char szParam[MAX_PARAM_LENGTH+1];
+ char szParam[MAX_PARAM_LENGTH + 1];
strncpy(szParam, pszParam, MAX_PARAM_LENGTH);
szParam[MAX_PARAM_LENGTH] = '\0';
char* pszTmp = strchr(szParam, ':');
@@ -486,19 +484,19 @@ bool bCreateIndexHTML(const char * pszRealPath, const char * pszIndexPath,
}
if (bSkip) {
- RelativeJump(pszLevelBegin[iLevel-1]);
- } else {
+ RelativeJump(pszLevelBegin[iLevel - 1]);
+ }
+ else {
bKnownFileType = true;
pszPos += 2;
pszPos += 1;
- pszPos += *(pszPos) * MAX_PARAM_LENGTH;
+ pszPos += *(pszPos)* MAX_PARAM_LENGTH;
}
break;
}
- default: {
- *(pszBuffer++) = *pszPos;
- }
+ default:
+ *(pszBuffer++) = *pszPos;
}
pszPos++;
@@ -518,4 +516,4 @@ bool bCreateIndexHTML(const char * pszRealPath, const char * pszIndexPath,
SetEndOfFile(hFile);
CloseHandle(hFile);
return TRUE;
-} \ No newline at end of file
+}
diff --git a/plugins/HTTPServer/src/IndexXML.cpp b/plugins/HTTPServer/src/IndexXML.cpp
index 6e25cfce28..04bc7edd8c 100644
--- a/plugins/HTTPServer/src/IndexXML.cpp
+++ b/plugins/HTTPServer/src/IndexXML.cpp
@@ -17,22 +17,22 @@
#include "Glob.h"
-static const TCHAR szXmlHeader1[] = _T("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\r\n")
- _T("<?xml-stylesheet type=\"text/xsl\" href=\"");
+static const TCHAR szXmlHeader1[] = _T("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\r\n")
+_T("<?xml-stylesheet type=\"text/xsl\" href=\"");
-static const TCHAR szXmlHeader2[] = _T("\"?>\r\n")
- _T("<config>\r\n");
+static const TCHAR szXmlHeader2[] = _T("\"?>\r\n")
+_T("<config>\r\n");
-static const TCHAR szXmlTail[] = _T("</config>");
+static const TCHAR szXmlTail[] = _T("</config>");
-
-static void ReplaceSign(char* pszSrc, int MaxLength, const char pszReplace,
- const char * pszNew) {
+static void ReplaceSign(char* pszSrc, int MaxLength, const char pszReplace,
+ const char * pszNew)
+{
static char szBuffer[1024];
char* pszSign = strchr(pszSrc, pszReplace);
if (pszSign) {
- strncpy(szBuffer, pszSrc, _countof(szBuffer)-1);
+ strncpy(szBuffer, pszSrc, _countof(szBuffer) - 1);
do {
mir_strcpy(szBuffer + (pszSign - pszSrc), pszNew);
@@ -43,7 +43,7 @@ static void ReplaceSign(char* pszSrc, int MaxLength, const char pszReplace,
strncpy(pszSrc, szBuffer, MaxLength);
- pszSrc[MaxLength-1] = '\0';
+ pszSrc[MaxLength - 1] = '\0';
}
}
@@ -63,7 +63,7 @@ static void ReplaceSign(char* pszSrc, int MaxLength, const char pszReplace,
bool bCreateIndexXML(const char * pszRealPath, const char * pszIndexPath, const char * pszSrvPath, DWORD dwRemoteIP)
{
- char szMask[MAX_PATH+1];
+ char szMask[MAX_PATH + 1];
mir_snprintf(szMask, "%s*", pszRealPath);
WIN32_FIND_DATAA fdFindFileData;
@@ -71,7 +71,7 @@ bool bCreateIndexXML(const char * pszRealPath, const char * pszIndexPath, const
if (hFind == INVALID_HANDLE_VALUE)
return FALSE;
- HANDLE hFile = CreateFile(pszIndexPath, GENERIC_WRITE, FILE_SHARE_READ, NULL,
+ HANDLE hFile = CreateFile(pszIndexPath, GENERIC_WRITE, FILE_SHARE_READ, NULL,
OPEN_ALWAYS, FILE_ATTRIBUTE_TEMPORARY, NULL);
if (hFile == INVALID_HANDLE_VALUE) {
@@ -80,9 +80,9 @@ bool bCreateIndexXML(const char * pszRealPath, const char * pszIndexPath, const
}
const int BUFFER_SIZE = 1000;
- char szBuffer[BUFFER_SIZE+1];
+ char szBuffer[BUFFER_SIZE + 1];
char* pszBuffer = szBuffer;
- char szFileName[MAX_PATH+1] = "";
+ char szFileName[MAX_PATH + 1] = "";
char* pszExt;
DWORD dwBytesWritten = 0;
@@ -102,8 +102,8 @@ bool bCreateIndexXML(const char * pszRealPath, const char * pszIndexPath, const
// check if a index.xsl exists in the same directory otherwise use the global
mir_snprintf(szMask, "%s%s", pszRealPath, "index.xsl");
- HANDLE hFileExists = CreateFile(szMask, GENERIC_READ,
- FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
+ HANDLE hFileExists = CreateFile(szMask, GENERIC_READ,
+ FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, NULL);
if (hFileExists == INVALID_HANDLE_VALUE) {
@@ -120,24 +120,25 @@ bool bCreateIndexXML(const char * pszRealPath, const char * pszIndexPath, const
// Write dirname
ReplaceSign(szFileName, MAX_PATH, '&', "&amp;");
- pszBuffer += mir_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);
// Find files and directories
do {
if (mir_strcmp(fdFindFileData.cFileName, ".") &&
- strncmp(fdFindFileData.cFileName, "@", 1) &&
- (mir_strcmp(fdFindFileData.cFileName, "..") || mir_strcmp(pszSrvPath, "/"))) { // hide .. in root
+ strncmp(fdFindFileData.cFileName, "@", 1) &&
+ (mir_strcmp(fdFindFileData.cFileName, "..") || mir_strcmp(pszSrvPath, "/"))) { // hide .. in root
pszBuffer = szBuffer;
mir_strcpy(szFileName, fdFindFileData.cFileName);
ReplaceSign(szFileName, MAX_PATH, '&', "&amp;");
if (fdFindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
- pszBuffer += mir_snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
+ pszBuffer += mir_snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
" <item name=\"%s\" isdir=\"true\"/>\r\n", szFileName);
- } else {
+ }
+ else {
pszExt = strrchr(szFileName, '.');
if (pszExt != NULL) {
@@ -145,24 +146,24 @@ bool bCreateIndexXML(const char * pszRealPath, const char * pszIndexPath, const
pszExt++;
}
- pszBuffer += mir_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);
+ szFileName, (pszExt == NULL) ? "" : pszExt, fdFindFileData.nFileSizeLow);
SYSTEMTIME systemTime;
FileTimeToSystemTime(&fdFindFileData.ftCreationTime, &systemTime);
- pszBuffer += mir_snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
- "created=\"%i/%02i/%02i %i:%02i:%02i\" ",
+ pszBuffer += mir_snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
+ "created=\"%i/%02i/%02i %i:%02i:%02i\" ",
systemTime.wYear, systemTime.wMonth, systemTime.wDay, systemTime.wHour,
systemTime.wMinute, systemTime.wSecond);
FileTimeToSystemTime(&fdFindFileData.ftLastWriteTime, &systemTime);
- pszBuffer += mir_snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
- "modified=\"%i/%02i/%02i %i:%02i:%02i\" ",
+ pszBuffer += mir_snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
+ "modified=\"%i/%02i/%02i %i:%02i:%02i\" ",
systemTime.wYear, systemTime.wMonth, systemTime.wDay, systemTime.wHour,
systemTime.wMinute, systemTime.wSecond);
- pszBuffer += mir_snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
+ pszBuffer += mir_snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
"/>\r\n");
}
@@ -176,28 +177,29 @@ bool bCreateIndexXML(const char * pszRealPath, const char * pszIndexPath, const
FindClose(hFind);
// Add other shared files & directories
- for (CLFileShareNode * pclCur = pclFirstNode; pclCur ; pclCur = pclCur->pclNext) {
+ for (CLFileShareNode * pclCur = pclFirstNode; pclCur; pclCur = pclCur->pclNext) {
if (!((pclCur->st.dwAllowedIP ^ dwRemoteIP) & pclCur->st.dwAllowedMask) && // hide inaccessible shares
- (size_t)(pclCur->nGetSrvPathLen()) > mir_strlen(pszSrvPath) &&
- !strstr(pclCur->st.pszRealPath, "\\@") &&
- !strncmp(pclCur->st.pszSrvPath, pszSrvPath, mir_strlen(pszSrvPath))) {
+ (size_t)(pclCur->nGetSrvPathLen()) > mir_strlen(pszSrvPath) &&
+ !strstr(pclCur->st.pszRealPath, "\\@") &&
+ !strncmp(pclCur->st.pszSrvPath, pszSrvPath, mir_strlen(pszSrvPath))) {
pszBuffer = szBuffer;
mir_strcpy(szFileName, &pclCur->st.pszSrvPath[mir_strlen(pszSrvPath)]);
ReplaceSign(szFileName, MAX_PATH, '&', "&amp;");
if (pclCur->bIsDirectory()) {
- szFileName[mir_strlen(szFileName)-1] = '\0';
+ szFileName[mir_strlen(szFileName) - 1] = '\0';
if (!strchr(szFileName, '/')) { // only one level deeper
- pszBuffer += mir_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))
break;
}
- } else {
+ }
+ else {
if (!strchr(szFileName, '/') && // only one level deeper
- strncmp(pszRealPath, pclCur->st.pszRealPath, mir_strlen(pszRealPath))) { // no duplicates
+ strncmp(pszRealPath, pclCur->st.pszRealPath, mir_strlen(pszRealPath))) { // no duplicates
pszExt = strrchr(szFileName, '.');
if (pszExt != NULL) {
@@ -209,7 +211,7 @@ bool bCreateIndexXML(const char * pszRealPath, const char * pszIndexPath, const
FILETIME ftFileCreateTime;
FILETIME ftFileAccessTime;
FILETIME ftFileModifyTime;
- HANDLE hFileS = CreateFile(pclCur->st.pszRealPath, GENERIC_READ,
+ HANDLE hFileS = CreateFile(pclCur->st.pszRealPath, GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFileS != INVALID_HANDLE_VALUE) {
dwFileSize = GetFileSize(hFileS, NULL);
@@ -217,24 +219,24 @@ bool bCreateIndexXML(const char * pszRealPath, const char * pszIndexPath, const
CloseHandle(hFileS);
}
- pszBuffer += mir_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 += mir_snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
- "created=\"%i/%02i/%02i %i:%02i:%02i\" ",
+ pszBuffer += mir_snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
+ "created=\"%i/%02i/%02i %i:%02i:%02i\" ",
systemTime.wYear, systemTime.wMonth, systemTime.wDay, systemTime.wHour,
systemTime.wMinute, systemTime.wSecond);
FileTimeToSystemTime(&ftFileModifyTime, &systemTime);
- pszBuffer += mir_snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
- "modified=\"%i/%02i/%02i %i:%02i:%02i\" ",
+ pszBuffer += mir_snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
+ "modified=\"%i/%02i/%02i %i:%02i:%02i\" ",
systemTime.wYear, systemTime.wMonth, systemTime.wDay, systemTime.wHour,
systemTime.wMinute, systemTime.wSecond);
- pszBuffer += mir_snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
+ pszBuffer += mir_snprintf(pszBuffer, BUFFER_SIZE - (pszBuffer - szBuffer),
"/>\r\n");
if (!WriteFile(hFile, szBuffer, pszBuffer - szBuffer, &dwBytesWritten, NULL))
@@ -250,4 +252,4 @@ bool bCreateIndexXML(const char * pszRealPath, const char * pszIndexPath, const
CloseHandle(hFile);
return TRUE;
-} \ No newline at end of file
+}
diff --git a/plugins/HTTPServer/src/MimeHandling.cpp b/plugins/HTTPServer/src/MimeHandling.cpp
index 85aa0a1312..78f8c3c91c 100644
--- a/plugins/HTTPServer/src/MimeHandling.cpp
+++ b/plugins/HTTPServer/src/MimeHandling.cpp
@@ -5,7 +5,8 @@ ContentTypeDB MIME = NULL;
/* Default Mime type when recognition fails */
char DefaultMime[] = "application/octet-stream";
-int bInitMimeHandling() {
+int bInitMimeHandling()
+{
FILE *mimeDB;
char line[LINE_MAX_SIZE];
char *tok = NULL;
@@ -24,7 +25,7 @@ int bInitMimeHandling() {
/*filter junk lines assuming Mime type start with letter
(convention ?) */
if ((line[0] <= 'z' && line[0] >= 'a')
- || (line[0] <= 'Z' && line[0] >= 'A')) {
+ || (line[0] <= 'Z' && line[0] >= 'A')) {
/*remove comments trailing comments*/
tok = strrchr(line, '#');
if (tok != NULL) {
@@ -54,7 +55,8 @@ int bInitMimeHandling() {
/*link*/
if (pDBCell->extList == NULL) {
pDBCell->extList = pExtCell;
- } else {
+ }
+ else {
extListCur->next = pExtCell;
}
extListCur = pExtCell;
@@ -64,11 +66,13 @@ int bInitMimeHandling() {
if (pDBCell->extList != NULL) { /*extension(s) found*/
if (MIME == NULL) {
MIME = pDBCell;
- } else {
+ }
+ else {
pDB->next = pDBCell;
}
pDB = pDBCell;
- } else { /*no extension found, freeing memory*/
+ }
+ else { /*no extension found, freeing memory*/
free(pDBCell->mimeType);
free(pDBCell);
}
@@ -83,7 +87,8 @@ int bInitMimeHandling() {
return 1;
}
-const char * pszGetMimeType(const char * pszFileName) {
+const char* pszGetMimeType(const char * pszFileName)
+{
ContentTypeDB courMIME;
ExtensionList courEXT;
const char* ext;
@@ -94,7 +99,8 @@ const char * pszGetMimeType(const char * pszFileName) {
if (ext[1] == '\0') {
/*empty extension */
return DefaultMime;
- } else {
+ }
+ else {
/*remove the "."*/
ext = ext + 1;
}
@@ -112,15 +118,16 @@ const char * pszGetMimeType(const char * pszFileName) {
}
/*extension unknown*/
return DefaultMime;
- } else {
+ }
+ else {
/*no extension*/
return DefaultMime;
}
}
-
#ifdef TEST
-void printDB() {
+void printDB()
+{
ContentTypeDB courMIME;
ExtensionList courEXT;
@@ -137,7 +144,8 @@ void printDB() {
}
}
-int main(int argc, char* argv[]) {
+int main(int argc, char* argv[])
+{
bInitMimeHandling();
printDB();
printf("%s\n", pszGetMimeType(argv[1]));
diff --git a/plugins/HTTPServer/src/main.cpp b/plugins/HTTPServer/src/main.cpp
index 5b543738b9..5e1ce54f3f 100644
--- a/plugins/HTTPServer/src/main.cpp
+++ b/plugins/HTTPServer/src/main.cpp
@@ -20,19 +20,19 @@
#define szConfigFile "HTTPServer.xml"
-const TCHAR szXmlHeader[] = _T("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\r\n")
- _T("<?xml-stylesheet type=\"text/xsl\" href=\"HTTPServer.xsl\"?>\r\n")
- _T("<config>\r\n");
+const TCHAR szXmlHeader[] = _T("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\r\n")
+_T("<?xml-stylesheet type=\"text/xsl\" href=\"HTTPServer.xsl\"?>\r\n")
+_T("<config>\r\n");
-const char szXmlData[] = "\t<share>\r\n"
- "\t\t<name>%s</name>\r\n"
- "\t\t<file>%s</file>\r\n"
- "\t\t<max_downloads>%d</max_downloads>\r\n"
- "\t\t<ip_address>%d.%d.%d.%d</ip_address>\r\n"
- "\t\t<ip_mask>%d.%d.%d.%d</ip_mask>\r\n"
- "\t</share>\r\n";
+const char szXmlData[] = "\t<share>\r\n"
+"\t\t<name>%s</name>\r\n"
+"\t\t<file>%s</file>\r\n"
+"\t\t<max_downloads>%d</max_downloads>\r\n"
+"\t\t<ip_address>%d.%d.%d.%d</ip_address>\r\n"
+"\t\t<ip_mask>%d.%d.%d.%d</ip_mask>\r\n"
+"\t</share>\r\n";
-const TCHAR szXmlTail[] = _T("</config>");
+const TCHAR szXmlTail[] = _T("</config>");
const char* pszDefaultShares[] = {
"htdocs\\@settings\\favicon.ico", "/favicon.ico",
@@ -64,7 +64,7 @@ static HANDLE hHttpGetAllShares = 0;
static HGENMENU hAcceptConnectionsMenuItem = 0;
-char szPluginPath[MAX_PATH] = {0};
+char szPluginPath[MAX_PATH] = { 0 };
int nPluginPathLen = 0;
DWORD dwLocalIpAddress = 0;
@@ -116,8 +116,9 @@ PLUGININFOEX pluginInfo = {
// Developer : KN
/////////////////////////////////////////////////////////////////////
-bool bOpenLogFile() {
- SHELLEXECUTEINFO st = {0};
+bool bOpenLogFile()
+{
+ SHELLEXECUTEINFO st = { 0 };
st.cbSize = sizeof(st);
st.fMask = SEE_MASK_INVOKEIDLIST;
st.hwnd = NULL;
@@ -128,7 +129,8 @@ bool bOpenLogFile() {
}
-bool bWriteToFile(HANDLE hFile, const char * pszSrc, int nLen = -1) {
+bool bWriteToFile(HANDLE hFile, const char * pszSrc, int nLen = -1)
+{
if (nLen < 0)
nLen = (int)mir_strlen(pszSrc);
DWORD dwBytesWritten;
@@ -150,7 +152,8 @@ bool bWriteToFile(HANDLE hFile, const char * pszSrc, int nLen = -1) {
// Developer : KN
/////////////////////////////////////////////////////////////////////
-void LogEvent(const TCHAR * pszTitle, const char * pszLog) {
+void LogEvent(const TCHAR * pszTitle, const char * pszLog)
+{
HANDLE hFile = CreateFile(sLogFilePath.c_str(), GENERIC_WRITE, FILE_SHARE_READ, 0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE) {
MessageBox(NULL, TranslateT("Failed to open or create log file"), MSG_BOX_TITEL, MB_OK);
@@ -168,14 +171,14 @@ void LogEvent(const TCHAR * pszTitle, const char * pszLog) {
int nLen = (int)strftime(szTmp, sizeof(szTmp), "%d-%m-%Y %H:%M:%S -- ", localtime(&now));
int nLogLen = (int)mir_strlen(pszLog);
- while (nLogLen > 0 && (pszLog[nLogLen-1] == '\r' || pszLog[nLogLen-1] == '\n'))
+ while (nLogLen > 0 && (pszLog[nLogLen - 1] == '\r' || pszLog[nLogLen - 1] == '\n'))
nLogLen--;
if (!bWriteToFile(hFile, szTmp, nLen) ||
- !bWriteToFile(hFile, pszTitle) ||
- !bWriteToFile(hFile, " : ") ||
- !bWriteToFile(hFile, pszLog, nLogLen) ||
- !bWriteToFile(hFile, "\r\n")) {
+ !bWriteToFile(hFile, pszTitle) ||
+ !bWriteToFile(hFile, " : ") ||
+ !bWriteToFile(hFile, pszLog, nLogLen) ||
+ !bWriteToFile(hFile, "\r\n")) {
MessageBox(NULL, TranslateT("Failed to write some part of the log file"), MSG_BOX_TITEL, MB_OK);
}
CloseHandle(hFile);
@@ -196,10 +199,11 @@ void LogEvent(const TCHAR * pszTitle, const char * pszLog) {
// Developer : KN
/////////////////////////////////////////////////////////////////////
-DWORD dwReadIPAddress(char * pszStr, bool &bError) {
+DWORD dwReadIPAddress(char * pszStr, bool &bError)
+{
DWORD ip = 0;
char *pszEnd;
- for (int n = 0 ; n < 4 ; n++) {
+ for (int n = 0; n < 4; n++) {
int nVal = strtol(pszStr, &pszEnd, 10);
if (pszEnd <= pszStr || (n != 3 && pszEnd[0] != '.') || (nVal < 0 || nVal > 255)) {
bError = true;
@@ -233,26 +237,26 @@ bool bReadConfigurationFile()
char szBuf[1000];
mir_strcpy(szBuf, szPluginPath);
mir_strcat(szBuf, szConfigFile);
- HANDLE hFile = CreateFile(szBuf, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
+ HANDLE hFile = CreateFile(szBuf, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE)
return false;
-
+
char *pszCurPos = szBuf;
bool bEof = false;
while (!bEof) {
DWORD dwBytesInBuffer = 0;
-
+
// move rest of buffer to front
if (pszCurPos && pszCurPos != szBuf) {
dwBytesInBuffer = DWORD(sizeof(szBuf) - (pszCurPos - szBuf));
memmove(szBuf, pszCurPos, dwBytesInBuffer * sizeof(TCHAR));
}
-
+
// append data to buffer
DWORD dwBytesRead = 0;
- bEof = !ReadFile(hFile, &szBuf[dwBytesInBuffer], sizeof(szBuf) - dwBytesInBuffer,
+ bEof = !ReadFile(hFile, &szBuf[dwBytesInBuffer], sizeof(szBuf) - dwBytesInBuffer,
&dwBytesRead, NULL) || dwBytesRead <= 0;
pszCurPos = szBuf;
@@ -260,8 +264,8 @@ bool bReadConfigurationFile()
while (pszCurPos && (pszCurPos = strstr(pszCurPos, "<share>")) != NULL) {
pszCurPos += 7;
- char * pszColData[5] = {NULL};
- for (int n = 0 ; n < 5 ; n++) {
+ char * pszColData[5] = { NULL };
+ for (int n = 0; n < 5; n++) {
pszColData[n] = strstr(pszCurPos, ">");
if (!pszColData[n])
break;
@@ -297,13 +301,14 @@ bool bReadConfigurationFile()
continue;
}
- if (! pclLastNode) {
+ if (!pclLastNode) {
pclLastNode = pclFirstNode = pcl;
- } else {
+ }
+ else {
pclLastNode->pclNext = pcl;
pclLastNode = pcl;
}
-
+
// refill buffer
if (!bEof && pszCurPos - szBuf > sizeof(szBuf) / 2)
break;
@@ -338,26 +343,27 @@ bool bWriteConfigurationFile()
if (hFile == INVALID_HANDLE_VALUE) {
TCHAR temp[200];
mir_sntprintf(temp, _T("%s%s"), TranslateT("Failed to open or create file "), _T(szConfigFile));
- MessageBox(NULL, temp , MSG_BOX_TITEL, MB_OK);
+ MessageBox(NULL, temp, MSG_BOX_TITEL, MB_OK);
return false;
}
DWORD dwBytesWriten = 0;
- if (! WriteFile(hFile, szXmlHeader, sizeof(szXmlHeader) - 1, &dwBytesWriten, NULL)) {
+ if (!WriteFile(hFile, szXmlHeader, sizeof(szXmlHeader) - 1, &dwBytesWriten, NULL)) {
TCHAR temp[200];
mir_sntprintf(temp, _T("%s%s"), TranslateT("Failed to write xml header to file "), _T(szConfigFile));
MessageBox(NULL, temp, MSG_BOX_TITEL, MB_OK);
- } else {
+ }
+ else {
CLFileShareNode * pclCur = pclFirstNode;
while (pclCur) {
- DWORD dwBytesToWrite = mir_snprintf(szBuf, szXmlData ,
- pclCur->st.pszSrvPath,
- pclCur->pszOrigRealPath,
- pclCur->st.nMaxDownloads,
- SplitIpAddress(pclCur->st.dwAllowedIP),
- SplitIpAddress(pclCur->st.dwAllowedMask));
-
- if (! WriteFile(hFile, szBuf, dwBytesToWrite, &dwBytesWriten, NULL)) {
+ DWORD dwBytesToWrite = mir_snprintf(szBuf, szXmlData,
+ pclCur->st.pszSrvPath,
+ pclCur->pszOrigRealPath,
+ pclCur->st.nMaxDownloads,
+ SplitIpAddress(pclCur->st.dwAllowedIP),
+ SplitIpAddress(pclCur->st.dwAllowedMask));
+
+ if (!WriteFile(hFile, szBuf, dwBytesToWrite, &dwBytesWriten, NULL)) {
TCHAR temp[200];
mir_sntprintf(temp, _T("%s%s"), TranslateT("Failed to write xml data to file "), _T(szConfigFile));
MessageBox(NULL, temp, MSG_BOX_TITEL, MB_OK);
@@ -366,10 +372,10 @@ bool bWriteConfigurationFile()
pclCur = pclCur->pclNext;
}
- if (! WriteFile(hFile, szXmlTail, sizeof(szXmlTail) - 1, &dwBytesWriten, NULL)) {
- TCHAR temp[200];
- mir_sntprintf(temp, _T("%s%s"), TranslateT("Failed to write xml tail to file "), _T(szConfigFile));
- MessageBox(NULL, temp, MSG_BOX_TITEL, MB_OK);
+ if (!WriteFile(hFile, szXmlTail, sizeof(szXmlTail) - 1, &dwBytesWriten, NULL)) {
+ TCHAR temp[200];
+ mir_sntprintf(temp, _T("%s%s"), TranslateT("Failed to write xml tail to file "), _T(szConfigFile));
+ MessageBox(NULL, temp, MSG_BOX_TITEL, MB_OK);
}
}
SetEndOfFile(hFile);
@@ -410,7 +416,7 @@ static INT_PTR nAddChangeRemoveShare(WPARAM wParam, LPARAM lParam)
return 1002;
CLFileShareListAccess clCritSection;
- bool bIsDirectory = (pclNew->pszSrvPath[mir_strlen(pclNew->pszSrvPath)-1] == '/');
+ bool bIsDirectory = (pclNew->pszSrvPath[mir_strlen(pclNew->pszSrvPath) - 1] == '/');
CLFileShareNode **pclPrev = &pclFirstNode;
CLFileShareNode * pclCur = pclFirstNode;
@@ -444,9 +450,10 @@ static INT_PTR nAddChangeRemoveShare(WPARAM wParam, LPARAM lParam)
// remove this one
*pclPrev = pclCur->pclNext;
delete pclCur;
- } else {
+ }
+ else {
// update info !!
- if (! pclCur->bSetInfo(pclNew))
+ if (!pclCur->bSetInfo(pclNew))
return 1003;
}
return !bWriteConfigurationFile();
@@ -608,7 +615,7 @@ static int nProtoAck(WPARAM /*wParam*/, LPARAM lParam)
//todo: ignore weather protos
ACKDATA *ack = (ACKDATA *)lParam;
if (ack->type != ACKTYPE_STATUS || //only send for statuses
- ack->result != ACKRESULT_SUCCESS) //only successful ones
+ ack->result != ACKRESULT_SUCCESS) //only successful ones
return 0;
bIsOnline = ((int)ack->lParam != ID_STATUS_AWAY && (int)ack->lParam != ID_STATUS_NA);
@@ -634,7 +641,7 @@ INT_PTR nToggelAcceptConnections(WPARAM wparam, LPARAM /*lparam*/)
if (!hDirectBoundPort) {
NETLIBUSERSETTINGS nus = { 0 };
nus.cbSize = sizeof(nus);
- if (!CallService(MS_NETLIB_GETUSERSETTINGS, (WPARAM) hNetlibUser, (LPARAM) &nus))
+ if (!CallService(MS_NETLIB_GETUSERSETTINGS, (WPARAM)hNetlibUser, (LPARAM)&nus))
Netlib_Logf(hNetlibUser, "Failed to get NETLIBUSERSETTINGS using MS_NETLIB_GETUSERSETTINGS");
NETLIBBIND nlb = { 0 };
@@ -645,10 +652,10 @@ INT_PTR nToggelAcceptConnections(WPARAM wparam, LPARAM /*lparam*/)
else
nlb.wPort = 80;
- hDirectBoundPort = (HANDLE) CallService(MS_NETLIB_BINDPORT, (WPARAM) hNetlibUser, (LPARAM) & nlb);
+ hDirectBoundPort = (HANDLE)CallService(MS_NETLIB_BINDPORT, (WPARAM)hNetlibUser, (LPARAM)& nlb);
if (!hDirectBoundPort) {
TCHAR szTemp[200];
- mir_snprintf(szTemp, TranslateT("Failed to bind to port %s\r\nThis is most likely because another program or service is using this port") ,
+ mir_snprintf(szTemp, TranslateT("Failed to bind to port %s\r\nThis is most likely because another program or service is using this port"),
nlb.wPort == 80 ? "80" : nus.szIncomingPorts);
MessageBox(NULL, szTemp, MSG_BOX_TITEL, MB_OK);
return 1001;
@@ -665,7 +672,7 @@ INT_PTR nToggelAcceptConnections(WPARAM wparam, LPARAM /*lparam*/)
}
else return 0; // no changes;
- if (! bShutdownInProgress)
+ if (!bShutdownInProgress)
db_set_b(NULL, MODULE, "AcceptConnections", hDirectBoundPort != 0);
return 0;
@@ -710,7 +717,7 @@ int MainInit(WPARAM /*wparam*/, LPARAM /*lparam*/)
{
if (!bReadConfigurationFile()) {
char szRealPath[MAX_PATH];
- char szSrvPath[MAX_PATH] = {0};
+ char szSrvPath[MAX_PATH] = { 0 };
STFileShareInfo share;
const char** p = pszDefaultShares;
@@ -743,7 +750,7 @@ int MainInit(WPARAM /*wparam*/, LPARAM /*lparam*/)
nlu.flags = NUF_OUTGOING | NUF_INCOMING | NUF_TCHAR;
nlu.szSettingsModule = MODULE;
nlu.ptszDescriptiveName = TranslateT("HTTP Server");
- hNetlibUser = (HANDLE) CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM) & nlu);
+ hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)& nlu);
if (!hNetlibUser) {
MessageBox(NULL, _T("Failed to register NetLib user"), MSG_BOX_TITEL, MB_OK);
return 0;
@@ -777,7 +784,7 @@ int PreShutdown(WPARAM /*wparam*/, LPARAM /*lparam*/)
CLFileShareListAccess clCrit;
bShutdownInProgress = true;
- for (CLFileShareNode * pclCur = pclFirstNode; pclCur ; pclCur = pclCur->pclNext) {
+ for (CLFileShareNode * pclCur = pclFirstNode; pclCur; pclCur = pclCur->pclNext) {
pclCur->CloseAllTransfers();
}
}
@@ -834,7 +841,8 @@ int nSystemShutdown(WPARAM /*wparam*/, LPARAM /*lparam*/)
// Developer : KN, Houdini
/////////////////////////////////////////////////////////////////////
-extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD /*mirandaVersion*/) {
+extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD /*mirandaVersion*/)
+{
return &pluginInfo;
}
@@ -857,25 +865,25 @@ extern "C" __declspec(dllexport) int Load()
mir_getCLI();
hHttpAcceptConnectionsService = CreateServiceFunction(MS_HTTP_ACCEPT_CONNECTIONS, nToggelAcceptConnections);
- if (! hHttpAcceptConnectionsService) {
+ if (!hHttpAcceptConnectionsService) {
MessageBox(NULL, _T("Failed to CreateServiceFunction MS_HTTP_ACCEPT_CONNECTIONS"), MSG_BOX_TITEL, MB_OK);
return 1;
}
hHttpAddChangeRemoveService = CreateServiceFunction(MS_HTTP_ADD_CHANGE_REMOVE, nAddChangeRemoveShare);
- if (! hHttpAddChangeRemoveService) {
+ if (!hHttpAddChangeRemoveService) {
MessageBox(NULL, _T("Failed to CreateServiceFunction MS_HTTP_ADD_CHANGE_REMOVE"), MSG_BOX_TITEL, MB_OK);
return 1;
}
hHttpGetShareService = CreateServiceFunction(MS_HTTP_GET_SHARE, nGetShare);
- if (! hHttpGetShareService) {
+ if (!hHttpGetShareService) {
MessageBox(NULL, _T("Failed to CreateServiceFunction MS_HTTP_GET_SHARE"), MSG_BOX_TITEL, MB_OK);
return 1;
}
hHttpGetAllShares = CreateServiceFunction(MS_HTTP_GET_ALL_SHARES, nHttpGetAllShares);
- if (! hHttpGetAllShares) {
+ if (!hHttpGetAllShares) {
MessageBox(NULL, _T("Failed to CreateServiceFunction MS_HTTP_GET_ALL_SHARES"), MSG_BOX_TITEL, MB_OK);
return 1;
}
@@ -893,15 +901,13 @@ extern "C" __declspec(dllexport) int Load()
return 1;
}
- if(CallService(MS_DB_GETPROFILEPATH,MAX_PATH,(LPARAM)szPluginPath))
- {
+ if (CallService(MS_DB_GETPROFILEPATH, MAX_PATH, (LPARAM)szPluginPath)) {
MessageBox(NULL, _T("Failed to retrieve plugin path."), MSG_BOX_TITEL, MB_OK);
return 1;
}
mir_tstrncat(szPluginPath, _T("\\HTTPServer\\"), _countof(szPluginPath) - mir_tstrlen(szPluginPath));
int err = CreateDirectoryTree(szPluginPath);
- if((err != 0) && (err != ERROR_ALREADY_EXISTS))
- {
+ if ((err != 0) && (err != ERROR_ALREADY_EXISTS)) {
MessageBox(NULL, _T("Failed to create HTTPServer directory."), MSG_BOX_TITEL, MB_OK);
return 1;
}
@@ -918,7 +924,7 @@ extern "C" __declspec(dllexport) int Load()
nMaxConnectionsTotal = db_get_dw(NULL, MODULE, "MaxConnectionsTotal", nMaxConnectionsTotal);
nMaxConnectionsPerUser = db_get_dw(NULL, MODULE, "MaxConnectionsPerUser", nMaxConnectionsPerUser);
bLimitOnlyWhenOnline = db_get_b(NULL, MODULE, "LimitOnlyWhenOnline", bLimitOnlyWhenOnline) != 0;
- indexCreationMode = (eIndexCreationMode) db_get_b(NULL, MODULE, "IndexCreationMode", 2);
+ indexCreationMode = (eIndexCreationMode)db_get_b(NULL, MODULE, "IndexCreationMode", 2);
if (db_get_b(NULL, MODULE, "AddAcceptConMenuItem", 1)) {
CMenuItem mi;
@@ -956,7 +962,7 @@ extern "C" __declspec(dllexport) int Load()
extern "C" __declspec(dllexport) int Unload()
{
nSystemShutdown(0, 0);
- if(hwndStatsticView)
+ if (hwndStatsticView)
DestroyWindow(hwndStatsticView);
return 0;
}