User.h
资源名称:warftpd.zip [点击查看]
上传用户:surprise9
上传日期:2007-01-04
资源大小:426k
文件大小:6k
源码类别:
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 : User.h
- // PURPOSE : User management
- // PROGRAM :
- // DATE : Sept. 28 1996
- // AUTHOR : Jarle Aase
- // ---
- // REVISION HISTORY
- //
- #ifndef __USERH
- #define __USERH
- class CLog;
- class CTextSock;
- #ifdef CC_CLIENT
- /////////////////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////////////////
- // C L I E N T S I D E A P I - all non-server applications without direct
- // access to the database must use these API calls.
- /////////////////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////////////////
- class DLL_WAR_CLIENT_ CRemoteUsr
- {
- public:
- CRemoteUsr();
- BOOL Create(LPVOID Remote, int timeout, CLog *Log, void (*OnError)(int nErrorNum, CRemoteUsr *Object));
- void LogMsg(int flag, LPCSTR Format, ...);
- USER AddUser(int UserType, LPCSTR UserID, BOOL Protect = FALSE, int PrivLevel = 0);
- LPCSTR FindUser(USER UserNo, CString& cBuf);
- USER FindUser(int UserType, LPCSTR UserID);
- BOOL SetParam(USER UserNum, LPCSTR Key, LPCSTR Value);
- BOOL SetParam(USER UserNum, LPCSTR Key, int Value);
- BOOL GetParam(USER UserNum, LPCSTR Key, int& Value, int DefValue);
- BOOL GetParam(USER UserNum, LPCSTR Key, CString& Value, LPCSTR DefValue);
- BOOL CreateAlias(LPCSTR Name, LPCSTR Alias);
- int GetType(USER UserNum);
- BOOL DeleteUser(LPCSTR UserName);
- BOOL RenameUser(LPCSTR UserID, LPCSTR NewName);
- // Higher level functions
- BOOL IsAdmin(USER User);
- int GetUserClass(USER User);
- BOOL ListUsers(int Type, LPCSTR Pattern, CLinkedList& List);
- BOOL ListUserParams(USER User, CString& Params);
- BOOL ListUsers(int Type, int System, int Class, int Group, CLinkedList& List);
- BOOL ParseUserList(CString& cSvrReply, CLinkedList& List);
- BOOL ParseUserParams(CString& cSvrReply, CString& cReturnBuf);
- CRemoteInterface *m_Remote;
- CLog *m_Log;
- void (*m_OnError)(int nErrorNum, CRemoteUsr *Object);
- int m_Timeout;
- };
- class DLL_WAR_CLIENT_ CUserInfo
- {
- public:
- CString m_Name;
- USER m_User;
- int m_Type;
- BOOL m_IsAdmin;
- BOOL m_FTPAccess;
- BOOL m_RAAccess;
- BOOL m_Protected;
- int m_PasswordMode;
- USER m_AliasFor; // Alias for user #
- USER m_Group;
- USER m_Class;
- USER m_System;
- CString m_VirtualIP; // only allowed on this IP number
- CUserInfo();
- };
- #ifndef _EDITUSEROPTIONH
- #include "edituseroption.h"
- #endif
- #else // CC_CLIENT - This is the server implementation
- /////////////////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////////////////
- // S E R V E R S I D E A P I
- /////////////////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////////////////
- // The public data common among all user implementations
- // Used for users, groups, classes and default
- class CUserBase
- {
- public:
- USER m_UserNum; // User number (unique identifier)
- CString m_UserID; // Nickname (unique identifier)
- BOOL m_Protect; // System defined user, dont delete!
- int m_PrivLevel; // Anonymous, user, admin
- };
- // User implementation in servers
- class DLL_WAR_DAEMON_ CUsr
- {
- public:
- static int m_NextUserNum; // Next user number to use
- static CUsr *m_pUserMngr; // Get pointer to user handle
- static LPCSTR m_pIniFile; // Get pointer to ini file
- static CLog *m_Log;
- public:
- CUsr();
- ~CUsr();
- BOOL Create(CLog *Log);
- static void LogMsg(int flag, LPCSTR Format, ...);
- static USER AddUser(int UserType, LPCSTR UserID, BOOL Protect = FALSE, int PrivLevel = 0);
- static LPCSTR FindUser(USER UserNo, CString& cBuf);
- static USER FindUser(int UserType, LPCSTR UserID);
- static void SetParam(USER UserNum, LPCSTR Key, LPCSTR Value);
- static void SetParam(USER UserNum, LPCSTR Key, int Value);
- static int GetParam(USER UserNum, LPCSTR Key, int DefValue);
- static LPCSTR GetParam(USER UserNum, LPCSTR Key, LPCSTR DefValue, CString& cBuf);
- static BOOL CreateAlias(LPCSTR Name, LPCSTR Alias);
- static BOOL DeleteUser(LPCSTR UserName);
- static BOOL DeleteAlias(LPCSTR AliasName);
- static BOOL RenameUser(LPCSTR UserID, LPCSTR NewName);
- static USER MapUser(USER User);
- static LPCSTR GetRecursiveParam(USER UserNum, LPCSTR Key, LPCSTR DefValue, CString& cBuf);
- static int GetRecursiveParam(USER UserNum, LPCSTR Key, int DefValue);
- // Higher level functions
- static int Login(int LoginMode, LPCSTR UserID, LPCSTR Password, CTextSock *Sock);
- static BOOL IsAdmin(USER User);
- static USER GetUserClass(USER User);
- static USER GetUserGroup(USER User);
- static USER GetUserSystem(USER User);
- static BOOL HasPermission(USER User, LPCSTR Option);
- static int GetType(USER User);
- static BOOL ListUsers(int Type, LPCSTR Pattern, CString& cBuf, BOOL IsInteractive);
- static BOOL ListUserParams(int Type, LPCSTR Pattern, CString& cBuf);
- static BOOL SetUserOption(int Type, LPCSTR Option);
- static BOOL GetUserOption(int Type, LPCSTR Option, CString& cReturnValue);
- };
- #endif // CC_CLIENT
- enum // m_PrivLevel
- {
- USERPRI_ANON,
- USERPRI_USER,
- USERPRI_ADMIN,
- USERPRI_INVALID
- };
- enum // User types
- {
- UT_USER, UT_GROUP, UT_CLASS, UT_SYSTEM, UT_INVALID
- };
- enum // Password mode (PWmode)
- {
- PW_NONE,
- PW_EMAIL,
- PW_NORMAL
- };
- // Clipboard format
- #define WAR_USER_CLPFORMAT "WarUserClp"
- #endif __USERH