summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2012-02-14 15:13:27 -0500
committerAdam <Adam@anope.org>2012-02-14 15:13:27 -0500
commita9772cde21407c89abd161d51aff45267f87b1fb (patch)
tree9e57ba6c121d3843888917d968dd4f5d030b57cf /include
parent086790d6331357022f4da17c76b26b9fc6e2ad90 (diff)
Clean up and reorganize our header files
Diffstat (limited to 'include')
-rw-r--r--include/CMakeLists.txt26
-rw-r--r--include/access.h19
-rw-r--r--include/account.h129
-rw-r--r--include/anope.h288
-rw-r--r--include/base.h106
-rw-r--r--include/bots.h11
-rw-r--r--include/botserv.h79
-rw-r--r--include/channels.h22
-rw-r--r--include/commands.h7
-rw-r--r--include/config.h51
-rw-r--r--include/defs.h52
-rw-r--r--include/dns.h21
-rw-r--r--include/extensible.h3
-rw-r--r--include/extern.h98
-rw-r--r--include/hashcomp.h15
-rw-r--r--include/lists.h94
-rw-r--r--include/logger.h16
-rw-r--r--include/mail.h15
-rw-r--r--include/memo.h63
-rw-r--r--include/modes.h57
-rw-r--r--include/module.h52
-rw-r--r--include/modules.h136
-rw-r--r--include/oper.h4
-rw-r--r--include/opertype.h5
-rw-r--r--include/protocol.h155
-rw-r--r--include/regchannel.h31
-rw-r--r--include/resource.h20
-rw-r--r--include/serialize.h162
-rw-r--r--include/servers.h3
-rw-r--r--include/service.h110
-rw-r--r--include/services.h913
-rw-r--r--include/signals.h49
-rw-r--r--include/socketengine.h2
-rw-r--r--include/sockets.h12
-rw-r--r--include/threadengine.h3
-rw-r--r--include/timers.h10
-rw-r--r--include/uplink.h44
-rw-r--r--include/users.h24
38 files changed, 1476 insertions, 1431 deletions
diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt
index c7d5456c7..5579fdf30 100644
--- a/include/CMakeLists.txt
+++ b/include/CMakeLists.txt
@@ -20,11 +20,24 @@ endif(NOT WIN32)
set(PCH_SOURCES_GCH "")
if(CMAKE_COMPILER_IS_GNUCXX)
string(REPLACE " " ";" PCH_CXXFLAGS ${CXXFLAGS})
- file(GLOB INCLUDE_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.h")
- remove_item_from_list(INCLUDE_SRCS "version.h")
- set(PCH_SOURCES "module.h;modules.h;services.h")
+ file(GLOB PCH_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.h")
+ sort_list(PCH_SOURCES)
+
foreach(PCH_SOURCE ${PCH_SOURCES})
+ find_includes(${PCH_SOURCE} INCLUDES)
+ set(INCLUDES_LIST)
+ foreach(INCLUDE ${INCLUDES})
+ # Extract the filename from the #include line
+ extract_include_filename(${INCLUDE} FILENAME QUOTE_TYPE)
+ if(QUOTE_TYPE STREQUAL "quotes")
+ find_in_list(PCH_SOURCES "${FILENAME}" FOUND)
+ if(NOT FOUND EQUAL -1)
+ append_to_list(INCLUDES_LIST ${FILENAME})
+ endif(NOT FOUND EQUAL -1)
+ endif(QUOTE_TYPE STREQUAL "quotes")
+ endforeach(INCLUDE)
+
set(PCH_EXTRAFLAGS "")
if(DEBUG_BUILD)
set(PCH_EXTRAFLAGS "-g")
@@ -33,13 +46,14 @@ if(CMAKE_COMPILER_IS_GNUCXX)
set(PCH_EXTRAFLAGS ${PCH_EXTRAFLAGS} -fPIC)
endif(PCH_SOURCE STREQUAL "module.h")
if(GETTEXT_INCLUDE)
- set(PCH_GETTEXT_INCLUDE "-I${GETTEXT_INCLUDE}")
+ set(PCH_GETTEXT_INCLUDE "-I${GETTEXT_INCLUDE}")
endif(GETTEXT_INCLUDE)
set(PCH_SOURCES_GCH "${PCH_SOURCES_GCH};${CMAKE_CURRENT_BINARY_DIR}/${PCH_SOURCE}.gch")
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${PCH_SOURCE}.gch
- COMMAND ${CMAKE_CXX_COMPILER} ARGS ${PCH_CXXFLAGS} ${PCH_EXTRAFLAGS} ${PCH_GETTEXT_INCLUDE} -I${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${PCH_SOURCE} -o ${CMAKE_CURRENT_BINARY_DIR}/${PCH_SOURCE}.gch
- DEPENDS ${INCLUDE_SRCS} VERBATIM
+ COMMAND ${CMAKE_CXX_COMPILER} ARGS ${PCH_CXXFLAGS} ${PCH_EXTRAFLAGS}
+ ${PCH_GETTEXT_INCLUDE} -I${CMAKE_CURRENT_BINARY_DIR} -I${Anope_SOURCE_DIR}/modules/pseudoclients ${CMAKE_CURRENT_SOURCE_DIR}/${PCH_SOURCE} -o ${CMAKE_CURRENT_BINARY_DIR}/${PCH_SOURCE}.gch
+ DEPENDS ${INCLUDES_LIST} VERBATIM
)
endforeach(PCH_SOURCE ${PCH_SOURCES})
endif(CMAKE_COMPILER_IS_GNUCXX)
diff --git a/include/access.h b/include/access.h
index 8b380895d..e19c15a76 100644
--- a/include/access.h
+++ b/include/access.h
@@ -1,6 +1,24 @@
+/*
+ *
+ * (C) 2003-2012 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ *
+ */
+
#ifndef ACCESS_H
#define ACCESS_H
+#include "services.h"
+#include "anope.h"
+#include "serialize.h"
+#include "service.h"
+
enum
{
ACCESS_INVALID = -10000,
@@ -28,7 +46,6 @@ class CoreExport PrivilegeManager
static void ClearPrivileges();
};
-class ChanAccess;
class CoreExport AccessProvider : public Service
{
diff --git a/include/account.h b/include/account.h
index 516bcace5..ffdc7b18f 100644
--- a/include/account.h
+++ b/include/account.h
@@ -1,10 +1,24 @@
+/*
+ *
+ * (C) 2003-2012 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ *
+ */
+
#ifndef ACCOUNT_H
#define ACCOUNT_H
+#include "extensible.h"
+#include "serialize.h"
#include "anope.h"
-
-class NickAlias;
-class NickCore;
+#include "memo.h"
+#include "base.h"
typedef Anope::insensitive_map<NickAlias *> nickalias_map;
typedef Anope::insensitive_map<NickCore *> nickcore_map;
@@ -93,8 +107,11 @@ const Anope::string NickCoreFlagStrings[] = {
"MEMO_MAIL", "HIDE_STATUS", "SUSPENDED", "AUTOOP", "FORBIDDEN", "UNCONFIRMED", ""
};
-class CoreExport NickAlias : public Extensible, public Flags<NickNameFlag, NS_END>, public Serializable
+class CoreExport NickAlias : public Base, public Extensible, public Flags<NickNameFlag, NS_END>, public Serializable
{
+ Anope::string vhost_ident, vhost_host, vhost_creator;
+ time_t vhost_created;
+
public:
/** Default constructor
* @param nickname The nick
@@ -114,7 +131,6 @@ class CoreExport NickAlias : public Extensible, public Flags<NickNameFlag, NS_EN
time_t time_registered; /* When the nick was registered */
time_t last_seen; /* When it was seen online for the last time */
NickCore *nc; /* I'm an alias of this */
- HostInfo hostinfo;
Anope::string serialize_name() const;
serialized_data serialize();
@@ -131,9 +147,46 @@ class CoreExport NickAlias : public Extensible, public Flags<NickNameFlag, NS_EN
* @param u The user
*/
void OnCancel(User *u);
+
+ /** Set a vhost for the user
+ * @param ident The ident
+ * @param host The host
+ * @param creator Who created the vhost
+ * @param time When the vhost was craated
+ */
+ void SetVhost(const Anope::string &ident, const Anope::string &host, const Anope::string &creator, time_t created = Anope::CurTime);
+
+ /** Remove a users vhost
+ **/
+ void RemoveVhost();
+
+ /** Check if the user has a vhost
+ * @return true or false
+ */
+ bool HasVhost() const;
+
+ /** Retrieve the vhost ident
+ * @return the ident
+ */
+ const Anope::string &GetVhostIdent() const;
+
+ /** Retrieve the vhost host
+ * @return the host
+ */
+ const Anope::string &GetVhostHost() const;
+
+ /** Retrieve the vhost creator
+ * @return the creator
+ */
+ const Anope::string &GetVhostCreator() const;
+
+ /** Retrieve when the vhost was created
+ * @return the time it was created
+ */
+ time_t GetVhostCreated() const;
};
-class CoreExport NickCore : public Extensible, public Flags<NickCoreFlag, NI_END>, public Serializable
+class CoreExport NickCore : public Base, public Extensible, public Flags<NickCoreFlag, NI_END>, public Serializable
{
public:
/** Default constructor
@@ -254,65 +307,11 @@ class CoreExport NickCore : public Extensible, public Flags<NickCoreFlag, NI_END
};
-/** Timer for colliding nicks to force people off of nicknames
- */
-class CoreExport NickServCollide : public Timer
-{
- dynamic_reference<User> u;
- Anope::string nick;
-
- public:
- /** Default constructor
- * @param nick The nick we're colliding
- * @param delay How long to delay before kicking the user off the nick
- */
- NickServCollide(User *user, time_t delay);
-
- /** Default destructor
- */
- virtual ~NickServCollide();
-
- /** Called when the delay is up
- * @param t The current time
- */
- void Tick(time_t t);
-};
-
-/** Timers for removing HELD status from nicks.
- */
-class NickServHeld : public Timer
-{
- dynamic_reference<NickAlias> na;
- Anope::string nick;
- public:
- NickServHeld(NickAlias *n, long t);
-
- ~NickServHeld();
-
- void Tick(time_t);
-};
-
-/** Timers for releasing nicks to be available for use
- */
-class CoreExport NickServRelease : public User, public Timer
-{
- Anope::string nick;
-
- public:
- /** Default constructor
- * @param na The nick
- * @param delay The delay before the nick is released
- */
- NickServRelease(NickAlias *na, time_t delay);
-
- /** Default destructor
- */
- virtual ~NickServRelease();
+extern void change_core_display(NickCore *nc);
+extern void change_core_display(NickCore *nc, const Anope::string &newdisplay);
- /** Called when the delay is up
- * @param t The current time
- */
- void Tick(time_t t);
-};
+extern NickAlias *findnick(const Anope::string &nick);
+extern NickCore *findcore(const Anope::string &nick);
+extern bool is_on_access(const User *u, const NickCore *nc);
#endif // ACCOUNT_H
diff --git a/include/anope.h b/include/anope.h
index ac7aa0740..992662650 100644
--- a/include/anope.h
+++ b/include/anope.h
@@ -11,13 +11,8 @@
#ifndef ANOPE_H
#define ANOPE_H
-#include <string>
-#include <vector>
-#include <set>
#include "hashcomp.h"
-class Message;
-
namespace Anope
{
template<typename T> class map : public std::map<string, T> { };
@@ -353,7 +348,7 @@ namespace Anope
* @param mask The pattern to check (e.g. foo*bar)
* @param case_sensitive Whether or not the match is case sensitive, default false.
*/
- extern CoreExport bool Match(const Anope::string &str, const Anope::string &mask, bool case_sensitive = false);
+ extern CoreExport bool Match(const string &str, const string &mask, bool case_sensitive = false);
/** Find a message in the message table
* @param name The name of the message were looking for
@@ -372,20 +367,20 @@ namespace Anope
* @param src The data to be converted
* @param dest The destination string
*/
- extern CoreExport void Unhex(const Anope::string &src, Anope::string &dest);
- extern CoreExport void Unhex(const Anope::string &src, char *dest);
+ extern CoreExport void Unhex(const string &src, string &dest);
+ extern CoreExport void Unhex(const string &src, char *dest);
/** Base 64 encode a string
* @param src The string to encode
* @param target Where the encoded string is placed
*/
- extern CoreExport void B64Encode(const Anope::string &src, Anope::string &target);
+ extern CoreExport void B64Encode(const string &src, string &target);
/** Base 64 decode a string
* @param src The base64 encoded string
* @param target The plain text result
*/
- extern CoreExport void B64Decode(const Anope::string &src, Anope::string &target);
+ extern CoreExport void B64Decode(const string &src, string &target);
/** Returns a sequence of data formatted as the format argument specifies.
** After the format parameter, the function expects at least as many
@@ -404,7 +399,7 @@ namespace Anope
/** Return the last error, uses errno/GetLastError() to determine this
* @return An error message
*/
- extern CoreExport const Anope::string LastError();
+ extern CoreExport const string LastError();
}
/** sepstream allows for splitting token seperated lists.
@@ -470,95 +465,250 @@ class spacesepstream : public sepstream
spacesepstream(const Anope::string &source) : sepstream(source, ' ') { }
};
-/** The base class that most classes in Anope inherit from
+/** This class can be used on its own to represent an exception, or derived to represent a module-specific exception.
+ * When a module whishes to abort, e.g. within a constructor, it should throw an exception using ModuleException or
+ * a class derived from ModuleException. If a module throws an exception during its constructor, the module will not
+ * be loaded. If this happens, the error message returned by ModuleException::GetReason will be displayed to the user
+ * attempting to load the module, or dumped to the console if the ircd is currently loading for the first time.
*/
-class dynamic_reference_base;
-class CoreExport Base
+class CoreException : public std::exception
+{
+ protected:
+ /** Holds the error message to be displayed
+ */
+ Anope::string err;
+ /** Source of the exception
+ */
+ Anope::string source;
+ public:
+ /** Default constructor, just uses the error mesage 'Core threw an exception'.
+ */
+ CoreException() : err("Core threw an exception"), source("The core") { }
+ /** This constructor can be used to specify an error message before throwing.
+ */
+ CoreException(const Anope::string &message) : err(message), source("The core") { }
+ /** This constructor can be used to specify an error message before throwing,
+ * and to specify the source of the exception.
+ */
+ CoreException(const Anope::string &message, const Anope::string &src) : err(message), source(src) { }
+ /** This destructor solves world hunger, cancels the world debt, and causes the world to end.
+ * Actually no, it does nothing. Never mind.
+ * @throws Nothing!
+ */
+ virtual ~CoreException() throw() { }
+ /** Returns the reason for the exception.
+ * The module should probably put something informative here as the user will see this upon failure.
+ */
+ virtual const Anope::string &GetReason() const
+ {
+ return err;
+ }
+
+ virtual const Anope::string &GetSource() const
+ {
+ return source;
+ }
+};
+
+class FatalException : public CoreException
{
- /* References to this base class */
- std::set<dynamic_reference_base *> References;
public:
- Base();
- virtual ~Base();
- void AddReference(dynamic_reference_base *r);
- void DelReference(dynamic_reference_base *r);
+ FatalException(const Anope::string &reason = "") : CoreException(reason) { }
+
+ virtual ~FatalException() throw() { }
};
-class dynamic_reference_base
+class ModuleException : public CoreException
{
- protected:
- bool invalid;
public:
- dynamic_reference_base() : invalid(false) { }
- virtual ~dynamic_reference_base() { }
- inline void Invalidate() { this->invalid = true; }
+ /** Default constructor, just uses the error mesage 'Module threw an exception'.
+ */
+ ModuleException() : CoreException("Module threw an exception", "A Module") { }
+
+ /** This constructor can be used to specify an error message before throwing.
+ */
+ ModuleException(const Anope::string &message) : CoreException(message, "A Module") { }
+ /** This destructor solves world hunger, cancels the world debt, and causes the world to end.
+ * Actually no, it does nothing. Never mind.
+ * @throws Nothing!
+ */
+ virtual ~ModuleException() throw() { }
+};
+
+class ConvertException : public CoreException
+{
+ public:
+ ConvertException(const Anope::string &reason = "") : CoreException(reason) { }
+
+ virtual ~ConvertException() throw() { }
};
-template<typename T>
-class dynamic_reference : public dynamic_reference_base
+/** Convert something to a string
+ */
+template<typename T> inline Anope::string stringify(const T &x)
+{
+ std::ostringstream stream;
+
+ if (!(stream << x))
+ throw ConvertException("Stringify fail");
+
+ return stream.str();
+}
+
+template<typename T> inline void convert(const Anope::string &s, T &x, Anope::string &leftover, bool failIfLeftoverChars = true)
+{
+ leftover.clear();
+ std::istringstream i(s.str());
+ char c;
+ bool res = i >> x;
+ if (!res)
+ throw ConvertException("Convert fail");
+ if (failIfLeftoverChars)
+ {
+ if (i.get(c))
+ throw ConvertException("Convert fail");
+ }
+ else
+ {
+ std::string left;
+ getline(i, left);
+ leftover = left;
+ }
+}
+
+template<typename T> inline void convert(const Anope::string &s, T &x, bool failIfLeftoverChars = true)
+{
+ Anope::string Unused;
+ convert(s, x, Unused, failIfLeftoverChars);
+}
+
+template<typename T> inline T convertTo(const Anope::string &s, Anope::string &leftover, bool failIfLeftoverChars = true)
+{
+ T x;
+ convert(s, x, leftover, failIfLeftoverChars);
+ return x;
+}
+
+template<typename T> inline T convertTo(const Anope::string &s, bool failIfLeftoverChars = true)
+{
+ T x;
+ convert(s, x, failIfLeftoverChars);
+ return x;
+}
+
+/** Debug cast to be used instead of dynamic_cast, this uses dynamic_cast
+ * for debug builds and static_cast on releass builds to speed up the program
+ * because dynamic_cast relies on RTTI.
+ */
+#ifdef DEBUG_BUILD
+# include <typeinfo>
+#endif
+template<typename T, typename O> inline T debug_cast(O ptr)
+{
+#ifdef DEBUG_BUILD
+ T ret = dynamic_cast<T>(ptr);
+ if (ptr != NULL && ret == NULL)
+ throw CoreException(Anope::string("debug_cast<") + typeid(T).name() + ">(" + typeid(O).name() + ") fail");
+ return ret;
+#else
+ return static_cast<T>(ptr);
+#endif
+}
+
+/*************************************************************************/
+
+/** Class with the ability to keep flags on items, they should extend from this
+ * where T is an enum.
+ */
+template<typename T, size_t Size = 32> class Flags
{
protected:
- T *ref;
+ std::bitset<Size> Flag_Values;
+ const Anope::string *Flag_Strings;
+
public:
- dynamic_reference(T *obj) : ref(obj)
+ Flags() : Flag_Strings(NULL) { }
+ Flags(const Anope::string *flag_strings) : Flag_Strings(flag_strings) { }
+
+ /** Add a flag to this item
+ * @param Value The flag
+ */
+ void SetFlag(T Value)
{
- if (ref)
- ref->AddReference(this);
+ Flag_Values[Value] = true;
}
- dynamic_reference(const dynamic_reference<T> &obj) : ref(obj.ref)
+ /** Remove a flag from this item
+ * @param Value The flag
+ */
+ void UnsetFlag(T Value)
{
- if (ref)
- ref->AddReference(this);
+ Flag_Values[Value] = false;
}
- virtual ~dynamic_reference()
+ /** Check if this item has a flag
+ * @param Value The flag
+ * @return true or false
+ */
+ bool HasFlag(T Value) const
{
- if (this->invalid)
- {
- this->invalid = false;
- this->ref = NULL;
- }
- else if (this->operator bool())
- ref->DelReference(this);
+ return Flag_Values.test(Value);
}
- virtual operator bool()
+ /** Check how many flags are set
+ * @return The number of flags set
+ */
+ size_t FlagCount() const
{
- if (this->invalid)
- {
- this->invalid = false;
- this->ref = NULL;
- }
- return this->ref != NULL;
+ return Flag_Values.count();
}
- virtual inline operator T*()
+ /** Unset all of the flags
+ */
+ void ClearFlags()
{
- if (this->operator bool())
- return this->ref;
- return NULL;
+ Flag_Values.reset();
}
- virtual inline T *operator->()
+ Anope::string ToString()
{
- if (this->operator bool())
- return this->ref;
- return NULL;
+ std::vector<Anope::string> v = ToVector();
+ Anope::string flag_buf;
+ for (unsigned i = 0; i < v.size(); ++i)
+ flag_buf += v[i] + " ";
+ flag_buf.trim();
+ return flag_buf;
}
- virtual inline void operator=(T *newref)
+ void FromString(const Anope::string &str)
{
- if (this->invalid)
- {
- this->invalid = false;
- this->ref = NULL;
- }
- else if (this->operator bool())
- this->ref->DelReference(this);
- this->ref = newref;
- if (this->operator bool())
- this->ref->AddReference(this);
+ spacesepstream sep(str);
+ Anope::string buf;
+ std::vector<Anope::string> v;
+
+ while (sep.GetToken(buf))
+ v.push_back(buf);
+
+ FromVector(v);
+ }
+
+ std::vector<Anope::string> ToVector()
+ {
+ std::vector<Anope::string> ret;
+ for (unsigned i = 0; this->Flag_Strings && !this->Flag_Strings[i].empty(); ++i)
+ if (this->HasFlag(static_cast<T>(i)))
+ ret.push_back(this->Flag_Strings[i]);
+ return ret;
+ }
+
+ void FromVector(const std::vector<Anope::string> &strings)
+ {
+ this->ClearFlags();
+
+ for (unsigned i = 0; this->Flag_Strings && !this->Flag_Strings[i].empty(); ++i)
+ for (unsigned j = 0; j < strings.size(); ++j)
+ if (this->Flag_Strings[i] == strings[j])
+ this->SetFlag(static_cast<T>(i));
}
};
diff --git a/include/base.h b/include/base.h
new file mode 100644
index 000000000..2a7cb5147
--- /dev/null
+++ b/include/base.h
@@ -0,0 +1,106 @@
+/*
+ *
+ * Copyright (C) 2008-2011 Adam <Adam@anope.org>
+ * Copyright (C) 2008-2012 Anope Team <team@anope.org>
+ *
+ * Please read COPYING and README for further details.
+ */
+
+#ifndef BASE_H
+#define BASE_H
+
+#include "services.h"
+
+/** The base class that most classes in Anope inherit from
+ */
+class CoreExport Base
+{
+ /* References to this base class */
+ std::set<dynamic_reference_base *> References;
+ public:
+ Base();
+ virtual ~Base();
+ void AddReference(dynamic_reference_base *r);
+ void DelReference(dynamic_reference_base *r);
+};
+
+class dynamic_reference_base
+{
+ protected:
+ bool invalid;
+ public:
+ dynamic_reference_base() : invalid(false) { }
+ virtual ~dynamic_reference_base() { }
+ inline void Invalidate() { this->invalid = true; }
+};
+
+template<typename T>
+class dynamic_reference : public dynamic_reference_base
+{
+ protected:
+ T *ref;
+ public:
+ dynamic_reference(T *obj) : ref(obj)
+ {
+ if (ref)
+ ref->AddReference(this);
+ }
+
+ dynamic_reference(const dynamic_reference<T> &obj) : ref(obj.ref)
+ {
+ if (ref)
+ ref->AddReference(this);
+ }
+
+ virtual ~dynamic_reference()
+ {
+ if (this->invalid)
+ {
+ this->invalid = false;
+ this->ref = NULL;
+ }
+ else if (this->operator bool())
+ ref->DelReference(this);
+ }
+
+ virtual operator bool()
+ {
+ if (this->invalid)
+ {
+ this->invalid = false;
+ this->ref = NULL;
+ }
+ return this->ref != NULL;
+ }
+
+ virtual inline operator T*()
+ {
+ if (this->operator bool())
+ return this->ref;
+ return NULL;
+ }
+
+ virtual inline T *operator->()
+ {
+ if (this->operator bool())
+ return this->ref;
+ return NULL;
+ }
+
+ virtual inline void operator=(T *newref)
+ {
+ if (this->invalid)
+ {
+ this->invalid = false;
+ this->ref = NULL;
+ }
+ else if (this->operator bool())
+ this->ref->DelReference(this);
+ this->ref = newref;
+ if (this->operator bool())
+ this->ref->AddReference(this);
+ }
+};
+
+#endif // BASE_H
+
diff --git a/include/bots.h b/include/bots.h
index 93ca7d9b9..243ae7556 100644
--- a/include/bots.h
+++ b/include/bots.h
@@ -8,7 +8,11 @@
#ifndef BOTS_H
#define BOTS_H
-class BotInfo;
+#include "users.h"
+#include "anope.h"
+#include "serialize.h"
+#include "commands.h"
+
extern CoreExport Anope::insensitive_map<BotInfo *> BotListByNick;
extern CoreExport Anope::map<BotInfo *> BotListByUID;
@@ -123,4 +127,9 @@ class CoreExport BotInfo : public User, public Flags<BotFlag, BI_END>, public Se
CommandInfo *GetCommand(const Anope::string &cname);
};
+extern BotInfo *findbot(const Anope::string &nick);
+
+extern void bot_raw_ban(User *requester, ChannelInfo *ci, const Anope::string &nick, const Anope::string &reason);
+extern void bot_raw_kick(User *requester, ChannelInfo *ci, const Anope::string &nick, const Anope::string &reason);
+
#endif // BOTS_H
diff --git a/include/botserv.h b/include/botserv.h
new file mode 100644
index 000000000..e5ef2c8ba
--- /dev/null
+++ b/include/botserv.h
@@ -0,0 +1,79 @@
+/*
+ *
+ * (C) 2003-2012 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ *
+ */
+
+#ifndef BOTSERV_H
+#define BOTSERV_H
+
+#include "anope.h"
+
+/* BotServ SET flags */
+enum BotServFlag
+{
+ BS_BEGIN,
+ /* BotServ won't kick ops */
+ BS_DONTKICKOPS,
+ /* BotServ won't kick voices */
+ BS_DONTKICKVOICES,
+ /* BotServ bot accepts fantasy commands */
+ BS_FANTASY,
+ /* BotServ should show greets */
+ BS_GREET,
+ /* BotServ bots are not allowed to be in this channel */
+ BS_NOBOT,
+ /* BotServ kicks for bolds */
+ BS_KICK_BOLDS,
+ /* BotServ kicks for colors */
+ BS_KICK_COLORS,
+ /* BOtServ kicks for reverses */
+ BS_KICK_REVERSES,
+ /* BotServ kicks for underlines */
+ BS_KICK_UNDERLINES,
+ /* BotServ kicks for badwords */
+ BS_KICK_BADWORDS,
+ /* BotServ kicks for caps */
+ BS_KICK_CAPS,
+ /* BotServ kicks for flood */
+ BS_KICK_FLOOD,
+ /* BotServ kicks for repeating */
+ BS_KICK_REPEAT,
+ /* BotServ kicks for italics */
+ BS_KICK_ITALICS,
+ /* BotServ kicks for amsgs */
+ BS_KICK_AMSGS,
+ BS_END
+};
+
+const Anope::string BotServFlagStrings[] = {
+ "BEGIN", "DONTKICKOPS", "DONTKICKVOICES", "FANTASY", "GREET", "NOBOT",
+ "KICK_BOLDs", "KICK_COLORS", "KICK_REVERSES", "KICK_UNDERLINES", "KICK_BADWORDS", "KICK_CAPS",
+ "KICK_FLOOD", "KICK_REPEAT", "KICK_ITALICS", "KICK_AMSGS", "MSG_PRIVMSG", "MSG_NOTICE",
+ "MSG_NOTICEOPS", ""
+};
+
+/* Indices for TTB (Times To Ban) */
+enum
+{
+ TTB_BOLDS,
+ TTB_COLORS,
+ TTB_REVERSES,
+ TTB_UNDERLINES,
+ TTB_BADWORDS,
+ TTB_CAPS,
+ TTB_FLOOD,
+ TTB_REPEAT,
+ TTB_ITALICS,
+ TTB_AMSGS,
+ TTB_SIZE
+};
+
+#endif // BOTSERV_H
diff --git a/include/channels.h b/include/channels.h
index 2aa4fc765..a4803fe00 100644
--- a/include/channels.h
+++ b/include/channels.h