www.pudn.com > warsrc.rar > DaemonAPI.h
// 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 : DaemonAPI.h
// PURPOSE : Daemon extention dll base class
// PROGRAM :
// DATE : Febr 16 1997
// AUTHOR : Jarle Aase
// ---
// REVISION HISTORY
//
#ifndef __WARDAPIH
#define __WARDAPIH
class CDaemonBase;
class CDaemonAPI;
class CSocketAPI;
class CRemoteInterface;
class CUserDialog;
class CDllInfo;
class CFuncList;
struct SFUNC
{
int (*pFunc)(LPVOID,int,WPARAM,LPARAM);
CDaemonAPI *pOrigin;
};
struct SFUNCREF
{
SFUNC *pFunc;
int Index;
CFuncList *pList;
};
// Simple base class for extention functions
class DLL_WAR_SOFTWARE_ CFuncList : public CLinkedList
{
public:
LPVOID Alloc(CDllInfo *pDLL, int Index, CDaemonAPI *pAPI, int (*pCallFunc)(LPVOID,int,WPARAM,LPARAM));
int Process(int nEvent, WPARAM wParam, LPARAM lParam);
BOOL AddFirst(CDllInfo *pDLL, int Index, CDaemonAPI *pAPI, int (*pFunc)(LPVOID,int,WPARAM,LPARAM));
BOOL AddLast(CDllInfo *pDLLC, int Index, CDaemonAPI *pAPI, int (*pFunc)(LPVOID,int,WPARAM,LPARAM));
BOOL AddFirst(CDllInfo *pDLL, int Index, CSocketAPI *pAPI, int (*pFunc)(LPVOID,int,WPARAM,LPARAM));
BOOL AddLast(CDllInfo *pDLL, int Index, CSocketAPI *pAPI, int (*pFunc)(LPVOID,int,WPARAM,LPARAM));
enum // Return values for Process
{
OkContinue, // Go on with processing
OkNoNext, // Don't pass on to next dll
OkAllDone, // All processing done. No dll or default processing required
AbortError, // Error, stop all processing
SuggestNo, // Process other plugins, but return AbortError
// unless OkAllDone or SuggestYes is returned by
// another plugin.
SuggestYes, // Process other plugins. Return OkContinue
// unless OkAllDone or SuggestNo is returned by
// another plugin.
};
};
class DLL_WAR_SOFTWARE_ CSocketAPI : public CObject
{
public:
CSocketAPI();
~CSocketAPI();
CSock *pSock;
};
#ifndef CC_CLIENT
class DLL_WAR_DAEMON_ CDaemonAPI : public CObject, public COptions
{
public:
CDaemonAPI();
~CDaemonAPI();
virtual void InitializeCOptions();
int GetModuleID() { return m_ModuleNum; }
CString GetModuleName() {return m_ModuleName; }
int Register(LPCSTR Name);
virtual int ApiInitInstance(int Event = 0, WPARAM wParam = 0, LPARAM lParam = 0);
virtual int ApiExitInstance(int Event = 0, WPARAM wParam = 0, LPARAM lParam = 0);
LogMsg(int Type, LPCSTR Format, ...);
virtual CDaemonAPI *GetPtr();
CDllInfo *GetDLLInfo();
private:
static m_ModuleCnt; // COptions ID counter
int m_ModuleNum; // COptions numeric identifier
CString m_ModuleName; // Module name
public:
int m_Error; // Error code
CLog *m_pLog; // Log handle
CDaemonBase *m_pBase; // Daemon pointer
};
#endif //CC_CLIENT
enum // Error codes
{
WDAPIE_NO_ERROR, // No error
WDAPIE_NAME_EXIST, // The name of the module is in use
WDAPIE_ERROR, // Unknown error
};
class DLL_WAR_SOFTWARE_ CDllInfo : public CObject
{
public:
CString m_Name;
CString m_Description;
CString m_ServerPath;
CString m_ManagerPath;
CString m_TempPath;
CString m_IniPath;
int m_OptionNum;
HINSTANCE m_pHI;
CLinkedList m_Refs; // SFUNCREF * to all functions used
CDaemonAPI *m_pAPI;
};
class DLL_WAR_SOFTWARE_ CAPIHandler : public COptions
{
public:
CAPIHandler();
~CAPIHandler();
static CAPIHandler *GetPtr() {return m_pMe; }
BOOL LoadExtentions();
BOOL DoLoadModule(LPCSTR IniName, BOOL DoLoad);
static CString ListAll();
void Unload(CDaemonAPI *pAPI);
void Unload(CSocketAPI *pSockAPI);
BOOL EnableDll(LPCSTR Cmd);
CString m_ScanDir; // Directory to scan for .emod files
public:
static CAPIHandler *m_pMe;
static CDaemonAPI *m_pCurrentLoadingModule;
static int m_CurrentLoadingModuleNum;
enum // Function location in KnownFuncNames[] and m_Funcs
{
ApiInitInstance,
ApiExitInstance,
OnLogin,
OnLogout,
OnPassword,
OnNewSocket,
OnNewTextSocket,
OnNewFTPDataSocket,
OnFTPDCoreCtrlSock,
OnPreFTPDAccept,
OnPostFTPDAccept,
OnFsysCheckPermission,
invalid
};
CFuncList m_Funcs[invalid];
CLinkedList m_Plugins; // CDLLInfo
};
struct LOGINPRMS
{
int LoginMode;
LPCSTR UserID;
LPCSTR Password;
CTextSock *Sock;
};
struct CHKPRMS
{
int User;
LPCSTR RootPath;
BOOL IsDir;
int PermsWanted;
};
struct SNDCTLMSG
{
int Rcode;
LPCSTR Text;
BOOL More;
BOOL CrLf;
};
#define PrcExt(FuncID, Event, wParam, lParam)\
CAPIHandler::m_pMe ? CAPIHandler::m_pMe->m_Funcs[FuncID].Process(Event,wParam,lParam) : 0
/////////////////////////////////////////////////////////////////////
// Client side support
#ifdef CC_CLIENT
class DLL_WAR_CLIENT_ CWarClientAPI : public CObject
{
public:
CWarClientAPI();
~CWarClientAPI();
BOOL SyncWithDaemon(CRemoteInterface *pRemote);
CDllInfo *LookupDllInfo(LPCSTR Name);
BOOL InitializeDll(CDllInfo *pDLL);
void RunFunctions(LPCSTR Name, WPARAM wParam, LPARAM lParam);
CLinkedList m_Plugins; // CDllInfo
};
// Base class for user dialog tabs
class DLL_WAR_CLIENT_ CWarUserDlgTemplate : public CDialog
{
public:
CWarUserDlgTemplate(UINT Resource, CWnd* pParent);
CUserDialog *m_pUserDlg;
};
#endif // CC_CLIENT
#endif __WARDAPIH