Options.h
资源名称:warftpd.zip [点击查看]
上传用户:surprise9
上传日期:2007-01-04
资源大小:426k
文件大小:14k
源码类别:
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 : Options.h
- // PURPOSE : All options and options member declarations.
- // Option implementation goes in the different implementation files
- // PROGRAM :
- // DATE : Nov. 17 1996
- // AUTHOR : Jarle Aase
- // ---
- // REVISION HISTORY
- //
- ///////////////////////////////////////////////////////////////////////////////////////
- // COptions
- // Handle local and remote options (.ini file settings)
- // Override to add app spesific settings
- class DLL_WAR_SOFTWARE_ COptions
- {
- private:
- CString m_IniName;
- LPVOID m_Remote;
- LPSTR m_Section;
- static CString m_DefaultIniFile;
- public:
- static CLookupList m_OptionsList; // List of all object groups
- CLookupList m_Options; // List for each datamember in this option group
- public:
- COptions();
- ~COptions();
- void Create(LPVOID Remote, LPCSTR Origin, LPCSTR Section, int SymbolicNumber);
- static BOOL SetOption(LPCSTR Option, BOOL DoMap = FALSE);
- static BOOL GetOption(LPCSTR Option, CString& cValue, BOOL DoMap = FALSE);
- static CString GetOption(int Grp, int Item);
- virtual BOOL SaveAll();
- virtual BOOL LoadAll();
- BOOL ListGroupOptions(CString& cReturnBuf);
- static void IniCallback(int nErrorCode, LPVOID ReplyBuf, LPVOID Arg);
- static COptions *FindOptionGroup(LPCSTR Name);
- CLookupListItem *FindOption(LPCSTR Name);
- static BOOL ListOptions(LPCSTR OptionGroupName, CString& cReturnBuf);
- static void SetDefaultIniFile(LPCSTR Name) {m_DefaultIniFile = Name;}
- protected:
- void ResetSection(LPCSTR Section);
- void GetIniItem(LPCSTR Key, CString& Value, LPCSTR DefValue);
- void GetIniItem(LPCSTR Key, int& Value, int DefValue);
- void PutIniItem(LPCSTR Key, CString& Value);
- void PutIniItem(LPCSTR Key, int Value);
- static CLookupListItem *ResolveOption(LPCSTR Option, CString& cPending);
- };
- // Declare an option
- #define DeclOpt(Name, DataMember, DefVal, Symbol, DataType)
- m_Options.AddItem((LPVOID)&DataMember, Symbol, Name, DataType); DataMember = DefVal;
- //////////////////////////////////////////////////////////////////////////////////
- // Ini file
- DLL_WAR_SOFTWARE_ LPCSTR ConvertToMultiline(CString& cDest, LPCSTR Src);
- DLL_WAR_SOFTWARE_ LPCSTR ConvertToSingelline(CString& cDest, LPCSTR Src);
- DLL_WAR_SOFTWARE_ void ResetSection(LPVOID Remote, LPCSTR IniName, LPCSTR Section);
- DLL_WAR_SOFTWARE_ void GetIniItem(LPVOID Remote, LPCSTR IniName, LPCSTR Section, LPCSTR Key, CString& Value, LPCSTR DefValue);
- DLL_WAR_SOFTWARE_ void GetIniItem(LPVOID Remote, LPCSTR IniName, LPCSTR Section, LPCSTR Key, int& Value, int DefValue);
- DLL_WAR_SOFTWARE_ void PutIniItem(LPVOID Remote, LPCSTR IniName, LPCSTR Section, LPCSTR Key, LPCSTR Value);
- DLL_WAR_SOFTWARE_ void PutIniItem(LPVOID Remote, LPCSTR IniName, LPCSTR Section, LPCSTR Key, int Value);
- DLL_WAR_SOFTWARE_ DWORD GetIniItemSectionNames(LPVOID Remote, LPCSTR IniName, LPCSTR Pattern, CString& cBuf);
- DLL_WAR_SOFTWARE_ DWORD GetIniItemSection(LPVOID Remote, LPCSTR IniName, LPCSTR SectKey, LPCSTR Pattern, CString& cBuf);
- /////////////////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////////////////
- // I N T E R - M O D U L E A B S S T R A C T O P T I O N S
- /////////////////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////////////////
- class DLL_WAR_SOFTWARE_ CLogOptions : public COptions
- {
- public:
- BOOL m_LogDebug;
- BOOL m_LogErrors;
- CString m_LogFile;
- CString m_WuLogFile;
- CString m_DataCh;
- CString m_CntrCh;
- BOOL m_LogFileAccess;
- BOOL m_LogInOut;
- BOOL m_LogSecurity;
- BOOL m_LogWarnings;
- BOOL m_LogWinsock;
- int m_LogLines;
- int m_Delay; // Flush delay in seconds
- CLogOptions();
- };
- // These manifests must *not* be changed after the server
- // is released.
- #define LOG_OPTIONS__LOG_DEBUG 1
- #define LOG_OPTIONS__LOG_ERRORS 2
- #define LOG_OPTIONS__LOG_FILE 3
- #define LOG_OPTIONS__LOG_FILE_ACCESS 4
- #define LOG_OPTIONS__LOG_LOG_IN_OUT 5
- #define LOG_OPTIONS__LOG_SECURITY 6
- #define LOG_OPTIONS__LOG_WARNINGS 7
- #define LOG_OPTIONS__LOG_WINSOCK 8
- #define LOG_OPTIONS__LOG_LINES 9
- #define LOG_OPTIONS__LOG_DELAY 10
- #define LOG_OPTIONS__LOG_WUFTPD 11
- #define LOG_OPTIONS__LOG_CNTRCH 12
- #define LOG_OPTIONS__LOG_DATACH 13
- #define DECLARE_LOG_OPTIONS
- DeclOpt("Show Debug Messages",m_LogDebug, FALSE, LOG_OPTIONS__LOG_DEBUG, DATATYPE_BOOL);
- DeclOpt("Show Errors",m_LogErrors, TRUE, LOG_OPTIONS__LOG_ERRORS, DATATYPE_BOOL);
- DeclOpt("File Name",m_LogFile, "Log\Log%y%m%d.Log", LOG_OPTIONS__LOG_WUFTPD, DATATYPE_CSTRING);
- DeclOpt("WU File Name",m_WuLogFile, "", LOG_OPTIONS__LOG_FILE, DATATYPE_CSTRING);
- DeclOpt("Data CH File Name",m_DataCh, "", LOG_OPTIONS__LOG_DATACH, DATATYPE_CSTRING);
- DeclOpt("Cntr CH File Name",m_CntrCh, "", LOG_OPTIONS__LOG_CNTRCH, DATATYPE_CSTRING);
- DeclOpt("Show Logins and Logouts",m_LogInOut, TRUE, LOG_OPTIONS__LOG_LOG_IN_OUT, DATATYPE_BOOL);
- DeclOpt("Show Security Violations",m_LogSecurity, TRUE, LOG_OPTIONS__LOG_SECURITY, DATATYPE_BOOL);
- DeclOpt("Show System Warnings",m_LogWarnings, TRUE, LOG_OPTIONS__LOG_WARNINGS, DATATYPE_BOOL);
- DeclOpt("Show File Access",m_LogFileAccess, TRUE, LOG_OPTIONS__LOG_FILE_ACCESS, DATATYPE_BOOL);
- DeclOpt("Show Winsock Activity",m_LogWinsock, FALSE, LOG_OPTIONS__LOG_WINSOCK, DATATYPE_BOOL);
- DeclOpt("Lines to remember",m_LogLines, 50, LOG_OPTIONS__LOG_LINES, DATATYPE_INT);
- DeclOpt("Log flush delay",m_Delay, 5, LOG_OPTIONS__LOG_DELAY, DATATYPE_INT);
- //////////////////////////////////////////////////////////////////
- // CFtpDaemonCore - The core of a working FTP daemon. Contains
- // global (static) data to maintain the connections.
- #define FTPDCORE_OPTIONS__SERVER_NAME 1
- #define FTPDCORE_OPTIONS__SERVER_EMAIL 2
- #define FTPDCORE_OPTIONS__ALLOW_ANON 3
- #define FTPDCORE_OPTIONS__MAX_CONNECTIONS 4
- #define FTPDCORE_OPTIONS__MAX_ANON_CONNECTOIONS 5
- #define FTPDCORE_OPTIONS__PORT 6
- #define FTPDCORE_OPTIONS__PASV_PORT 7
- #define FTPDCORE_OPTIONS__IP_NAME 8
- class DLL_WAR_SOFTWARE_ CFTPDaemonCoreOptions : public COptions
- {
- public:
- CString m_ServerName;
- CString m_ServerEmail;
- BOOL m_AllowAnonLogin;
- int m_MaxConnections;
- int m_MaxAnonConnections;
- int m_Port;
- int m_PasvPort;
- CString m_IPname;
- public:
- CFTPDaemonCoreOptions();
- };
- #define DECLARE_FTPDCORE_OPTIONS
- DeclOpt("Server Name",m_ServerName, "Jgaa's Fan club FTP server", FTPDCORE_OPTIONS__SERVER_NAME, DATATYPE_CSTRING);
- DeclOpt("Server Email",m_ServerEmail, "Someone@somewhere.com", FTPDCORE_OPTIONS__SERVER_EMAIL, DATATYPE_CSTRING);
- DeclOpt("Allow Anon Login",m_AllowAnonLogin, TRUE, FTPDCORE_OPTIONS__ALLOW_ANON, DATATYPE_BOOL);
- DeclOpt("Max Connections",m_MaxConnections, 50, FTPDCORE_OPTIONS__MAX_CONNECTIONS, DATATYPE_INT);
- DeclOpt("Max Anon Connections",m_MaxAnonConnections, 10, FTPDCORE_OPTIONS__MAX_ANON_CONNECTOIONS, DATATYPE_INT);
- DeclOpt("FTP port",m_Port, 21, FTPDCORE_OPTIONS__PORT, DATATYPE_INT);
- DeclOpt("FTP default data port",m_PasvPort, 20, FTPDCORE_OPTIONS__PASV_PORT, DATATYPE_INT);
- DeclOpt("FTPD Listen IP", m_IPname, "0.0.0.0", FTPDCORE_OPTIONS__IP_NAME, DATATYPE_CSTRING);
- #define RA_OPTIONS__IP_NAME 1
- #define RA_OPTIONS__PORT 2
- #define RA_OPTIONS__ALLOWNETWORK 3
- #define RA_OPTIONS__TIMEOUT 4
- #define RA_OPTIONS__MAXQUEUE 5
- class DLL_WAR_SOFTWARE_ CRemoteAdminOptions : public COptions
- {
- public:
- CString m_IPname;
- int m_Port;
- int m_Timeout; // Seconds
- int m_MaxQueue;
- BOOL m_AllowNetworkAccess;
- public:
- CRemoteAdminOptions();
- };
- #define DECLARE_RA_OPTIONS
- DeclOpt("RA Listen IP", m_IPname, "0.0.0.0", RA_OPTIONS__IP_NAME, DATATYPE_CSTRING);
- DeclOpt("FTP default data port",m_Port, 22, RA_OPTIONS__PORT, DATATYPE_INT);
- DeclOpt("Allow Network Access",m_AllowNetworkAccess, TRUE, RA_OPTIONS__ALLOWNETWORK, DATATYPE_BOOL);
- DeclOpt("Timeout",m_Timeout, 120, RA_OPTIONS__TIMEOUT, DATATYPE_INT);
- DeclOpt("Max Queue",m_MaxQueue, 500, RA_OPTIONS__MAXQUEUE, DATATYPE_INT);
- #define NTSERVICE__SERVICENAME 1
- #define NTSERVICE__VISUALNAME 2
- #define NTSERVICE__SERVICEMODE 3
- #define NTSERVICE__LOGINASLOCALADMIN 4
- #define NTSERVICE__LOGINUSERNAME 5
- #define NTSERVICE__LOGINUSERPWD 6
- class DLL_WAR_SOFTWARE_ CDaemonNTSOptions : public COptions
- {
- public:
- CString m_ServiceName;
- CString m_VisualName;
- int m_ServiceMode;
- BOOL m_LoginAsLocalAdmin;
- CString m_LoginUserName;
- CString m_LoginUserPwd;
- public:
- CDaemonNTSOptions();
- };
- #define DECLARE_NTSERVICE_OPTIONS
- DeclOpt("Service Name", m_ServiceName, "", NTSERVICE__SERVICENAME, DATATYPE_CSTRING);
- DeclOpt("Visual Name", m_VisualName, "", NTSERVICE__VISUALNAME, DATATYPE_CSTRING);
- DeclOpt("Service Mode", m_ServiceMode, 3, NTSERVICE__SERVICENAME, DATATYPE_INT);
- DeclOpt("Login as Local Administrator", m_LoginAsLocalAdmin, TRUE, NTSERVICE__SERVICENAME, DATATYPE_BOOL);
- DeclOpt("Login aa User Name", m_LoginUserName, "", NTSERVICE__SERVICENAME, DATATYPE_CSTRING);
- DeclOpt("Login Password", m_LoginUserPwd, "", NTSERVICE__SERVICENAME, DATATYPE_CSTRING);
- #define GUIOPTIONS_PANETRACKING 1
- #define GUIOPTIONS_DIRCHMSG 2
- #define GUIOPTIONS_SITEMSGPOPUP 3
- #define GUIOPTIONS_CMDLINE 4
- class DLL_WAR_SOFTWARE_ CGUIOptions : public COptions
- {
- public:
- BOOL m_EnablePaneTracking;
- BOOL m_EnableDirChMsg;
- BOOL m_EnableSiteMsgsPopup;
- BOOL m_EnableCmdLine;
- public:
- CGUIOptions();
- };
- #define DECLARE_GUI_OPTIONS
- DeclOpt("Pane Tracking", m_EnablePaneTracking, FALSE, GUIOPTIONS_PANETRACKING, DATATYPE_BOOL);
- DeclOpt("Change DIR Popup", m_EnableDirChMsg, TRUE, GUIOPTIONS_DIRCHMSG, DATATYPE_BOOL);
- DeclOpt("SITE MSG popup", m_EnableSiteMsgsPopup, TRUE, GUIOPTIONS_SITEMSGPOPUP, DATATYPE_BOOL);
- DeclOpt("CMD Line", m_EnableCmdLine, TRUE, GUIOPTIONS_CMDLINE, DATATYPE_BOOL);
- #define FTPCOPTIONS_EMAIL 1
- #define FTPCOPTIONS_LOCALPATH 2
- #define FTPCOPTIONS_TXTEXT 3
- #define FTPCOPTIONS_USEPASV 4
- #define FTPCOPTIONS_OPTIMIZECMDS 5
- #define FTPCOPTIONS_INDEX 6
- #define FTPCOPTIONS_SHOWINDEX 7
- #define FTPCOPTIONS_MAXINDEXLEN 7
- class DLL_WAR_SOFTWARE_ CFTPClientOptions : public COptions
- {
- public:
- CString m_Email;
- CString m_LocalPath;
- CString m_TextExtentions;
- int m_UsePASV;
- BOOL m_DoOptimizeCommands;
- CString m_Index;
- BOOL m_ShowIndex;
- int m_MaxIndexLen;
- public:
- CFTPClientOptions();
- };
- #define DECLARE_FTPC_OPTIONS
- DeclOpt("Email", m_Email, "WarGuest@", FTPCOPTIONS_EMAIL, DATATYPE_CSTRING);
- DeclOpt("Local Path", m_LocalPath, "", FTPCOPTIONS_LOCALPATH, DATATYPE_CSTRING);
- DeclOpt("Text Extentions", m_TextExtentions, "*.txtrn*.htmrn*.htmlrn*.lstrn*.inirn*.crn*.cpprn*.hrn*.makrnmakefile", FTPCOPTIONS_TXTEXT, DATATYPE_CSTRING);
- DeclOpt("Use PASV mode", m_UsePASV, FALSE, FTPCOPTIONS_USEPASV, DATATYPE_BOOL);
- DeclOpt("Optimize Commands", m_DoOptimizeCommands, TRUE, FTPCOPTIONS_OPTIMIZECMDS, DATATYPE_BOOL);
- DeclOpt("Index Patterns", m_Index, "*index*.txt", FTPCOPTIONS_INDEX, DATATYPE_CSTRING);
- DeclOpt("Show Index", m_ShowIndex, TRUE, FTPCOPTIONS_SHOWINDEX, DATATYPE_BOOL);
- DeclOpt("Max Index Length", m_MaxIndexLen, (1024 * 5), FTPCOPTIONS_MAXINDEXLEN, DATATYPE_INT);
- #define ADVANCEDOPTIONS_OVERLAPPEDIO 1
- #define ADVANCEDOPTIONS_TASKPRIORITY 2
- class DLL_WAR_SOFTWARE_ CAdvancedOptions : public COptions
- {
- public:
- int m_OverlappedIO;
- int m_TaskPriority;
- static int m_PriMap[4];
- static int m_OverlappedMap[9];
- public:
- CAdvancedOptions();
- static GetPriority(int map) {ASSERT((map >= 0) && (map <= 3)); return m_PriMap[map]; }
- static GetOvlMap(int map) {ASSERT((map >= 0) && (map <= 8)); return m_OverlappedMap[map]; }
- };
- #define DECLARE_ADVANCED_OPTIONS
- DeclOpt("Overlapped IO", m_OverlappedIO, 0, ADVANCEDOPTIONS_OVERLAPPEDIO, DATATYPE_INT);
- DeclOpt("Task Priority", m_TaskPriority, 2, ADVANCEDOPTIONS_TASKPRIORITY, DATATYPE_INT);
- #define CFTPCLIENTOPTIONS_FIREWALLHOST 1
- #define CFTPCLIENTOPTIONS_FIREWALLPORT 2
- #define CFTPCLIENTOPTIONS_FIREWALLTYPE 3
- class DLL_WAR_SOFTWARE_ CFTPClientFirewallOptions : public COptions
- {
- public:
- CString m_FirewallHost;
- CString m_FirewallPort;
- int m_FirewallType;
- public:
- CFTPClientFirewallOptions();
- };
- #define DECLARE_FTPCFIREWALL_OPTIONS
- DeclOpt("Firewall Host", m_FirewallHost, "", CFTPCLIENTOPTIONS_FIREWALLHOST, DATATYPE_CSTRING);
- DeclOpt("Firewall Port", m_FirewallPort, "21", CFTPCLIENTOPTIONS_FIREWALLPORT, DATATYPE_CSTRING);
- DeclOpt("Firewall Type", m_FirewallType, 0, CFTPCLIENTOPTIONS_FIREWALLTYPE, DATATYPE_INT);
- #define CAPIHANDLEROPTIONS_SCANDIR 1
- #define DECLARE_APIHANDLER_OPTIONS
- DeclOpt("Firewall Host", m_ScanDir, "..\Extentions", CAPIHANDLEROPTIONS_SCANDIR, DATATYPE_CSTRING);
- enum // COptions groups
- {
- COPTION_GROUP_FTPLOG = 1,
- COPTION_FTPD_CORE,
- COPTION_GROUP_CLIENTLOG,
- COPTION_RA_DAEMON, // Remote Admin server side
- COPTION_NTSERVICE,
- COPTION_GUIOPTIONS,
- COPTION_FTPCLIENT,
- COPTION_ADVANCEDOPTIONS,
- COPTION_CFTPCLIENTFIREWALL,
- COPTION_APIHANDLER,
- COPTION_INVALID
- };