summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/modules/encryption.h37
-rw-r--r--include/modules/os_forbid.h48
-rw-r--r--include/modules/os_ignore.h54
-rw-r--r--include/service.h2
-rw-r--r--include/sockets.h2
5 files changed, 55 insertions, 88 deletions
diff --git a/include/modules/encryption.h b/include/modules/encryption.h
new file mode 100644
index 000000000..95c5703aa
--- /dev/null
+++ b/include/modules/encryption.h
@@ -0,0 +1,37 @@
+/*
+ *
+ * (C) 2003-2014 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.
+ *
+ */
+
+namespace Encryption
+{
+ typedef std::pair<const unsigned char *, size_t> Hash;
+ typedef std::pair<const uint32_t *, size_t> IV;
+
+ class Context
+ {
+ public:
+ virtual ~Context() { }
+ virtual void Update(const unsigned char *data, size_t len) = 0;
+ virtual void Finalize() = 0;
+ virtual Hash GetFinalizedHash() = 0;
+ };
+
+ class Provider : public Service
+ {
+ public:
+ Provider(Module *creator, const Anope::string &sname) : Service(creator, "Encryption::Provider", sname) { }
+ virtual ~Provider() { }
+
+ virtual Context *CreateContext(IV * = NULL) = 0;
+ virtual IV GetDefaultIV() = 0;
+ };
+}
+
diff --git a/include/modules/os_forbid.h b/include/modules/os_forbid.h
index 3f1fe9a7f..fe96ba5c6 100644
--- a/include/modules/os_forbid.h
+++ b/include/modules/os_forbid.h
@@ -10,7 +10,7 @@ enum ForbidType
FT_SIZE
};
-struct ForbidData : Serializable
+struct ForbidData
{
Anope::string mask;
Anope::string creator;
@@ -19,9 +19,9 @@ struct ForbidData : Serializable
time_t expires;
ForbidType type;
- ForbidData() : Serializable("ForbidData") { }
- void Serialize(Serialize::Data &data) const anope_override;
- static Serializable* Unserialize(Serializable *obj, Serialize::Data &data);
+ virtual ~ForbidData() { }
+ protected:
+ ForbidData() : created(0), expires(0) { }
};
class ForbidService : public Service
@@ -33,6 +33,8 @@ class ForbidService : public Service
virtual void RemoveForbid(ForbidData *d) = 0;
+ virtual ForbidData* CreateForbid() = 0;
+
virtual ForbidData *FindForbid(const Anope::string &mask, ForbidType type) = 0;
virtual std::vector<ForbidData *> GetForbids() = 0;
@@ -40,43 +42,5 @@ class ForbidService : public Service
static ServiceReference<ForbidService> forbid_service("ForbidService", "forbid");
-void ForbidData::Serialize(Serialize::Data &data) const
-{
- data["mask"] << this->mask;
- data["creator"] << this->creator;
- data["reason"] << this->reason;
- data["created"] << this->created;
- data["expires"] << this->expires;
- data["type"] << this->type;
-}
-
-Serializable* ForbidData::Unserialize(Serializable *obj, Serialize::Data &data)
-{
- if (!forbid_service)
- return NULL;
-
- ForbidData *fb;
- if (obj)
- fb = anope_dynamic_static_cast<ForbidData *>(obj);
- else
- fb = new ForbidData;
-
- data["mask"] >> fb->mask;
- data["creator"] >> fb->creator;
- data["reason"] >> fb->reason;
- data["created"] >> fb->created;
- data["expires"] >> fb->expires;
- unsigned int t;
- data["type"] >> t;
- fb->type = static_cast<ForbidType>(t);
-
- if (t > FT_SIZE - 1)
- return NULL;
-
- if (!obj)
- forbid_service->AddForbid(fb);
- return fb;
-}
-
#endif
diff --git a/include/modules/os_ignore.h b/include/modules/os_ignore.h
index 0f2c2f0d8..2511d47b2 100644
--- a/include/modules/os_ignore.h
+++ b/include/modules/os_ignore.h
@@ -10,70 +10,36 @@
*/
-struct IgnoreData : Serializable
+struct IgnoreData
{
Anope::string mask;
Anope::string creator;
Anope::string reason;
time_t time; /* When do we stop ignoring them? */
- IgnoreData() : Serializable("IgnoreData") { }
- void Serialize(Serialize::Data &data) const anope_override;
- static Serializable* Unserialize(Serializable *obj, Serialize::Data &data);
+ virtual ~IgnoreData() { }
+ protected:
+ IgnoreData() : time(0) { }
};
class IgnoreService : public Service
{
protected:
- std::list<IgnoreData> ignores;
-
IgnoreService(Module *c) : Service(c, "IgnoreService", "ignore") { }
public:
- virtual IgnoreData* AddIgnore(const Anope::string &mask, const Anope::string &creator, const Anope::string &reason, time_t delta = Anope::CurTime) = 0;
+ virtual void AddIgnore(IgnoreData *) = 0;
+
+ virtual void DelIgnore(IgnoreData *) = 0;
- virtual bool DelIgnore(const Anope::string &mask) = 0;
+ virtual void ClearIgnores() = 0;
- inline void ClearIgnores() { this->ignores.clear(); }
+ virtual IgnoreData *Create() = 0;
virtual IgnoreData *Find(const Anope::string &mask) = 0;
- inline std::list<IgnoreData> &GetIgnores() { return this->ignores; }
+ virtual std::vector<IgnoreData *> &GetIgnores() = 0;
};
static ServiceReference<IgnoreService> ignore_service("IgnoreService", "ignore");
-void IgnoreData::Serialize(Serialize::Data &data) const
-{
- data["mask"] << this->mask;
- data["creator"] << this->creator;
- data["reason"] << this->reason;
- data["time"] << this->time;
-}
-
-Serializable* IgnoreData::Unserialize(Serializable *obj, Serialize::Data &data)
-{
- if (!ignore_service)
- return NULL;
-
- if (obj)
- {
- IgnoreData *ign = anope_dynamic_static_cast<IgnoreData *>(obj);
- data["mask"] >> ign->mask;
- data["creator"] >> ign->creator;
- data["reason"] >> ign->reason;
- data["time"] >> ign->time;
- return ign;
- }
-
- Anope::string smask, screator, sreason;
- time_t t;
-
- data["mask"] >> smask;
- data["creator"] >> screator;
- data["reason"] >> sreason;
- data["time"] >> t;
-
- return ignore_service->AddIgnore(smask, screator, sreason, t);
-}
-
diff --git a/include/service.h b/include/service.h
index db0b2af4b..8142363d6 100644
--- a/include/service.h
+++ b/include/service.h
@@ -20,7 +20,7 @@
/** Anything that inherits from this class can be referred to
* using ServiceReference. Any interfaces provided by modules,
* such as commands, use this. This is also used for modules
- * that publish a service (m_ssl, etc).
+ * that publish a service (m_ssl_openssl, etc).
*/
class CoreExport Service : public virtual Base
{
diff --git a/include/sockets.h b/include/sockets.h
index 744f1a23e..0dfa5d9d0 100644
--- a/include/sockets.h
+++ b/include/sockets.h
@@ -347,7 +347,7 @@ class CoreExport BinarySocket : public virtual Socket
/** Write data to the socket
* @param buffer The data to write
- * @param l The length of the data
+ * @param l The length of the data; if 0 then this function returns without doing anything
*/
virtual void Write(const char *buffer, size_t l);
void Write(const char *message, ...);