diff options
author | Adam <Adam@anope.org> | 2014-02-17 19:39:25 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2014-02-17 19:39:25 -0500 |
commit | ef7dc94f8891e1dba8ac3dcad5966d1025b6226a (patch) | |
tree | 621a5ed520f08b6ff8e5cecac6c9a6b752f36736 /include | |
parent | 7b4eec97480bace2621b8caa4b17f0ea50aa1f98 (diff) |
Move most of the implementation details out of os_forbid.h, fixes crashing if a module adding a forbid is unloaded without removing the forbid
Diffstat (limited to 'include')
-rw-r--r-- | include/modules/os_forbid.h | 48 |
1 files changed, 6 insertions, 42 deletions
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 |