4 Revision 1.1 2003/01/23 19:45:58 brain
7 Revision 1.12 2003/01/22 20:59:10 brain
8 Added FileReader class documentation
10 Revision 1.11 2003/01/22 20:49:16 brain
11 Added FileReader file-caching class
12 Changed m_randquote to use FileReader class
14 Revision 1.10 2003/01/22 00:57:27 brain
15 Changes to documentation
17 Revision 1.9 2003/01/22 00:44:26 brain
18 Added documentation comments
20 Revision 1.8 2003/01/21 20:31:24 brain
21 Modified to add documentation
22 Added ConfigReader class for modules
24 Revision 1.7 2003/01/15 22:47:44 brain
25 Changed user and channel structs to classes (finally)
27 Revision 1.6 2003/01/13 22:30:50 brain
28 Added Admin class (holds /admin info for modules)
29 Added methods to Server class
42 /** Low level definition of a FileReader classes file cache area
44 typedef deque<string> file_cache;
47 // This #define allows us to call a method in all
48 // loaded modules in a readable simple way, e.g.:
49 // 'FOREACH_MOD OnConnect(user);'
51 #define FOREACH_MOD for (int i = 0; i <= MODCOUNT; i++) modules[i]->
53 // class Version holds the version information of a Module, returned
54 // by Module::GetVersion (thanks RD)
56 /** Holds a module's Version information
57 * The four members (set by the constructor only) indicate details as to the version number
58 * of a module. A class of type Version is returned by the GetVersion method of the Module class.
63 const int Major, Minor, Revision, Build;
64 Version(int major, int minor, int revision, int build);
69 * This class contains the admin details of the local server. It is constructed by class Server,
70 * and has three read-only values, Name, Email and Nick that contain the specified values for the
71 * server where the module is running.
76 const string Name, Email, Nick;
77 Admin(string name,string email,string nick);
80 /** Base class for all InspIRCd modules
81 * This class is the base class for InspIRCd modules. All modules must inherit from this class,
82 * its methods will be called when irc server events occur. class inherited from module must be
83 * instantiated by the ModuleFactory class (see relevent section) for the plugin to be initialised.
88 /** Default constructor
89 * creates a module class
92 /** Default destructor
93 * destroys a module class
96 /** Returns the version number of a Module.
97 * The method should return a Version object with its version information assigned via
100 virtual Version GetVersion();
101 /** Called when a user connects.
102 * The details of the connecting user are available to you in the parameter userrec *user
104 virtual void OnUserConnect(userrec* user);
105 /** Called when a user quits.
106 * The details of the exiting user are available to you in the parameter userrec *user
108 virtual void OnUserQuit(userrec* user);
109 /** Called when a user joins a channel.
110 * The details of the joining user are available to you in the parameter userrec *user,
111 * and the details of the channel they have joined is available in the variable chanrec *channel
113 virtual void OnUserJoin(userrec* user, chanrec* channel);
114 /** Called when a user parts a channel.
115 * The details of the leaving user are available to you in the parameter userrec *user,
116 * and the details of the channel they have left is available in the variable chanrec *channel
118 virtual void OnUserPart(userrec* user, chanrec* channel);
122 /** Allows server output and query functions
123 * This class contains methods which allow a module to query the state of the irc server, and produce
124 * output to users and other servers. All modules should instantiate at least one copy of this class,
125 * and use its member functions to perform their tasks.
130 /** Default constructor.
131 * Creates a Server object.
134 /** Default destructor.
135 * Destroys a Server object.
139 /** Sends text to all opers.
140 * This method sends a server notice to all opers with the usermode +s.
142 virtual void SendOpers(string s);
143 /** Sends a debug string.
144 * This method writes a line of text to the debug log. If debugging is disabled
145 * in the configuration, this command has no effect.
147 virtual void Debug(string s);
148 /** Sends a line of text down a TCP/IP socket.
149 * This method writes a line of text to an established socket, cutting it to 510 characters
150 * plus a carriage return and linefeed if required.
152 virtual void Send(int Socket, string s);
153 /** Sends text from the server to a socket.
154 * This method writes a line of text to an established socket, with the servername prepended
155 * as used by numerics (see RFC 1459)
157 virtual void SendServ(int Socket, string s);
158 /** Sends text from a user to a socket.
159 * This method writes a line of text to an established socket, with the given user's nick/ident
160 * /host combination prepended, as used in PRIVSG etc commands (see RFC 1459)
162 virtual void SendFrom(int Socket, userrec* User, string s);
163 /** Sends text from a user to another user.
164 * This method writes a line of text to a user, with a user's nick/ident
165 * /host combination prepended, as used in PRIVMSG etc commands (see RFC 1459)
167 virtual void SendTo(userrec* Source, userrec* Dest, string s);
168 /** Sends text from a user to a channel (mulicast).
169 * This method writes a line of text to a channel, with the given user's nick/ident
170 * /host combination prepended, as used in PRIVMSG etc commands (see RFC 1459). If the
171 * IncludeSender flag is set, then the text is also sent back to the user from which
172 * it originated, as seen in MODE (see RFC 1459).
174 virtual void SendChannel(userrec* User, chanrec* Channel, string s,bool IncludeSender);
175 /** Returns true if two users share a common channel.
176 * This method is used internally by the NICK and QUIT commands, and the Server::SendCommon
179 virtual bool CommonChannels(userrec* u1, userrec* u2);
180 /** Sends text from a user to one or more channels (mulicast).
181 * This method writes a line of text to all users which share a common channel with a given
182 * user, with the user's nick/ident/host combination prepended, as used in PRIVMSG etc
183 * commands (see RFC 1459). If the IncludeSender flag is set, then the text is also sent
184 * back to the user from which it originated, as seen in NICK (see RFC 1459). Otherwise, it
185 * is only sent to the other recipients, as seen in QUIT.
187 virtual void SendCommon(userrec* User, string text,bool IncludeSender);
188 /** Sends a WALLOPS message.
189 * This method writes a WALLOPS message to all users with the +w flag, originating from the
192 virtual void SendWallops(userrec* User, string text);
194 /** Returns true if a nick is valid.
195 * Nicks for unregistered connections will return false.
197 virtual bool IsNick(string nick);
198 /** Attempts to look up a nick and return a pointer to it.
199 * This function will return NULL if the nick does not exist.
201 virtual userrec* FindNick(string nick);
202 /** Attempts to look up a channel and return a pointer to it.
203 * This function will return NULL if the channel does not exist.
205 virtual chanrec* FindChannel(string channel);
206 /** Attempts to look up a user's privilages on a channel.
207 * This function will return a string containing either @, %, +, or an empty string,
208 * representing the user's privilages upon the channel you specify.
210 virtual string ChanMode(userrec* User, chanrec* Chan);
211 /** Returns the server name of the server where the module is loaded.
213 virtual string GetServerName();
214 /** Returns the network name, global to all linked servers.
216 virtual string GetNetworkName();
217 /** Returns the information of the server as returned by the /ADMIN command.
218 * See the Admin class for further information of the return value. The members
219 * Admin::Nick, Admin::Email and Admin::Name contain the information for the
220 * server where the module is loaded.
222 virtual Admin GetAdmin();
226 /** Allows reading of values from configuration files
227 * This class allows a module to read from either the main configuration file (inspircd.conf) or from
228 * a module-specified configuration file. It may either be instantiated with one parameter or none.
229 * Constructing the class using one parameter allows you to specify a path to your own configuration
230 * file, otherwise, inspircd.conf is read.
235 /** The filename of the configuration file, as set by the constructor.
239 /** Default constructor.
240 * This constructor initialises the ConfigReader class to read the inspircd.conf file
241 * as specified when running ./configure.
243 ConfigReader(); // default constructor reads ircd.conf
244 /** Overloaded constructor.
245 * This constructor initialises the ConfigReader class to read a user-specified config file
247 ConfigReader(string filename); // read a module-specific config
248 /** Default destructor.
249 * This method destroys the ConfigReader class.
252 /** Retrieves a value from the config file.
253 * This method retrieves a value from the config file. Where multiple copies of the tag
254 * exist in the config file, index indicates which of the values to retrieve.
256 string ReadValue(string tag, string name, int index);
257 /** Counts the number of times a given tag appears in the config file.
258 * This method counts the number of times a tag appears in a config file, for use where
259 * there are several tags of the same kind, e.g. with opers and connect types. It can be
260 * used with the index value of ConfigReader::ReadValue to loop through all copies of a
261 * multiple instance tag.
263 int Enumerate(string tag);
264 /** Returns true if a config file is valid.
265 * This method is unimplemented and will always return true.
272 /** Caches a text file into memory and can be used to retrieve lines from it.
273 * This class contains methods for read-only manipulation of a text file in memory.
274 * Either use the constructor type with one parameter to load a file into memory
275 * at construction, or use the LoadFile method to load a file.
281 /** Default constructor.
282 * This method does not load any file into memory, you must use the LoadFile method
283 * after constructing the class this way.
286 /** Secondary constructor.
287 * This method initialises the class with a file loaded into it ready for GetLine and
288 * and other methods to be called. If the file could not be loaded, FileReader::FileSize
291 FileReader(string filename);
292 /** Default destructor.
293 * This deletes the memory allocated to the file.
296 /** Used to load a file.
297 * This method loads a file into the class ready for GetLine and
298 * and other methods to be called. If the file could not be loaded, FileReader::FileSize
301 void LoadFile(string filename);
302 /** Retrieve one line from the file.
303 * This method retrieves one line from the text file. If an empty non-NULL string is returned,
304 * the index was out of bounds, or the line had no data on it.
306 string GetLine(int x);
307 /** Returns the size of the file in lines.
308 * This method returns the number of lines in the read file. If it is 0, no lines have been
309 * read into memory, either because the file is empty or it does not exist, or cannot be
310 * opened due to permission problems.
316 /** Instantiates classes inherited from Module
317 * This class creates a class inherited from type Module, using new. This is to allow for modules
318 * to create many different variants of Module, dependent on architecture, configuration, etc.
319 * In most cases, the simple class shown in the example module m_foobar.so will suffice for most
326 virtual ~ModuleFactory() { }
327 /** Creates a new module.
328 * Your inherited class of ModuleFactory must return a pointer to your Module class
331 virtual Module * CreateModule() = 0;