Main Page   Namespace List   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 // This define is similar to the one above but returns a result in MOD_RESULT.
00039 // The first module to return a nonzero result is the value to be accepted,
00040 // and any modules after are ignored.
00041 
00042 // *********************************************************************************************
00043 
00044 #define FOREACH_RESULT(x) { MOD_RESULT = 0; \
00045                         for (int i = 0; i <= MODCOUNT; i++) { \
00046                         int res = modules[i]->x ; \
00047                         if (res) { \
00048                                 MOD_RESULT = res; \
00049                                 break; \
00050                         } \
00051                 } \
00052    } 
00053    
00054 // *********************************************************************************************
00055 
00056 extern void createcommand(char* cmd, handlerfunc f, char flags, int minparams);
00057 extern void server_mode(char **parameters, int pcnt, userrec *user);
00058 
00059 // class Version holds the version information of a Module, returned
00060 // by Module::GetVersion (thanks RD)
00061 
00066 class Version : public classbase
00067 {
00068  public:
00069          const int Major, Minor, Revision, Build;
00070          Version(int major, int minor, int revision, int build);
00071 };
00072 
00078 class Admin : public classbase
00079 {
00080  public:
00081          const std::string Name, Email, Nick;
00082          Admin(std::string name, std::string email, std::string nick);
00083 };
00084 
00090 class Module : public classbase
00091 {
00092  public:
00093 
00097         Module();
00098 
00102         virtual ~Module();
00103 
00108         virtual Version GetVersion();
00109 
00113         virtual void OnUserConnect(userrec* user);
00114 
00118         virtual void OnUserQuit(userrec* user);
00119 
00124         virtual void OnUserJoin(userrec* user, chanrec* channel);
00125 
00130         virtual void OnUserPart(userrec* user, chanrec* channel);
00131 
00138         virtual void OnPacketTransmit(char *p);
00139 
00147         virtual void OnPacketReceive(char *p);
00148 
00154         virtual void OnRehash();
00155 
00162         virtual void OnServerRaw(std::string &raw, bool inbound);
00163 
00172         virtual bool OnExtendedMode(userrec* user, chanrec* chan, char modechar, int type, bool mode_on, string_list &params);
00173         
00186         virtual int Module::OnUserPreJoin(userrec* user, chanrec* chan, char* cname);
00187  
00188 };
00189 
00190 
00196 class Server : public classbase
00197 {
00198  public:
00202         Server();
00206         virtual ~Server();
00207 
00211         virtual void SendOpers(std::string s);
00216         virtual void Log(int level, std::string s);
00221         virtual void Send(int Socket, std::string s);
00226         virtual void SendServ(int Socket, std::string s);
00231         virtual void SendFrom(int Socket, userrec* User, std::string s);
00236         virtual void SendTo(userrec* Source, userrec* Dest, std::string s);
00243         virtual void SendChannel(userrec* User, chanrec* Channel, std::string s,bool IncludeSender);
00248         virtual bool CommonChannels(userrec* u1, userrec* u2);
00256         virtual void SendCommon(userrec* User, std::string text,bool IncludeSender);
00261         virtual void SendWallops(userrec* User, std::string text);
00262 
00266         virtual bool IsNick(std::string nick);
00270         virtual userrec* FindNick(std::string nick);
00274         virtual chanrec* FindChannel(std::string channel);
00279         virtual std::string ChanMode(userrec* User, chanrec* Chan);
00282         virtual std::string GetServerName();
00285         virtual std::string GetNetworkName();
00291         virtual Admin GetAdmin();
00310         virtual bool AddExtendedMode(char modechar, int type, bool requires_oper, int params_when_on, int params_when_off);
00311 
00326         virtual void AddCommand(char* cmd, handlerfunc f, char flags, int minparams);
00327          
00349         virtual void SendMode(char **parameters, int pcnt, userrec *user);
00350 };
00351 
00358 class ConfigReader : public classbase
00359 {
00360   protected:
00363         std::string fname;
00364   public:
00369         ConfigReader();                 // default constructor reads ircd.conf
00373         ConfigReader(std::string filename);     // read a module-specific config
00377         ~ConfigReader();
00382         std::string ReadValue(std::string tag, std::string name, int index);
00389         int Enumerate(std::string tag);
00393         bool Verify();
00394 };
00395 
00396 
00397 
00403 class FileReader : public classbase
00404 {
00405  file_cache fc;
00406  public:
00411          FileReader();
00417          FileReader(std::string filename);
00421          ~FileReader();
00427          void LoadFile(std::string filename);
00432          bool Exists();
00433          std::string GetLine(int x);
00439          int FileSize();
00440 };
00441 
00442 
00449 class ModuleFactory : public classbase
00450 {
00451  public:
00452         ModuleFactory() { }
00453         virtual ~ModuleFactory() { }
00458         virtual Module * CreateModule() = 0;
00459 };
00460 
00461 
00462 typedef DLLFactory<ModuleFactory> ircd_module;
00463 
00464 #endif

Generated on Sun Apr 4 23:02:14 2004 for InspIRCd by doxygen1.3-rc3