summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2011-11-08 17:29:16 -0500
committerAdam <Adam@anope.org>2011-11-08 17:29:16 -0500
commitb5ff856f47d8e54d12c568462a06351633c29610 (patch)
treea4e2f96c59ee49aa5e6cacdfd30db6155151ad36 /include
parent97b9055f92f21cd91af44a3d5dacce0024536cff (diff)
Windows
Diffstat (limited to 'include')
-rw-r--r--include/access.h13
-rw-r--r--include/account.h4
-rw-r--r--include/anope.h6
-rw-r--r--include/bots.h2
-rw-r--r--include/dns.h10
-rw-r--r--include/extensible.h2
-rw-r--r--include/hashcomp.h33
-rw-r--r--include/modules.h23
-rw-r--r--include/oper.h4
-rw-r--r--include/regchannel.h18
-rw-r--r--include/serialize.h149
-rw-r--r--include/services.h55
-rw-r--r--include/sockets.h6
-rw-r--r--include/threadengine.h17
14 files changed, 130 insertions, 212 deletions
diff --git a/include/access.h b/include/access.h
index d86539d8f..1e5f6a496 100644
--- a/include/access.h
+++ b/include/access.h
@@ -1,7 +1,7 @@
#ifndef ACCESS_H
#define ACCESS_H
-struct Privilege
+struct CoreExport Privilege
{
Anope::string name;
Anope::string desc;
@@ -10,7 +10,7 @@ struct Privilege
bool operator==(const Privilege &other);
};
-class PrivilegeManager
+class CoreExport PrivilegeManager
{
static std::vector<Privilege> privs;
public:
@@ -31,7 +31,7 @@ class CoreExport AccessProvider : public Service<AccessProvider>
virtual ChanAccess *Create() = 0;
};
-class CoreExport ChanAccess
+class CoreExport ChanAccess : public Serializable
{
public:
AccessProvider *provider;
@@ -41,11 +41,12 @@ class CoreExport ChanAccess
time_t last_seen;
time_t created;
- virtual Anope::string serialize_name() = 0;
- virtual SerializableBase::serialized_data serialize() = 0;
-
ChanAccess(AccessProvider *p);
virtual ~ChanAccess();
+
+ serialized_data serialize();
+ static void unserialize(serialized_data &);
+
virtual bool Matches(User *u, NickCore *nc) = 0;
virtual bool HasPriv(const Anope::string &name) = 0;
virtual Anope::string Serialize() = 0;
diff --git a/include/account.h b/include/account.h
index 395d883dc..2d12c99cb 100644
--- a/include/account.h
+++ b/include/account.h
@@ -93,7 +93,7 @@ const Anope::string NickCoreFlagStrings[] = {
"MEMO_MAIL", "HIDE_STATUS", "SUSPENDED", "AUTOOP", "FORBIDDEN", "UNCONFIRMED", ""
};
-class CoreExport NickAlias : public Extensible, public Flags<NickNameFlag, NS_END>, public Serializable<NickAlias>
+class CoreExport NickAlias : public Extensible, public Flags<NickNameFlag, NS_END>, public Serializable
{
public:
/** Default constructor
@@ -132,7 +132,7 @@ class CoreExport NickAlias : public Extensible, public Flags<NickNameFlag, NS_EN
void OnCancel(User *u);
};
-class CoreExport NickCore : public Extensible, public Flags<NickCoreFlag, NI_END>, public Serializable<NickCore>
+class CoreExport NickCore : public Extensible, public Flags<NickCoreFlag, NI_END>, public Serializable
{
public:
/** Default constructor
diff --git a/include/anope.h b/include/anope.h
index 60eb59775..837f0c82e 100644
--- a/include/anope.h
+++ b/include/anope.h
@@ -21,7 +21,7 @@ class Message;
namespace Anope
{
template<typename T> class map : public std::map<string, T> { };
- template<typename T> class insensitive_map : public std::map<string, T, std::less<ci::string> > { };
+ template<typename T> class insensitive_map : public std::map<string, T, ci::less> { };
/**
* A wrapper string class around all the other string classes, this class will
@@ -265,7 +265,7 @@ namespace Anope
{
Anope::string new_string = *this;
for (size_type i = 0; i < new_string.length(); ++i)
- new_string[i] = tolower(new_string[i]);
+ new_string[i] = static_cast<char>(tolower(new_string[i]));
return new_string;
}
@@ -276,7 +276,7 @@ namespace Anope
{
Anope::string new_string = *this;
for (size_type i = 0; i < new_string.length(); ++i)
- new_string[i] = toupper(new_string[i]);
+ new_string[i] = static_cast<char>(toupper(new_string[i]));
return new_string;
}
diff --git a/include/bots.h b/include/bots.h
index 64d185840..00c0c87a1 100644
--- a/include/bots.h
+++ b/include/bots.h
@@ -32,7 +32,7 @@ enum BotFlag
static const Anope::string BotFlagString[] = { "BEGIN", "CORE", "PRIVATE", "CONF", "" };
-class CoreExport BotInfo : public User, public Flags<BotFlag, BI_END>, public Serializable<BotInfo>
+class CoreExport BotInfo : public User, public Flags<BotFlag, BI_END>, public Serializable
{
public:
uint32_t chancount;
diff --git a/include/dns.h b/include/dns.h
index d72cc08de..23e779b67 100644
--- a/include/dns.h
+++ b/include/dns.h
@@ -52,7 +52,7 @@ class Module;
struct DNSQuery;
class DNSPacket;
-struct Question
+struct CoreExport Question
{
Anope::string name;
QueryType type;
@@ -62,7 +62,7 @@ struct Question
Question(const Anope::string &, QueryType, unsigned short = 1);
};
-struct ResourceRecord : public Question
+struct CoreExport ResourceRecord : public Question
{
unsigned int ttl;
Anope::string rdata;
@@ -72,7 +72,7 @@ struct ResourceRecord : public Question
ResourceRecord(const Question &);
};
-struct DNSQuery
+struct CoreExport DNSQuery
{
std::vector<Question> questions;
std::vector<ResourceRecord> answers, authorities, additional;
@@ -134,11 +134,11 @@ class DNSPacket : public DNSQuery
unsigned short Pack(unsigned char *output, unsigned short output_size);
};
-/** DNS manager, manages the connection and all requests
+/** DNS manager, manages all requests
*/
class CoreExport DNSManager : public Timer, public Socket
{
- typedef std::multimap<Anope::string, ResourceRecord, std::less<ci::string> > cache_map;
+ typedef std::multimap<Anope::string, ResourceRecord, ci::less> cache_map;
cache_map cache;
sockaddrs addrs;
public:
diff --git a/include/extensible.h b/include/extensible.h
index c5de2dae4..c4dd3a0f3 100644
--- a/include/extensible.h
+++ b/include/extensible.h
@@ -10,7 +10,7 @@
#include "anope.h"
#include "hashcomp.h"
-class ExtensibleItem
+class CoreExport ExtensibleItem
{
public:
ExtensibleItem();
diff --git a/include/hashcomp.h b/include/hashcomp.h
index d78b01857..a4a86889f 100644
--- a/include/hashcomp.h
+++ b/include/hashcomp.h
@@ -139,6 +139,16 @@ namespace irc
/** This typedef declares irc::string based upon irc_char_traits.
*/
typedef std::basic_string<char, irc_char_traits, std::allocator<char> > string;
+
+ struct CoreExport less
+ {
+ /** Compare two Anope::strings as irc::strings and find which one is less
+ * @param s1 The first string
+ * @param s2 The second string
+ * @return true if s1 < s2, else false
+ */
+ bool operator()(const Anope::string &s1, const Anope::string &s2) const;
+ };
}
/** The ci namespace contains a number of helper classes.
@@ -193,16 +203,9 @@ namespace ci
/** This typedef declares ci::string based upon ci_char_traits.
*/
typedef std::basic_string<char, ci_char_traits, std::allocator<char> > string;
-}
-namespace std
-{
- /** An overload for std::less<ci::string> that uses Anope::string, passed for the third template argument
- * to std::map and std::multimap
- */
- template<> struct CoreExport less<ci::string>
+ struct CoreExport less
{
- public:
/** Compare two Anope::strings as ci::strings and find which one is less
* @param s1 The first string
* @param s2 The second string
@@ -210,20 +213,6 @@ namespace std
*/
bool operator()(const Anope::string &s1, const Anope::string &s2) const;
};
-
- /** An overload for std;:less<irc::string> that uses Anope::string, passed for the third tempalte argument
- * to std::map and std::multimap
- */
- template<> struct CoreExport less<irc::string>
- {
- public:
- /** Compare two Anope::strings as irc::strings and find which one is less
- * @param s1 The first string
- * @param s2 The second string
- * @return true if s1 < s2, else false
- */
- bool operator()(const Anope::string &s1, const Anope::string &s2) const;
- };
}
/* Define operators for + and == with irc::string to std::string for easy assignment
diff --git a/include/modules.h b/include/modules.h
index 695917dbf..d3a43cd8a 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -18,27 +18,6 @@
#include "timers.h"
#include "hashcomp.h"
-/* Cross OS compatibility macros */
-#ifdef _WIN32
- typedef HMODULE ano_module_t;
-
-# define dlopen(file, unused) LoadLibrary(file)
-# define dlsym(file, symbol) (HMODULE)GetProcAddress(file, symbol)
-# define dlclose(file) FreeLibrary(file) ? 0 : 1
-# define ano_modclearerr() SetLastError(0)
-# define ano_moderr() (Anope::LastError().empty() ? NULL : Anope::LastError().c_str())
-#else
- typedef void * ano_module_t;
-
-/* We call dlerror() here because it clears the module error after being
- * called. This previously read 'errno = 0', but that didn't work on
- * all POSIX-compliant architectures. This way the error is guaranteed
- * to be cleared, POSIX-wise. -GD
- */
-# define ano_modclearerr() dlerror()
-# define ano_moderr() dlerror()
-#endif
-
/** Possible return types from events.
*/
enum EventReturn
@@ -215,7 +194,7 @@ class CoreExport Module : public Extensible
/** Handle for this module, obtained from dlopen()
*/
- ano_module_t handle;
+ void *handle;
/** Time this module was created
*/
diff --git a/include/oper.h b/include/oper.h
index 1537681a1..62f783282 100644
--- a/include/oper.h
+++ b/include/oper.h
@@ -11,7 +11,7 @@
class XLineManager;
-class CoreExport XLine : public Serializable<XLine>
+class CoreExport XLine : public Serializable
{
protected:
XLine();
@@ -42,7 +42,7 @@ class CoreExport XLineManager : public Service<XLineManager>
char type;
/* List of XLines in this XLineManager */
std::vector<XLine *> XLines;
- static std::map<Anope::string, XLine *, std::less<ci::string> > XLinesByUID;
+ static std::map<Anope::string, XLine *, ci::less> XLinesByUID;
public:
/* List of XLine managers we check users against in XLineManager::CheckAll */
static std::list<XLineManager *> XLineManagers;
diff --git a/include/regchannel.h b/include/regchannel.h
index e22d64e5f..3f6c29581 100644
--- a/include/regchannel.h
+++ b/include/regchannel.h
@@ -75,12 +75,13 @@ enum BadWordType
};
/* Structure used to contain bad words. */
-struct BadWord : Serializable<BadWord>
+struct CoreExport BadWord : Serializable
{
ChannelInfo *ci;
Anope::string word;
BadWordType type;
+ BadWord();
serialized_data serialize();
static void unserialize(serialized_data &);
};
@@ -96,10 +97,10 @@ enum AutoKickFlag
const Anope::string AutoKickFlagString[] = { "AK_ISNICK", "" };
/* AutoKick data. */
-class AutoKick : public Flags<AutoKickFlag>, public Serializable<AutoKick>
+class CoreExport AutoKick : public Flags<AutoKickFlag>, public Serializable
{
public:
- AutoKick() : Flags<AutoKickFlag>(AutoKickFlagString) { }
+ AutoKick();
ChannelInfo *ci;
/* Only one of these can be in use */
Anope::string mask;
@@ -114,9 +115,9 @@ class AutoKick : public Flags<AutoKickFlag>, public Serializable<AutoKick>
static void unserialize(serialized_data &);
};
-struct ModeLock : Serializable<ModeLock>
+struct CoreExport ModeLock : Serializable
{
- ModeLock() { }
+ ModeLock();
public:
ChannelInfo *ci;
bool set;
@@ -125,13 +126,13 @@ struct ModeLock : Serializable<ModeLock>
Anope::string setter;
time_t created;
- ModeLock(ChannelInfo *ch, bool s, ChannelModeName n, const Anope::string &p, const Anope::string &se = "", time_t c = Anope::CurTime) : ci(ch), set(s), name(n), param(p), setter(se), created(c) { }
+ ModeLock(ChannelInfo *ch, bool s, ChannelModeName n, const Anope::string &p, const Anope::string &se = "", time_t c = Anope::CurTime);
serialized_data serialize();
static void unserialize(serialized_data &);
};
-struct LogSetting : Serializable<LogSetting>
+struct CoreExport LogSetting : Serializable
{
ChannelInfo *ci;
/* Our service name of the command */
@@ -144,11 +145,12 @@ struct LogSetting : Serializable<LogSetting>
Anope::string creator;
time_t created;
+ LogSetting();
serialized_data serialize();
static void unserialize(serialized_data &);
};
-class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag, CI_END>, public Serializable<ChannelInfo>
+class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag, CI_END>, public Serializable
{
private:
NickCore *founder; /* Channel founder */
diff --git a/include/serialize.h b/include/serialize.h
index 7f12cf176..8bd26bfda 100644
--- a/include/serialize.h
+++ b/include/serialize.h
@@ -14,11 +14,11 @@ namespace Serialize
private:
DataType type;
bool key;
- unsigned max;
+ unsigned _max;
public:
- stringstream() : std::stringstream(), type(DT_TEXT), key(false), max(0) { }
- stringstream(const stringstream &ss) : std::stringstream(ss.str()), type(DT_TEXT), key(false), max(0) { }
+ stringstream() : std::stringstream(), type(DT_TEXT), key(false), _max(0) { }
+ stringstream(const stringstream &ss) : std::stringstream(ss.str()), type(DT_TEXT), key(false), _max(0) { }
Anope::string astr() const { return this->str(); }
template<typename T> std::istream &operator>>(T &val)
{
@@ -51,116 +51,117 @@ namespace Serialize
}
stringstream &setMax(unsigned m)
{
- this->max = m;
+ this->_max = m;
return *this;
}
unsigned getMax() const
{
- return this->max;
+ return this->_max;
}
};
}
-class SerializableBase;
-
-extern std::vector<SerializableBase *> serialized_types;
-extern std::list<SerializableBase *> *serialized_items;
extern void RegisterTypes();
-class SerializableBase
+class CoreExport Serializable
{
- public:
- typedef std::map<Anope::string, Serialize::stringstream> serialized_data;
+ private:
+ static std::list<Serializable *> serizliable_items;
- virtual ~SerializableBase() { }
- virtual Anope::string serialize_name() = 0;
- virtual serialized_data serialize() = 0;
- virtual void alloc(serialized_data &) = 0;
-};
+ Anope::string serizliable_name;
+ std::list<Serializable *>::iterator s_iter;
-template<typename Type> class Serializable : public SerializableBase
-{
- public:
- static class SerializableAllocator : public SerializableBase
+ Serializable()
{
- Anope::string name;
+ throw CoreException();
+ }
- public:
- SerializableAllocator()
- {
- }
+ protected:
+ Serializable(const Anope::string &n) : serizliable_name(n)
+ {
+ serizliable_items.push_front(this);
+ this->s_iter = serizliable_items.begin();
+ }
- void Register(const Anope::string &n, int pos = -1)
- {
- this->name = n;
- serialized_types.insert(serialized_types.begin() + (pos < 0 ? serialized_types.size() : pos), this);
- }
+ Serializable(const Serializable &)
+ {
+ serizliable_items.push_front(this);
+ this->s_iter = serizliable_items.begin();
+ }
- void Unregister()
- {
- std::vector<SerializableBase *>::iterator it = std::find(serialized_types.begin(), serialized_types.end(), this);
- if (it != serialized_types.end())
- serialized_types.erase(it);
- }
+ virtual ~Serializable()
+ {
+ serizliable_items.erase(this->s_iter);
+ }
- Anope::string serialize_name()
- {
- if (this->name.empty())
- throw CoreException();
- return this->name;
- }
+ Serializable &operator=(const Serializable &)
+ {
+ return *this;
+ }
- serialized_data serialize()
- {
- throw CoreException();
- }
+ public:
+ typedef std::map<Anope::string, Serialize::stringstream> serialized_data;
- void alloc(serialized_data &data)
- {
- Type::unserialize(data);
- }
- } Alloc;
+ const Anope::string &GetSerializeName()
+ {
+ return this->serizliable_name;
+ }
- private:
- std::list<SerializableBase *>::iterator s_iter;
+ virtual serialized_data serialize() = 0;
- protected:
- Serializable()
+ static const std::list<Serializable *> &GetItems()
{
- if (serialized_items == NULL)
- serialized_items = new std::list<SerializableBase *>();
- serialized_items->push_front(this);
- this->s_iter = serialized_items->begin();
+ return serizliable_items;
}
+};
- Serializable(const Serializable &)
+class CoreExport SerializeType
+{
+ typedef void (*unserialize_func)(Serializable::serialized_data &);
+
+ static std::vector<Anope::string> type_order;
+ static Anope::map<SerializeType *> types;
+
+ Anope::string name;
+ unserialize_func unserialize;
+
+ public:
+ SerializeType(const Anope::string &n, unserialize_func f) : name(n), unserialize(f)
{
- serialized_items->push_front(this);
- this->s_iter = serialized_items->begin();
+ type_order.push_back(this->name);
+ types[this->name] = this;
}
- ~Serializable()
+ ~SerializeType()
{
- serialized_items->erase(this->s_iter);
+ std::vector<Anope::string>::iterator it = std::find(type_order.begin(), type_order.end(), this->name);
+ if (it != type_order.end())
+ type_order.erase(it);
+ types.erase(this->name);
}
- Serializable &operator=(const Serializable &)
+ const Anope::string &GetName()
{
- return *this;
+ return this->name;
}
- public:
- Anope::string serialize_name()
+ void Create(Serializable::serialized_data &data)
{
- return Alloc.serialize_name();
+ this->unserialize(data);
}
- void alloc(serialized_data &)
+ static SerializeType *Find(const Anope::string &name)
{
- throw CoreException();
+ Anope::map<SerializeType *>::iterator it = types.find(name);
+ if (it != types.end())
+ return it->second;
+ return NULL;
}
-};
-template<typename T> typename Serializable<T>::SerializableAllocator Serializable<T>::Alloc;
+ static const std::vector<Anope::string> &GetTypeOrder()
+ {
+ return type_order;
+ }
+};
#endif // SERIALIZE_H
diff --git a/include/services.h b/include/services.h
index 3ce8ad86f..c6cb6aa57 100644
--- a/include/services.h
+++ b/include/services.h
@@ -20,19 +20,16 @@
#define BUFSIZE 1024
-/* Some SUN fixs */
-#ifdef __sun
-# ifndef INADDR_NONE
-# define INADDR_NONE (-1)
-# endif
-#endif
-
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdexcept>
#include <string.h>
+#if HAVE_STRINGS_H
+# include <strings.h>
+#endif
+
#include <signal.h>
#include <time.h>
#include <errno.h>
@@ -40,9 +37,9 @@
#include <sys/stat.h> /* for umask() on some systems */
#include <sys/types.h>
-#include <sys/wait.h>
#include <fcntl.h>
#include <typeinfo>
+#include <ctype.h>
#if GETTEXT_FOUND
# include <libintl.h>
@@ -57,11 +54,12 @@
# include <arpa/inet.h>
# include <sys/socket.h>
# include <sys/time.h>
+# include <sys/wait.h>
# include <dirent.h>
+# include <pthread.h>
# define DllExport
# define CoreExport
# define MARK_DEPRECATED __attribute((deprecated))
-# define DeleteFile unlink
#else
# include "anope_windows.h"
#endif
@@ -73,35 +71,6 @@
# define FORMAT(type, fmt, start)
#endif
-#if HAVE_STRINGS_H
-# include <strings.h>
-#endif
-
-#ifdef _AIX
-/* Some AIX boxes seem to have bogus includes that don't have these
- * prototypes. */
-extern int strcasecmp(const char *, const char *);
-extern int strncasecmp(const char *, const char *, size_t);
-# undef FD_ZERO
-# define FD_ZERO(p) memset((p), 0, sizeof(*(p)))
-#endif /* _AIX */
-
-/* Alias stricmp/strnicmp to strcasecmp/strncasecmp if we have the latter
- * but not the former. */
-#if !HAVE_STRICMP && HAVE_STRCASECMP
-# define stricmp strcasecmp
-# define strnicmp strncasecmp
-#endif
-
-/* We have our own versions of toupper()/tolower(). */
-#include <ctype.h>
-#undef tolower
-#undef toupper
-#define tolower tolower_
-#define toupper toupper_
-extern int toupper(char);
-extern int tolower(char);
-
/** This definition is used as shorthand for the various classes
* and functions needed to make a module loadable by the OS.
* It defines the class factory and external AnopeInit and AnopeFini functions.
@@ -115,12 +84,6 @@ extern int tolower(char);
} \
BOOLEAN WINAPI DllMain(HINSTANCE, DWORD nReason, LPVOID) \
{ \
- switch (nReason) \
- { \
- case DLL_PROCESS_ATTACH: \
- case DLL_PROCESS_DETACH: \
- break; \
- } \
return TRUE; \
} \
extern "C" DllExport void AnopeFini(x *); \
@@ -343,7 +306,7 @@ template<typename T, size_t Size = 32> class Flags
class Module;
-template<typename T> class CoreExport Service : public Base
+template<typename T> class Service : public Base
{
static Anope::map<T *> services;
public:
@@ -538,7 +501,7 @@ const Anope::string MemoFlagStrings[] = {
/* Memo info structures. Since both nicknames and channels can have memos,
* we encapsulate memo data in a MemoList to make it easier to handle. */
-class CoreExport Memo : public Flags<MemoFlag>, public Serializable<Memo>
+class CoreExport Memo : public Flags<MemoFlag>, public Serializable
{
public:
Memo();
diff --git a/include/sockets.h b/include/sockets.h
index b8d6033ee..444daced7 100644
--- a/include/sockets.h
+++ b/include/sockets.h
@@ -16,12 +16,6 @@
#define NET_BUFSIZE 65535
-#ifdef _WIN32
-# define CloseSocket closesocket
-#else
-# define CloseSocket close
-#endif
-
/** A sockaddr union used to combine IPv4 and IPv6 sockaddrs
*/
union CoreExport sockaddrs
diff --git a/include/threadengine.h b/include/threadengine.h
index 06c4900a4..b840092d4 100644
--- a/include/threadengine.h
+++ b/include/threadengine.h
@@ -1,17 +1,6 @@
#ifndef THREADENGINE_H
#define THREADENGINE_H
-#ifdef _WIN32
-typedef HANDLE ThreadHandle;
-typedef CRITICAL_SECTION MutexHandle;
-typedef HANDLE CondHandle;
-#else
-# include <pthread.h>
-typedef pthread_t ThreadHandle;
-typedef pthread_mutex_t MutexHandle;
-typedef pthread_cond_t CondHandle;
-#endif
-
class Thread;
class CoreExport Thread : public Pipe, public Extensible
@@ -22,7 +11,7 @@ class CoreExport Thread : public Pipe, public Extensible
public:
/* Handle for this thread */
- ThreadHandle Handle;
+ pthread_t Handle;
/** Threads constructor
*/
@@ -66,7 +55,7 @@ class CoreExport Mutex
{
protected:
/* A mutex, used to keep threads in sync */
- MutexHandle mutex;
+ pthread_mutex_t mutex;
public:
/** Constructor
@@ -96,7 +85,7 @@ class CoreExport Condition : public Mutex
{
private:
/* A condition */
- CondHandle cond;
+ pthread_cond_t cond;
public:
/** Constructor