Daemon.cpp
资源名称:warftpd.zip [点击查看]
上传用户:surprise9
上传日期:2007-01-04
资源大小:426k
文件大小:19k
源码类别:
Ftp客户端
开发平台:
Visual C++
- // This is part of the WAR SOFTWARE SERIES initiated by Jarle Aase
- // Copyright 1996 by Jarle Aase. All rights reserved.
- // See the "War Software Series Licende Agreement" for details concerning
- // use and distribution.
- // ---
- // This source code, executables and programs containing source code or
- // binaries or proprietetary technology from the War Software Series are
- // NOT alloed used, viewed or tested by any governmental agencies in
- // any countries. This includes the government, departments, police,
- // military etc.
- // ---
- // This file is intended for use with Tab space = 2
- // Created and maintained in MSVC Developer Studio
- // ---
- // NAME : Daemon.cpp
- // PURPOSE : General entry point module for War Daemons
- // PROGRAM :
- // DATE : Sept. 19 1996
- // AUTHOR : Jarle Aase
- // ---
- // REVISION HISTORY
- //
- #include "stdafx.h"
- #include "..IncludeWarDaemon.h"
- #include "..IncludeWarService.h"
- #include "FsysSecurity.h"
- #include "ServerDlg.h"
- #include <process.h>
- #include <direct.h>
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- static CDaemon *DaemonPtr; // Pointer to the deamon object
- static WSADATA socInfo; // Windows socket info
- DLL_WAR_DAEMON_ BOOL g_DoRestart = FALSE; // Restart
- VOID CALLBACK TimerProc(HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime);
- ////////////////////////////////////////////////////////////////////
- // CDaemon class
- IMPLEMENT_DYNAMIC(CDaemon, CObject)
- CDaemon::CDaemon()
- {
- DaemonPtr = this;
- m_pWnd = NULL;
- }
- CDaemon::~CDaemon()
- {
- DaemonPtr = NULL;
- if (m_pWnd)
- delete m_pWnd;
- }
- // Main entry point. Does not return until the server is
- // terminated.
- void CDaemon::Process(
- LPCSTR SvrType,
- LPCSTR ProgramName,
- LPCSTR ProgramVersion,
- LPCSTR ProgramCopyright,
- CRuntimeClass *MainThreadClass)
- {
- char *CmdLine = GetCommandLine();
- #ifdef _DEBUG
- //DebugBreak();
- #endif
- CString cMyHomeDir, cMyName, cBuf;
- ::GetLineParam("-Name", cMyName, "Default");
- cBuf = GetStartupPath();
- LPSTR p = cBuf.GetBuffer(1);
- if (p = strrchr(p, '\'))
- *p = 0;
- cBuf.ReleaseBuffer();
- cMyHomeDir.Format("%s\Daemons\%s\%s",cBuf, SvrType, cMyName);
- if (_chdir(cMyHomeDir))
- {
- cBuf.Format("Unable to change directory to '%s'.rnPlease reinstall the server.", cMyHomeDir);
- AfxMessageBox(cBuf);
- return;
- }
- if (CmdLine && ((CmdLine = strrchr(CmdLine,' ')) != NULL))
- ++CmdLine;
- m_NTSoptions = new CDaemonNTSOptions();
- m_NTSoptions->Create(NULL, NULL, "NTService", COPTION_NTSERVICE);
- m_NTSoptions->LoadAll();
- if (m_NTSoptions->m_ServiceName.IsEmpty())
- {
- // Assign default values
- m_NTSoptions->m_ServiceName.Format("%s V2", ProgramName);
- m_NTSoptions->m_VisualName.Format("%s %s", ProgramName, ProgramVersion);
- m_NTSoptions->m_ServiceMode = 3;
- m_NTSoptions->m_LoginAsLocalAdmin = TRUE;
- m_NTSoptions->SaveAll();
- }
- m_Service = new CNTService(m_NTSoptions->m_ServiceName, MainThreadClass);
- ::GetLineParam("-ServiceMode", cBuf, "auto");
- BOOL SuspendService = (cBuf == "off");
- if (SuspendService
- || !m_Service->IsInstalled()
- || !m_Service->StartService())
- {
- delete m_Service;
- m_Service = NULL;
- g_DoRestart = TRUE;
- m_pWnd = new CWnd;
- m_pWnd->m_hWnd = NULL;
- if (!m_pWnd->CreateEx(0, AfxRegisterWndClass(0),
- _T("War Daemon App Message Sink"),
- WS_OVERLAPPED, 0, 0, 0, 0, NULL, NULL))
- {
- TRACE0("Warning: unable to create War Daemon App Message Sink window!n");
- AfxThrowResourceException();
- }
- ASSERT(m_pWnd->m_hWnd != NULL);
- ASSERT(CWnd::FromHandlePermanent(m_pWnd->m_hWnd) == m_pWnd);
- AfxGetThread()->m_pMainWnd = CDaemonNotificationWnd::GetWin();
- while(g_DoRestart)
- {
- _chdir(cMyHomeDir);
- g_DoRestart = FALSE;
- // Start the thread and run quiet as a normal program
- m_MainThread = AfxBeginThread(MainThreadClass);
- HANDLE hList[2];
- hList[0] = m_MainThread->m_hThread;
- hList[1] = INVALID_HANDLE_VALUE;
- again:
- DWORD Rval = MsgWaitForMultipleObjects(1, hList, FALSE, INFINITE, QS_ALLINPUT);
- if (Rval == (WAIT_OBJECT_0 + 1 ))
- {
- // Message
- MSG Msg;
- if (PeekMessage(&Msg, m_pWnd->m_hWnd, 0, 0, PM_REMOVE))
- {
- TranslateMessage(&Msg);
- DispatchMessage(&Msg);
- }
- goto again;
- }
- //WaitForSingleObject(m_MainThread->m_hThread,INFINITE);
- }
- }
- m_NTSoptions->SaveAll();
- delete m_NTSoptions;
- m_NTSoptions = NULL;
- }
- /////////////////////////////////////////////////////////////////////////////
- // CDaemonBase
- IMPLEMENT_DYNCREATE(CDaemonBase, CWinThread)
- CDaemonBase *CDaemonBase::m_pDaemonBase = NULL;
- CDaemonBase::CDaemonBase()
- {
- m_RemoteAdminListenSocket = NULL;
- m_pDaemonBase = this;
- m_TrayIsInitialized = 0;
- m_hIcon = (HICON)0;
- m_SysTrayIdle = (HICON)0;
- m_SysTrayOnline = (HICON)0;
- m_SysTrayOffline = (HICON)0;
- m_pWnd = NULL;
- }
- CDaemonBase::~CDaemonBase()
- {
- m_pDaemonBase = NULL;
- if (m_pWnd)
- delete (CDaemonNotificationWnd *)m_pWnd;
- }
- void CDaemonBase::LogMsg(int flag, LPCSTR Format, ...)
- {
- if (!ShouldLog(m_Log, flag))
- return;
- ASSERT(AfxIsValidString(Format, FALSE));
- va_list argList;
- va_start(argList, Format);
- m_Log->LogMsgV(flag, Format, argList);
- va_end(argList);
- }
- BOOL CDaemonBase::InitInstance()
- {
- #ifdef _DEBUG
- //DebugBreak();
- #endif
- CString cMyHomeDir, cMyName, cBuf;
- ::GetLineParam("-Name", cMyName, "Default");
- cBuf = GetStartupPath();
- LPSTR p = cBuf.GetBuffer(1);
- if (p = strrchr(p, '\'))
- *p = 0;
- cBuf.ReleaseBuffer();
- cMyHomeDir.Format("%s\Daemons\%s\%s",cBuf, m_ServerStat.m_ServerType, cMyName);
- if (_chdir(cMyHomeDir))
- {
- cBuf.Format("Unable to change directory to '%s'.rnPlease reinstall the server.", cMyHomeDir);
- AfxMessageBox(cBuf);
- return FALSE;
- }
- CDaemonNotificationWnd* pWnd = new CDaemonNotificationWnd;
- m_pWnd = pWnd;
- pWnd->m_hWnd = NULL;
- if (!pWnd->CreateEx(0, AfxRegisterWndClass(0),
- _T("War Daemon Notification Sink"),
- WS_OVERLAPPED, 0, 0, 0, 0, NULL, NULL))
- {
- TRACE0("Warning: unable to create War Daemon notify window!n");
- AfxThrowResourceException();
- }
- ASSERT(pWnd->m_hWnd != NULL);
- ASSERT(CWnd::FromHandlePermanent(pWnd->m_hWnd) == pWnd);
- m_pMainWnd = CDaemonNotificationWnd::GetWin();
- CSock::SetDNSWin(m_pMainWnd);
- // Load options
- m_RAOptions.Create(NULL, NULL, "Remote Admin", COPTION_RA_DAEMON);
- m_RAOptions.LoadAll();
- m_AdvancedOptions.Create(NULL,NULL,"Advanced",COPTION_ADVANCEDOPTIONS);
- m_AdvancedOptions.LoadAll();
- // Set priority
- SetPriorityClass(GetCurrentProcess(),CAdvancedOptions::GetPriority(m_AdvancedOptions.m_TaskPriority));
- LogMsg(LOGF_SYSTEM,"%s %s %s",
- CProgramInfo::m_PROGRAM,
- CProgramInfo::m_VERSION,
- CProgramInfo::m_COPYRIGHT);
- LogMsg(LOGF_SYSTEM,"This program is not lisenced to governmental or military use.");
- LogMsg(LOGF_SYSTEM,"%s detected.", OsName());
- if (DaemonPtr->m_Service)
- {
- LogMsg(LOGF_SYSTEM,"Running as NT service '%s' (%s).",
- COptions::GetOption(COPTION_NTSERVICE, NTSERVICE__VISUALNAME),
- COptions::GetOption(COPTION_NTSERVICE, NTSERVICE__SERVICENAME));
- }
- {
- char buf[MAX_PATH];
- if (_getcwd(buf,sizeof(buf)))
- LogMsg(LOGF_SYSTEM,"Current Server homedir is: '%s'", buf);
- else
- LogMsg(LOGF_ERROR,"Current Server homedir is -UNKNOWN-");
- }
- // We need sockets for the server control network interface
- #ifndef _MAC
- if (!AfxSocketInit(&socInfo))
- {
- //AfxMessageBox(CG_IDS_SOCKETS_INIT_FAILED1);
- return FALSE;
- }
- #endif // _MAC
- LogMsg(LOGF_SYSTEM,"%s", socInfo.szDescription);
- CSock::GetHostIpNumber(cBuf);
- LogMsg(LOGF_SYSTEM,"Primary local IP number reported by Winsock is %s", cBuf);
- LogMsg(LOGF_SYSTEM,"Services online on 0.0.0.0 will use any local IP number.");
- m_TimerID = ::SetTimer(NULL,0,1000,TimerProc);
- if (!m_TimerID)
- LogMsg(LOGF_WARNINGS,"CWarMainThread::InitInstance(): Failed to start primary timer. Server might be unreliable.");
- // Set priority
- //switch(g_Priority)
- //{
- // case 0: SetPriorityClass(GetCurrentProcess(),REALTIME_PRIORITY_CLASS); break;
- // case 1: SetPriorityClass(GetCurrentProcess(),HIGH_PRIORITY_CLASS); break;
- // case 2: SetPriorityClass(GetCurrentProcess(),NORMAL_PRIORITY_CLASS); break;
- // case 3: SetPriorityClass(GetCurrentProcess(),IDLE_PRIORITY_CLASS); break;
- //}
- // Initialize user
- ASSERT(m_User != NULL);
- if (!m_User->Create(m_Log))
- {
- LogMsg(LOGF_ERROR,"Failed to initialize user database. Terminating.");
- return FALSE;
- }
- // Initialize vfsys
- /*
- ASSERT(m_Fsys != NULL);
- if (!m_Fsys->Create(m_Log))
- {
- LogMsg(LOGF_ERROR,"Failed to initialize file system. Terminating.");
- return FALSE;
- }
- */
- ASSERT(m_RemoteAdminListenSocket != NULL);
- // Set the static log pointer for all sockets in this server
- m_RemoteAdminListenSocket->SetLog(m_Log);
- // Enable remote admin...
- if (!m_RemoteAdminListenSocket->Initialize(m_RAOptions.m_Port, NULL, m_RAOptions.m_IPname))
- {
- m_RemoteAdminListenSocket = NULL;
- LogMsg(LOGF_ERROR,"CDaemonBase::InitInstance(): Failed to start remote admin service. Terminating.");
- return FALSE;
- }
- CTextSock::InitSvrEvents();
- if (!DaemonPtr->m_Service)
- {
- // Not a service
- UpdateSystemTray("Initializing");
- }
- GoOnline(TRUE);
- // Load extention dll's
- m_pExtModules = new CAPIHandler;
- m_pExtModules->LoadExtentions();
- return TRUE;
- }
- int CDaemonBase::ExitInstance()
- {
- if (m_Log)
- {
- m_Log->SaveAll();
- LogMsg(LOGF_DEBUG,"ExitInstance() - Shutting down basic server resources.");
- m_Log->m_LogWin = NULL;
- }
- if (m_pExtModules)
- {
- delete m_pExtModules;
- m_pExtModules = NULL;
- }
- m_RAOptions.SaveAll();
- m_AdvancedOptions.SaveAll();
- if (m_RemoteAdminListenSocket)
- delete m_RemoteAdminListenSocket;
- CTextSock::TerminateSvrEvents();
- if (m_TrayIsInitialized)
- UpdateSystemTray(NULL);
- return CWinThread::ExitInstance();
- }
- BEGIN_MESSAGE_MAP(CDaemonBase, CWinThread)
- //{{AFX_MSG_MAP(CDaemonBase)
- // NOTE - the ClassWizard will add and remove mapping macros here.
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CDaemonBase message handlers
- // Override to fix MSVC 4.2 bug
- BOOL CDaemonBase::PreTranslateMessage(MSG* pMsg)
- {
- // If this is a timer callback message let it pass on through to the
- // DispatchMessage call.
- if( (pMsg->message==WM_TIMER) && (pMsg->hwnd==NULL) )
- return FALSE;
- return CWinThread::PreTranslateMessage(pMsg);
- }
- // General purpose message handler
- LRESULT CDaemonBase::GenericProcessMessage(WPARAM WParam, LPARAM LParam)
- {
- switch(WParam)
- {
- case PPT_SHUTDOWN:
- Shutdown((BOOL)LParam,TRUE);
- break;
- case PPT_SHUTDOWN_FAST:
- Shutdown((BOOL)LParam,TRUE,TRUE);
- break;
- case PPT_PAUSE:
- //GoOffline(TRUE);
- break;
- case PPT_CONTINUE:
- //GoOnlineInit(dlg->m_portNumber);
- break;
- }
- return TRUE;
- }
- void CDaemonBase::Shutdown(BOOL DoSave, BOOL Force, BOOL Critcal)
- {
- PostQuitMessage(0);
- }
- BOOL CDaemonBase::OnIdle( LONG lCount )
- {
- //MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_ALLINPUT);
- CWinThread::OnIdle(lCount);
- return CSock::OnIdle(lCount);
- }
- void CDaemonBase::RefreshStats()
- {
- // Must be initialized by derived class
- ASSERT(GetSvrStat()->m_ServerName.IsEmpty() == FALSE);
- // Update Admin port number
- GetSvrStat()->m_RemoteAPort = m_RAOptions.m_Port;
- // Update events.
- }
- BOOL CDaemonBase::UpdateSystemTray(LPCSTR ToolTip)
- {
- if (DaemonPtr->m_Service)
- return FALSE; // Not allowed when running as a service...
- if (!HasShell())
- return FALSE; // NT 3.51 does not have the system tray.
- NOTIFYICONDATA nd;
- if (ToolTip)
- sprintf(nd.szTip,"%s", ToolTip);
- else
- nd.szTip[0] = 0;
- nd.cbSize = sizeof(nd);
- nd.hWnd = m_pMainWnd->m_hWnd;
- nd.uID = 1;
- nd.uFlags = NIF_ICON | NIF_MESSAGE | (*nd.szTip ? NIF_TIP : 0);
- nd.uCallbackMessage = WMU_SNM;
- if (m_ServerStat.m_IsOnline)
- {
- if (m_ServerStat.m_UserConnections)
- nd.hIcon = m_SysTrayOnline;
- else
- nd.hIcon = m_SysTrayIdle;
- }
- else
- nd.hIcon = m_SysTrayOffline;
- m_TrayIsInitialized = Shell_NotifyIcon(
- ToolTip ? m_TrayIsInitialized ? NIM_MODIFY : NIM_ADD : NIM_DELETE , &nd);
- return m_TrayIsInitialized;
- }
- LONG CDaemonBase::OnTrayIconMessage(WPARAM WParam, LPARAM LParam)
- {
- if (!m_pDaemonBase)
- return FALSE;
- if (WParam == 1)
- {
- if (LParam == WM_LBUTTONDOWN)
- {
- //ShowWindow(SW_SHOWNORMAL);
- //MessageBox("Icon Clicked");
- return TRUE;
- }
- if (LParam == WM_RBUTTONDOWN)
- {
- POINT MousePos;
- GetCursorPos(&MousePos);
- CMenu Menu, *pMenu;
- Menu.LoadMenu(IDR_SVRPOPUPMENU);
- pMenu = Menu.GetSubMenu(0);
- if (m_pDaemonBase->m_ServerStat.m_IsOnline)
- pMenu->EnableMenuItem(ID_MENU_GOONLINE, MF_GRAYED);
- else
- pMenu->EnableMenuItem(ID_MENU_GOOFFLINE, MF_GRAYED);
- CDaemonNotificationWnd::GetWin()->SetForegroundWindow();
- pMenu->TrackPopupMenu(TPM_RIGHTBUTTON | TPM_RIGHTALIGN, MousePos.x, MousePos.y, CDaemonNotificationWnd::GetWin());
- pMenu->DestroyMenu();
- return TRUE;
- }
- }
- return FALSE;
- }
- BOOL CDaemonBase::GoOnline(BOOL Online)
- {
- ASSERT(FALSE); // Must be overridden.
- return FALSE;
- }
- BOOL CDaemonBase::StartManager()
- {
- CString cBuf;
- LPTSTR NotUsed;
- char Path[MAX_PATH];
- GetFullPathName(".\Daemon.wdm", MAX_PATH, Path, &NotUsed);
- HINSTANCE Rval = ShellExecute(
- AfxGetThread()->m_pMainWnd->m_hWnd,
- "open",
- Path,
- NULL,
- "",
- SW_SHOW);
- if (Rval <= (HINSTANCE)32)
- LogMsg(LOGF_ERROR,"StartManager() - Unable to start manager.");
- return (Rval > (HINSTANCE)32);
- }
- ///////////////////////////////////////////////////////////////////////////////////////
- // Support functions
- VOID CALLBACK TimerProc(HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime)
- {
- static long count;
- static BOOL blink;
- static long LastSave;
- static DWORD LastCalled;
- if (((LastCalled + 999) > GetTickCount()) && (LastCalled < GetTickCount()))
- return; // Just ignore queued TIMER messages
- LastCalled = GetTickCount();
- CDaemonBase *pSvr = CDaemonBase::GetSvr();
- if (pSvr)
- pSvr->m_Log->Flush(FALSE);
- // Call thread idle functions and check for shutdown...
- }
- ///////////////////////////////////////////////////////////////////////////////////////
- // CDaemonStatusSvr
- CDaemonStatusSvr::CDaemonStatusSvr()
- {
- m_EventHandle = CDaemonEvent::DsRegister(EVT_STAT, (LPVOID)this, SendStat);
- }
- CDaemonStatusSvr::~CDaemonStatusSvr()
- {
- if (m_EventHandle)
- CDaemonEvent::DsClose(m_EventHandle);
- m_ServerName.Empty();
- m_ServerEmail.Empty();
- m_ServerType.Empty();
- m_ServerListeningIP.Empty();
- m_ServerStartedFmt.Empty();
- }
- // Format data for telnet output
- LPCSTR CDaemonStatusSvr::FormatStats(CString& cReturnBuf, BOOL IsInteractive)
- {
- char timebuf[32];
- CString cBuf;
- char RS = IsInteractive ? 'n' : 1;
- int Padding = IsInteractive ? 20 : 0;
- CLog::FormatTime(m_ServerStarted, timebuf);
- cReturnBuf.Empty();
- cBuf.Format("00 %s%c", IsInteractive ? "Server information:" : "", RS);
- cReturnBuf += cBuf;
- cBuf.Format("01 %-*s%s%c", Padding, IsInteractive ? "Type:" : "", m_ServerType, RS);
- cReturnBuf += cBuf;
- cBuf.Format("02 %-*s%s%c", Padding, IsInteractive ? "Name:" : "", m_ServerName, RS);
- cReturnBuf += cBuf;
- cBuf.Format("03 %-*s%s%c", Padding, IsInteractive ? "Created:" : "", timebuf, RS);
- cReturnBuf += cBuf;
- cBuf.Format("04 %-*s%s%c", Padding, IsInteractive ? "Shutdown:" : "", m_ShutdownPending ? "Pending" : "Not set", RS);
- cReturnBuf += cBuf;
- cBuf.Format("05 %-*s%s%c", Padding, IsInteractive ? "Online:" : "", m_IsOnline ? "Yes" : "No", RS);
- cReturnBuf += cBuf;
- cBuf.Format("06 %-*s%s%c", Padding, IsInteractive ? "Listening IP:" : "", m_ServerListeningIP, RS);
- cReturnBuf += cBuf;
- cBuf.Format("07 %-*s%d%c", Padding, IsInteractive ? "Port number:" : "", m_ServerPort, RS);
- cReturnBuf += cBuf;
- cBuf.Format("08 %-*s%d%c", Padding, IsInteractive ? "Current users:" : "", m_UserConnections, RS);
- cReturnBuf += cBuf;
- cBuf.Format("09 %-*s%d%c", Padding, IsInteractive ? "Current operators:" : "", m_OperatorConnections, RS);
- cReturnBuf += cBuf;
- cBuf.Format("10 %-*s%d%c", Padding, IsInteractive ? "Current xfers:" : "", m_FileXfers, RS);
- cReturnBuf += cBuf;
- cBuf.Format("11 %-*s%d%c", Padding, IsInteractive ? "Total users:" : "", m_UserConnectionsTotal, RS);
- cReturnBuf += cBuf;
- cBuf.Format("12 %-*s%d%c", Padding, IsInteractive ? "Total operators" : "", m_OperatorConnectionsTotal, RS);
- cReturnBuf += cBuf;
- cBuf.Format("13 %-*s%d%c", Padding, IsInteractive ? "Total xfers:" : "", m_FileXfersTotal, RS);
- cReturnBuf += cBuf;
- return cReturnBuf;
- }
- LPCSTR CDaemonStatusSvr::GetStats(CString& cBuf)
- {
- return CDaemonBase::GetSvrStat()->FormatStats(cBuf);
- }
- // Send stats to a single client (called when the clinet register to the stats..
- void CDaemonStatusSvr::SendStat(LPVOID pOrigin, CDaemonEvent *pCliEv)
- {
- CString cBuf;
- CDaemonStatusSvr *pMe = (CDaemonStatusSvr *)pOrigin;
- LPCSTR Stats = CDaemonBase::GetSvrStat()->FormatStats(cBuf, FALSE);
- ASSERT(AfxIsValidString(Stats));
- pCliEv->Event(pMe->m_EventHandle, Stats);
- }
- void CDaemonStatusSvr::SendStatToAll()
- {
- CString cBuf;
- LPCSTR Stats = CDaemonBase::GetSvrStat()->FormatStats(cBuf, FALSE);
- ASSERT(AfxIsValidString(Stats));
- CDaemonEvent::DsEvent(CDaemonBase::GetSvrStat()->m_EventHandle, Stats);
- // Update the tray icon.
- CString cState;
- if (CDaemonBase::GetSvrStat()->m_UserConnections)
- cState.Format("%d users", CDaemonBase::GetSvrStat()->m_UserConnections);
- else
- cState = CDaemonBase::GetSvrStat()->m_IsOnline ? "Online" : "Offline";
- cBuf.Format("Port %d: %s", CDaemonBase::GetSvrStat()->m_ServerPort, cState);
- CDaemonBase::GetSvr()->UpdateSystemTray(cBuf);
- }
- // Increment/decrement the connection counters
- void CDaemonStatusSvr::IncCounter(int& Current, int& Total, BOOL Add)
- {
- if (Add)
- {
- ++Current;
- ++Total;
- }
- else
- {
- --Current;
- ASSERT(Current >= 0);
- }
- SendStatToAll();
- }
- void CDaemonStatusSvr::IncUserCnt(BOOL Add)
- {
- CDaemonStatusSvr *pStat = CDaemonBase::GetSvrStat();
- ASSERT(AfxIsValidAddress(pStat, sizeof(CDaemonStatusSvr)));
- IncCounter(pStat->m_UserConnections,pStat->m_UserConnectionsTotal, Add);
- }
- void CDaemonStatusSvr::IncOperatorCnt(BOOL Add)
- {
- CDaemonStatusSvr *pStat = CDaemonBase::GetSvrStat();
- ASSERT(AfxIsValidAddress(pStat, sizeof(CDaemonStatusSvr)));
- IncCounter(pStat->m_OperatorConnections,pStat->m_OperatorConnectionsTotal, Add);
- }
- void CDaemonStatusSvr::IncXferCnt(BOOL Add)
- {
- CDaemonStatusSvr *pStat = CDaemonBase::GetSvrStat();
- ASSERT(AfxIsValidAddress(pStat, sizeof(CDaemonStatusSvr)));
- IncCounter(pStat->m_FileXfers,pStat->m_FileXfersTotal, Add);
- }
- void CDaemonStatusSvr::SetOnline(BOOL IsOnline)
- {
- CDaemonStatusSvr *pStat = CDaemonBase::GetSvrStat();
- ASSERT(AfxIsValidAddress(pStat, sizeof(CDaemonStatusSvr)));
- pStat->m_IsOnline = IsOnline;
- SendStatToAll();
- }
- /////////////////////////////////////////////////////////////////////////////
- // CMyDaemonNTSOptions - Spesific routines for logging to daemons