summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2003-01-26 23:53:03 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2003-01-26 23:53:03 +0000
commitf81a2e12b09634cacd4ccf9da584c835ee71bf24 (patch)
tree7772d7719b6b369bd618eafb8f4b926d21192dcc /include
parent767b12b0ab6a0d4ed5f7335b26d1c0f842d99543 (diff)
Modified documentation for base classes
Added base classes git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@151 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'include')
-rw-r--r--include/base.h27
-rw-r--r--include/base.h~27
-rw-r--r--include/channels.h15
-rw-r--r--include/channels.h~203
-rw-r--r--include/connection.h44
-rw-r--r--include/connection.h~44
-rw-r--r--include/ctables.h13
-rw-r--r--include/ctables.h~59
-rw-r--r--include/modules.h23
-rw-r--r--include/modules.h~339
-rw-r--r--include/servers.h19
-rw-r--r--include/servers.h~54
-rw-r--r--include/users.h92
-rw-r--r--include/users.h~172
14 files changed, 1024 insertions, 107 deletions
diff --git a/include/base.h b/include/base.h
new file mode 100644
index 000000000..d5102bd7c
--- /dev/null
+++ b/include/base.h
@@ -0,0 +1,27 @@
+/*
+
+$Log$
+Revision 1.1 2003/01/26 23:52:59 brain
+Modified documentation for base classes
+Added base classes
+
+
+*/
+
+#include "inspircd_config.h"
+#include <time.h>
+
+#ifndef __BASE_H__
+#define __BASE_H__
+
+class classbase
+{
+ public:
+ time_t age;
+
+ classbase() { age = time(NULL); }
+ ~classbase() { }
+};
+
+#endif
+
diff --git a/include/base.h~ b/include/base.h~
new file mode 100644
index 000000000..8a1503c44
--- /dev/null
+++ b/include/base.h~
@@ -0,0 +1,27 @@
+/*
+
+$Log$
+Revision 1.1 2003/01/26 23:52:59 brain
+Modified documentation for base classes
+Added base classes
+
+
+*/
+
+#include "inspircd_config.h"
+#include <time.h>
+
+#ifndef __BASE_H__
+#define __BASE_H__
+
+class classbase
+{
+ public:
+ time_t age;
+ private:
+ classbase() { age = time(NULL); }
+ ~classbase() { }
+};
+
+#endif
+
diff --git a/include/channels.h b/include/channels.h
index c9cdd7b31..8d27f098d 100644
--- a/include/channels.h
+++ b/include/channels.h
@@ -1,8 +1,12 @@
/*
$Log$
-Revision 1.1 2003/01/23 19:45:58 brain
-Initial revision
+Revision 1.2 2003/01/26 23:52:59 brain
+Modified documentation for base classes
+Added base classes
+
+Revision 1.1.1.1 2003/01/23 19:45:58 brain
+InspIRCd second source tree
Revision 1.7 2003/01/22 00:44:26 brain
Added documentation comments
@@ -20,6 +24,7 @@ Changed user and channel structs to classes (finally)
*/
#include "inspircd_config.h"
+#include "base.h"
#include <time.h>
#include <vector>
@@ -29,7 +34,7 @@ Changed user and channel structs to classes (finally)
/** Holds an entry for a ban list, exemption list, or invite list.
* This class contains a single element in a channel list, such as a banlist.
*/
-class HostItem
+class HostItem : public classbase
{
public:
time_t set_time;
@@ -82,7 +87,7 @@ typedef vector<InviteItem> InviteList;
* This class represents a channel, and contains its name, modes, time created, topic, topic set time,
* etc, and an instance of the BanList type.
*/
-class chanrec
+class chanrec : public classbase
{
public:
/** The channels name.
@@ -178,7 +183,7 @@ class chanrec
* a userrec and chanrec class. The uc_modes member holds a bitmask of which privilages the user
* has on the channel, such as op, voice, etc.
*/
-class ucrec
+class ucrec : public classbase
{
public:
/** Contains a bitmask of the UCMODE_OP ... UCMODE_FOUNDER values.
diff --git a/include/channels.h~ b/include/channels.h~
new file mode 100644
index 000000000..dc1ed38a2
--- /dev/null
+++ b/include/channels.h~
@@ -0,0 +1,203 @@
+/*
+
+$Log$
+Revision 1.1 2003/01/26 23:52:59 brain
+Modified documentation for base classes
+Added base classes
+
+Revision 1.1.1.1 2003/01/23 19:45:58 brain
+InspIRCd second source tree
+
+Revision 1.7 2003/01/22 00:44:26 brain
+Added documentation comments
+
+Revision 1.6 2003/01/21 21:11:17 brain
+Added documentation
+
+Revision 1.5 2003/01/16 20:11:55 brain
+fixed some ugly pointer bugs (thanks dblack and a|KK|y!)
+
+Revision 1.4 2003/01/15 22:47:44 brain
+Changed user and channel structs to classes (finally)
+
+
+*/
+
+#include "inspircd_config.h"
+#include <time.h>
+#include <vector>
+
+#ifndef __CHANNELS_H__
+#define __CHANNELS_H__
+
+/** Holds an entry for a ban list, exemption list, or invite list.
+ * This class contains a single element in a channel list, such as a banlist.
+ */
+class HostItem
+{
+ public:
+ time_t set_time;
+ char set_by[NICKMAX];
+ char data[MAXBUF];
+
+ HostItem() { /* stub */ }
+ virtual ~HostItem() { /* stub */ }
+};
+
+// banlist is inherited from HostList mainly for readability
+// reasons only
+
+/** A subclass of HostItem designed to hold channel bans (+b)
+ */
+class BanItem : public HostItem
+{
+};
+
+// same with this...
+
+/** A subclass of HostItem designed to hold channel exempts (+e)
+ */
+class ExemptItem : public HostItem
+{
+};
+
+// and this...
+
+/** A subclass of HostItem designed to hold channel invites (+I)
+ */
+class InviteItem : public HostItem
+{
+};
+
+
+/** Holds a complete ban list
+ */
+typedef vector<BanItem> BanList;
+
+/** Holds a complete exempt list
+ */
+typedef vector<ExemptItem> ExemptList;
+
+/** Holds a complete invite list
+ */
+typedef vector<InviteItem> InviteList;
+
+/** Holds all relevent information for a channel.
+ * This class represents a channel, and contains its name, modes, time created, topic, topic set time,
+ * etc, and an instance of the BanList type.
+ */
+class chanrec
+{
+ public:
+ /** The channels name.
+ */
+ char name[CHANMAX]; /* channel name */
+ /** Custom modes for the channel.
+ * Plugins may use this field in any way they see fit.
+ */
+ char custom_modes[MAXMODES]; /* modes handled by modules */
+ /** Channel topic.
+ * If this is an empty string, no channel topic is set.
+ */
+ char topic[MAXBUF];
+ /** Creation time.
+ */
+ time_t created;
+ /** Time topic was set.
+ * If no topic was ever set, this will be equal to chanrec::created
+ */
+ time_t topicset;
+ /** The last user to set the topic.
+ * If this member is an empty string, no topic was ever set.
+ */
+ char setby[NICKMAX];
+
+ /** Contains the channel user limit.
+ * If this value is zero, there is no limit in place.
+ */
+ long limit;
+
+ /** Contains the channel key.
+ * If this value is an empty string, there is no channel key in place.
+ */
+ char key[32];
+
+ /** Nonzero if the mode +t is set.
+ */
+ short int topiclock;
+
+ /** Nonzero if the mode +n is set.
+ */
+ short int noexternal;
+
+ /** Nonzero if the mode +i is set.
+ */
+ short int inviteonly;
+
+ /** Nonzero if the mode +m is set.
+ */
+ short int moderated;
+
+ /** Nonzero if the mode +s is set.
+ * This value cannot be set at the same time as chanrec::c_private
+ */
+ short int secret;
+
+ /** Nonzero if the mode +p is set.
+ * This value cannot be set at the same time as chanrec::secret
+ */
+ short int c_private;
+
+ /** The list of all bans set on the channel.
+ */
+ BanList bans;
+
+ /** Creates a channel record and initialises it with default values
+ */
+ chanrec()
+ {
+ strcpy(name,"");
+ strcpy(custom_modes,"");
+ strcpy(topic,"");
+ strcpy(setby,"");
+ strcpy(key,"");
+ created = topicset = limit = 0;
+ topiclock = noexternal = inviteonly = moderated = secret = c_private = false;
+ }
+
+ virtual ~chanrec() { /* stub */ }
+};
+
+/* used to hold a channel and a users modes on that channel, e.g. +v, +h, +o
+ * needs to come AFTER struct chanrec */
+
+#define UCMODE_OP 1
+#define UCMODE_VOICE 2
+#define UCMODE_HOP 4
+#define UCMODE_PROTECT 8
+#define UCMODE_FOUNDER 16
+
+/** Holds a user's modes on a channel
+ * This class associates a users privilages with a channel by creating a pointer link between
+ * a userrec and chanrec class. The uc_modes member holds a bitmask of which privilages the user
+ * has on the channel, such as op, voice, etc.
+ */
+class ucrec
+{
+ public:
+ /** Contains a bitmask of the UCMODE_OP ... UCMODE_FOUNDER values.
+ * If this value is zero, the user has no privilages upon the channel.
+ */
+ long uc_modes;
+
+ /** Points to the channel record where the given modes apply.
+ * If the record is not in use, this value will be NULL.
+ */
+ chanrec *channel;
+
+ ucrec() { /* stub */ }
+ virtual ~ucrec() { /* stub */ }
+};
+
+#endif
+
diff --git a/include/connection.h b/include/connection.h
new file mode 100644
index 000000000..d74d6d20f
--- /dev/null
+++ b/include/connection.h
@@ -0,0 +1,44 @@
+/*
+
+$Log$
+Revision 1.1 2003/01/26 23:52:59 brain
+Modified documentation for base classes
+Added base classes
+
+Revision 1.1 2003/01/26 20:15:00 brain
+Added server classes for linking
+
+
+*/
+
+#include "inspircd_config.h"
+#include "base.h"
+#include <string>
+#include <map.h>
+
+#ifndef __CONNECTION_H__
+#define __CONNECTION_H__
+
+class connection : public classbase
+{
+ public:
+ int fd; // file descriptor
+ char host[256]; // hostname
+ long ip; // ipv4 address
+ char inbuf[MAXBUF]; // recvQ
+ long bytes_in;
+ long bytes_out;
+ long cmds_in;
+ long cmds_out;
+ bool haspassed;
+ int port;
+ int registered;
+ time_t lastping;
+ time_t signon;
+ time_t idle_lastmsg;
+ time_t nping;
+};
+
+
+#endif
+
diff --git a/include/connection.h~ b/include/connection.h~
new file mode 100644
index 000000000..d74d6d20f
--- /dev/null
+++ b/include/connection.h~
@@ -0,0 +1,44 @@
+/*
+
+$Log$
+Revision 1.1 2003/01/26 23:52:59 brain
+Modified documentation for base classes
+Added base classes
+
+Revision 1.1 2003/01/26 20:15:00 brain
+Added server classes for linking
+
+
+*/
+
+#include "inspircd_config.h"
+#include "base.h"
+#include <string>
+#include <map.h>
+
+#ifndef __CONNECTION_H__
+#define __CONNECTION_H__
+
+class connection : public classbase
+{
+ public:
+ int fd; // file descriptor
+ char host[256]; // hostname
+ long ip; // ipv4 address
+ char inbuf[MAXBUF]; // recvQ
+ long bytes_in;
+ long bytes_out;
+ long cmds_in;
+ long cmds_out;
+ bool haspassed;
+ int port;
+ int registered;
+ time_t lastping;
+ time_t signon;
+ time_t idle_lastmsg;
+ time_t nping;
+};
+
+
+#endif
+
diff --git a/include/ctables.h b/include/ctables.h
index 78eb150d9..33b4d564c 100644
--- a/include/ctables.h
+++ b/include/ctables.h
@@ -14,8 +14,12 @@
* ---------------------------------------------------
$Log$
- Revision 1.1 2003/01/23 19:45:58 brain
- Initial revision
+ Revision 1.2 2003/01/26 23:52:59 brain
+ Modified documentation for base classes
+ Added base classes
+
+ Revision 1.1.1.1 2003/01/23 19:45:58 brain
+ InspIRCd second source tree
Revision 1.3 2003/01/15 22:47:44 brain
Changed user and channel structs to classes (finally)
@@ -32,6 +36,7 @@
*/
#include "inspircd_config.h"
#include "inspircd.h"
+#include "base.h"
#ifndef __CTABLES_H__
#define __CTABLES_H__
@@ -40,7 +45,9 @@ typedef void (handlerfunc) (char**, int, userrec*);
/* a structure that defines a command */
-struct command_t {
+class command_t : public classbase
+{
+ public:
char command[MAXBUF]; /* command name */
handlerfunc *handler_function; /* handler function as in typedef */
char flags_needed; /* user flags needed to execute the command or 0 */
diff --git a/include/ctables.h~ b/include/ctables.h~
new file mode 100644
index 000000000..489cfafe9
--- /dev/null
+++ b/include/ctables.h~
@@ -0,0 +1,59 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2003 ChatSpike-Dev.
+ * E-mail:
+ * <brain@chatspike.net>
+ * <Craig@chatspike.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+
+ $Log$
+ Revision 1.1 2003/01/26 23:52:59 brain
+ Modified documentation for base classes
+ Added base classes
+
+ Revision 1.1.1.1 2003/01/23 19:45:58 brain
+ InspIRCd second source tree
+
+ Revision 1.3 2003/01/15 22:47:44 brain
+ Changed user and channel structs to classes (finally)
+
+ Revision 1.2 2003/01/09 21:09:50 brain
+ added '/stats M' command
+
+ Revision 1.1 2003/01/07 01:02:14 brain
+
+ definitions for command table types
+
+
+ * ---------------------------------------------------
+ */
+#include "inspircd_config.h"
+#include "inspircd.h"
+#include "base.h"
+
+#ifndef __CTABLES_H__
+#define __CTABLES_H__
+
+typedef void (handlerfunc) (char**, int, userrec*);
+
+/* a structure that defines a command */
+
+class command_t : public classbase
+{
+ char command[MAXBUF]; /* command name */
+ handlerfunc *handler_function; /* handler function as in typedef */
+ char flags_needed; /* user flags needed to execute the command or 0 */
+ int min_params; /* minimum number of parameters command takes */
+ long use_count; /* used by /stats m */
+ long total_bytes; /* used by /stats m */
+};
+
+#endif
+
diff --git a/include/modules.h b/include/modules.h
index 971f3ec26..5a7ec9fbf 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -1,8 +1,12 @@
/*
$Log$
-Revision 1.1 2003/01/23 19:45:58 brain
-Initial revision
+Revision 1.2 2003/01/26 23:52:59 brain
+Modified documentation for base classes
+Added base classes
+
+Revision 1.1.1.1 2003/01/23 19:45:58 brain
+InspIRCd second source tree
Revision 1.12 2003/01/22 20:59:10 brain
Added FileReader class documentation
@@ -36,6 +40,7 @@ Added methods to Server class
#define __PLUGIN_H
#include "dynamic.h"
+#include "base.h"
#include <string>
#include <deque>
@@ -57,7 +62,7 @@ typedef deque<string> file_cache;
* The four members (set by the constructor only) indicate details as to the version number
* of a module. A class of type Version is returned by the GetVersion method of the Module class.
*/
-class Version
+class Version : public classbase
{
public:
const int Major, Minor, Revision, Build;
@@ -70,7 +75,7 @@ class Version
* and has three read-only values, Name, Email and Nick that contain the specified values for the
* server where the module is running.
*/
-class Admin
+class Admin : public classbase
{
public:
const string Name, Email, Nick;
@@ -82,7 +87,7 @@ class Admin
* its methods will be called when irc server events occur. class inherited from module must be
* instantiated by the ModuleFactory class (see relevent section) for the plugin to be initialised.
*/
-class Module
+class Module : public classbase
{
public:
/** Default constructor
@@ -124,7 +129,7 @@ class Module
* output to users and other servers. All modules should instantiate at least one copy of this class,
* and use its member functions to perform their tasks.
*/
-class Server
+class Server : public classbase
{
public:
/** Default constructor.
@@ -229,7 +234,7 @@ class Server
* Constructing the class using one parameter allows you to specify a path to your own configuration
* file, otherwise, inspircd.conf is read.
*/
-class ConfigReader
+class ConfigReader : public classbase
{
protected:
/** The filename of the configuration file, as set by the constructor.
@@ -274,7 +279,7 @@ class ConfigReader
* Either use the constructor type with one parameter to load a file into memory
* at construction, or use the LoadFile method to load a file.
*/
-class FileReader
+class FileReader : public classbase
{
file_cache fc;
public:
@@ -319,7 +324,7 @@ class FileReader
* In most cases, the simple class shown in the example module m_foobar.so will suffice for most
* modules.
*/
-class ModuleFactory
+class ModuleFactory : public classbase
{
public:
ModuleFactory() { }
diff --git a/include/modules.h~ b/include/modules.h~
new file mode 100644
index 000000000..ec5df7da6
--- /dev/null
+++ b/include/modules.h~
@@ -0,0 +1,339 @@
+/*
+
+$Log$
+Revision 1.1 2003/01/26 23:52:59 brain
+Modified documentation for base classes
+Added base classes
+
+Revision 1.1.1.1 2003/01/23 19:45:58 brain
+InspIRCd second source tree
+
+Revision 1.12 2003/01/22 20:59:10 brain
+Added FileReader class documentation
+
+Revision 1.11 2003/01/22 20:49:16 brain
+Added FileReader file-caching class
+Changed m_randquote to use FileReader class
+
+Revision 1.10 2003/01/22 00:57:27 brain
+Changes to documentation
+
+Revision 1.9 2003/01/22 00:44:26 brain
+Added documentation comments
+
+Revision 1.8 2003/01/21 20:31:24 brain
+Modified to add documentation
+Added ConfigReader class for modules
+
+Revision 1.7 2003/01/15 22:47:44 brain
+Changed user and channel structs to classes (finally)
+
+Revision 1.6 2003/01/13 22:30:50 brain
+Added Admin class (holds /admin info for modules)
+Added methods to Server class
+
+
+*/
+
+
+#ifndef __PLUGIN_H
+#define __PLUGIN_H
+
+#include "dynamic.h"
+#include "base.h"
+#include <string>
+#include <deque>
+
+/** Low level definition of a FileReader classes file cache area
+ */
+typedef deque<string> file_cache;
+
+
+// This #define allows us to call a method in all
+// loaded modules in a readable simple way, e.g.:
+// 'FOREACH_MOD OnConnect(user);'
+
+#define FOREACH_MOD for (int i = 0; i <= MODCOUNT; i++) modules[i]->
+
+// class Version holds the version information of a Module, returned
+// by Module::GetVersion (thanks RD)
+
+/** Holds a module's Version information
+ * The four members (set by the constructor only) indicate details as to the version number
+ * of a module. A class of type Version is returned by the GetVersion method of the Module class.
+ */
+class Version
+{
+ public:
+ const int Major, Minor, Revision, Build;
+ Version(int major, int minor, int revision, int build);
+};
+
+
+/** Holds /ADMIN data
+ * This class contains the admin details of the local server. It is constructed by class Server,
+ * and has three read-only values, Name, Email and Nick that contain the specified values for the
+ * server where the module is running.
+ */
+class Admin
+{
+ public:
+ const string Name, Email, Nick;
+ Admin(string name,string email,string nick);
+};
+
+/** Base class for all InspIRCd modules
+ * This class is the base class for InspIRCd modules. All modules must inherit from this class,
+ * its methods will be called when irc server events occur. class inherited from module must be
+ * instantiated by the ModuleFactory class (see relevent section) for the plugin to be initialised.
+ */
+class Module
+{
+ public:
+ /** Default constructor
+ * creates a module class
+ */
+ Module();
+ /** Default destructor
+ * destroys a module class
+ */
+ virtual ~Module();
+ /** Returns the version number of a Module.
+ * The method should return a Version object with its version information assigned via
+ * Version::Version
+ */
+ virtual Version GetVersion();
+ /** Called when a user connects.
+ * The details of the connecting user are available to you in the parameter userrec *user
+ */
+ virtual void OnUserConnect(userrec* user);
+ /** Called when a user quits.
+ * The details of the exiting user are available to you in the parameter userrec *user
+ */
+ virtual void OnUserQuit(userrec* user);
+ /** Called when a user joins a channel.
+ * The details of the joining user are available to you in the parameter userrec *user,
+ * and the details of the channel they have joined is available in the variable chanrec *channel
+ */
+ virtual void OnUserJoin(userrec* user, chanrec* channel);
+ /** Called when a user parts a channel.
+ * The details of the leaving user are available to you in the parameter userrec *user,
+ * and the details of the channel they have left is available in the variable chanrec *channel
+ */
+ virtual void OnUserPart(userrec* user, chanrec* channel);
+};
+
+
+/** Allows server output and query functions
+ * This class contains methods which allow a module to query the state of the irc server, and produce
+ * output to users and other servers. All modules should instantiate at least one copy of this class,
+ * and use its member functions to perform their tasks.
+ */
+class Server
+{
+ public:
+ /** Default constructor.
+ * Creates a Server object.
+ */
+ Server();
+ /** Default destructor.
+ * Destroys a Server object.
+ */
+ virtual ~Server();
+
+ /** Sends text to all opers.
+ * This method sends a server notice to all opers with the usermode +s.
+ */
+ virtual void SendOpers(string s);
+ /** Sends a debug string.
+ * This method writes a line of text to the debug log. If debugging is disabled
+ * in the configuration, this command has no effect.
+ */
+ virtual void Debug(string s);
+ /** Sends a line of text down a TCP/IP socket.
+ * This method writes a line of text to an established socket, cutting it to 510 characters
+ * plus a carriage return and linefeed if required.
+ */
+ virtual void Send(int Socket, string s);
+ /** Sends text from the server to a socket.
+ * This method writes a line of text to an established socket, with the servername prepended
+ * as used by numerics (see RFC 1459)
+ */
+ virtual void SendServ(int Socket, string s);
+ /** Sends text from a user to a socket.
+ * This method writes a line of text to an established socket, with the given user's nick/ident
+ * /host combination prepended, as used in PRIVSG etc commands (see RFC 1459)
+ */
+ virtual void SendFrom(int Socket, userrec* User, string s);
+ /** Sends text from a user to another user.
+ * This method writes a line of text to a user, with a user's nick/ident
+ * /host combination prepended, as used in PRIVMSG etc commands (see RFC 1459)
+ */
+ virtual void SendTo(userrec* Source, userrec* Dest, string s);
+ /** Sends text from a user to a channel (mulicast).
+ * This method writes a line of text to a channel, with the given user's nick/ident
+ * /host combination prepended, as used in PRIVMSG etc commands (see RFC 1459). If the
+ * IncludeSender flag is set, then the text is also sent back to the user from which
+ * it originated, as seen in MODE (see RFC 1459).
+ */
+ virtual void SendChannel(userrec* User, chanrec* Channel, string s,bool IncludeSender);
+ /** Returns true if two users share a common channel.
+ * This method is used internally by the NICK and QUIT commands, and the Server::SendCommon
+ * method.
+ */
+ virtual bool CommonChannels(userrec* u1, userrec* u2);
+ /** Sends text from a user to one or more channels (mulicast).
+ * This method writes a line of text to all users which share a common channel with a given
+ * user, with the user's nick/ident/host combination prepended, as used in PRIVMSG etc
+ * commands (see RFC 1459). If the IncludeSender flag is set, then the text is also sent
+ * back to the user from which it originated, as seen in NICK (see RFC 1459). Otherwise, it
+ * is only sent to the other recipients, as seen in QUIT.
+ */
+ virtual void SendCommon(userrec* User, string text,bool IncludeSender);
+ /** Sends a WALLOPS message.
+ * This method writes a WALLOPS message to all users with the +w flag, originating from the
+ * specified user.
+ */
+ virtual void SendWallops(userrec* User, string text);
+
+ /** Returns true if a nick is valid.
+ * Nicks for unregistered connections will return false.
+ */
+ virtual bool IsNick(string nick);
+ /** Attempts to look up a nick and return a pointer to it.
+ * This function will return NULL if the nick does not exist.
+ */
+ virtual userrec* FindNick(string nick);
+ /** Attempts to look up a channel and return a pointer to it.
+ * This function will return NULL if the channel does not exist.
+ */
+ virtual chanrec* FindChannel(string channel);
+ /** Attempts to look up a user's privilages on a channel.
+ * This function will return a string containing either @, %, +, or an empty string,
+ * representing the user's privilages upon the channel you specify.
+ */
+ virtual string ChanMode(userrec* User, chanrec* Chan);
+ /** Returns the server name of the server where the module is loaded.
+ */
+ virtual string GetServerName();
+ /** Returns the network name, global to all linked servers.
+ */
+ virtual string GetNetworkName();
+ /** Returns the information of the server as returned by the /ADMIN command.
+ * See the Admin class for further information of the return value. The members
+ * Admin::Nick, Admin::Email and Admin::Name contain the information for the
+ * server where the module is loaded.
+ */
+ virtual Admin GetAdmin();
+
+};
+
+/** Allows reading of values from configuration files
+ * This class allows a module to read from either the main configuration file (inspircd.conf) or from
+ * a module-specified configuration file. It may either be instantiated with one parameter or none.
+ * Constructing the class using one parameter allows you to specify a path to your own configuration
+ * file, otherwise, inspircd.conf is read.
+ */
+class ConfigReader
+{
+ protected:
+ /** The filename of the configuration file, as set by the constructor.
+ */
+ string fname;
+ public:
+ /** Default constructor.
+ * This constructor initialises the ConfigReader class to read the inspircd.conf file
+ * as specified when running ./configure.
+ */
+ ConfigReader(); // default constructor reads ircd.conf
+ /** Overloaded constructor.
+ * This constructor initialises the ConfigReader class to read a user-specified config file
+ */
+ ConfigReader(string filename); // read a module-specific config
+ /** Default destructor.
+ * This method destroys the ConfigReader class.
+ */
+ ~ConfigReader();
+ /** Retrieves a value from the config file.
+ * This method retrieves a value from the config file. Where multiple copies of the tag
+ * exist in the config file, index indicates which of the values to retrieve.
+ */
+ string ReadValue(string tag, string name, int index);
+ /** Counts the number of times a given tag appears in the config file.
+ * This method counts the number of times a tag appears in a config file, for use where
+ * there are several tags of the same kind, e.g. with opers and connect types. It can be
+ * used with the index value of ConfigReader::ReadValue to loop through all copies of a
+ * multiple instance tag.
+ */
+ int Enumerate(string tag);
+ /** Returns true if a config file is valid.
+ * This method is unimplemented and will always return true.
+ */
+ bool Verify();
+};
+
+
+
+/** Caches a text file into memory and can be used to retrieve lines from it.
+ * This class contains methods for read-only manipulation of a text file in memory.
+ * Either use the constructor type with one parameter to load a file into memory
+ * at construction, or use the LoadFile method to load a file.
+ */
+class FileReader
+{
+ file_cache fc;
+ public:
+ /** Default constructor.
+ * This method does not load any file into memory, you must use the LoadFile method
+ * after constructing the class this way.
+ */
+ FileReader();
+ /** Secondary constructor.
+ * This method initialises the class with a file loaded into it ready for GetLine and
+ * and other methods to be called. If the file could not be loaded, FileReader::FileSize
+ * returns 0.
+ */
+ FileReader(string filename);
+ /** Default destructor.
+ * This deletes the memory allocated to the file.
+ */
+ ~FileReader();
+ /** Used to load a file.
+ * This method loads a file into the class ready for GetLine and
+ * and other methods to be called. If the file could not be loaded, FileReader::FileSize
+ * returns 0.
+ */
+ void LoadFile(string filename);
+ /** Retrieve one line from the file.
+ * This method retrieves one line from the text file. If an empty non-NULL string is returned,
+ * the index was out of bounds, or the line had no data on it.
+ */
+ string GetLine(int x);
+ /** Returns the size of the file in lines.
+ * This method returns the number of lines in the read file. If it is 0, no lines have been
+ * read into memory, either because the file is empty or it does not exist, or cannot be
+ * opened due to permission problems.
+ */
+ int FileSize();
+};
+
+
+/** Instantiates classes inherited from Module
+ * This class creates a class inherited from type Module, using new. This is to allow for modules
+ * to create many different variants of Module, dependent on architecture, configuration, etc.
+ * In most cases, the simple class shown in the example module m_foobar.so will suffice for most
+ * modules.
+ */
+class ModuleFactory
+{
+ public:
+ ModuleFactory() { }
+ virtual ~ModuleFactory() { }
+ /** Creates a new module.
+ * Your inherited class of ModuleFactory must return a pointer to your Module class
+ * using this method.
+ */
+ virtual Module * CreateModule() = 0;
+};
+
+#endif
diff --git a/include/servers.h b/include/servers.h
index e62f4d3fa..b6e10f91d 100644
--- a/include/servers.h
+++ b/include/servers.h
@@ -1,6 +1,10 @@
/*
$Log$
+Revision 1.2 2003/01/26 23:52:59 brain
+Modified documentation for base classes
+Added base classes
+
Revision 1.1 2003/01/26 20:15:00 brain
Added server classes for linking
@@ -8,7 +12,9 @@ Added server classes for linking
*/
#include "inspircd_config.h"
+#include "connection.h"
#include <string>
+#include <map.h>
#ifndef __SERVERS_H__
#define __SERVERS_H__
@@ -16,12 +22,10 @@ Added server classes for linking
#define LINK_ACTIVE 1
#define LINK_INACTIVE 0
-typedef vector<serverrec*> server_list;
-
-class serverrec
+class serverrec : public connection
{
private:
- server_list leaf; // list of child servers (leaves)
+ map<string, serverrec*> leaf; // list of child servers (leaves)
public:
char name[MAXBUF]; // server name
int pingtime; // last ping response (ms)
@@ -37,11 +41,14 @@ class serverrec
serverrec();
serverrec(char* n, int link_t, long ver, bool jupe);
- ~serverrec()
+ ~serverrec();
void AddLeaf(serverrec *child);
- void DelLeaf(char* n);
+ void DelLeaf(string n);
};
+
+typedef map<string, serverrec*> server_list;
+
#endif
diff --git a/include/servers.h~ b/include/servers.h~
new file mode 100644
index 000000000..d8d7d6add
--- /dev/null
+++ b/include/servers.h~
@@ -0,0 +1,54 @@
+/*
+
+$Log$
+Revision 1.1 2003/01/26 23:52:59 brain
+Modified documentation for base classes
+Added base classes
+
+Revision 1.1 2003/01/26 20:15:00 brain
+Added server classes for linking
+
+
+*/
+
+#include "inspircd_config.h"
+#include "connection.h"
+#include <string>
+#include <map.h>
+
+#ifndef __SERVERS_H__
+#define __SERVERS_H__
+
+#define LINK_ACTIVE 1
+#define LINK_INACTIVE 0
+
+class serverrec : public connection
+{
+ private:
+ map<string, serverrec*> leaf; // list of child servers (leaves)
+ public:
+ char name[MAXBUF]; // server name
+ int pingtime; // last ping response (ms)
+ int linktype; // link type, LINK_ACTIVE or LINK_INACTIVE
+ time_t lastping; // time the link was last pinged
+ long usercount_i; // invisible users on server
+ long usercount; // non-invisible users on server
+ long opercount; // opers on server
+ time_t connected_at; // time server was connected into the network
+ time_t hops_away; // number of hops away (for quick access)
+ long version; // ircd version
+ bool jupiter; // is a JUPE server (faked to enforce a server ban)
+
+ serverrec();
+ serverrec(char* n, int link_t, long ver, bool jupe);
+ ~serverrec();
+ void AddLeaf(serverrec *child);
+ void DelLeaf(string n);
+};
+
+
+
+typedef map<string, serverrec*> server_list;
+
+#endif
+
diff --git a/include/users.h b/include/users.h
index dddda8dd6..b1b21ae0b 100644
--- a/include/users.h
+++ b/include/users.h
@@ -1,8 +1,12 @@
/*
$Log$
-Revision 1.1 2003/01/23 19:45:58 brain
-Initial revision
+Revision 1.2 2003/01/26 23:52:59 brain
+Modified documentation for base classes
+Added base classes
+
+Revision 1.1.1.1 2003/01/23 19:45:58 brain
+InspIRCd second source tree
Revision 1.9 2003/01/22 00:44:26 brain
Added documentation comments
@@ -31,6 +35,7 @@ added /ISON command (for mIRC etc basic notify)
#include "inspircd_config.h"
#include "channels.h"
+#include "connection.h"
#include <string>
@@ -80,7 +85,7 @@ typedef vector<ConnectClass> ClassVector;
* user's nickname and hostname. Use the Find method of the server class to locate a specific user
* by nickname.
*/
-class userrec
+class userrec : public connection
{
private:
@@ -95,18 +100,10 @@ class userrec
char nick[NICKMAX];
- /** The users ip address in network order.
- */
- unsigned long ip;
-
/** The users ident reply.
*/
char ident[64];
- /** The users hostname, or ip address in string form.
- */
- char host[256];
-
/** The host displayed to non-opers (used for cloaking etc).
* This usually matches the value of userrec::host.
*/
@@ -116,55 +113,12 @@ class userrec
*/
char fullname[128];
- /** The users file descriptor.
- * If this is zero, the socket has been closed and the core has not yet
- * realised and removed the record from memory.
- */
- int fd;
-
/** The user's mode string.
* This may contain any of the following RFC characters: o, w, s, i
* Your module may define other mode characters as it sees fit.
*/
char modes[32];
- /** The users input buffer.
- * Used by the C recv() function.
- */
- char inbuf[MAXBUF];
-
- /** The last time the user was pinged by the core.
- * When this value is more than 120 seconds difference from 'time(NULL)', a ping is sent
- * to the client. If the user has an outstanding PING request the next time this
- * event occurs after 4 total minutes, they are disconnected.
- */
- time_t lastping;
-
- /** The users signon time.
- */
- time_t signon;
-
- /** The time the user last sent a message.
- * See also userrec::lastping and userrec::signon
- */
- time_t idle_lastmsg;
-
- /** True if the user replied to their last ping.
- * If this is true, the user can be sent another ping at the specified time, otherwise
- * they will be discnnected. See also userrec::lastping
- */
- time_t nping;
-
- /** Bit 1 is set if the user sent a NICK command, bit 2 is set if the user sent a USER command.
- * If both bits are set then the connection is awaiting MOTD. Sending of MOTD sets bit 3, and
- * makes the value of userrec::registered == 7, showing a fully established client session.
- */
- int registered;
-
- /** A list of the channels the user is currently on.
- * If any of these values are NULL, the record is not in use and may be associated with
- * a channel by the JOIN command. see RFC 1459.
- */
ucrec chans[MAXCHANS];
/** The server the user is connected to.
@@ -176,41 +130,11 @@ class userrec
*/
char awaymsg[512];
- /** The port that the user connected to.
- */
- int port;
-
- /** Stores the number of incoming bytes from the connection.
- * Used by /STATS
- */
- long bytes_in;
-
- /** Stores the number of outgoing bytes to the connection.
- * Used by /STATS
- */
- long bytes_out;
-
- /** Stores the number of incoming commands from the connection.
- * Used by /STATS
- */
- long cmds_in;
-
- /** Stores the number of outgoing commands to the connection.
- * Used by /STATS
- */
- long cmds_out;
-
/** Stores the result of the last GetFullHost or GetRealHost call.
* You may use this to increase the speed of use of this class.
*/
char result[256];
- /** True if a correct password has been given using PASS command.
- * If the user is a member of a connection class that does not require a password,
- * the value stored here is of no use.
- */
- bool haspassed;
-
userrec();
virtual ~userrec() { }
diff --git a/include/users.h~ b/include/users.h~
new file mode 100644
index 000000000..4f00b0d17
--- /dev/null
+++ b/include/users.h~
@@ -0,0 +1,172 @@
+/*
+
+$Log$
+Revision 1.1 2003/01/26 23:52:59 brain
+Modified documentation for base classes
+Added base classes
+
+Revision 1.1.1.1 2003/01/23 19:45:58 brain
+InspIRCd second source tree
+
+Revision 1.9 2003/01/22 00:44:26 brain
+Added documentation comments
+
+Revision 1.8 2003/01/21 21:11:17 brain
+Added documentation
+
+Revision 1.7 2003/01/17 13:21:38 brain
+Added CONNECT ALLOW and CONNECT DENY config tags
+Added PASS command
+
+Revision 1.6 2003/01/17 10:37:55 brain
+Added /INVITE command and relevent structures
+
+Revision 1.5 2003/01/16 20:11:56 brain
+fixed some ugly pointer bugs (thanks dblack and a|KK|y!)
+
+Revision 1.4 2003/01/15 22:47:44 brain
+Changed user and channel structs to classes (finally)
+
+Revision 1.3 2003/01/14 21:14:30 brain
+added /ISON command (for mIRC etc basic notify)
+
+
+*/
+
+#include "inspircd_config.h"
+#include "channels.h"
+#include "connection.h"
+
+#include <string>
+
+#ifndef __USERS_H__
+#define __USERS_H__
+
+#define STATUS_OP 4
+#define STATUS_HOP 2
+#define STATUS_VOICE 1
+#define STATUS_NORMAL 0
+
+#define CC_ALLOW 0
+#define CC_DENY 1
+
+/** Holds a channel name to which a user has been invited.
+ */
+class Invited
+{
+ public:
+ char channel[CHANMAX];
+};
+
+
+/** Holds information relevent to &lt;connect allow&gt; and &lt;connect deny&gt; tags in the config file.
+ */
+class ConnectClass
+{
+ public:
+ int type;
+ char host[MAXBUF];
+ char pass[MAXBUF];
+};
+
+/** Holds a complete list of all channels to which a user has been invited and has not yet joined.
+ */
+typedef vector<Invited> InvitedList;
+
+
+
+/** Holds a complete list of all allow and deny tags from the configuration file (connection classes)
+ */
+typedef vector<ConnectClass> ClassVector;
+
+/** Holds all information about a user
+ * This class stores all information about a user connected to the irc server. Everything about a
+ * connection is stored here primarily, from the user's socket ID (file descriptor) through to the
+ * user's nickname and hostname. Use the Find method of the server class to locate a specific user
+ * by nickname.
+ */
+class userrec : public connection
+{
+ private:
+
+ /** A list of channels the user has a pending invite to.
+ */
+ InvitedList invites;
+ public:
+
+ /** The users nickname.
+ * An invalid nickname indicates an unregistered connection prior to the NICK command.
+ */
+
+ char nick[NICKMAX];
+
+ /** The users ident reply.
+ */
+ char ident[64];
+
+ /** The host displayed to non-opers (used for cloaking etc).
+ * This usually matches the value of userrec::host.
+ */
+ char dhost[256];
+
+ /** The users full name.
+ */
+ char fullname[128];
+
+ /** The user's mode string.
+ * This may contain any of the following RFC characters: o, w, s, i
+ * Your module may define other mode characters as it sees fit.
+ */
+ char modes[32];
+
+ ucrec chans[MAXCHANS];
+
+ /** The server the user is connected to.
+ */
+ char server[256];
+
+ /** The user's away message.
+ * If this string is empty, the user is not marked as away.
+ */
+ char awaymsg[512];
+
+ /** Stores the result of the last GetFullHost or GetRealHost call.
+ * You may use this to increase the speed of use of this class.
+ */
+ char result[256];
+
+ userrec();
+
+ virtual ~userrec() { }
+
+ /** Returns the full displayed host of the user
+ * This member function returns the hostname of the user as seen by other users
+ * on the server, in nick!ident&at;host form.
+ */
+ virtual char* GetFullHost();
+
+ /** Returns the full real host of the user
+ * This member function returns the hostname of the user as seen by other users
+ * on the server, in nick!ident&at;host form. If any form of hostname cloaking is in operation,
+ * e.g. through a module, then this method will ignore it and return the true hostname.
+ */
+ virtual char* GetFullRealHost();
+
+ /** Returns true if a user is invited to a channel.
+ */
+ virtual bool IsInvited(char* channel);
+
+ /** Adds a channel to a users invite list (invites them to a channel)
+ */
+ virtual void InviteTo(char* channel);
+
+ /** Removes a channel from a users invite list.
+ * This member function is called on successfully joining an invite only channel
+ * to which the user has previously been invited, to clear the invitation.
+ */
+ virtual void RemoveInvite(char* channel);
+
+};
+
+
+#endif