InspIRCd  2.0
 All Classes Namespaces Functions Variables Typedefs Enumerations
modules.h
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  * Copyright (C) 2009-2010 Daniel De Graaf <danieldg@inspircd.org>
5  * Copyright (C) 2006-2007, 2009 Dennis Friis <peavey@inspircd.org>
6  * Copyright (C) 2003-2008 Craig Edwards <craigedwards@brainbox.cc>
7  * Copyright (C) 2008 Thomas Stagner <aquanight@inspircd.org>
8  * Copyright (C) 2007 Robin Burchell <robin+git@viroteck.net>
9  * Copyright (C) 2006-2007 Oliver Lupton <oliverlupton@gmail.com>
10  * Copyright (C) 2003 randomdan <???@???>
11  *
12  * This file is part of InspIRCd. InspIRCd is free software: you can
13  * redistribute it and/or modify it under the terms of the GNU General Public
14  * License as published by the Free Software Foundation, version 2.
15  *
16  * This program is distributed in the hope that it will be useful, but WITHOUT
17  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
19  * details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program. If not, see <http://www.gnu.org/licenses/>.
23  */
24 
25 
26 #ifndef MODULES_H
27 #define MODULES_H
28 
29 #include "dynamic.h"
30 #include "base.h"
31 #include "ctables.h"
32 #include "inspsocket.h"
33 #include <string>
34 #include <deque>
35 #include <sstream>
36 #include "timer.h"
37 #include "mode.h"
38 #include "dns.h"
39 
42 enum ModuleFlags {
43  VF_NONE = 0, // module is not special at all
44  VF_STATIC = 1, // module is static, cannot be /unloadmodule'd
45  VF_VENDOR = 2, // module is a vendor module (came in the original tarball, not 3rd party)
46  VF_COMMON = 4, // module needs to be common on all servers in a network to link
47  VF_OPTCOMMON = 8, // module should be common on all servers for unsurprising behavior
48  VF_CORE = 16 // module is a core command, can be assumed loaded on all servers
49 };
50 
53 enum TargetTypeFlags {
54  TYPE_USER = 1,
55  TYPE_CHANNEL,
56  TYPE_SERVER,
57  TYPE_OTHER
58 };
59 
62 enum MessageType {
63  MSG_PRIVMSG = 0,
64  MSG_NOTICE = 1
65 };
66 
67 #define MOD_RES_ALLOW (ModResult(1))
68 #define MOD_RES_PASSTHRU (ModResult(0))
69 #define MOD_RES_DENY (ModResult(-1))
70 
75 struct ModResult {
76  int res;
77  ModResult() : res(0) {}
78  explicit ModResult(int r) : res(r) {}
79  inline bool operator==(const ModResult& r) const
80  {
81  return res == r.res;
82  }
83  inline bool operator!=(const ModResult& r) const
84  {
85  return res != r.res;
86  }
87  inline bool operator!() const
88  {
89  return !res;
90  }
91  inline bool check(bool def) const
92  {
93  return (res == 1 || (res == 0 && def));
94  }
98  inline ModResult operator+(const ModResult& r) const
99  {
100  if (res == r.res || r.res == 0)
101  return *this;
102  if (res == 0)
103  return r;
104  // they are different, and neither is passthru
105  return MOD_RES_ALLOW;
106  }
107 };
108 
112 #define INSPIRCD_VERSION_MAJ 200
113 
119 #define INSPIRCD_VERSION_API 8
120 
126 #define FOREACH_MOD(y,x) do { \
127  EventHandlerIter safei; \
128  for (EventHandlerIter _i = ServerInstance->Modules->EventHandlers[y].begin(); _i != ServerInstance->Modules->EventHandlers[y].end(); ) \
129  { \
130  safei = _i; \
131  ++safei; \
132  try \
133  { \
134  (*_i)->x ; \
135  } \
136  catch (CoreException& modexcept) \
137  { \
138  ServerInstance->Logs->Log("MODULE",DEFAULT,"Exception caught: %s",modexcept.GetReason()); \
139  } \
140  _i = safei; \
141  } \
142 } while (0);
143 
150 #define DO_EACH_HOOK(n,v,args) \
151 do { \
152  EventHandlerIter iter_ ## n = ServerInstance->Modules->EventHandlers[I_ ## n].begin(); \
153  while (iter_ ## n != ServerInstance->Modules->EventHandlers[I_ ## n].end()) \
154  { \
155  Module* mod_ ## n = *iter_ ## n; \
156  iter_ ## n ++; \
157  try \
158  { \
159  v = (mod_ ## n)->n args;
160 
161 #define WHILE_EACH_HOOK(n) \
162  } \
163  catch (CoreException& except_ ## n) \
164  { \
165  ServerInstance->Logs->Log("MODULE",DEFAULT,"Exception caught: %s", (except_ ## n).GetReason()); \
166  (void) mod_ ## n; /* catch mismatched pairs */ \
167  } \
168  } \
169 } while(0)
170 
178 #define FIRST_MOD_RESULT(n,v,args) do { \
179  v = MOD_RES_PASSTHRU; \
180  DO_EACH_HOOK(n,v,args) \
181  { \
182  if (v != MOD_RES_PASSTHRU) \
183  break; \
184  } \
185  WHILE_EACH_HOOK(n); \
186 } while (0)
187 
192 class CoreExport Version
193 {
194  public:
197  const std::string description;
198 
201  const int Flags;
202 
204  const std::string link_data;
205 
207  Version(const std::string &desc, int flags = VF_NONE);
208 
210  Version(const std::string &desc, int flags, const std::string& linkdata);
211 
212  virtual ~Version() {}
213 };
214 
220 class CoreExport Request : public classbase
221 {
222  public:
227  const char* const id;
235 
243  Request(Module* src, Module* dst, const char* idstr);
246  void Send();
247 };
248 
249 
255 class CoreExport Event : public classbase
256 {
257  public:
266  const std::string id;
267 
270  Event(Module* src, const std::string &eventid);
275  void Send();
276 };
277 
278 class CoreExport DataProvider : public ServiceProvider
279 {
280  public:
281  DataProvider(Module* Creator, const std::string& Name)
282  : ServiceProvider(Creator, Name, SERVICE_DATA) {}
283 };
284 
285 class CoreExport dynamic_reference_base : public interfacebase
286 {
287  private:
288  std::string name;
289  protected:
290  DataProvider* value;
291  public:
292  ModuleRef creator;
293  dynamic_reference_base(Module* Creator, const std::string& Name);
295  inline void ClearCache() { value = NULL; }
296  inline const std::string& GetProvider() { return name; }
297  void SetProvider(const std::string& newname);
298  void lookup();
299  operator bool();
300  static void reset_all();
301 };
302 
303 template<typename T>
305 {
306  public:
307  dynamic_reference(Module* Creator, const std::string& Name)
308  : dynamic_reference_base(Creator, Name) {}
309  inline T* operator->()
310  {
311  if (!value)
312  lookup();
313  return static_cast<T*>(value);
314  }
315 };
316 
319 enum Priority { PRIORITY_FIRST, PRIORITY_LAST, PRIORITY_BEFORE, PRIORITY_AFTER };
320 
323 enum Implementation
324 {
325  I_BEGIN,
326  I_OnUserConnect, I_OnUserQuit, I_OnUserDisconnect, I_OnUserJoin, I_OnUserPart, I_OnRehash,
327  I_OnSendSnotice, I_OnUserPreJoin, I_OnUserPreKick, I_OnUserKick, I_OnOper, I_OnInfo, I_OnWhois,
328  I_OnUserPreInvite, I_OnUserInvite, I_OnUserPreMessage, I_OnUserPreNotice, I_OnUserPreNick,
329  I_OnUserMessage, I_OnUserNotice, I_OnMode, I_OnGetServerDescription, I_OnSyncUser,
330  I_OnSyncChannel, I_OnDecodeMetaData, I_OnWallops, I_OnAcceptConnection, I_OnUserInit,
331  I_OnChangeHost, I_OnChangeName, I_OnAddLine, I_OnDelLine, I_OnExpireLine,
332  I_OnUserPostNick, I_OnPreMode, I_On005Numeric, I_OnKill, I_OnRemoteKill, I_OnLoadModule,
333  I_OnUnloadModule, I_OnBackgroundTimer, I_OnPreCommand, I_OnCheckReady, I_OnCheckInvite,
334  I_OnRawMode, I_OnCheckKey, I_OnCheckLimit, I_OnCheckBan, I_OnCheckChannelBan, I_OnExtBanCheck,
335  I_OnStats, I_OnChangeLocalUserHost, I_OnPreTopicChange,
336  I_OnPostTopicChange, I_OnEvent, I_OnGlobalOper, I_OnPostConnect, I_OnAddBan,
337  I_OnDelBan, I_OnChangeLocalUserGECOS, I_OnUserRegister, I_OnChannelPreDelete, I_OnChannelDelete,
338  I_OnPostOper, I_OnSyncNetwork, I_OnSetAway, I_OnPostCommand, I_OnPostJoin,
339  I_OnWhoisLine, I_OnBuildNeighborList, I_OnGarbageCollect, I_OnSetConnectClass,
340  I_OnText, I_OnPassCompare, I_OnRunTestSuite, I_OnNamesListItem, I_OnNumeric, I_OnHookIO,
341  I_OnPreRehash, I_OnModuleRehash, I_OnSendWhoLine, I_OnChangeIdent, I_OnSetUserIP,
342  I_END
343 };
344 
350 class CoreExport Module : public classbase, public usecountbase
351 {
352  public:
355  std::string ModuleSourceFile;
359 
363  bool dying;
364 
369  Module();
370 
374  virtual void init() {}
375 
379  virtual CullResult cull();
380 
384  virtual ~Module();
385 
386  virtual void Prioritize()
387  {
388  }
389 
394  virtual Version GetVersion() = 0;
395 
400  virtual void OnUserConnect(LocalUser* user);
401 
410  virtual void OnUserQuit(User* user, const std::string &message, const std::string &oper_message);
411 
418  virtual void OnUserDisconnect(LocalUser* user);
419 
424  virtual ModResult OnChannelPreDelete(Channel *chan);
425 
429  virtual void OnChannelDelete(Channel* chan);
430 
440  virtual void OnUserJoin(Membership* memb, bool sync, bool created, CUList& except_list);
441 
447  virtual void OnPostJoin(Membership* memb);
448 
456  virtual void OnUserPart(Membership* memb, std::string &partmessage, CUList& except_list);
457 
468  virtual void OnPreRehash(User* user, const std::string &parameter);
469 
478  virtual void OnModuleRehash(User* user, const std::string &parameter);
479 
486  virtual void OnRehash(User* user);
487 
495  virtual ModResult OnSendSnotice(char &snomask, std::string &type, const std::string &message);
496 
517  virtual ModResult OnUserPreJoin(User* user, Channel* chan, const char* cname, std::string &privs, const std::string &keygiven);
518 
528  virtual ModResult OnUserPreKick(User* source, Membership* memb, const std::string &reason);
529 
538  virtual void OnUserKick(User* source, Membership* memb, const std::string &reason, CUList& except_list);
539 
546  virtual void OnOper(User* user, const std::string &opertype);
547 
556  virtual void OnPostOper(User* user, const std::string &opername, const std::string &opertype);
557 
568  virtual void OnInfo(User* user);
569 
576  virtual void OnWhois(User* source, User* dest);
577 
588  virtual ModResult OnUserPreInvite(User* source,User* dest,Channel* channel, time_t timeout);
589 
598  virtual void OnUserInvite(User* source,User* dest,Channel* channel, time_t timeout);
599 
616  virtual ModResult OnUserPreMessage(User* user,void* dest,int target_type, std::string &text,char status, CUList &exempt_list);
617 
637  virtual ModResult OnUserPreNotice(User* user,void* dest,int target_type, std::string &text,char status, CUList &exempt_list);
638 
648  virtual void OnBuildNeighborList(User* source, UserChanList &include_c, std::map<User*,bool> &exceptions);
649 
660  virtual ModResult OnUserPreNick(User* user, const std::string &newnick);
661 
672  virtual void OnUserMessage(User* user, void* dest, int target_type, const std::string &text, char status, const CUList &exempt_list);
673 
684  virtual void OnUserNotice(User* user, void* dest, int target_type, const std::string &text, char status, const CUList &exempt_list);
685 
699  virtual void OnText(User* user, void* dest, int target_type, const std::string &text, char status, CUList &exempt_list);
700 
711  virtual void OnMode(User* user, void* dest, int target_type, const std::vector<std::string> &text, const std::vector<TranslateType> &translate);
712 
721  virtual void OnGetServerDescription(const std::string &servername,std::string &description);
722 
735  virtual void OnSyncUser(User* user, Module* proto, void* opaque);
736 
750  virtual void OnSyncChannel(Channel* chan, Module* proto, void* opaque);
751 
752  /* Allows modules to syncronize metadata not related to users or channels, over the network during a netburst.
753  * Whenever the linking module wants to send out data, but doesnt know what the data
754  * represents (e.g. it is Extensible metadata, added to a User or Channel by a module) then
755  * this method is called. You should use the ProtoSendMetaData function after you've
756  * correctly decided how the data should be represented, to send the metadata on its way if
757  * if it belongs to your module.
758  * @param proto A pointer to the module handling network protocol
759  * @param opaque An opaque pointer set by the protocol module, should not be modified!
760  * @param displayable If this value is true, the data is going to be displayed to a user,
761  * and not sent across the network. Use this to determine wether or not to show sensitive data.
762  */
763  virtual void OnSyncNetwork(Module* proto, void* opaque);
764 
771  virtual void OnDecodeMetaData(Extensible* target, const std::string &extname, const std::string &extdata);
772 
787  virtual void ProtoSendMode(void* opaque, TargetTypeFlags target_type, void* target, const std::vector<std::string> &modeline, const std::vector<TranslateType> &translate);
788 
802  virtual void ProtoSendMetaData(void* opaque, Extensible* target, const std::string &extname, const std::string &extdata);
803 
808  virtual void OnWallops(User* user, const std::string &text);
809 
815  virtual void OnChangeHost(User* user, const std::string &newhost);
816 
822  virtual void OnChangeName(User* user, const std::string &gecos);
823 
829  virtual void OnChangeIdent(User* user, const std::string &ident);
830 
836  virtual void OnAddLine(User* source, XLine* line);
837 
843  virtual void OnDelLine(User* source, XLine* line);
844 
849  virtual void OnExpireLine(XLine *line);
850 
860  virtual void OnCleanup(int target_type, void* item);
861 
871  virtual void OnUserPostNick(User* user, const std::string &oldnick);
872 
884  virtual ModResult OnPreMode(User* source, User* dest, Channel* channel, const std::vector<std::string>& parameters);
885 
890  virtual void On005Numeric(std::string &output);
891 
905  virtual ModResult OnKill(User* source, User* dest, const std::string &reason);
906 
913  virtual void OnRemoteKill(User* source, User* dest, const std::string &reason, const std::string &operreason);
914 
926  virtual void OnLoadModule(Module* mod);
927 
939  virtual void OnUnloadModule(Module* mod);
940 
947  virtual void OnBackgroundTimer(time_t curtime);
948 
966  virtual ModResult OnPreCommand(std::string &command, std::vector<std::string>& parameters, LocalUser *user, bool validated, const std::string &original_line);
967 
979  virtual void OnPostCommand(const std::string &command, const std::vector<std::string>& parameters, LocalUser *user, CmdResult result, const std::string &original_line);
980 
984  virtual void OnUserInit(LocalUser* user);
985 
996  virtual ModResult OnCheckReady(LocalUser* user);
997 
1007  virtual ModResult OnUserRegister(LocalUser* user);
1008 
1017  virtual ModResult OnCheckInvite(User* user, Channel* chan);
1018 
1031  virtual ModResult OnRawMode(User* user, Channel* chan, const char mode, const std::string &param, bool adding, int pcnt);
1032 
1043  virtual ModResult OnCheckKey(User* user, Channel* chan, const std::string &keygiven);
1044 
1053  virtual ModResult OnCheckLimit(User* user, Channel* chan);
1054 
1062  virtual ModResult OnCheckChannelBan(User* user, Channel* chan);
1063 
1072  virtual ModResult OnCheckBan(User* user, Channel* chan, const std::string& mask);
1073 
1078  virtual ModResult OnExtBanCheck(User* user, Channel* chan, char type);
1079 
1089  virtual ModResult OnStats(char symbol, User* user, string_list &results);
1090 
1097  virtual ModResult OnChangeLocalUserHost(LocalUser* user, const std::string &newhost);
1098 
1105  virtual ModResult OnChangeLocalUserGECOS(LocalUser* user, const std::string &newhost);
1106 
1115  virtual ModResult OnPreTopicChange(User* user, Channel* chan, const std::string &topic);
1116 
1123  virtual void OnPostTopicChange(User* user, Channel* chan, const std::string &topic);
1124 
1129  virtual void OnEvent(Event& event);
1130 
1135  virtual void OnRequest(Request& request);
1136 
1147  virtual ModResult OnPassCompare(Extensible* ex, const std::string &password, const std::string &input, const std::string& hashtype);
1148 
1155  virtual void OnGlobalOper(User* user);
1156 
1163  virtual void OnPostConnect(User* user);
1164 
1172  virtual ModResult OnAddBan(User* source, Channel* channel,const std::string &banmask);
1173 
1181  virtual ModResult OnDelBan(User* source, Channel* channel,const std::string &banmask);
1182 
1187  virtual void OnHookIO(StreamSocket* user, ListenSocket* via);
1188 
1196  virtual ModResult OnAcceptConnection(int fd, ListenSocket* sock, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server);
1197 
1207  virtual void OnStreamSocketAccept(StreamSocket* sock, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server);
1208 
1217  virtual int OnStreamSocketWrite(StreamSocket* sock, std::string& sendq);
1218 
1223  virtual void OnStreamSocketClose(StreamSocket* sock);
1224 
1229  virtual void OnStreamSocketConnect(StreamSocket* sock);
1230 
1238  virtual int OnStreamSocketRead(StreamSocket* sock, std::string& recvq);
1239 
1248  virtual ModResult OnSetAway(User* user, const std::string &awaymsg);
1249 
1261  virtual ModResult OnWhoisLine(User* user, User* dest, int &numeric, std::string &text);
1262 
1268  virtual void OnGarbageCollect();
1269 
1274  virtual ModResult OnSetConnectClass(LocalUser* user, ConnectClass* myclass);
1275 
1279  virtual void OnRunTestSuite();
1280 
1285  virtual void OnNamesListItem(User* issuer, Membership* item, std::string &prefixes, std::string &nick);
1286 
1287  virtual ModResult OnNumeric(User* user, unsigned int numeric, const std::string &text);
1288 
1295  virtual void OnSendWhoLine(User* source, const std::vector<std::string>& params, User* user, std::string& line);
1296 
1301  virtual void OnSetUserIP(LocalUser* user);
1302 };
1303 
1304 
1305 #define CONF_NO_ERROR 0x000000
1306 #define CONF_NOT_A_NUMBER 0x000010
1307 #define CONF_INT_NEGATIVE 0x000080
1308 #define CONF_VALUE_NOT_FOUND 0x000100
1309 #define CONF_FILE_NOT_FOUND 0x000200
1310 
1311 
1318 class CoreExport ConfigReader : public interfacebase
1319 {
1320  protected:
1323  long error;
1324 
1325  public:
1330  ConfigReader();
1334  ~ConfigReader();
1335 
1340  std::string ReadValue(const std::string &tag, const std::string &name, int index, bool allow_linefeeds = false);
1346  std::string ReadValue(const std::string &tag, const std::string &name, const std::string &default_value, int index, bool allow_linefeeds = false);
1347 
1353  bool ReadFlag(const std::string &tag, const std::string &name, int index);
1360  bool ReadFlag(const std::string &tag, const std::string &name, const std::string &default_value, int index);
1361 
1371  int ReadInteger(const std::string &tag, const std::string &name, int index, bool need_positive);
1380  int ReadInteger(const std::string &tag, const std::string &name, const std::string &default_value, int index, bool need_positive);
1381 
1386  long GetError();
1387 
1394  int Enumerate(const std::string &tag);
1395 };
1396 
1397 
1398 
1404 class CoreExport FileReader : public classbase
1405 {
1408  std::vector<std::string> fc;
1409 
1412  unsigned long contentsize;
1413 
1416  void CalcSize();
1417 
1418  public:
1423  FileReader();
1424 
1430  FileReader(const std::string &filename);
1431 
1435  ~FileReader();
1436 
1442  void LoadFile(const std::string &filename);
1443 
1446  std::string Contents();
1447 
1450  unsigned long ContentSize();
1451 
1455  bool Exists();
1456 
1461  std::string GetLine(int x);
1462 
1468  int FileSize();
1469 };
1470 
1473 typedef std::vector<Module*> IntModuleList;
1474 
1477 typedef IntModuleList::iterator EventHandlerIter;
1478 
1482 class CoreExport ModuleManager
1483 {
1484  private:
1487  std::string LastModuleError;
1488 
1491  int ModCount;
1492 
1496  std::map<std::string, Module*> Modules;
1497 
1498  enum {
1499  PRIO_STATE_FIRST,
1500  PRIO_STATE_AGAIN,
1501  PRIO_STATE_LAST
1502  } prioritizationState;
1503 
1505  bool CanUnload(Module*);
1506  public:
1507 
1511  IntModuleList EventHandlers[I_END];
1512 
1514  std::multimap<std::string, ServiceProvider*> DataProviders;
1515 
1518  ModuleManager();
1519 
1522  ~ModuleManager();
1523 
1540  bool SetPriority(Module* mod, Implementation i, Priority s, Module* which = NULL);
1541 
1543  inline bool SetPriority(Module* mod, Implementation i, Priority s, Module** dptr)
1544  {
1545  return SetPriority(mod, i, s, *dptr);
1546  }
1547 
1556  bool SetPriority(Module* mod, Priority s);
1557 
1565  bool Attach(Implementation i, Module* mod);
1566 
1574  bool Detach(Implementation i, Module* mod);
1575 
1581  void Attach(Implementation* i, Module* mod, size_t sz);
1582 
1586  void DetachAll(Module* mod);
1587 
1591  std::string& LastError();
1592 
1598  bool Load(const std::string& filename, bool defer = false);
1599 
1605  bool Unload(Module* module);
1606 
1611  void Reload(Module* module, HandlerBase1<void, bool>* callback);
1612 
1615  void LoadAll();
1616  void UnloadAll();
1617  void DoSafeUnload(Module*);
1618 
1622  int GetCount()
1623  {
1624  return this->ModCount;
1625  }
1626 
1632  Module* Find(const std::string &name);
1633 
1635  void AddService(ServiceProvider&);
1636 
1638  void DelService(ServiceProvider&);
1639 
1640  inline void AddServices(ServiceProvider** list, int count)
1641  {
1642  for(int i=0; i < count; i++)
1643  AddService(*list[i]);
1644  }
1645 
1649  ServiceProvider* FindService(ServiceType Type, const std::string& name);
1650 
1651  template<typename T> inline T* FindDataService(const std::string& name)
1652  {
1653  return static_cast<T*>(FindService(SERVICE_DATA, name));
1654  }
1655 
1662  const std::vector<std::string> GetAllModuleNames(int filter);
1663 };
1664 
1668 #define MODULE_INIT_STR MODULE_INIT_STR_FN_2(MODULE_INIT_SYM)
1669 #define MODULE_INIT_STR_FN_2(x) MODULE_INIT_STR_FN_1(x)
1670 #define MODULE_INIT_STR_FN_1(x) #x
1671 #define MODULE_INIT_SYM MODULE_INIT_SYM_FN_2(INSPIRCD_VERSION_MAJ, INSPIRCD_VERSION_API)
1672 #define MODULE_INIT_SYM_FN_2(x,y) MODULE_INIT_SYM_FN_1(x,y)
1673 #define MODULE_INIT_SYM_FN_1(x,y) inspircd_module_ ## x ## _ ## y
1674 
1675 #ifdef PURE_STATIC
1676 
1677 struct AllCommandList {
1678  typedef Command* (*fn)(Module*);
1679  AllCommandList(fn cmd);
1680 };
1681 #define COMMAND_INIT(x) static Command* MK_ ## x(Module* m) { return new x(m); } \
1682  static const AllCommandList PREP_ ## x(&MK_ ## x);
1683 
1684 struct AllModuleList {
1685  typedef Module* (*fn)();
1686  fn init;
1687  std::string name;
1688  AllModuleList(fn mod, const std::string& Name);
1689 };
1690 
1691 #define MODULE_INIT(x) static Module* MK_ ## x() { return new x; } \
1692  static const AllModuleList PREP_ ## x(&MK_ ## x, MODNAMESTR);
1693 
1694 #define MODNAMESTR MODNAMESTR_FN_2(MODNAME)
1695 #define MODNAMESTR_FN_2(x) MODNAMESTR_FN_1(x)
1696 #define MODNAMESTR_FN_1(x) #x
1697 
1698 #else
1699 
1704 #ifdef _WIN32
1705 
1706 #define MODULE_INIT(y) \
1707  extern "C" DllExport Module * MODULE_INIT_SYM() \
1708  { \
1709  return new y; \
1710  } \
1711  BOOLEAN WINAPI DllMain(HINSTANCE hDllHandle, DWORD nReason, LPVOID Reserved) \
1712  { \
1713  switch ( nReason ) \
1714  { \
1715  case DLL_PROCESS_ATTACH: \
1716  case DLL_PROCESS_DETACH: \
1717  break; \
1718  } \
1719  return TRUE; \
1720  }
1721 
1722 #else
1723 
1724 #define MODULE_INIT(y) \
1725  extern "C" DllExport Module * MODULE_INIT_SYM() \
1726  { \
1727  return new y; \
1728  } \
1729  extern "C" const char inspircd_src_version[] = VERSION " r" REVISION;
1730 #endif
1731 
1732 #define COMMAND_INIT(c) MODULE_INIT(CommandModule<c>)
1733 
1734 #endif
1735 
1736 #endif
Definition: modules.h:192
const char *const id
Definition: modules.h:227
virtual CullResult cull()
Definition: base.cpp:34
Definition: base.h:109
Definition: caller.h:64
ModuleRef dest
Definition: modules.h:234
Definition: modules.h:255
std::multimap< std::string, ServiceProvider * > DataProviders
Definition: modules.h:1514
Definition: extensible.h:76
ModuleRef source
Definition: modules.h:261
Definition: users.h:230
bool dying
Definition: modules.h:363
Definition: users.h:81
ModuleRef source
Definition: modules.h:231
Definition: ctables.h:102
const std::string id
Definition: modules.h:266
Definition: users.h:742
Definition: socket.h:58
Definition: base.h:42
virtual void init()
Definition: modules.h:374
Definition: modules.h:220
Definition: inspsocket.h:103
Definition: membership.h:23
ModResult operator+(const ModResult &r) const
Definition: modules.h:98
const std::string description
Definition: modules.h:197
int GetCount()
Definition: modules.h:1622
Definition: modules.h:1482
const int Flags
Definition: modules.h:201
const std::string link_data
Definition: modules.h:204
Definition: modules.h:350
Definition: modules.h:75
DLLManager * ModuleDLLManager
Definition: modules.h:358
Definition: base.h:61
std::string ModuleSourceFile
Definition: modules.h:355
Definition: modules.h:1318
Definition: modules.h:285
Definition: dynamic.h:29
Definition: modules.h:278
bool SetPriority(Module *mod, Implementation i, Priority s, Module **dptr)
Definition: modules.h:1543
Definition: modules.h:304
Definition: xline.h:33
Definition: base.h:244
Definition: modules.h:1404
long error
Definition: modules.h:1323
Definition: base.h:32
Definition: socket.h:146
Definition: channels.h:59