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 
00040 // class Version holds the version information of a Module, returned
00041 // by Module::GetVersion (thanks RD)
00042 
00047 class Version : public classbase
00048 {
00049  public:
00050          const int Major, Minor, Revision, Build;
00051          Version(int major, int minor, int revision, int build);
00052 };
00053 
00059 class Admin : public classbase
00060 {
00061  public:
00062          const std::string Name, Email, Nick;
00063          Admin(std::string name, std::string email, std::string nick);
00064 };
00065 
00071 class Module : public classbase
00072 {
00073  public:
00074 
00078         Module();
00079 
00083         virtual ~Module();
00084 
00089         virtual Version GetVersion();
00090 
00094         virtual void OnUserConnect(userrec* user);
00095 
00099         virtual void OnUserQuit(userrec* user);
00100 
00105         virtual void OnUserJoin(userrec* user, chanrec* channel);
00106 
00111         virtual void OnUserPart(userrec* user, chanrec* channel);
00112 
00119         virtual void Module::OnPacketTransmit(char *p);
00120 
00128         virtual void Module::OnPacketReceive(char *p);
00129 
00135         virtual void OnRehash();
00136 
00143         virtual void OnServerRaw(std::string &raw, bool inbound);
00144 
00153         virtual bool OnExtendedMode(userrec* user, chanrec* chan, char modechar, int type, bool mode_on, string_list &params);
00154          
00155 };
00156 
00157 
00163 class Server : public classbase
00164 {
00165  public:
00169         Server();
00173         virtual ~Server();
00174 
00178         virtual void SendOpers(std::string s);
00183         virtual void Log(int level, std::string s);
00188         virtual void Send(int Socket, std::string s);
00193         virtual void SendServ(int Socket, std::string s);
00198         virtual void SendFrom(int Socket, userrec* User, std::string s);
00203         virtual void SendTo(userrec* Source, userrec* Dest, std::string s);
00210         virtual void SendChannel(userrec* User, chanrec* Channel, std::string s,bool IncludeSender);
00215         virtual bool CommonChannels(userrec* u1, userrec* u2);
00223         virtual void SendCommon(userrec* User, std::string text,bool IncludeSender);
00228         virtual void SendWallops(userrec* User, std::string text);
00229 
00233         virtual bool IsNick(std::string nick);
00237         virtual userrec* FindNick(std::string nick);
00241         virtual chanrec* FindChannel(std::string channel);
00246         virtual std::string ChanMode(userrec* User, chanrec* Chan);
00249         virtual std::string GetServerName();
00252         virtual std::string GetNetworkName();
00258         virtual Admin GetAdmin();
00276         virtual bool AddExtendedMode(char modechar, int type, bool default_on, int params_when_on, int params_when_off);
00277 
00292         virtual void AddCommand(char* cmd, handlerfunc f, char flags, int minparams);
00293          
00294 };
00295 
00302 class ConfigReader : public classbase
00303 {
00304   protected:
00307         std::string fname;
00308   public:
00313         ConfigReader();                 // default constructor reads ircd.conf
00317         ConfigReader(std::string filename);     // read a module-specific config
00321         ~ConfigReader();
00326         std::string ReadValue(std::string tag, std::string name, int index);
00333         int Enumerate(std::string tag);
00337         bool Verify();
00338 };
00339 
00340 
00341 
00347 class FileReader : public classbase
00348 {
00349  file_cache fc;
00350  public:
00355          FileReader();
00361          FileReader(std::string filename);
00365          ~FileReader();
00371          void LoadFile(std::string filename);
00376          bool Exists();
00377          std::string GetLine(int x);
00383          int FileSize();
00384 };
00385 
00386 
00393 class ModuleFactory : public classbase
00394 {
00395  public:
00396         ModuleFactory() { }
00397         virtual ~ModuleFactory() { }
00402         virtual Module * CreateModule() = 0;
00403 };
00404 
00405 
00406 typedef DLLFactory<ModuleFactory> ircd_module;
00407 
00408 #endif

Generated on Fri Apr 2 13:37:27 2004 for InspIRCd by doxygen1.3-rc3