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 #include <sstream>
00027 
00030 typedef std::deque<std::string> file_cache;
00031 typedef file_cache string_list;
00032 
00033 
00034 // This #define allows us to call a method in all
00035 // loaded modules in a readable simple way, e.g.:
00036 // 'FOREACH_MOD OnConnect(user);'
00037 
00038 #define FOREACH_MOD for (int i = 0; i <= MODCOUNT; i++) modules[i]->
00039 
00040 // This define is similar to the one above but returns a result in MOD_RESULT.
00041 // The first module to return a nonzero result is the value to be accepted,
00042 // and any modules after are ignored.
00043 
00044 // *********************************************************************************************
00045 
00046 #define FOREACH_RESULT(x) { MOD_RESULT = 0; \
00047                         for (int i = 0; i <= MODCOUNT; i++) { \
00048                         int res = modules[i]->x ; \
00049                         if (res) { \
00050                                 MOD_RESULT = res; \
00051                                 break; \
00052                         } \
00053                 } \
00054    } 
00055    
00056 // *********************************************************************************************
00057 
00058 extern void createcommand(char* cmd, handlerfunc f, char flags, int minparams);
00059 extern void server_mode(char **parameters, int pcnt, userrec *user);
00060 
00061 // class Version holds the version information of a Module, returned
00062 // by Module::GetVersion (thanks RD)
00063 
00068 class Version : public classbase
00069 {
00070  public:
00071          const int Major, Minor, Revision, Build;
00072          Version(int major, int minor, int revision, int build);
00073 };
00074 
00080 class Admin : public classbase
00081 {
00082  public:
00083          const std::string Name, Email, Nick;
00084          Admin(std::string name, std::string email, std::string nick);
00085 };
00086 
00092 class Module : public classbase
00093 {
00094  public:
00095 
00099         Module();
00100 
00104         virtual ~Module();
00105 
00110         virtual Version GetVersion();
00111 
00115         virtual void OnUserConnect(userrec* user);
00116 
00120         virtual void OnUserQuit(userrec* user);
00121 
00126         virtual void OnUserJoin(userrec* user, chanrec* channel);
00127 
00132         virtual void OnUserPart(userrec* user, chanrec* channel);
00133 
00140         virtual void OnPacketTransmit(char *p);
00141 
00149         virtual void OnPacketReceive(char *p);
00150 
00156         virtual void OnRehash();
00157 
00164         virtual void OnServerRaw(std::string &raw, bool inbound);
00165 
00175         virtual bool OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list &params);
00176         
00189         virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname);
00190         
00191         
00196         virtual void OnOper(userrec* user);
00197         
00206         virtual void OnInfo(userrec* user);
00207         
00212         virtual void OnWhois(userrec* source, userrec* dest);
00213         
00222         virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string text);
00223 
00232         virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string text);
00233         
00241         virtual int OnUserPreNick(userrec* user, std::string newnick);
00242 };
00243 
00244 
00250 class Server : public classbase
00251 {
00252  public:
00256         Server();
00260         virtual ~Server();
00261 
00265         virtual void SendOpers(std::string s);
00270         virtual void Log(int level, std::string s);
00275         virtual void Send(int Socket, std::string s);
00280         virtual void SendServ(int Socket, std::string s);
00285         virtual void SendFrom(int Socket, userrec* User, std::string s);
00300         virtual void SendTo(userrec* Source, userrec* Dest, std::string s);
00307         virtual void SendChannel(userrec* User, chanrec* Channel, std::string s,bool IncludeSender);
00312         virtual bool CommonChannels(userrec* u1, userrec* u2);
00320         virtual void SendCommon(userrec* User, std::string text,bool IncludeSender);
00325         virtual void SendWallops(userrec* User, std::string text);
00326 
00330         virtual bool IsNick(std::string nick);
00334         virtual int CountUsers(chanrec* c);
00338         virtual userrec* FindNick(std::string nick);
00342         virtual chanrec* FindChannel(std::string channel);
00347         virtual std::string ChanMode(userrec* User, chanrec* Chan);
00350         virtual std::string GetServerName();
00353         virtual std::string GetNetworkName();
00359         virtual Admin GetAdmin();
00378         virtual bool AddExtendedMode(char modechar, int type, bool requires_oper, int params_when_on, int params_when_off);
00379 
00394         virtual void AddCommand(char* cmd, handlerfunc f, char flags, int minparams);
00395          
00417         virtual void SendMode(char **parameters, int pcnt, userrec *user);
00418         
00431         virtual void SendToModeMask(std::string modes, int flags, std::string text);
00432 
00438         virtual chanrec* JoinUserToChannel(userrec* user, std::string cname, std::string key);
00439         
00445         virtual chanrec* PartUserFromChannel(userrec* user, std::string cname, std::string reason);
00446         
00452         virtual void ChangeUserNick(userrec* user, std::string nickname);
00453         
00464         virtual void QuitUser(userrec* user, std::string reason);
00465         
00470         virtual bool MatchText(std::string sliteral, std::string spattern);
00471         
00483         virtual void CallCommandHandler(std::string commandname, char** parameters, int pcnt, userrec* user);
00484         
00490         virtual void ChangeHost(userrec* user, std::string host);
00491         
00497         virtual void ChangeGECOS(userrec* user, std::string gecos);
00498         
00507         virtual bool IsUlined(std::string server);
00508 };
00509 
00516 class ConfigReader : public classbase
00517 {
00518   protected:
00524         std::stringstream *cache;
00527         bool error;
00528         
00529   public:
00534         ConfigReader();                 // default constructor reads ircd.conf
00538         ConfigReader(std::string filename);     // read a module-specific config
00542         ~ConfigReader();
00547         std::string ReadValue(std::string tag, std::string name, int index);
00554         int Enumerate(std::string tag);
00559         bool Verify();
00560 
00566         int EnumerateValues(std::string tag, int index);
00567 };
00568 
00569 
00570 
00576 class FileReader : public classbase
00577 {
00578  file_cache fc;
00579  public:
00584          FileReader();
00585 
00591          FileReader(std::string filename);
00592 
00596          ~FileReader();
00597 
00603          void LoadFile(std::string filename);
00604 
00608          bool Exists();
00609          
00614          std::string GetLine(int x);
00615 
00621          int FileSize();
00622 };
00623 
00624 
00631 class ModuleFactory : public classbase
00632 {
00633  public:
00634         ModuleFactory() { }
00635         virtual ~ModuleFactory() { }
00640         virtual Module * CreateModule() = 0;
00641 };
00642 
00643 
00644 typedef DLLFactory<ModuleFactory> ircd_module;
00645 
00646 #endif

Generated on Sun Apr 25 00:24:05 2004 for InspIRCd by doxygen1.3-rc3