Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

modules.h

Go to the documentation of this file.
00001 /*
00002 
00003 
00004 
00005 */
00006 
00007 
00008 #ifndef __PLUGIN_H
00009 #define __PLUGIN_H
00010 
00011 #define DEBUG 10
00012 #define VERBOSE 20
00013 #define DEFAULT 30
00014 #define SPARSE 40
00015 #define NONE 50
00016 
00017 #define MT_CHANNEL 1
00018 #define MT_CLIENT 2
00019 #define MT_SERVER 3
00020 
00021 #include "dynamic.h"
00022 #include "base.h"
00023 #include "ctables.h"
00024 #include <string>
00025 #include <deque>
00026 
00029 typedef std::deque<std::string> file_cache;
00030 typedef file_cache string_list;
00031 
00032 // This #define allows us to call a method in all
00033 // loaded modules in a readable simple way, e.g.:
00034 // 'FOREACH_MOD OnConnect(user);'
00035 
00036 #define FOREACH_MOD for (int i = 0; i <= MODCOUNT; i++) modules[i]->
00037 
00038 extern void createcommand(char* cmd, handlerfunc f, char flags, int minparams);
00039 extern void server_mode(char **parameters, int pcnt, userrec *user);
00040 
00041 // class Version holds the version information of a Module, returned
00042 // by Module::GetVersion (thanks RD)
00043 
00048 class Version : public classbase
00049 {
00050  public:
00051          const int Major, Minor, Revision, Build;
00052          Version(int major, int minor, int revision, int build);
00053 };
00054 
00060 class Admin : public classbase
00061 {
00062  public:
00063          const std::string Name, Email, Nick;
00064          Admin(std::string name, std::string email, std::string nick);
00065 };
00066 
00072 class Module : public classbase
00073 {
00074  public:
00075 
00079         Module();
00080 
00084         virtual ~Module();
00085 
00090         virtual Version GetVersion();
00091 
00095         virtual void OnUserConnect(userrec* user);
00096 
00100         virtual void OnUserQuit(userrec* user);
00101 
00106         virtual void OnUserJoin(userrec* user, chanrec* channel);
00107 
00112         virtual void OnUserPart(userrec* user, chanrec* channel);
00113 
00120         virtual void Module::OnPacketTransmit(char *p);
00121 
00129         virtual void Module::OnPacketReceive(char *p);
00130 
00136         virtual void OnRehash();
00137 
00144         virtual void OnServerRaw(std::string &raw, bool inbound);
00145 
00154         virtual bool OnExtendedMode(userrec* user, chanrec* chan, char modechar, int type, bool mode_on, string_list &params);
00155         
00156  
00157 };
00158 
00159 
00165 class Server : public classbase
00166 {
00167  public:
00171         Server();
00175         virtual ~Server();
00176 
00180         virtual void SendOpers(std::string s);
00185         virtual void Log(int level, std::string s);
00190         virtual void Send(int Socket, std::string s);
00195         virtual void SendServ(int Socket, std::string s);
00200         virtual void SendFrom(int Socket, userrec* User, std::string s);
00205         virtual void SendTo(userrec* Source, userrec* Dest, std::string s);
00212         virtual void SendChannel(userrec* User, chanrec* Channel, std::string s,bool IncludeSender);
00217         virtual bool CommonChannels(userrec* u1, userrec* u2);
00225         virtual void SendCommon(userrec* User, std::string text,bool IncludeSender);
00230         virtual void SendWallops(userrec* User, std::string text);
00231 
00235         virtual bool IsNick(std::string nick);
00239         virtual userrec* FindNick(std::string nick);
00243         virtual chanrec* FindChannel(std::string channel);
00248         virtual std::string ChanMode(userrec* User, chanrec* Chan);
00251         virtual std::string GetServerName();
00254         virtual std::string GetNetworkName();
00260         virtual Admin GetAdmin();
00278         virtual bool AddExtendedMode(char modechar, int type, bool default_on, int params_when_on, int params_when_off);
00279 
00294         virtual void AddCommand(char* cmd, handlerfunc f, char flags, int minparams);
00295          
00313         virtual void SendMode(char **parameters, int pcnt, userrec *user);
00314 };
00315 
00322 class ConfigReader : public classbase
00323 {
00324   protected:
00327         std::string fname;
00328   public:
00333         ConfigReader();                 // default constructor reads ircd.conf
00337         ConfigReader(std::string filename);     // read a module-specific config
00341         ~ConfigReader();
00346         std::string ReadValue(std::string tag, std::string name, int index);
00353         int Enumerate(std::string tag);
00357         bool Verify();
00358 };
00359 
00360 
00361 
00367 class FileReader : public classbase
00368 {
00369  file_cache fc;
00370  public:
00375          FileReader();
00381          FileReader(std::string filename);
00385          ~FileReader();
00391          void LoadFile(std::string filename);
00396          bool Exists();
00397          std::string GetLine(int x);
00403          int FileSize();
00404 };
00405 
00406 
00413 class ModuleFactory : public classbase
00414 {
00415  public:
00416         ModuleFactory() { }
00417         virtual ~ModuleFactory() { }
00422         virtual Module * CreateModule() = 0;
00423 };
00424 
00425 
00426 typedef DLLFactory<ModuleFactory> ircd_module;
00427 
00428 #endif

Generated on Fri Apr 2 14:46:05 2004 for InspIRCd by doxygen1.3-rc3