1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
7 * <brain@chatspike.net>
8 * <Craig@chatspike.net>
10 * Written by Craig Edwards, Craig McLure, and others.
11 * This program is free but copyrighted software; see
12 * the file COPYING for details.
14 * ---------------------------------------------------
17 #ifndef __INSPIRCD_H__
18 #define __INSPIRCD_H__
23 #include "inspircd_config.h"
28 #include "helperfuncs.h"
29 #include "socketengine.h"
30 #include "command_parse.h"
32 /** Returned by some functions to indicate failure,
33 * and the exit code of the program if it terminates.
39 #define ETIREDGERBILS EAGAIN
41 /** Debug levels for use with InspIRCd::Log()
53 * This define is used in place of strcmp when we
54 * want to check if a char* string contains only one
55 * letter. Pretty fast, its just two compares and an
58 #define IS_SINGLE(x,y) ( (*x == y) && (*(x+1) == 0) )
60 /** Delete a pointer, and NULL its value
62 #define DELETE(x) {if (x) { delete x; x = NULL; }}
64 /** Template function to convert any input type to std::string
66 template<typename T> inline std::string ConvToStr(const T &in)
68 std::stringstream tmp;
69 if (!(tmp << in)) return std::string();
73 /** This class contains various STATS counters
74 * It is used by the InspIRCd class, which internally
75 * has an instance of it.
77 class serverstats : public classbase
80 /** Number of accepted connections
82 unsigned long statsAccept;
83 /** Number of failed accepts
85 unsigned long statsRefused;
86 /** Number of unknown commands seen
88 unsigned long statsUnknown;
89 /** Number of nickname collisions handled
91 unsigned long statsCollisions;
92 /** Number of DNS queries sent out
94 unsigned long statsDns;
95 /** Number of good DNS replies received
96 * NOTE: This may not tally to the number sent out,
97 * due to timeouts and other latency issues.
99 unsigned long statsDnsGood;
100 /** Number of bad (negative) DNS replies received
101 * NOTE: This may not tally to the number sent out,
102 * due to timeouts and other latency issues.
104 unsigned long statsDnsBad;
105 /** Number of inbound connections seen
107 unsigned long statsConnects;
108 /** Total bytes of data transmitted
111 /** Total bytes of data received
114 /** Number of bound listening ports
116 unsigned long BoundPortCount;
118 /** The constructor initializes all the counts to zero
121 : statsAccept(0), statsRefused(0), statsUnknown(0), statsCollisions(0), statsDns(0),
122 statsDnsGood(0), statsDnsBad(0), statsConnects(0), statsSent(0.0), statsRecv(0.0),
130 /** The main singleton class of the irc server.
131 * This class contains instances of all the other classes
132 * in this software, with the exception of the base class,
133 * classbase. Amongst other things, it contains a ModeParser,
134 * a DNS object, a CommandParser object, and a list of active
135 * Module objects, and facilities for Module objects to
136 * interact with the core system it implements. You should
137 * NEVER attempt to instantiate a class of type InspIRCd
138 * yourself. If you do, this is equivalent to spawning a second
139 * IRC server, and could have catastrophic consequences for the
140 * program in terms of ram usage (basically, you could create
141 * an obese forkbomb built from recursively spawning irc servers!)
143 class InspIRCd : public classbase
146 /** Holds a string describing the last module error to occur
150 /** This is an internal flag used by the mainloop
154 /** List of server names we've seen.
156 servernamelist servernames;
158 /** Remove a ModuleFactory pointer
159 * @param j Index number of the ModuleFactory to remove
161 void EraseFactory(int j);
163 /** Remove a Module pointer
164 * @param j Index number of the Module to remove
166 void EraseModule(int j);
168 /** Build the ISUPPORT string by triggering all modules On005Numeric events
170 void BuildISupport();
172 /** Move a given module to a specific slot in the list
173 * @param modulename The module name to relocate
174 * @param slot The slot to move the module into
176 void MoveTo(std::string modulename,int slot);
178 /** Display the startup banner
182 /** Set up the signal handlers
183 * @param SEGVHandler create a handler for segfaults (deprecated)
185 void SetSignals(bool SEGVHandler);
187 /** Daemonize the ircd and close standard input/output streams
188 * @return True if the program daemonized succesfully
192 /** Build the upper/lowercase comparison table
196 /** Moves the given module to the last slot in the list
197 * @param modulename The module name to relocate
199 void MoveToLast(std::string modulename);
201 /** Moves the given module to the first slot in the list
202 * @param modulename The module name to relocate
204 void MoveToFirst(std::string modulename);
206 /** Moves one module to be placed after another in the list
207 * @param modulename The module name to relocate
208 * @param after The module name to place the module after
210 void MoveAfter(std::string modulename, std::string after);
212 /** Moves one module to be placed before another in the list
213 * @param modulename The module name to relocate
214 * @param after The module name to place the module before
216 void MoveBefore(std::string modulename, std::string before);
218 /** Process a user whos socket has been flagged as active
219 * @param cu The user to process
220 * @return There is no actual return value, however upon exit, the user 'cu' may have been deleted
222 void ProcessUser(userrec* cu);
224 /** Iterate the list of InspSocket objects, removing ones which have timed out
225 * @param TIME the current time
227 void DoSocketTimeouts(time_t TIME);
229 /** Perform background user events such as PING checks
230 * @param TIME the current time
232 void DoBackgroundUserStuff(time_t TIME);
234 /** Returns true when all modules have done pre-registration checks on a user
235 * @param user The user to verify
236 * @return True if all modules have finished checking this user
238 bool AllModulesReportReady(userrec* user);
240 /** Total number of modules loaded into the ircd, minus one
244 /** Logfile pathname specified on the commandline, or empty string
246 char LogFileName[MAXBUF];
248 /** The feature names published by various modules
250 featurelist Features;
252 /** The current time, updated in the mainloop
256 /** The time that was recorded last time around the mainloop
260 /** A 64k buffer used to read client lines into
262 char ReadBuffer[65535];
264 /** Number of seconds in a minute
266 const long duration_m;
268 /** Number of seconds in an hour
270 const long duration_h;
272 /** Number of seconds in a day
274 const long duration_d;
276 /** Number of seconds in a week
278 const long duration_w;
280 /** Number of seconds in a year
282 const long duration_y;
285 /** Time this ircd was booted
289 /** Mode handler, handles mode setting and removal
293 /** Command parser, handles client to server commands
295 CommandParser* Parser;
297 /** Socket engine, handles socket activity events
301 /** Stats class, holds miscellaneous stats counters
305 /** Server Config class, holds configuration file data
307 ServerConfig* Config;
309 /** Module sockets list, holds the active set of InspSocket classes
311 std::vector<InspSocket*> module_sockets;
313 /** Socket reference table, provides fast lookup of fd to InspSocket*
315 InspSocket* socket_ref[MAX_DESCRIPTORS];
317 /** user reference table, provides fast lookup of fd to userrec*
319 userrec* fd_ref_table[MAX_DESCRIPTORS];
321 /** Client list, a hash_map containing all clients, local and remote
323 user_hash clientlist;
325 /** Channel list, a hash_map containing all channels
329 /** Local client list, a vector containing only local clients
331 std::vector<userrec*> local_users;
333 /** Oper list, a vector containing all local and remote opered users
335 std::vector<userrec*> all_opers;
337 /** Whowas container, contains a map of vectors of users tracked by WHOWAS
339 irc::whowas::whowas_users whowas;
341 /** DNS class, provides resolver facilities to the core and modules
345 /** Timer manager class, triggers InspTimer timer events
347 TimerManager* Timers;
349 /** Command list, a hash_map of command names to command_t*
351 command_table cmdlist;
353 /** X-Line manager. Handles G/K/Q/E line setting, removal and matching
355 XLineManager* XLines;
357 /** A list of Module* module classes
358 * Note that this list is always exactly 255 in size.
359 * The actual number of loaded modules is available from GetModuleCount()
363 /** A list of ModuleFactory* module factories
364 * Note that this list is always exactly 255 in size.
365 * The actual number of loaded modules is available from GetModuleCount()
369 /** Get the current time
370 * Because this only calls time() once every time around the mainloop,
371 * it is much faster than calling time() directly.
372 * @return The current time as an epoch value (time_t)
376 /** Get the total number of currently loaded modules
377 * @return The number of loaded modules
379 int GetModuleCount();
381 /** Find a module by name, and return a Module* to it.
382 * This is preferred over iterating the module lists yourself.
383 * @param name The module name to look up
384 * @return A pointer to the module, or NULL if the module cannot be found
386 Module* FindModule(const std::string &name);
388 /** Bind all ports specified in the configuration file.
389 * @param bail True if the function should bail back to the shell on failure
390 * @return The number of ports actually bound without error
392 int BindPorts(bool bail);
394 /** Returns true if this server has the given port bound to the given address
395 * @param port The port number
396 * @param addr The address
397 * @return True if we have a port listening on this address
399 bool HasPort(int port, char* addr);
401 /** Binds a socket on an already open file descriptor
402 * @param sockfd A valid file descriptor of an open socket
403 * @param client A sockaddr to use as temporary storage
404 * @param server A sockaddr to use as temporary storage
405 * @param port The port number to bind to
406 * @param addr The address to bind to (IP only)
407 * @return True if the port was bound successfully
409 bool BindSocket(int sockfd, insp_sockaddr client, insp_sockaddr server, int port, char* addr);
411 /** Adds a server name to the list of servers we've seen
412 * @param The servername to add
414 void AddServerName(const std::string &servername);
416 /** Finds a cached char* pointer of a server name,
417 * This is used to optimize userrec by storing only the pointer to the name
418 * @param The servername to find
419 * @return A pointer to this name, gauranteed to never become invalid
421 const char* FindServerNamePtr(const std::string &servername);
423 /** Returns true if we've seen the given server name before
424 * @param The servername to find
425 * @return True if we've seen this server name before
427 bool FindServerName(const std::string &servername);
429 /** Gets the GECOS (description) field of the given server.
430 * If the servername is not that of the local server, the name
431 * is passed to handling modules which will attempt to determine
432 * the GECOS that bleongs to the given servername.
433 * @param servername The servername to find the description of
434 * @return The description of this server, or of the local server
436 std::string GetServerDescription(const char* servername);
438 /** Write text to all opers connected to this server
439 * @param text The text format string
440 * @param ... Format args
442 void WriteOpers(const char* text, ...);
444 /** Write text to all opers connected to this server
445 * @param text The text to send
447 void WriteOpers(const std::string &text);
449 /** Find a nickname in the nick hash
450 * @param nick The nickname to find
451 * @return A pointer to the user, or NULL if the user does not exist
453 userrec* FindNick(const std::string &nick);
455 /** Find a nickname in the nick hash
456 * @param nick The nickname to find
457 * @return A pointer to the user, or NULL if the user does not exist
459 userrec* FindNick(const char* nick);
461 /** Find a channel in the channels hash
462 * @param chan The channel to find
463 * @return A pointer to the channel, or NULL if the channel does not exist
465 chanrec* FindChan(const std::string &chan);
467 /** Find a channel in the channels hash
468 * @param chan The channel to find
469 * @return A pointer to the channel, or NULL if the channel does not exist
471 chanrec* FindChan(const char* chan);
473 /** Called by the constructor to load all modules from the config file.
475 void LoadAllModules();
477 /** Check for a 'die' tag in the config file, and abort if found
478 * @return Depending on the configuration, this function may never return
482 /** Check we aren't running as root, and exit if we are
483 * @return Depending on the configuration, this function may never return
487 /** Determine the right path for, and open, the logfile
488 * @param argv The argv passed to main() initially, used to calculate program path
489 * @param argc The argc passed to main() initially, used to calculate program path
491 void OpenLog(char** argv, int argc);
493 /** Convert a user to a pseudoclient, disconnecting the real user
494 * @param user The user to convert
495 * @param message The quit message to display when exiting the user
496 * @return True if the operation succeeded
498 bool UserToPseudo(userrec* user, const std::string &message);
500 /** Convert a pseudoclient to a real user, discarding the pseudoclient
501 * @param alive A live client
502 * @param zombie A pseudoclient
503 * @param message The message to display when quitting the pseudoclient
504 * @return True if the operation succeeded
506 bool PseudoToUser(userrec* alive, userrec* zombie, const std::string &message);
508 /** Send a server notice to all local users
509 * @param text The text format string to send
510 * @param ... The format arguments
512 void ServerNoticeAll(char* text, ...);
514 /** Send a server message (PRIVMSG) to all local users
515 * @param text The text format string to send
516 * @param ... The format arguments
518 void ServerPrivmsgAll(char* text, ...);
520 /** Send text to all users with a specific set of modes
521 * @param modes The modes to check against, without a +, e.g. 'og'
522 * @param flags one of WM_OR or WM_AND. If you specify WM_OR, any one of the
523 * mode characters in the first parameter causes receipt of the message, and
524 * if you specify WM_OR, all the modes must be present.
525 * @param text The text format string to send
526 * @param ... The format arguments
528 void WriteMode(const char* modes, int flags, const char* text, ...);
530 /** Return true if a channel name is valid
531 * @param chname A channel name to verify
532 * @return True if the name is valid
534 bool IsChannel(const char *chname);
536 /** Rehash the local server
537 * @param status This value is unused, and required for signal handler functions
539 static void Rehash(int status);
541 /** Causes the server to exit immediately
542 * @param The exit code to give to the operating system
544 static void Exit(int status);
546 /** Return a count of users, unknown and known connections
547 * @return The number of users
551 /** Return a count of fully registered connections only
552 * @return The number of registered users
554 int RegisteredUserCount();
556 /** Return a count of invisible (umode +i) users only
557 * @return The number of invisible users
559 int InvisibleUserCount();
561 /** Return a count of opered (umode +o) users only
562 * @return The number of opers
566 /** Return a count of unregistered (before NICK/USER) users only
567 * @return The number of unregistered (unknown) connections
569 int UnregisteredUserCount();
571 /** Return a count of channels on the network
572 * @return The number of channels
576 /** Return a count of local users on this server only
577 * @return The number of local users
579 long LocalUserCount();
581 /** Send an error notice to all local users, opered and unopered
582 * @param s The error string to send
584 void SendError(const char *s);
586 /** For use with Module::Prioritize().
587 * When the return value of this function is returned from
588 * Module::Prioritize(), this specifies that the module wishes
589 * to be ordered exactly BEFORE 'modulename'. For more information
590 * please see Module::Prioritize().
591 * @param modulename The module your module wants to be before in the call list
592 * @returns a priority ID which the core uses to relocate the module in the list
594 long PriorityBefore(const std::string &modulename);
596 /** For use with Module::Prioritize().
597 * When the return value of this function is returned from
598 * Module::Prioritize(), this specifies that the module wishes
599 * to be ordered exactly AFTER 'modulename'. For more information please
600 * see Module::Prioritize().
601 * @param modulename The module your module wants to be after in the call list
602 * @returns a priority ID which the core uses to relocate the module in the list
604 long PriorityAfter(const std::string &modulename);
606 /** Publish a 'feature'.
607 * There are two ways for a module to find another module it depends on.
608 * Either by name, using InspIRCd::FindModule, or by feature, using this
609 * function. A feature is an arbitary string which identifies something this
610 * module can do. For example, if your module provides SSL support, but other
611 * modules provide SSL support too, all the modules supporting SSL should
612 * publish an identical 'SSL' feature. This way, any module requiring use
613 * of SSL functions can just look up the 'SSL' feature using FindFeature,
614 * then use the module pointer they are given.
615 * @param FeatureName The case sensitive feature name to make available
616 * @param Mod a pointer to your module class
617 * @returns True on success, false if the feature is already published by
620 bool PublishFeature(const std::string &FeatureName, Module* Mod);
622 /** Unpublish a 'feature'.
623 * When your module exits, it must call this method for every feature it
624 * is providing so that the feature table is cleaned up.
625 * @param FeatureName the feature to remove
627 bool UnpublishFeature(const std::string &FeatureName);
629 /** Find a 'feature'.
630 * There are two ways for a module to find another module it depends on.
631 * Either by name, using InspIRCd::FindModule, or by feature, using the
632 * InspIRCd::PublishFeature method. A feature is an arbitary string which
633 * identifies something this module can do. For example, if your module
634 * provides SSL support, but other modules provide SSL support too, all
635 * the modules supporting SSL should publish an identical 'SSL' feature.
636 * To find a module capable of providing the feature you want, simply
637 * call this method with the feature name you are looking for.
638 * @param FeatureName The feature name you wish to obtain the module for
639 * @returns A pointer to a valid module class on success, NULL on failure.
641 Module* FindFeature(const std::string &FeatureName);
643 /** Given a pointer to a Module, return its filename
644 * @param m The module pointer to identify
645 * @return The module name or an empty string
647 const std::string& GetModuleName(Module* m);
649 /** Return true if a nickname is valid
650 * @param n A nickname to verify
651 * @return True if the nick is valid
653 bool IsNick(const char* n);
655 /** Return true if an ident is valid
656 * @param An ident to verify
657 * @return True if the ident is valid
659 bool IsIdent(const char* n);
661 /** Find a username by their file descriptor.
662 * It is preferred to use this over directly accessing the fd_ref_table array.
663 * @param socket The file descriptor of a user
664 * @return A pointer to the user if the user exists locally on this descriptor
666 userrec* FindDescriptor(int socket);
668 /** Add a new mode to this server's mode parser
669 * @param mh The modehandler to add
670 * @param modechar The mode character this modehandler handles
671 * @return True if the mode handler was added
673 bool AddMode(ModeHandler* mh, const unsigned char modechar);
675 /** Add a new mode watcher to this server's mode parser
676 * @param mw The modewatcher to add
677 * @return True if the modewatcher was added
679 bool AddModeWatcher(ModeWatcher* mw);
681 /** Delete a mode watcher from this server's mode parser
682 * @param mw The modewatcher to delete
683 * @return True if the modewatcher was deleted
685 bool DelModeWatcher(ModeWatcher* mw);
687 /** Add a dns Resolver class to this server's active set
688 * @param r The resolver to add
689 * @return True if the resolver was added
691 bool AddResolver(Resolver* r);
693 /** Add a command to this server's command parser
694 * @param f A command_t command handler object to add
695 * @throw ModuleException Will throw ModuleExcption if the command already exists
697 void AddCommand(command_t *f);
699 /** Send a modechange.
700 * The parameters provided are identical to that sent to the
701 * handler for class cmd_mode.
702 * @param parameters The mode parameters
703 * @param pcnt The number of items you have given in the first parameter
704 * @param user The user to send error messages to
706 void SendMode(const char **parameters, int pcnt, userrec *user);
708 /** Match two strings using pattern matching.
709 * This operates identically to the global function match(),
710 * except for that it takes std::string arguments rather than
712 * @param sliteral The literal string to match against
713 * @param spattern The pattern to match against. CIDR and globs are supported.
715 bool MatchText(const std::string &sliteral, const std::string &spattern);
717 /** Call the handler for a given command.
718 * @param commandname The command whos handler you wish to call
719 * @param parameters The mode parameters
720 * @param pcnt The number of items you have given in the first parameter
721 * @param user The user to execute the command as
722 * @return True if the command handler was called successfully
724 bool CallCommandHandler(const std::string &commandname, const char** parameters, int pcnt, userrec* user);
726 /** Return true if the command is a module-implemented command and the given parameters are valid for it
727 * @param parameters The mode parameters
728 * @param pcnt The number of items you have given in the first parameter
729 * @param user The user to test-execute the command as
730 * @return True if the command handler is a module command, and there are enough parameters and the user has permission to the command
732 bool IsValidModuleCommand(const std::string &commandname, int pcnt, userrec* user);
734 /** Add a gline and apply it
735 * @param duration How long the line should last
736 * @param source Who set the line
737 * @param reason The reason for the line
738 * @param hostmask The hostmask to set the line against
740 void AddGLine(long duration, const std::string &source, const std::string &reason, const std::string &hostmask);
742 /** Add a qline and apply it
743 * @param duration How long the line should last
744 * @param source Who set the line
745 * @param reason The reason for the line
746 * @param nickname The nickmask to set the line against
748 void AddQLine(long duration, const std::string &source, const std::string &reason, const std::string &nickname);
750 /** Add a zline and apply it
751 * @param duration How long the line should last
752 * @param source Who set the line
753 * @param reason The reason for the line
754 * @param ipaddr The ip-mask to set the line against
756 void AddZLine(long duration, const std::string &source, const std::string &reason, const std::string &ipaddr);
758 /** Add a kline and apply it
759 * @param duration How long the line should last
760 * @param source Who set the line
761 * @param reason The reason for the line
762 * @param hostmask The hostmask to set the line against
764 void AddKLine(long duration, const std::string &source, const std::string &reason, const std::string &hostmask);
767 * @param duration How long the line should last
768 * @param source Who set the line
769 * @param reason The reason for the line
770 * @param hostmask The hostmask to set the line against
772 void AddELine(long duration, const std::string &source, const std::string &reason, const std::string &hostmask);
775 * @param hostmask The gline to delete
776 * @return True if the item was removed
778 bool DelGLine(const std::string &hostmask);
781 * @param nickname The qline to delete
782 * @return True if the item was removed
784 bool DelQLine(const std::string &nickname);
787 * @param ipaddr The zline to delete
788 * @return True if the item was removed
790 bool DelZLine(const std::string &ipaddr);
793 * @param hostmask The kline to delete
794 * @return True if the item was removed
796 bool DelKLine(const std::string &hostmask);
799 * @param hostmask The kline to delete
800 * @return True if the item was removed
802 bool DelELine(const std::string &hostmask);
804 /** Return true if the given parameter is a valid nick!user\@host mask
805 * @param mask A nick!user\@host masak to match against
806 * @return True i the mask is valid
808 bool IsValidMask(const std::string &mask);
810 /** Add an InspSocket class to the active set
811 * @param sock A socket to add to the active set
813 void AddSocket(InspSocket* sock);
815 /** Remove an InspSocket class from the active set at next time around the loop
816 * @param sock A socket to remove from the active set
818 void RemoveSocket(InspSocket* sock);
820 /** Delete a socket immediately without waiting for the next iteration of the mainloop
821 * @param sock A socket to delete from the active set
823 void DelSocket(InspSocket* sock);
825 /** Rehash the local server
829 /** Return the channel whos index number matches that provided
830 * @param The index number of the channel to fetch
831 * @return A channel record, or NUll if index < 0 or index >= InspIRCd::ChannelCount()
833 chanrec* GetChannelIndex(long index);
835 /** Dump text to a user target, splitting it appropriately to fit
836 * @param User the user to dump the text to
837 * @param LinePrefix text to prefix each complete line with
838 * @param TextStream the text to send to the user
840 void DumpText(userrec* User, const std::string &LinePrefix, stringstream &TextStream);
842 /** Check if the given nickmask matches too many users, send errors to the given user
843 * @param nick A nickmask to match against
844 * @param user A user to send error text to
845 * @return True if the nick matches too many users
847 bool NickMatchesEveryone(const std::string &nick, userrec* user);
849 /** Check if the given IP mask matches too many users, send errors to the given user
850 * @param ip An ipmask to match against
851 * @param user A user to send error text to
852 * @return True if the ip matches too many users
854 bool IPMatchesEveryone(const std::string &ip, userrec* user);
856 /** Check if the given hostmask matches too many users, send errors to the given user
857 * @param mask A hostmask to match against
858 * @param user A user to send error text to
859 * @return True if the host matches too many users
861 bool HostMatchesEveryone(const std::string &mask, userrec* user);
863 /** Calculate a duration in seconds from a string in the form 1y2w3d4h6m5s
864 * @param str A string containing a time in the form 1y2w3d4h6m5s
865 * (one year, two weeks, three days, four hours, six minutes and five seconds)
866 * @return The total number of seconds
868 long Duration(const char* str);
870 /** Attempt to compare an oper password to a string from the config file.
871 * This will be passed to handling modules which will compare the data
872 * against possible hashed equivalents in the input string.
873 * @param data The data from the config file
874 * @param input The data input by the oper
875 * @return 0 if the strings match, 1 or -1 if they do not
877 int OperPassCompare(const char* data,const char* input);
879 /** Check if a given server is a uline.
880 * An empty string returns true, this is by design.
881 * @param server The server to check for uline status
882 * @return True if the server is a uline OR the string is empty
884 bool ULine(const char* server);
886 /** Returns the subversion revision ID of this ircd
887 * @return The revision ID or an empty string
889 std::string GetRevision();
891 /** Returns the full version string of this ircd
892 * @return The version string
894 std::string GetVersionString();
896 /** Attempt to write the process id to a given file
897 * @param filename The PID file to attempt to write to
898 * @return This function may bail if the file cannot be written
900 void WritePID(const std::string &filename);
902 /** Returns text describing the last module error
903 * @return The last error message to occur
907 /** Load a given module file
908 * @param filename The file to load
909 * @return True if the module was found and loaded
911 bool LoadModule(const char* filename);
913 /** Unload a given module file
914 * @param filename The file to unload
915 * @return True if the module was unloaded
917 bool UnloadModule(const char* filename);
919 /** This constructor initialises all the subsystems and reads the config file.
920 * @param argc The argument count passed to main()
921 * @param argv The argument list passed to main()
922 * @throw <anything> If anything is thrown from here and makes it to
923 * you, you should probably just give up and go home. Yes, really.
924 * It's that bad. Higher level classes should catch any non-fatal exceptions.
926 InspIRCd(int argc, char** argv);
928 /** Do one iteration of the mainloop
929 * @param process_module_sockets True if module sockets are to be processed
930 * this time around the event loop. The is the default.
932 void DoOneIteration(bool process_module_sockets = true);
934 /** Output a log message to the ircd.log file
935 * The text will only be output if the current loglevel
936 * is less than or equal to the level you provide
937 * @param level A log level from the DebugLevel enum
938 * @param text Format string of to write to the log
939 * @param ... Format arguments of text to write to the log
941 void Log(int level, const char* text, ...);
943 /** Output a log message to the ircd.log file
944 * The text will only be output if the current loglevel
945 * is less than or equal to the level you provide
946 * @param level A log level from the DebugLevel enum
947 * @param text Text to write to the log
949 void Log(int level, const std::string &text);
951 /** Begin execution of the server.
952 * NOTE: this function NEVER returns. Internally,
953 * after performing some initialisation routines,
954 * it will repeatedly call DoOneIteration in a loop.
955 * @return The return value for this function is undefined.