summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/CMakeLists.txt48
-rw-r--r--include/access.h8
-rw-r--r--include/account.h15
-rw-r--r--include/anope.h41
-rw-r--r--include/base.h20
-rw-r--r--include/bots.h5
-rw-r--r--include/channels.h5
-rw-r--r--include/commands.h15
-rw-r--r--include/config.h17
-rw-r--r--include/defs.h2
-rw-r--r--include/extensible.h21
-rw-r--r--include/hashcomp.h26
-rw-r--r--include/language.h13
-rw-r--r--include/lists.h11
-rw-r--r--include/logger.h27
-rw-r--r--include/mail.h9
-rw-r--r--include/memo.h9
-rw-r--r--include/messages.h42
-rw-r--r--include/modes.h31
-rw-r--r--include/module.h5
-rw-r--r--include/modules.h38
-rw-r--r--include/modules/bs_badwords.h8
-rw-r--r--include/modules/bs_kick.h6
-rw-r--r--include/modules/cs_entrymsg.h6
-rw-r--r--include/modules/cs_log.h8
-rw-r--r--include/modules/cs_mode.h8
-rw-r--r--include/modules/dns.h25
-rw-r--r--include/modules/encryption.h6
-rw-r--r--include/modules/httpd.h32
-rw-r--r--include/modules/ldap.h13
-rw-r--r--include/modules/ns_cert.h6
-rw-r--r--include/modules/os_forbid.h13
-rw-r--r--include/modules/os_ignore.h8
-rw-r--r--include/modules/os_news.h5
-rw-r--r--include/modules/os_session.h15
-rw-r--r--include/modules/pseudoclients/chanserv.h5
-rw-r--r--include/modules/pseudoclients/global.h5
-rw-r--r--include/modules/pseudoclients/memoserv.h5
-rw-r--r--include/modules/pseudoclients/nickserv.h5
-rw-r--r--include/modules/redis.h8
-rw-r--r--include/modules/sasl.h6
-rw-r--r--include/modules/set_misc.h7
-rw-r--r--include/modules/sql.h40
-rw-r--r--include/modules/ssl.h2
-rw-r--r--include/modules/suspend.h6
-rw-r--r--include/modules/xmlrpc.h6
-rw-r--r--include/opertype.h7
-rw-r--r--include/protocol.h24
-rw-r--r--include/pstdint.h800
-rw-r--r--include/regchannel.h10
-rw-r--r--include/regexpr.h9
-rw-r--r--include/serialize.h27
-rw-r--r--include/servers.h7
-rw-r--r--include/service.h11
-rw-r--r--include/services.h25
-rw-r--r--include/socketengine.h5
-rw-r--r--include/sockets.h66
-rw-r--r--include/sysconf.h.cmake56
-rw-r--r--include/threadengine.h13
-rw-r--r--include/timers.h5
-rw-r--r--include/uplink.h11
-rw-r--r--include/users.h12
-rw-r--r--include/version.cpp10
-rw-r--r--include/xline.h11
64 files changed, 389 insertions, 1382 deletions
diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt
index a434be6e1..763826344 100644
--- a/include/CMakeLists.txt
+++ b/include/CMakeLists.txt
@@ -3,7 +3,7 @@ set_source_files_properties(version.cpp PROPERTIES LANGUAGE CXX COMPILE_FLAGS "$
# Generate version-bin executable to modify version.h, setting it's linker flags as well
add_executable(version-bin version.cpp)
set_target_properties(version-bin PROPERTIES LINKER_LANGUAGE CXX LINK_FLAGS "${LDFLAGS}")
-get_target_property(version_BINARY version-bin LOCATION)
+set(version_BINARY "$<TARGET_FILE:version-bin>")
# Modify version.h from the above executable, with dependencies to version.cpp
# and all of the source files in the main build
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/version.h ${CMAKE_CURRENT_BINARY_DIR}/build.h
@@ -16,49 +16,7 @@ add_to_cpack_ignored_files("${version_BINARY}$" TRUE)
if(NOT WIN32)
add_to_cpack_ignored_files("version.h$" TRUE)
add_to_cpack_ignored_files("build.h$" TRUE)
-endif(NOT WIN32)
-
-set(PCH_SOURCES_GCH "")
-if(USE_PCH AND CMAKE_COMPILER_IS_GNUCXX)
- string(REPLACE " " ";" PCH_CXXFLAGS "${CXXFLAGS} ${CMAKE_CXX_FLAGS}")
-
- 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)
- append_to_list(INCLUDES_LIST ${PCH_SOURCE})
- 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")
- endif(DEBUG_BUILD)
- if(PCH_SOURCE STREQUAL "module.h")
- set(PCH_EXTRAFLAGS ${PCH_EXTRAFLAGS} -fPIC)
- endif(PCH_SOURCE STREQUAL "module.h")
- if(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} -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(USE_PCH AND CMAKE_COMPILER_IS_GNUCXX)
+endif()
# Add a custom target to the above file
-add_custom_target(headers DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/version.h ${CMAKE_CURRENT_BINARY_DIR}/build.h ${PCH_SOURCES_GCH})
+add_custom_target(headers DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/version.h ${CMAKE_CURRENT_BINARY_DIR}/build.h)
diff --git a/include/access.h b/include/access.h
index c668c6c38..f22e098bf 100644
--- a/include/access.h
+++ b/include/access.h
@@ -9,8 +9,7 @@
* Based on the original code of Services by Andy Church.
*/
-#ifndef ACCESS_H
-#define ACCESS_H
+#pragma once
#include "services.h"
#include "anope.h"
@@ -85,6 +84,7 @@ class CoreExport ChanAccess : public Serializable
/* Channel this access entry is on */
Serialize::Reference<ChannelInfo> ci;
Anope::string creator;
+ Anope::string description;
time_t last_seen;
time_t created;
@@ -95,7 +95,7 @@ class CoreExport ChanAccess : public Serializable
const Anope::string &Mask() const;
NickCore *GetAccount() const;
- void Serialize(Serialize::Data &data) const anope_override;
+ void Serialize(Serialize::Data &data) const override;
static Serializable* Unserialize(Serializable *obj, Serialize::Data &);
static const unsigned int MAX_DEPTH = 4;
@@ -170,5 +170,3 @@ class CoreExport AccessGroup
inline bool empty() const { return paths.empty(); }
};
-
-#endif
diff --git a/include/account.h b/include/account.h
index 16fe19646..d48b25872 100644
--- a/include/account.h
+++ b/include/account.h
@@ -9,8 +9,7 @@
* Based on the original code of Services by Andy Church.
*/
-#ifndef ACCOUNT_H
-#define ACCOUNT_H
+#pragma once
#include "extensible.h"
#include "serialize.h"
@@ -20,7 +19,7 @@
typedef Anope::hash_map<NickAlias *> nickalias_map;
typedef Anope::hash_map<NickCore *> nickcore_map;
-typedef TR1NS::unordered_map<uint64_t, NickCore *> nickcoreid_map;
+typedef std::unordered_map<uint64_t, NickCore *> nickcoreid_map;
extern CoreExport Serialize::Checker<nickalias_map> NickAliasList;
extern CoreExport Serialize::Checker<nickcore_map> NickCoreList;
@@ -54,7 +53,7 @@ class CoreExport NickAlias : public Serializable, public Extensible
NickAlias(const Anope::string &nickname, NickCore *nickcore);
~NickAlias();
- void Serialize(Serialize::Data &data) const anope_override;
+ void Serialize(Serialize::Data &data) const override;
static Serializable* Unserialize(Serializable *obj, Serialize::Data &);
/** Set a vhost for the user
@@ -149,7 +148,7 @@ class CoreExport NickCore : public Serializable, public Extensible
NickCore(const Anope::string &nickdisplay, uint64_t nickid = 0);
~NickCore();
- void Serialize(Serialize::Data &data) const anope_override;
+ void Serialize(Serialize::Data &data) const override;
static Serializable* Unserialize(Serializable *obj, Serialize::Data &);
/** Changes the display for this account
@@ -240,8 +239,8 @@ class CoreExport IdentifyRequest
Anope::string password;
std::set<Module *> holds;
- bool dispatched;
- bool success;
+ bool dispatched = false;
+ bool success = false;
static std::set<IdentifyRequest *> Requests;
@@ -286,5 +285,3 @@ class CoreExport IdentifyRequest
static void ModuleUnload(Module *m);
};
-
-#endif // ACCOUNT_H
diff --git a/include/anope.h b/include/anope.h
index ed894c4ce..22094cf1d 100644
--- a/include/anope.h
+++ b/include/anope.h
@@ -9,8 +9,7 @@
* Based on the original code of Services by Andy Church.
*/
-#ifndef ANOPE_H
-#define ANOPE_H
+#pragma once
#include <signal.h>
@@ -54,9 +53,7 @@ namespace Anope
string(const ci::string &_str) : _string(_str.c_str()) { }
string(const string &_str, size_type pos, size_type n = npos) : _string(_str._string, pos, n) { }
template <class InputIterator> string(InputIterator first, InputIterator last) : _string(first, last) { }
-#if __cplusplus >= 201103L
string(const string &) = default;
-#endif
/**
* Assignment operators, so any type of string can be assigned to this class.
@@ -257,8 +254,8 @@ namespace Anope
inline string lower() const
{
Anope::string new_string = *this;
- for (size_type i = 0; i < new_string.length(); ++i)
- new_string[i] = Anope::tolower(new_string[i]);
+ for (auto &chr : new_string)
+ chr = Anope::tolower(chr);
return new_string;
}
@@ -268,8 +265,8 @@ namespace Anope
inline string upper() const
{
Anope::string new_string = *this;
- for (size_type i = 0; i < new_string.length(); ++i)
- new_string[i] = Anope::toupper(new_string[i]);
+ for (auto &chr : new_string)
+ chr = Anope::toupper(chr);
return new_string;
}
@@ -315,7 +312,7 @@ namespace Anope
{
inline size_t operator()(const string &s) const
{
- return TR1NS::hash<std::string>()(s.lower().str());
+ return std::hash<std::string>()(s.lower().str());
}
};
@@ -323,7 +320,7 @@ namespace Anope
{
inline size_t operator()(const string &s) const
{
- return TR1NS::hash<std::string>()(s.str());
+ return std::hash<std::string>()(s.str());
}
};
@@ -337,7 +334,7 @@ namespace Anope
template<typename T> class map : public std::map<string, T, ci::less> { };
template<typename T> class multimap : public std::multimap<string, T, ci::less> { };
- template<typename T> class hash_map : public TR1NS::unordered_map<string, T, hash_ci, compare> { };
+ template<typename T> class hash_map : public std::unordered_map<string, T, hash_ci, compare> { };
#ifndef REPRODUCIBLE_BUILD
static const char *const compiled = __TIME__ " " __DATE__;
@@ -369,11 +366,11 @@ namespace Anope
*/
extern CoreExport bool ReadOnly, NoFork, NoThird, NoExpire, ProtocolDebug;
- /** The root of the services installation. Usually ~/services
+ /** The root of the Anope installation. Usually ~/anope
*/
extern CoreExport Anope::string ServicesDir;
- /** Services binary name (eg services)
+ /** Anope binary name (eg anope)
*/
extern CoreExport Anope::string ServicesBin;
@@ -465,14 +462,6 @@ namespace Anope
*/
extern CoreExport void Encrypt(const Anope::string &src, Anope::string &dest);
- /** Decrypts what is in 'src' to 'dest'.
- * @param src The source string to decrypt
- * @param dest The destination where the decrypted string is placed
- * @return true if decryption was successful. This is usually not the case
- * as most encryption methods we use are one way.
- */
- extern CoreExport bool Decrypt(const Anope::string &src, Anope::string &dest);
-
/** Hashes a buffer with SipHash-2-4
* @param src The start of the buffer to hash
* @param src_sz The total number of bytes in the buffer
@@ -577,7 +566,7 @@ class CoreExport sepstream
char sep;
/** Current string position
*/
- size_t pos;
+ size_t pos = 0;
/** If set then GetToken() can return an empty string
*/
bool allow_empty;
@@ -683,7 +672,7 @@ class CoreException : public std::exception
* Actually no, it does nothing. Never mind.
* @throws Nothing!
*/
- virtual ~CoreException() throw() { }
+ virtual ~CoreException() noexcept = default;
/** Returns the reason for the exception.
* The module should probably put something informative here as the user will see this upon failure.
*/
@@ -712,7 +701,7 @@ class ModuleException : public CoreException
* Actually no, it does nothing. Never mind.
* @throws Nothing!
*/
- virtual ~ModuleException() throw() { }
+ virtual ~ModuleException() noexcept = default;
};
class ConvertException : public CoreException
@@ -720,7 +709,7 @@ class ConvertException : public CoreException
public:
ConvertException(const Anope::string &reason = "") : CoreException(reason) { }
- virtual ~ConvertException() throw() { }
+ virtual ~ConvertException() noexcept = default;
};
/** Convert something to a string
@@ -794,5 +783,3 @@ template<typename T, typename O> inline T anope_dynamic_static_cast(O ptr)
return static_cast<T>(ptr);
}
#endif
-
-#endif // ANOPE_H
diff --git a/include/base.h b/include/base.h
index 819d3c116..a88877bc5 100644
--- a/include/base.h
+++ b/include/base.h
@@ -6,8 +6,7 @@
* Please read COPYING and README for further details.
*/
-#ifndef BASE_H
-#define BASE_H
+#pragma once
#include "services.h"
@@ -16,9 +15,8 @@
class CoreExport Base
{
/* References to this base class */
- std::set<ReferenceBase *> *references;
+ std::set<ReferenceBase *> *references = nullptr;
public:
- Base();
virtual ~Base();
/** Adds a reference to this object. Eg, when a Reference
@@ -33,11 +31,11 @@ class CoreExport Base
class ReferenceBase
{
protected:
- bool invalid;
+ bool invalid = false;
public:
- ReferenceBase() : invalid(false) { }
+ ReferenceBase() = default;
ReferenceBase(const ReferenceBase &other) : invalid(other.invalid) { }
- virtual ~ReferenceBase() { }
+ virtual ~ReferenceBase() = default;
inline void Invalidate() { this->invalid = true; }
};
@@ -48,11 +46,9 @@ template<typename T>
class Reference : public ReferenceBase
{
protected:
- T *ref;
+ T *ref = nullptr;
public:
- Reference() : ref(NULL)
- {
- }
+ Reference() = default;
Reference(T *obj) : ref(obj)
{
@@ -139,5 +135,3 @@ class Reference : public ReferenceBase
return false;
}
};
-
-#endif // BASE_H
diff --git a/include/bots.h b/include/bots.h
index 8c4aa2e7e..4b2f40ddf 100644
--- a/include/bots.h
+++ b/include/bots.h
@@ -6,8 +6,7 @@
* Please read COPYING and README for further details.
*/
-#ifndef BOTS_H
-#define BOTS_H
+#pragma once
#include "users.h"
#include "anope.h"
@@ -131,5 +130,3 @@ class CoreExport BotInfo : public User, public Serializable
*/
static BotInfo* Find(const Anope::string &nick, bool nick_only = false);
};
-
-#endif // BOTS_H
diff --git a/include/channels.h b/include/channels.h
index e3ce9acf1..da4ab33a4 100644
--- a/include/channels.h
+++ b/include/channels.h
@@ -6,8 +6,7 @@
* Please read COPYING and README for further details.
*/
-#ifndef CHANNELS_H
-#define CHANNELS_H
+#pragma once
#include "anope.h"
#include "extensible.h"
@@ -311,5 +310,3 @@ class CoreExport Channel : public Base, public Extensible
static void DeleteChannels();
};
-
-#endif // CHANNELS_H
diff --git a/include/commands.h b/include/commands.h
index b1fb4a4ae..451727500 100644
--- a/include/commands.h
+++ b/include/commands.h
@@ -9,8 +9,7 @@
* Based on the original code of Services by Andy Church.
*/
-#ifndef COMMAND_H
-#define COMMAND_H
+#pragma once
#include "service.h"
#include "anope.h"
@@ -26,8 +25,6 @@ struct CommandInfo
{
typedef Anope::map<CommandInfo> map;
- CommandInfo() : hide(false), prepend_channel(false) { }
-
/* Service name of the command */
Anope::string name;
/* Permission required to execute the command */
@@ -35,9 +32,9 @@ struct CommandInfo
/* Group this command is in */
Anope::string group;
/* whether or not to hide this command in help output */
- bool hide;
+ bool hide = false;
/* Only used with fantasy */
- bool prepend_channel;
+ bool prepend_channel = false;
};
/* Where the replies from commands go to. User inherits from this and is the normal
@@ -45,7 +42,7 @@ struct CommandInfo
*/
struct CoreExport CommandReply
{
- virtual ~CommandReply() { }
+ virtual ~CommandReply() = default;
virtual void SendMessage(BotInfo *source, const Anope::string &msg) = 0;
};
@@ -120,7 +117,7 @@ class CoreExport Command : public Service
Command(Module *owner, const Anope::string &sname, size_t min_params, size_t max_params = 0);
public:
- virtual ~Command();
+ virtual ~Command() = default;
protected:
void SetDesc(const Anope::string &d);
@@ -183,5 +180,3 @@ class CoreExport Command : public Service
*/
static bool FindCommandFromService(const Anope::string &command_service, BotInfo* &bi, Anope::string &name);
};
-
-#endif // COMMANDS_H
diff --git a/include/config.h b/include/config.h
index f3e5d8816..bcd792adb 100644
--- a/include/config.h
+++ b/include/config.h
@@ -9,8 +9,7 @@
* Based on the original code of Services by Andy Church.
*/
-#ifndef CONFIG_H
-#define CONFIG_H
+#pragma once
#include "account.h"
#include "regchannel.h"
@@ -66,7 +65,7 @@ namespace Configuration
}
bool Set(const Anope::string &tag, const Anope::string &value);
- const item_map* GetItems() const;
+ const item_map &GetItems() const;
};
template<> CoreExport const Anope::string Block::Get(const Anope::string &tag, const Anope::string& def) const;
@@ -83,7 +82,7 @@ namespace Configuration
{
Anope::string name;
bool executable;
- FILE *fp;
+ FILE *fp = nullptr;
public:
File(const Anope::string &, bool);
~File();
@@ -158,10 +157,10 @@ namespace Configuration
Anope::string host;
unsigned port;
Anope::string password;
- bool ipv6;
+ int protocol;
- Uplink(const Anope::string &_host, int _port, const Anope::string &_password, bool _ipv6) : host(_host), port(_port), password(_password), ipv6(_ipv6) { }
- inline bool operator==(const Uplink &other) const { return host == other.host && port == other.port && password == other.password && ipv6 == other.ipv6; }
+ Uplink(const Anope::string &_host, int _port, const Anope::string &_password, int _protocol) : host(_host), port(_port), password(_password), protocol(_protocol) { }
+ inline bool operator==(const Uplink &other) const { return host == other.host && port == other.port && password == other.password && protocol == other.protocol; }
inline bool operator!=(const Uplink &other) const { return !(*this == other); }
};
}
@@ -185,10 +184,8 @@ class ConfigException : public CoreException
* Actually no, it does nothing. Never mind.
* @throws Nothing!
*/
- virtual ~ConfigException() throw() { }
+ virtual ~ConfigException() noexcept = default;
};
extern Configuration::File ServicesConf;
extern CoreExport Configuration::Conf *Config;
-
-#endif // CONFIG_H
diff --git a/include/defs.h b/include/defs.h
index 2ce36f6e3..83ec924d9 100644
--- a/include/defs.h
+++ b/include/defs.h
@@ -9,6 +9,8 @@
* Based on the original code of Services by Andy Church.
*/
+#pragma once
+
class AccessGroup;
class AutoKick;
class BotInfo;
diff --git a/include/extensible.h b/include/extensible.h
index fee168bcc..317ea9f64 100644
--- a/include/extensible.h
+++ b/include/extensible.h
@@ -6,8 +6,7 @@
* Please read COPYING and README for further details.
*/
-#ifndef EXTENSIBLE_H
-#define EXTENSIBLE_H
+#pragma once
#include "anope.h"
#include "serialize.h"
@@ -93,7 +92,7 @@ class BaseExtensibleItem : public ExtensibleBase
return t;
}
- void Unset(Extensible *obj) anope_override
+ void Unset(Extensible *obj) override
{
T *value = Get(obj);
items.erase(obj);
@@ -128,7 +127,7 @@ template<typename T>
class ExtensibleItem : public BaseExtensibleItem<T>
{
protected:
- T* Create(Extensible *obj) anope_override
+ T* Create(Extensible *obj) override
{
return new T(obj);
}
@@ -140,7 +139,7 @@ template<typename T>
class PrimitiveExtensibleItem : public BaseExtensibleItem<T>
{
protected:
- T* Create(Extensible *obj) anope_override
+ T* Create(Extensible *obj) override
{
return new T();
}
@@ -152,7 +151,7 @@ template<>
class PrimitiveExtensibleItem<bool> : public BaseExtensibleItem<bool>
{
protected:
- bool* Create(Extensible *) anope_override
+ bool* Create(Extensible *) override
{
return NULL;
}
@@ -166,13 +165,13 @@ class SerializableExtensibleItem : public PrimitiveExtensibleItem<T>
public:
SerializableExtensibleItem(Module *m, const Anope::string &n) : PrimitiveExtensibleItem<T>(m, n) { }
- void ExtensibleSerialize(const Extensible *e, const Serializable *s, Serialize::Data &data) const anope_override
+ void ExtensibleSerialize(const Extensible *e, const Serializable *s, Serialize::Data &data) const override
{
T* t = this->Get(e);
data[this->name] << *t;
}
- void ExtensibleUnserialize(Extensible *e, Serializable *s, Serialize::Data &data) anope_override
+ void ExtensibleUnserialize(Extensible *e, Serializable *s, Serialize::Data &data) override
{
T t;
if (data[this->name] >> t)
@@ -188,12 +187,12 @@ class SerializableExtensibleItem<bool> : public PrimitiveExtensibleItem<bool>
public:
SerializableExtensibleItem(Module *m, const Anope::string &n) : PrimitiveExtensibleItem<bool>(m, n) { }
- void ExtensibleSerialize(const Extensible *e, const Serializable *s, Serialize::Data &data) const anope_override
+ void ExtensibleSerialize(const Extensible *e, const Serializable *s, Serialize::Data &data) const override
{
data[this->name] << true;
}
- void ExtensibleUnserialize(Extensible *e, Serializable *s, Serialize::Data &data) anope_override
+ void ExtensibleUnserialize(Extensible *e, Serializable *s, Serialize::Data &data) override
{
bool b = false;
data[this->name] >> b;
@@ -259,5 +258,3 @@ void Extensible::Shrink(const Anope::string &name)
else
Log(LOG_DEBUG) << "Shrink for nonexistent type " << name << " on " << static_cast<void *>(this);
}
-
-#endif // EXTENSIBLE_H
diff --git a/include/hashcomp.h b/include/hashcomp.h
index bc6c8a9b9..930717444 100644
--- a/include/hashcomp.h
+++ b/include/hashcomp.h
@@ -6,19 +6,11 @@
* Please read COPYING and README for further details.
*/
-#ifndef HASHCOMP_H
-#define HASHCOMP_H
+#pragma once
#include <string>
#include <locale>
-
-#if defined _LIBCPP_VERSION || defined _WIN32
#include <unordered_map>
-#define TR1NS std
-#else
-#include <tr1/unordered_map>
-#define TR1NS std::tr1
-#endif
#include "services.h"
@@ -29,16 +21,16 @@ namespace Anope
/* Casemap in use by Anope. ci::string's comparison functions use this (and thus Anope::string) */
extern std::locale casemap;
- extern void CaseMapRebuild();
- extern unsigned char tolower(unsigned char);
- extern unsigned char toupper(unsigned char);
+ extern CoreExport void CaseMapRebuild();
+ extern CoreExport unsigned char tolower(unsigned char);
+ extern CoreExport unsigned char toupper(unsigned char);
/* ASCII case insensitive ctype. */
template<typename char_type>
class ascii_ctype : public std::ctype<char_type>
{
public:
- char_type do_toupper(char_type c) const anope_override
+ char_type do_toupper(char_type c) const override
{
if (c >= 'a' && c <= 'z')
return c - 32;
@@ -46,7 +38,7 @@ namespace Anope
return c;
}
- char_type do_tolower(char_type c) const anope_override
+ char_type do_tolower(char_type c) const override
{
if (c >= 'A' && c <= 'Z')
return c + 32;
@@ -60,7 +52,7 @@ namespace Anope
class rfc1459_ctype : public ascii_ctype<char_type>
{
public:
- char_type do_toupper(char_type c) const anope_override
+ char_type do_toupper(char_type c) const override
{
if (c == '{' || c == '}' || c == '|')
return c - 32;
@@ -68,7 +60,7 @@ namespace Anope
return ascii_ctype<char_type>::do_toupper(c);
}
- char_type do_tolower(char_type c) const anope_override
+ char_type do_tolower(char_type c) const override
{
if (c == '[' || c == ']' || c == '\\')
return c + 32;
@@ -195,5 +187,3 @@ inline bool operator!=(const std::string &leftval, const ci::string &rightval)
{
return !(leftval.c_str() == rightval);
}
-
-#endif // HASHCOMP_H
diff --git a/include/language.h b/include/language.h
index 0ac0ef0c9..ef568ad94 100644
--- a/include/language.h
+++ b/include/language.h
@@ -6,12 +6,14 @@
* Please read COPYING and README for further details.
*/
+#pragma once
+
#include "anope.h"
namespace Language
{
- /* Languages we support as configured in services.conf. They are
+ /* Languages we support as configured in anope.conf. They are
* added to this list if we detect a language exists in the correct
* location for each language.
*/
@@ -70,10 +72,11 @@ namespace Language
#define READ_ONLY_MODE _("Services are in read-only mode!")
#define PASSWORD_INCORRECT _("Password incorrect.")
#define ACCESS_DENIED _("Access denied.")
-#define MORE_OBSCURE_PASSWORD _("Please try again with a more obscure password. Passwords should be at least\n" \
- "five characters long, should not be something easily guessed\n" \
- "(e.g. your real name or your nick), and cannot contain the space or tab characters.")
-#define PASSWORD_TOO_LONG _("Your password is too long. It must not exceed %u characters.")
+#define MORE_OBSCURE_PASSWORD _("Please try again with a more obscure password. Passwords should not be\n" \
+ "something that could be easily guessed (e.g. your real name or your nick) and\n" \
+ "cannot contain the space or tab characters.\n")
+#define PASSWORD_TOO_SHORT _("Your password is too short. It must must be longer than %u characters.")
+#define PASSWORD_TOO_LONG _("Your password is too long. It must be shorter than %u characters.")
#define NICK_NOT_REGISTERED _("Your nick isn't registered.")
#define NICK_X_NOT_REGISTERED _("Nick \002%s\002 isn't registered.")
#define NICK_X_NOT_IN_USE _("Nick \002%s\002 isn't currently in use.")
diff --git a/include/lists.h b/include/lists.h
index 5f4605bc7..6e134d7ca 100644
--- a/include/lists.h
+++ b/include/lists.h
@@ -9,8 +9,7 @@
* Based on the original code of Services by Andy Church.
*/
-#ifndef LISTS_H
-#define LISTS_H
+#pragma once
#include "services.h"
#include "anope.h"
@@ -25,7 +24,7 @@
class CoreExport NumberList
{
private:
- bool is_valid;
+ bool is_valid = true;
std::set<unsigned> numbers;
@@ -39,7 +38,7 @@ class CoreExport NumberList
/** Destructor, does nothing
*/
- virtual ~NumberList();
+ virtual ~NumberList() = default;
/** Should be called after the constructors are done running. This calls the callbacks.
*/
@@ -83,12 +82,10 @@ class CoreExport InfoFormatter
{
NickCore *nc;
std::vector<std::pair<Anope::string, Anope::string> > replies;
- unsigned longest;
+ unsigned longest = 0;
public:
InfoFormatter(NickCore *nc);
void Process(std::vector<Anope::string> &);
Anope::string &operator[](const Anope::string &key);
void AddOption(const Anope::string &opt);
};
-
-#endif // LISTS_H
diff --git a/include/logger.h b/include/logger.h
index e82bca52d..c23b00666 100644
--- a/include/logger.h
+++ b/include/logger.h
@@ -9,8 +9,7 @@
* Based on the original code of Services by Andy Church.
*/
-#ifndef LOGGER_H
-#define LOGGER_H
+#pragma once
#include "anope.h"
#include "defs.h"
@@ -53,23 +52,23 @@ class CoreExport Log
{
public:
/* Bot that should log this message */
- BotInfo *bi;
+ BotInfo *bi = nullptr;
/* For commands, the user executing the command, but might not always exist */
- User *u;
+ User *u = nullptr;
/* For commands, the account executing the command, but will not always exist */
- NickCore *nc;
+ NickCore *nc = nullptr;
/* For commands, the command being executed */
- Command *c;
+ Command *c = nullptr;
/* For commands, the command source */
- CommandSource *source;
+ CommandSource *source = nullptr;
/* Used for LOG_CHANNEL */
- Channel *chan;
+ Channel *chan = nullptr;
/* For commands, the channel the command was executed on, will not always exist */
- const ChannelInfo *ci;
+ const ChannelInfo *ci = nullptr;
/* For LOG_SERVER */
- Server *s;
+ Server *s = nullptr;
/* For LOG_MODULE */
- Module *m;
+ Module *m = nullptr;
LogType type;
Anope::string category;
@@ -113,10 +112,10 @@ class CoreExport Log
class CoreExport LogInfo
{
public:
- BotInfo *bot;
+ BotInfo *bot = nullptr;
std::vector<Anope::string> targets;
std::vector<LogFile *> logfiles;
- int last_day;
+ int last_day = 0;
std::vector<Anope::string> sources;
int log_age;
std::vector<Anope::string> admin;
@@ -140,5 +139,3 @@ class CoreExport LogInfo
/* Logs the message l if configured to */
void ProcessMessage(const Log *l);
};
-
-#endif // LOGGER_H
diff --git a/include/mail.h b/include/mail.h
index 1e24183fe..e06357825 100644
--- a/include/mail.h
+++ b/include/mail.h
@@ -9,8 +9,7 @@
* Based on the original code of Services by Andy Church.
*/
-#ifndef MAIL_H
-#define MAIL_H
+#pragma once
#include "anope.h"
#include "threadengine.h"
@@ -35,7 +34,7 @@ namespace Mail
Anope::string content_type;
bool dont_quote_addresses;
- bool success;
+ bool success = false;
public:
/** Construct this message. Once constructed call Thread::Start to launch the mail sending.
* @param sf Config->SendFrom
@@ -49,9 +48,7 @@ namespace Mail
~Message();
/* Called from within the thread to actually send the mail */
- void Run() anope_override;
+ void Run() override;
};
} // namespace Mail
-
-#endif // MAIL_H
diff --git a/include/memo.h b/include/memo.h
index c6a1ec2d9..e97cc9da0 100644
--- a/include/memo.h
+++ b/include/memo.h
@@ -9,8 +9,7 @@
* Based on the original code of Services by Andy Church.
*/
-#ifndef MEMO_H
-#define MEMO_H
+#pragma once
#include "anope.h"
#include "serialize.h"
@@ -24,7 +23,7 @@ class CoreExport Memo : public Serializable
Memo();
~Memo();
- void Serialize(Serialize::Data &data) const anope_override;
+ void Serialize(Serialize::Data &data) const override;
static Serializable* Unserialize(Serializable *obj, Serialize::Data &);
Anope::string owner;
@@ -39,7 +38,7 @@ class CoreExport Memo : public Serializable
*/
struct CoreExport MemoInfo
{
- int16_t memomax;
+ int16_t memomax = 0;
Serialize::Checker<std::vector<Memo *> > memos;
std::vector<Anope::string> ignores;
@@ -51,5 +50,3 @@ struct CoreExport MemoInfo
static MemoInfo *GetMemoInfo(const Anope::string &targ, bool &is_chan);
};
-
-#endif // MEMO_H
diff --git a/include/messages.h b/include/messages.h
index 4efb74acb..85ce8effa 100644
--- a/include/messages.h
+++ b/include/messages.h
@@ -9,6 +9,8 @@
* Based on the original code of Services by Andy Church.
*/
+#pragma once
+
#include "protocol.h"
/* Common IRCD messages.
@@ -23,35 +25,35 @@ namespace Message
{
Away(Module *creator, const Anope::string &mname = "AWAY") : IRCDMessage(creator, mname, 0) { SetFlag(IRCDMESSAGE_REQUIRE_USER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override;
};
struct CoreExport Capab : IRCDMessage
{
Capab(Module *creator, const Anope::string &mname = "CAPAB") : IRCDMessage(creator, mname, 1) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override;
};
struct CoreExport Error : IRCDMessage
{
Error(Module *creator, const Anope::string &mname = "ERROR") : IRCDMessage(creator, mname, 1) { }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override;
};
struct CoreExport Invite : IRCDMessage
{
Invite(Module *creator, const Anope::string &mname = "INVITE") : IRCDMessage(creator, mname, 2) { SetFlag(IRCDMESSAGE_REQUIRE_USER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override;
};
struct CoreExport Join : IRCDMessage
{
Join(Module *creator, const Anope::string &mname = "JOIN") : IRCDMessage(creator, mname, 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override;
typedef std::pair<ChannelStatus, User *> SJoinUser;
@@ -69,105 +71,105 @@ namespace Message
{
Kick(Module *creator, const Anope::string &mname = "KICK") : IRCDMessage(creator, mname, 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override;
};
struct CoreExport Kill : IRCDMessage
{
Kill(Module *creator, const Anope::string &mname = "KILL") : IRCDMessage(creator, mname, 2) { }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override;
};
struct CoreExport Mode : IRCDMessage
{
Mode(Module *creator, const Anope::string &mname = "MODE") : IRCDMessage(creator, mname, 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override;
};
struct CoreExport MOTD : IRCDMessage
{
MOTD(Module *creator, const Anope::string &mname = "MOTD") : IRCDMessage(creator, mname, 1) { }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override;
};
struct CoreExport Notice : IRCDMessage
{
Notice(Module *creator, const Anope::string &mname = "NOTICE") : IRCDMessage(creator, mname, 2) { SetFlag(IRCDMESSAGE_REQUIRE_USER); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override;
};
struct CoreExport Part : IRCDMessage
{
Part(Module *creator, const Anope::string &mname = "PART") : IRCDMessage(creator, mname, 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override;
};
struct CoreExport Ping : IRCDMessage
{
Ping(Module *creator, const Anope::string &mname = "PING") : IRCDMessage(creator, mname, 1) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override;
};
struct CoreExport Privmsg : IRCDMessage
{
Privmsg(Module *creator, const Anope::string &mname = "PRIVMSG") : IRCDMessage(creator, mname, 2) { SetFlag(IRCDMESSAGE_REQUIRE_USER); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override;
};
struct CoreExport Quit : IRCDMessage
{
Quit(Module *creator, const Anope::string &mname = "QUIT") : IRCDMessage(creator, mname, 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override;
};
struct CoreExport SQuit : IRCDMessage
{
SQuit(Module *creator, const Anope::string &mname = "SQUIT") : IRCDMessage(creator, mname, 2) { }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override;
};
struct CoreExport Stats : IRCDMessage
{
Stats(Module *creator, const Anope::string &mname = "STATS") : IRCDMessage(creator, mname, 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override;
};
struct CoreExport Time : IRCDMessage
{
Time(Module *creator, const Anope::string &mname = "TIME") : IRCDMessage(creator, mname, 0) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override;
};
struct CoreExport Topic : IRCDMessage
{
Topic(Module *creator, const Anope::string &mname = "TOPIC") : IRCDMessage(creator, mname, 2) { SetFlag(IRCDMESSAGE_REQUIRE_USER); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override;
};
struct CoreExport Version : IRCDMessage
{
Version(Module *creator, const Anope::string &mname = "VERSION") : IRCDMessage(creator, mname, 0) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override;
};
struct CoreExport Whois : IRCDMessage
{
Whois(Module *creator, const Anope::string &mname = "WHOIS") : IRCDMessage(creator, mname, 1) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+ void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override;
};
} // namespace Message
diff --git a/include/modes.h b/include/modes.h
index 134fb04b2..3c34a6b31 100644
--- a/include/modes.h
+++ b/include/modes.h
@@ -6,8 +6,7 @@
* Please read COPYING and README for further details.
*/
-#ifndef MODES_H
-#define MODES_H
+#pragma once
#include "anope.h"
#include "base.h"
@@ -55,7 +54,7 @@ class CoreExport Mode : public Base
* @param type The mode type
*/
Mode(const Anope::string &mname, ModeClass mclass, char mc, ModeType type);
- virtual ~Mode();
+ virtual ~Mode() = default;
/** Can a user set this mode, used for mlock
* @param u The user
@@ -105,7 +104,7 @@ class CoreExport ChannelMode : public Mode
*/
ChannelMode(const Anope::string &name, char mc);
- bool CanSet(User *u) const anope_override;
+ bool CanSet(User *u) const override;
virtual void Check() { }
@@ -217,11 +216,11 @@ class CoreExport ChannelModeVirtual : public T
~ChannelModeVirtual();
- void Check() anope_override;
+ void Check() override;
- ChannelMode *Wrap(Anope::string &param) anope_override;
+ ChannelMode *Wrap(Anope::string &param) override;
- ChannelMode *Unwrap(ChannelMode *cm, Anope::string &param) anope_override = 0;
+ ChannelMode *Unwrap(ChannelMode *cm, Anope::string &param) override = 0;
};
/* The status a user has on a channel (+v, +h, +o) etc */
@@ -229,7 +228,7 @@ class CoreExport ChannelStatus
{
Anope::string modes;
public:
- ChannelStatus();
+ ChannelStatus() = default;
ChannelStatus(const Anope::string &modes);
void AddMode(char c);
void DelMode(char c);
@@ -245,7 +244,7 @@ class CoreExport UserModeOperOnly : public UserMode
public:
UserModeOperOnly(const Anope::string &mname, char um) : UserMode(mname, um) { }
- bool CanSet(User *u) const anope_override;
+ bool CanSet(User *u) const override;
};
class CoreExport UserModeNoone : public UserMode
@@ -253,7 +252,7 @@ class CoreExport UserModeNoone : public UserMode
public:
UserModeNoone(const Anope::string &mname, char um) : UserMode(mname, um) { }
- bool CanSet(User *u) const anope_override;
+ bool CanSet(User *u) const override;
};
/** Channel mode +k (key)
@@ -263,7 +262,7 @@ class CoreExport ChannelModeKey : public ChannelModeParam
public:
ChannelModeKey(char mc) : ChannelModeParam("KEY", mc) { }
- bool IsValid(Anope::string &value) const anope_override;
+ bool IsValid(Anope::string &value) const override;
};
/** This class is used for oper only channel modes
@@ -274,7 +273,7 @@ class CoreExport ChannelModeOperOnly : public ChannelMode
ChannelModeOperOnly(const Anope::string &mname, char mc) : ChannelMode(mname, mc) { }
/* Opers only */
- bool CanSet(User *u) const anope_override;
+ bool CanSet(User *u) const override;
};
/** This class is used for channel modes only servers may set
@@ -284,7 +283,7 @@ class CoreExport ChannelModeNoone : public ChannelMode
public:
ChannelModeNoone(const Anope::string &mname, char mc) : ChannelMode(mname, mc) { }
- bool CanSet(User *u) const anope_override;
+ bool CanSet(User *u) const override;
};
/** This is the mode manager
@@ -394,8 +393,8 @@ class CoreExport Entry
Anope::string name;
Anope::string mask;
public:
- unsigned short cidr_len;
- int family;
+ unsigned short cidr_len = 0;
+ int family = 0;
Anope::string nick, user, host, real;
/** Constructor
@@ -418,5 +417,3 @@ class CoreExport Entry
*/
bool Matches(User *u, bool full = false) const;
};
-
-#endif // MODES_H
diff --git a/include/module.h b/include/module.h
index b9a1e6a2f..d1c68cb7c 100644
--- a/include/module.h
+++ b/include/module.h
@@ -9,8 +9,7 @@
* Based on the original code of Services by Andy Church.
*/
-#ifndef MODULE_H
-#define MODULE_H
+#pragma once
#include "access.h"
#include "account.h"
@@ -50,5 +49,3 @@
#include "modules/pseudoclients/global.h"
#include "modules/pseudoclients/memoserv.h"
#include "modules/pseudoclients/nickserv.h"
-
-#endif // MODULE_H
diff --git a/include/modules.h b/include/modules.h
index 659804b1d..13030bca2 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -9,11 +9,10 @@
* Based on the original code of Services by Andy Church.
*/
-#include "serialize.h"
-#ifndef MODULES_H
-#define MODULES_H
+#pragma once
+#include "serialize.h"
#include "base.h"
#include "modes.h"
#include "timers.h"
@@ -25,32 +24,7 @@
* and functions needed to make a module loadable by the OS.
* It defines the class factory and external AnopeInit and AnopeFini functions.
*/
-#ifdef _WIN32
-# define MODULE_INIT(x) \
- extern "C" DllExport Module *AnopeInit(const Anope::string &, const Anope::string &); \
- extern "C" Module *AnopeInit(const Anope::string &modname, const Anope::string &creator) \
- { \
- return new x(modname, creator); \
- } \
- BOOLEAN WINAPI DllMain(HINSTANCE, DWORD, LPVOID) \
- { \
- return TRUE; \
- } \
- extern "C" DllExport void AnopeFini(x *); \
- extern "C" void AnopeFini(x *m) \
- { \
- delete m; \
- } \
- extern "C" DllExport ModuleVersionC AnopeVersion() \
- { \
- ModuleVersionC ver; \
- ver.version_major = VERSION_MAJOR; \
- ver.version_minor = VERSION_MINOR; \
- ver.version_patch = VERSION_PATCH; \
- return ver; \
- }
-#else
-# define MODULE_INIT(x) \
+#define MODULE_INIT(x) \
extern "C" DllExport Module *AnopeInit(const Anope::string &modname, const Anope::string &creator) \
{ \
return new x(modname, creator); \
@@ -67,7 +41,6 @@
ver.version_patch = VERSION_PATCH; \
return ver; \
}
-#endif
/**
* This #define allows us to call a method in all
@@ -322,7 +295,7 @@ class CoreExport Module : public Extensible
*/
virtual void OnUserKicked(const MessageSource &source, User *target, const Anope::string &channel, ChannelStatus &status, const Anope::string &kickmsg) { throw NotImplementedException(); }
- /** Called when Services' configuration is being (re)loaded.
+ /** Called when the configuration is being (re)loaded.
* @param conf The config that is being built now and will replace the global Config object
* @throws A ConfigException to abort the config (re)loading process.
*/
@@ -405,7 +378,6 @@ class CoreExport Module : public Extensible
* see src/encrypt.c for detailed informations
*/
virtual EventReturn OnEncrypt(const Anope::string &src, Anope::string &dest) { throw NotImplementedException(); }
- virtual EventReturn OnDecrypt(const Anope::string &hashm, const Anope::string &src, Anope::string &dest) { throw NotImplementedException(); }
/** Called on fantasy command
* @param source The source of the command
@@ -1235,5 +1207,3 @@ class CoreExport ModuleManager
*/
static ModuleVersion GetVersion(void *handle);
};
-
-#endif // MODULES_H
diff --git a/include/modules/bs_badwords.h b/include/modules/bs_badwords.h
index 9f9f017e1..ef773269f 100644
--- a/include/modules/bs_badwords.h
+++ b/include/modules/bs_badwords.h
@@ -9,6 +9,8 @@
* Based on the original code of Services by Andy Church.
*/
+#pragma once
+
/** Flags for badwords
*/
enum BadWordType
@@ -30,14 +32,14 @@ struct BadWord
Anope::string word;
BadWordType type;
- virtual ~BadWord() { }
+ virtual ~BadWord() = default;
protected:
- BadWord() { }
+ BadWord() = default;
};
struct BadWords
{
- virtual ~BadWords() { }
+ virtual ~BadWords() = default;
/** Add a badword to the badword list
* @param word The badword
diff --git a/include/modules/bs_kick.h b/include/modules/bs_kick.h
index 4108b0603..c296e9221 100644
--- a/include/modules/bs_kick.h
+++ b/include/modules/bs_kick.h
@@ -9,6 +9,8 @@
* Based on the original code of Services by Andy Church.
*/
+#pragma once
+
/* Indices for TTB (Times To Ban) */
enum
{
@@ -36,9 +38,9 @@ struct KickerData
bool dontkickops, dontkickvoices;
protected:
- KickerData() { }
+ KickerData() = default;
public:
- virtual ~KickerData() { }
+ virtual ~KickerData() = default;
virtual void Check(ChannelInfo *ci) = 0;
};
diff --git a/include/modules/cs_entrymsg.h b/include/modules/cs_entrymsg.h
index 89ffe39ff..e3586d5e9 100644
--- a/include/modules/cs_entrymsg.h
+++ b/include/modules/cs_entrymsg.h
@@ -6,6 +6,8 @@
* Please read COPYING and README for further details.
*/
+#pragma once
+
struct EntryMsg
{
Anope::string chan;
@@ -13,9 +15,9 @@ struct EntryMsg
Anope::string message;
time_t when;
- virtual ~EntryMsg() { }
+ virtual ~EntryMsg() = default;
protected:
- EntryMsg() { }
+ EntryMsg() = default;
};
struct EntryMessageList : Serialize::Checker<std::vector<EntryMsg *> >
diff --git a/include/modules/cs_log.h b/include/modules/cs_log.h
index ba2953e60..e283beabb 100644
--- a/include/modules/cs_log.h
+++ b/include/modules/cs_log.h
@@ -9,6 +9,8 @@
* Based on the original code of Services by Andy Church.
*/
+#pragma once
+
struct LogSetting
{
Anope::string chan;
@@ -22,9 +24,9 @@ struct LogSetting
Anope::string creator;
time_t created;
- virtual ~LogSetting() { }
+ virtual ~LogSetting() = default;
protected:
- LogSetting() { }
+ LogSetting() = default;
};
struct LogSettings : Serialize::Checker<std::vector<LogSetting *> >
@@ -37,6 +39,6 @@ struct LogSettings : Serialize::Checker<std::vector<LogSetting *> >
}
public:
- virtual ~LogSettings() { }
+ virtual ~LogSettings() = default;
virtual LogSetting *Create() = 0;
};
diff --git a/include/modules/cs_mode.h b/include/modules/cs_mode.h
index 3904d2f4d..e62042d04 100644
--- a/include/modules/cs_mode.h
+++ b/include/modules/cs_mode.h
@@ -9,6 +9,8 @@
* Based on the original code of Services by Andy Church.
*/
+#pragma once
+
struct ModeLock
{
Anope::string ci;
@@ -18,16 +20,16 @@ struct ModeLock
Anope::string setter;
time_t created;
- virtual ~ModeLock() { }
+ virtual ~ModeLock() = default;
protected:
- ModeLock() { }
+ ModeLock() = default;
};
struct ModeLocks
{
typedef std::vector<ModeLock *> ModeList;
- virtual ~ModeLocks() { }
+ virtual ~ModeLocks() = default;
/** Check if a mode is mlocked
* @param mode The mode
diff --git a/include/modules/dns.h b/include/modules/dns.h
index 5139f7e16..1c5941588 100644
--- a/include/modules/dns.h
+++ b/include/modules/dns.h
@@ -9,8 +9,7 @@
* Based on the original code of Services by Andy Church.
*/
-#ifndef DNS_H
-#define DNS_H
+#pragma once
namespace DNS
{
@@ -73,10 +72,10 @@ namespace DNS
struct Question
{
Anope::string name;
- QueryType type;
- unsigned short qclass;
+ QueryType type = QUERY_NONE;
+ unsigned short qclass = 0;
- Question() : type(QUERY_NONE), qclass(0) { }
+ Question() = default;
Question(const Anope::string &n, QueryType t, unsigned short c = 1) : name(n), type(t), qclass(c) { }
inline bool operator==(const Question & other) const { return name == other.name && type == other.type && qclass == other.qclass; }
@@ -91,12 +90,12 @@ namespace DNS
struct ResourceRecord : Question
{
- unsigned int ttl;
+ unsigned int ttl = 0;
Anope::string rdata;
time_t created;
- ResourceRecord(const Anope::string &n, QueryType t, unsigned short c = 1) : Question(n, t, c), ttl(0), created(Anope::CurTime) { }
- ResourceRecord(const Question &q) : Question(q), ttl(0), created(Anope::CurTime) { }
+ ResourceRecord(const Anope::string &n, QueryType t, unsigned short c = 1) : Question(n, t, c), created(Anope::CurTime) { }
+ ResourceRecord(const Question &q) : Question(q), created(Anope::CurTime) { }
};
struct Query
@@ -118,7 +117,7 @@ namespace DNS
{
public:
Manager(Module *creator) : Service(creator, "DNS::Manager", "dns/manager") { }
- virtual ~Manager() { }
+ virtual ~Manager() = default;
virtual void Process(Request *req) = 0;
virtual void RemoveRequest(Request *req) = 0;
@@ -139,12 +138,12 @@ namespace DNS
/* Use result cache if available */
bool use_cache;
/* Request id */
- unsigned short id;
+ unsigned short id = 0;
/* Creator of this request */
Module *creator;
Request(Manager *mgr, Module *c, const Anope::string &addr, QueryType qt, bool cache = false) : Timer(0), Question(addr, qt), manager(mgr),
- use_cache(cache), id(0), creator(c) { }
+ use_cache(cache), creator(c) { }
virtual ~Request()
{
@@ -164,7 +163,7 @@ namespace DNS
/** Used to time out the query, xalls OnError and lets the TimerManager
* delete this request.
*/
- void Tick(time_t) anope_override
+ void Tick(time_t) override
{
Log(LOG_DEBUG_2) << "Resolver: timeout for query " << this->name;
Query rr(*this);
@@ -174,5 +173,3 @@ namespace DNS
};
} // namespace DNS
-
-#endif // DNS_H
diff --git a/include/modules/encryption.h b/include/modules/encryption.h
index 68f92ce12..70bf6fb08 100644
--- a/include/modules/encryption.h
+++ b/include/modules/encryption.h
@@ -9,6 +9,8 @@
* Based on the original code of Services by Andy Church.
*/
+#pragma once
+
namespace Encryption
{
typedef std::pair<const unsigned char *, size_t> Hash;
@@ -17,7 +19,7 @@ namespace Encryption
class Context
{
public:
- virtual ~Context() { }
+ virtual ~Context() = default;
virtual void Update(const unsigned char *data, size_t len) = 0;
virtual void Finalize() = 0;
virtual Hash GetFinalizedHash() = 0;
@@ -27,7 +29,7 @@ namespace Encryption
{
public:
Provider(Module *creator, const Anope::string &sname) : Service(creator, "Encryption::Provider", sname) { }
- virtual ~Provider() { }
+ virtual ~Provider() = default;
virtual Context *CreateContext(IV * = NULL) = 0;
virtual IV GetDefaultIV() = 0;
diff --git a/include/modules/httpd.h b/include/modules/httpd.h
index 1637f9961..207499d3b 100644
--- a/include/modules/httpd.h
+++ b/include/modules/httpd.h
@@ -6,8 +6,7 @@
* Please read COPYING and README for further details.
*/
-#ifndef ANOPE_HTTPD_H
-#define ANOPE_HTTPD_H
+#pragma once
enum HTTPError
{
@@ -21,13 +20,14 @@ enum HTTPError
/* A message to someone */
struct HTTPReply
{
- HTTPError error;
+ HTTPError error = HTTP_ERROR_OK;
Anope::string content_type;
std::map<Anope::string, Anope::string, ci::less> headers;
typedef std::list<std::pair<Anope::string, Anope::string> > cookie;
std::vector<cookie> cookies;
- HTTPReply() : error(HTTP_ERROR_OK), length(0) { }
+ HTTPReply() = default;
+ HTTPReply& operator=(const HTTPReply &) = default;
HTTPReply(const HTTPReply& other) : error(other.error), length(other.length)
{
@@ -35,14 +35,14 @@ struct HTTPReply
headers = other.headers;
cookies = other.cookies;
- for (unsigned i = 0; i < other.out.size(); ++i)
- out.push_back(new Data(other.out[i]->buf, other.out[i]->len));
+ for (const auto &datum : other.out)
+ out.push_back(new Data(datum->buf, datum->len));
}
~HTTPReply()
{
- for (unsigned i = 0; i < out.size(); ++i)
- delete out[i];
+ for (const auto *datum : out)
+ delete datum;
out.clear();
}
@@ -65,7 +65,7 @@ struct HTTPReply
};
std::deque<Data *> out;
- size_t length;
+ size_t length = 0;
void Write(const Anope::string &message)
{
@@ -93,7 +93,7 @@ struct HTTPMessage
class HTTPClient;
class HTTPProvider;
-class HTTPPage : public Base
+class HTTPPage : public virtual Base
{
Anope::string url;
Anope::string content_type;
@@ -196,10 +196,8 @@ namespace HTTPUtils
{
Anope::string encoded;
- for (unsigned i = 0; i < url.length(); ++i)
+ for (const auto c : url)
{
- const char& c = url[i];
-
if (isalnum(c) || c == '.' || c == '-' || c == '*' || c == '_')
encoded += c;
else if (c == ' ')
@@ -215,9 +213,9 @@ namespace HTTPUtils
{
Anope::string dst;
- for (unsigned i = 0; i < src.length(); ++i)
+ for (const auto c : src)
{
- switch (src[i])
+ switch (c)
{
case '<':
dst += "&lt;";
@@ -232,12 +230,10 @@ namespace HTTPUtils
dst += "&amp;";
break;
default:
- dst += src[i];
+ dst += c;
}
}
return dst;
}
}
-
-#endif // ANOPE_HTTPD_H
diff --git a/include/modules/ldap.h b/include/modules/ldap.h
index 2f5382a0b..34f73f65b 100644
--- a/include/modules/ldap.h
+++ b/include/modules/ldap.h
@@ -6,15 +6,14 @@
* Please read COPYING and README for further details.
*/
-#ifndef ANOPE_LDAP_H
-#define ANOPE_LDAP_H
+#pragma once
class LDAPException : public ModuleException
{
public:
LDAPException(const Anope::string &reason) : ModuleException(reason) { }
- virtual ~LDAPException() throw() { }
+ virtual ~LDAPException() noexcept = default;
};
struct LDAPModification
@@ -43,8 +42,8 @@ struct LDAPAttributes : public std::map<Anope::string, std::vector<Anope::string
const std::vector<Anope::string> keys() const
{
std::vector<Anope::string> k;
- for (const_iterator it = this->begin(), it_end = this->end(); it != it_end; ++it)
- k.push_back(it->first);
+ for (const auto &[key, _] : *this)
+ k.push_back(key);
return k;
}
@@ -116,7 +115,7 @@ class LDAPInterface
Module *owner;
LDAPInterface(Module *m) : owner(m) { }
- virtual ~LDAPInterface() { }
+ virtual ~LDAPInterface() = default;
virtual void OnResult(const LDAPResult &r) = 0;
virtual void OnError(const LDAPResult &err) = 0;
@@ -167,5 +166,3 @@ class LDAPProvider : public Service
*/
virtual void Modify(LDAPInterface *i, const Anope::string &base, LDAPMods &attributes) = 0;
};
-
-#endif // ANOPE_LDAP_H
diff --git a/include/modules/ns_cert.h b/include/modules/ns_cert.h
index 946467520..824964ba8 100644
--- a/include/modules/ns_cert.h
+++ b/include/modules/ns_cert.h
@@ -9,12 +9,14 @@
* Based on the original code of Services by Andy Church.
*/
+#pragma once
+
struct NSCertList
{
protected:
- NSCertList() { }
+ NSCertList() = default;
public:
- virtual ~NSCertList() { }
+ virtual ~NSCertList() = default;
/** Add an entry to the nick's certificate list
*
diff --git a/include/modules/os_forbid.h b/include/modules/os_forbid.h
index eacf3425c..35dfc5c7f 100644
--- a/include/modules/os_forbid.h
+++ b/include/modules/os_forbid.h
@@ -6,8 +6,7 @@
* Please read COPYING and README for further details.
*/
-#ifndef OS_FORBID_H
-#define OS_FORBID_H
+#pragma once
enum ForbidType
{
@@ -23,13 +22,13 @@ struct ForbidData
Anope::string mask;
Anope::string creator;
Anope::string reason;
- time_t created;
- time_t expires;
+ time_t created = 0;
+ time_t expires = 0;
ForbidType type;
- virtual ~ForbidData() { }
+ virtual ~ForbidData() = default;
protected:
- ForbidData() : created(0), expires(0) { }
+ ForbidData() = default;
};
class ForbidService : public Service
@@ -51,5 +50,3 @@ class ForbidService : public Service
};
static ServiceReference<ForbidService> forbid_service("ForbidService", "forbid");
-
-#endif
diff --git a/include/modules/os_ignore.h b/include/modules/os_ignore.h
index 0d7ebc04d..14b71f9ac 100644
--- a/include/modules/os_ignore.h
+++ b/include/modules/os_ignore.h
@@ -9,16 +9,18 @@
* Based on the original code of Services by Andy Church.
*/
+#pragma once
+
struct IgnoreData
{
Anope::string mask;
Anope::string creator;
Anope::string reason;
- time_t time; /* When do we stop ignoring them? */
+ time_t time = 0; /* When do we stop ignoring them? */
- virtual ~IgnoreData() { }
+ virtual ~IgnoreData() = default;
protected:
- IgnoreData() : time(0) { }
+ IgnoreData() = default;
};
class IgnoreService : public Service
diff --git a/include/modules/os_news.h b/include/modules/os_news.h
index 06703939b..10228e82a 100644
--- a/include/modules/os_news.h
+++ b/include/modules/os_news.h
@@ -6,8 +6,7 @@
* Please read COPYING and README for further details.
*/
-#ifndef OS_NEWS
-#define OS_NEWS
+#pragma once
enum NewsType
{
@@ -48,5 +47,3 @@ class NewsService : public Service
};
static ServiceReference<NewsService> news_service("NewsService", "news");
-
-#endif // OS_NEWS
diff --git a/include/modules/os_session.h b/include/modules/os_session.h
index ce12f7758..eb8c2aaca 100644
--- a/include/modules/os_session.h
+++ b/include/modules/os_session.h
@@ -6,16 +6,15 @@
* Please read COPYING and README for further details.
*/
-#ifndef OS_SESSION_H
-#define OS_SESSION_H
+#pragma once
struct Session
{
cidr addr; /* A cidr (sockaddrs + len) representing this session */
- unsigned count; /* Number of clients with this host */
- unsigned hits; /* Number of subsequent kills for a host */
+ unsigned count = 1; /* Number of clients with this host */
+ unsigned hits = 0; /* Number of subsequent kills for a host */
- Session(const sockaddrs &ip, int len) : addr(ip, len), count(1), hits(0) { }
+ Session(const sockaddrs &ip, int len) : addr(ip, len) { }
};
struct Exception : Serializable
@@ -28,14 +27,14 @@ struct Exception : Serializable
time_t expires; /* Time when it expires. 0 == no expiry */
Exception() : Serializable("Exception") { }
- void Serialize(Serialize::Data &data) const anope_override;
+ void Serialize(Serialize::Data &data) const override;
static Serializable* Unserialize(Serializable *obj, Serialize::Data &data);
};
class SessionService : public Service
{
public:
- typedef TR1NS::unordered_map<cidr, Session *, cidr::hash> SessionMap;
+ typedef std::unordered_map<cidr, Session *, cidr::hash> SessionMap;
typedef std::vector<Exception *> ExceptionVector;
SessionService(Module *m) : Service(m, "SessionService", "session") { }
@@ -90,5 +89,3 @@ Serializable* Exception::Unserialize(Serializable *obj, Serialize::Data &data)
session_service->AddException(ex);
return ex;
}
-
-#endif
diff --git a/include/modules/pseudoclients/chanserv.h b/include/modules/pseudoclients/chanserv.h
index befd42fd8..013596ed9 100644
--- a/include/modules/pseudoclients/chanserv.h
+++ b/include/modules/pseudoclients/chanserv.h
@@ -6,8 +6,7 @@
* Please read COPYING and README for further details.
*/
-#ifndef CHANSERV_H
-#define CHANSERV_H
+#pragma once
class ChanServService : public Service
{
@@ -21,5 +20,3 @@ class ChanServService : public Service
*/
virtual void Hold(Channel *c) = 0;
};
-
-#endif // CHANSERV_H
diff --git a/include/modules/pseudoclients/global.h b/include/modules/pseudoclients/global.h
index 030f73f80..b27ad3562 100644
--- a/include/modules/pseudoclients/global.h
+++ b/include/modules/pseudoclients/global.h
@@ -6,8 +6,7 @@
* Please read COPYING and README for further details.
*/
-#ifndef GLOBAL_H
-#define GLOBAL_H
+#pragma once
class GlobalService : public Service
{
@@ -26,5 +25,3 @@ class GlobalService : public Service
*/
virtual void SendGlobal(BotInfo *sender, const Anope::string &source, const Anope::string &message) = 0;
};
-
-#endif // GLOBAL_H
diff --git a/include/modules/pseudoclients/memoserv.h b/include/modules/pseudoclients/memoserv.h
index 77c47692d..ea3fc964e 100644
--- a/include/modules/pseudoclients/memoserv.h
+++ b/include/modules/pseudoclients/memoserv.h
@@ -6,8 +6,7 @@
* Please read COPYING and README for further details.
*/
-#ifndef MEMOSERV_H
-#define MEMOSERV_H
+#pragma once
class MemoServService : public Service
{
@@ -37,5 +36,3 @@ class MemoServService : public Service
*/
virtual void Check(User *u) = 0;
};
-
-#endif // MEMOSERV_H
diff --git a/include/modules/pseudoclients/nickserv.h b/include/modules/pseudoclients/nickserv.h
index 9310cff1f..5207d7021 100644
--- a/include/modules/pseudoclients/nickserv.h
+++ b/include/modules/pseudoclients/nickserv.h
@@ -6,8 +6,7 @@
* Please read COPYING and README for further details.
*/
-#ifndef NICKSERV_H
-#define NICKSERV_H
+#pragma once
class NickServService : public Service
{
@@ -20,5 +19,3 @@ class NickServService : public Service
virtual void Collide(User *u, NickAlias *na) = 0;
virtual void Release(NickAlias *na) = 0;
};
-
-#endif // NICKSERV_H
diff --git a/include/modules/redis.h b/include/modules/redis.h
index 82ce5c0ad..f30311f34 100644
--- a/include/modules/redis.h
+++ b/include/modules/redis.h
@@ -6,6 +6,8 @@
* Please read COPYING and README for further details.
*/
+#pragma once
+
namespace Redis
{
struct Reply
@@ -30,8 +32,8 @@ namespace Redis
i = 0;
bulk.clear();
multi_bulk_size = 0;
- for (unsigned j = 0; j < multi_bulk.size(); ++j)
- delete multi_bulk[j];
+ for (const auto *reply : multi_bulk)
+ delete reply;
multi_bulk.clear();
}
@@ -47,7 +49,7 @@ namespace Redis
Module *owner;
Interface(Module *m) : owner(m) { }
- virtual ~Interface() { }
+ virtual ~Interface() = default;
virtual void OnResult(const Reply &r) = 0;
virtual void OnError(const Anope::string &error) { Log(owner) << error; }
diff --git a/include/modules/sasl.h b/include/modules/sasl.h
index c1d319f4c..f5482d31b 100644
--- a/include/modules/sasl.h
+++ b/include/modules/sasl.h
@@ -6,6 +6,8 @@
* Please read COPYING and README for further details.
*/
+#pragma once
+
namespace SASL
{
struct Message
@@ -82,7 +84,7 @@ namespace SASL
public:
IdentifyRequest(Module *m, const Anope::string &id, const Anope::string &acc, const Anope::string &pass, const Anope::string &h, const Anope::string &i) : ::IdentifyRequest(m, acc, pass), uid(id), hostname(h), ip(i) { }
- void OnSuccess() anope_override
+ void OnSuccess() override
{
if (!sasl)
return;
@@ -108,7 +110,7 @@ namespace SASL
}
}
- void OnFail() anope_override
+ void OnFail() override
{
if (!sasl)
return;
diff --git a/include/modules/set_misc.h b/include/modules/set_misc.h
index 453c77f02..892972d6d 100644
--- a/include/modules/set_misc.h
+++ b/include/modules/set_misc.h
@@ -6,12 +6,15 @@
* Please read COPYING and README for further details.
*/
+#pragma once
+
struct MiscData
{
Anope::string object;
Anope::string name;
Anope::string data;
- MiscData() { }
- virtual ~MiscData() { }
+ virtual ~MiscData() = default;
+ protected:
+ MiscData() = default;
};
diff --git a/include/modules/sql.h b/include/modules/sql.h
index 091e662cf..607f8bcd9 100644
--- a/include/modules/sql.h
+++ b/include/modules/sql.h
@@ -6,6 +6,8 @@
* Please read COPYING and README for further details.
*/
+#pragma once
+
namespace SQL
{
@@ -21,7 +23,7 @@ namespace SQL
Clear();
}
- std::iostream& operator[](const Anope::string &key) anope_override
+ std::iostream& operator[](const Anope::string &key) override
{
std::stringstream *&ss = data[key];
if (!ss)
@@ -29,44 +31,46 @@ namespace SQL
return *ss;
}
- std::set<Anope::string> KeySet() const anope_override
+ std::set<Anope::string> KeySet() const override
{
std::set<Anope::string> keys;
- for (Map::const_iterator it = this->data.begin(), it_end = this->data.end(); it != it_end; ++it)
- keys.insert(it->first);
+ for (const auto &[key, _] : this->data)
+ keys.insert(key);
return keys;
}
- size_t Hash() const anope_override
+ size_t Hash() const override
{
size_t hash = 0;
- for (Map::const_iterator it = this->data.begin(), it_end = this->data.end(); it != it_end; ++it)
- if (!it->second->str().empty())
- hash ^= Anope::hash_cs()(it->second->str());
+ for (const auto &[_, value] : this->data)
+ {
+ if (!value->str().empty())
+ hash ^= Anope::hash_cs()(value->str());
+ }
return hash;
}
std::map<Anope::string, std::iostream *> GetData() const
{
std::map<Anope::string, std::iostream *> d;
- for (Map::const_iterator it = this->data.begin(), it_end = this->data.end(); it != it_end; ++it)
- d[it->first] = it->second;
+ for (const auto &[key, value] : this->data)
+ d[key] = value;
return d;
}
void Clear()
{
- for (Map::const_iterator it = this->data.begin(), it_end = this->data.end(); it != it_end; ++it)
- delete it->second;
+ for (const auto &[_, value] : this->data)
+ delete value;
this->data.clear();
}
- void SetType(const Anope::string &key, Type t) anope_override
+ void SetType(const Anope::string &key, Type t) override
{
this->types[key] = t;
}
- Type GetType(const Anope::string &key) const anope_override
+ Type GetType(const Anope::string &key) const override
{
std::map<Anope::string, Type>::const_iterator it = this->types.find(key);
if (it != this->types.end())
@@ -82,7 +86,7 @@ namespace SQL
public:
Exception(const Anope::string &reason) : ModuleException(reason) { }
- virtual ~Exception() throw() { }
+ virtual ~Exception() noexcept = default;
};
/** A SQL query
@@ -141,10 +145,10 @@ namespace SQL
Query query;
Anope::string error;
public:
- unsigned int id;
+ unsigned int id = 0;
Anope::string finished_query;
- Result() : id(0) { }
+ Result() = default;
Result(unsigned int i, const Query &q, const Anope::string &fq, const Anope::string &err = "") : query(q), error(err), id(i), finished_query(fq) { }
inline operator bool() const { return this->error.empty(); }
@@ -187,7 +191,7 @@ namespace SQL
Module *owner;
Interface(Module *m) : owner(m) { }
- virtual ~Interface() { }
+ virtual ~Interface() = default;
virtual void OnResult(const Result &r) = 0;
virtual void OnError(const Result &r) = 0;
diff --git a/include/modules/ssl.h b/include/modules/ssl.h
index abbb867f7..4d1fa63e4 100644
--- a/include/modules/ssl.h
+++ b/include/modules/ssl.h
@@ -6,6 +6,8 @@
* Please read COPYING and README for further details.
*/
+#pragma once
+
class SSLService : public Service
{
public:
diff --git a/include/modules/suspend.h b/include/modules/suspend.h
index df44f56c7..a085e23e6 100644
--- a/include/modules/suspend.h
+++ b/include/modules/suspend.h
@@ -9,11 +9,13 @@
* Based on the original code of Services by Andy Church.
*/
+#pragma once
+
struct SuspendInfo
{
Anope::string what, by, reason;
time_t when, expires;
- SuspendInfo() { }
- virtual ~SuspendInfo() { }
+ SuspendInfo() = default;
+ virtual ~SuspendInfo() = default;
};
diff --git a/include/modules/xmlrpc.h b/include/modules/xmlrpc.h
index 1c324deab..81d8b3f7e 100644
--- a/include/modules/xmlrpc.h
+++ b/include/modules/xmlrpc.h
@@ -6,6 +6,8 @@
* Please read COPYING and README for further details.
*/
+#pragma once
+
#include "httpd.h"
class XMLRPCRequest
@@ -19,7 +21,7 @@ class XMLRPCRequest
HTTPReply& r;
XMLRPCRequest(HTTPReply &_r) : r(_r) { }
- inline void reply(const Anope::string &dname, const Anope::string &ddata) { this->replies.insert(std::make_pair(dname, ddata)); }
+ inline void reply(const Anope::string &dname, const Anope::string &ddata) { this->replies.emplace(dname, ddata); }
inline const std::map<Anope::string, Anope::string> &get_replies() { return this->replies; }
};
@@ -28,7 +30,7 @@ class XMLRPCServiceInterface;
class XMLRPCEvent
{
public:
- virtual ~XMLRPCEvent() { }
+ virtual ~XMLRPCEvent() = default;
virtual bool Run(XMLRPCServiceInterface *iface, HTTPClient *client, XMLRPCRequest &request) = 0;
};
diff --git a/include/opertype.h b/include/opertype.h
index 937915cb9..628180cbb 100644
--- a/include/opertype.h
+++ b/include/opertype.h
@@ -6,8 +6,7 @@
* Please read COPYING and README for further details.
*/
-#ifndef OPERTYPE_H
-#define OPERTYPE_H
+#pragma once
#include "services.h"
#include "account.h"
@@ -22,7 +21,7 @@ struct CoreExport Oper
/* The type of operator this operator is */
OperType *ot;
/* Whether the user must be an IRC operator (umode +o) to be considered a services operator */
- bool require_oper;
+ bool require_oper = true;
Anope::string password;
Anope::string certfp;
/* Hosts allowed to use this operator block */
@@ -123,5 +122,3 @@ class CoreExport OperType
*/
const std::list<Anope::string> GetPrivs() const;
};
-
-#endif // OPERTYPE_H
diff --git a/include/protocol.h b/include/protocol.h
index 874a5ff34..4f7990b51 100644
--- a/include/protocol.h
+++ b/include/protocol.h
@@ -9,8 +9,7 @@
* Based on the original code of Services by Andy Church.
*/
-#ifndef PROTOCOL_H
-#define PROTOCOL_H
+#pragma once
#include "services.h"
#include "anope.h"
@@ -61,10 +60,10 @@ class CoreExport IRCDProto : public Service
bool CanSZLine;
/* Can we place temporary holds on specific nicknames? */
bool CanSVSHold;
- /* See os_oline */
- bool CanSVSO;
/* See ns_cert */
bool CanCertFP;
+ /* Can we send arbitrary message tags? */
+ bool CanSendTags;
/* Whether this IRCd requires unique IDs for each user or server. See TS6/P10. */
bool RequiresID;
/* If this IRCd has unique ids, whether the IDs and nicknames are ambiguous */
@@ -180,10 +179,6 @@ class CoreExport IRCDProto : public Service
virtual void SendInvite(const MessageSource &source, const Channel *c, User *u);
virtual void SendGlobops(const MessageSource &source, const char *fmt, ...);
- /** Sets oper flags on a user, currently only supported by Unreal
- */
- virtual void SendSVSO(BotInfo *, const Anope::string &, const Anope::string &) { }
-
/** Sends a nick change of one of our clients.
*/
virtual void SendNickChange(User *u, const Anope::string &newnick);
@@ -230,7 +225,7 @@ class CoreExport IRCDProto : public Service
virtual void SendSASLMechanisms(std::vector<Anope::string> &) { }
virtual void SendSASLMessage(const SASL::Message &) { }
- virtual void SendSVSLogin(const Anope::string &uid, const Anope::string &acc, const Anope::string &vident, const Anope::string &vhost) { }
+ virtual void SendSVSLogin(const Anope::string &uid, NickAlias *na) { }
virtual bool IsNickValid(const Anope::string &);
virtual bool IsChannelValid(const Anope::string &);
@@ -250,8 +245,8 @@ class CoreExport IRCDProto : public Service
class CoreExport MessageSource
{
Anope::string source;
- User *u;
- Server *s;
+ User *u = nullptr;
+ Server *s = nullptr;
public:
MessageSource(const Anope::string &);
@@ -279,8 +274,7 @@ class CoreExport IRCDMessage : public Service
public:
IRCDMessage(Module *owner, const Anope::string &n, unsigned p = 0);
unsigned GetParamCount() const;
- virtual void Run(MessageSource &, const std::vector<Anope::string> &params) = 0;
- virtual void Run(MessageSource &, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags);
+ virtual void Run(MessageSource &, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) = 0;
void SetFlag(IRCDMessageFlag f) { flags.insert(f); }
bool HasFlag(IRCDMessageFlag f) const { return flags.count(f); }
@@ -294,7 +288,7 @@ private:
Anope::string message;
/** The current position within the message. */
- Anope::string::size_type position;
+ Anope::string::size_type position = 0;
public:
/** Create a tokenstream and fill it with the provided data. */
@@ -314,5 +308,3 @@ private:
};
extern CoreExport IRCDProto *IRCD;
-
-#endif // PROTOCOL_H
diff --git a/include/pstdint.h b/include/pstdint.h
deleted file mode 100644
index b034ae086..000000000
--- a/include/pstdint.h
+++ /dev/null
@@ -1,800 +0,0 @@
-/* A portable stdint.h
- ****************************************************************************
- * BSD License:
- ****************************************************************************
- *
- * Copyright (c) 2005-2011 Paul Hsieh
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- ****************************************************************************
- *
- * Version 0.1.12
- *
- * The ANSI C standard committee, for the C99 standard, specified the
- * inclusion of a new standard include file called stdint.h. This is
- * a very useful and long desired include file which contains several
- * very precise definitions for integer scalar types that is
- * critically important for making portable several classes of
- * applications including cryptography, hashing, variable length
- * integer libraries and so on. But for most developers its likely
- * useful just for programming sanity.
- *
- * The problem is that most compiler vendors have decided not to
- * implement the C99 standard, and the next C++ language standard
- * (which has a lot more mindshare these days) will be a long time in
- * coming and its unknown whether or not it will include stdint.h or
- * how much adoption it will have. Either way, it will be a long time
- * before all compilers come with a stdint.h and it also does nothing
- * for the extremely large number of compilers available today which
- * do not include this file, or anything comparable to it.
- *
- * So that's what this file is all about. Its an attempt to build a
- * single universal include file that works on as many platforms as
- * possible to deliver what stdint.h is supposed to. A few things
- * that should be noted about this file:
- *
- * 1) It is not guaranteed to be portable and/or present an identical
- * interface on all platforms. The extreme variability of the
- * ANSI C standard makes this an impossibility right from the
- * very get go. Its really only meant to be useful for the vast
- * majority of platforms that possess the capability of
- * implementing usefully and precisely defined, standard sized
- * integer scalars. Systems which are not intrinsically 2s
- * complement may produce invalid constants.
- *
- * 2) There is an unavoidable use of non-reserved symbols.
- *
- * 3) Other standard include files are invoked.
- *
- * 4) This file may come in conflict with future platforms that do
- * include stdint.h. The hope is that one or the other can be
- * used with no real difference.
- *
- * 5) In the current version, if your platform can't represent
- * int32_t, int16_t and int8_t, it just dumps out with a compiler
- * error.
- *
- * 6) 64 bit integers may or may not be defined. Test for their
- * presence with the test: #ifdef INT64_MAX or #ifdef UINT64_MAX.
- * Note that this is different from the C99 specification which
- * requires the existence of 64 bit support in the compiler. If
- * this is not defined for your platform, yet it is capable of
- * dealing with 64 bits then it is because this file has not yet
- * been extended to cover all of your system's capabilities.
- *
- * 7) (u)intptr_t may or may not be defined. Test for its presence
- * with the test: #ifdef PTRDIFF_MAX. If this is not defined
- * for your platform, then it is because this file has not yet
- * been extended to cover all of your system's capabilities, not
- * because its optional.
- *
- * 8) The following might not been defined even if your platform is
- * capable of defining it:
- *
- * WCHAR_MIN
- * WCHAR_MAX
- * (u)int64_t
- * PTRDIFF_MIN
- * PTRDIFF_MAX
- * (u)intptr_t
- *
- * 9) The following have not been defined:
- *
- * WINT_MIN
- * WINT_MAX
- *
- * 10) The criteria for defining (u)int_least(*)_t isn't clear,
- * except for systems which don't have a type that precisely
- * defined 8, 16, or 32 bit types (which this include file does
- * not support anyways). Default definitions have been given.
- *
- * 11) The criteria for defining (u)int_fast(*)_t isn't something I
- * would trust to any particular compiler vendor or the ANSI C
- * committee. It is well known that "compatible systems" are
- * commonly created that have very different performance
- * characteristics from the systems they are compatible with,
- * especially those whose vendors make both the compiler and the
- * system. Default definitions have been given, but its strongly
- * recommended that users never use these definitions for any
- * reason (they do *NOT* deliver any serious guarantee of
- * improved performance -- not in this file, nor any vendor's
- * stdint.h).
- *
- * 12) The following macros:
- *
- * PRINTF_INTMAX_MODIFIER
- * PRINTF_INT64_MODIFIER
- * PRINTF_INT32_MODIFIER
- * PRINTF_INT16_MODIFIER
- * PRINTF_LEAST64_MODIFIER
- * PRINTF_LEAST32_MODIFIER
- * PRINTF_LEAST16_MODIFIER
- * PRINTF_INTPTR_MODIFIER
- *
- * are strings which have been defined as the modifiers required
- * for the "d", "u" and "x" printf formats to correctly output
- * (u)intmax_t, (u)int64_t, (u)int32_t, (u)int16_t, (u)least64_t,
- * (u)least32_t, (u)least16_t and (u)intptr_t types respectively.
- * PRINTF_INTPTR_MODIFIER is not defined for some systems which
- * provide their own stdint.h. PRINTF_INT64_MODIFIER is not
- * defined if INT64_MAX is not defined. These are an extension
- * beyond what C99 specifies must be in stdint.h.
- *
- * In addition, the following macros are defined:
- *
- * PRINTF_INTMAX_HEX_WIDTH
- * PRINTF_INT64_HEX_WIDTH
- * PRINTF_INT32_HEX_WIDTH
- * PRINTF_INT16_HEX_WIDTH
- * PRINTF_INT8_HEX_WIDTH
- * PRINTF_INTMAX_DEC_WIDTH
- * PRINTF_INT64_DEC_WIDTH
- * PRINTF_INT32_DEC_WIDTH
- * PRINTF_INT16_DEC_WIDTH
- * PRINTF_INT8_DEC_WIDTH
- *
- * Which specifies the maximum number of characters required to
- * print the number of that type in either hexadecimal or decimal.
- * These are an extension beyond what C99 specifies must be in
- * stdint.h.
- *
- * Compilers tested (all with 0 warnings at their highest respective
- * settings): Borland Turbo C 2.0, WATCOM C/C++ 11.0 (16 bits and 32
- * bits), Microsoft Visual C++ 6.0 (32 bit), Microsoft Visual Studio
- * .net (VC7), Intel C++ 4.0, GNU gcc v3.3.3
- *
- * This file should be considered a work in progress. Suggestions for
- * improvements, especially those which increase coverage are strongly
- * encouraged.
- *
- * Acknowledgements
- *
- * The following people have made significant contributions to the
- * development and testing of this file:
- *
- * Chris Howie
- * John Steele Scott
- * Dave Thorup
- * John Dill
- *
- */
-
-#include <stddef.h>
-#include <limits.h>
-#include <signal.h>
-
-/*
- * For gcc with _STDINT_H, fill in the PRINTF_INT*_MODIFIER macros, and
- * do nothing else. On the Mac OS X version of gcc this is _STDINT_H_.
- */
-
-#if ((defined(__STDC__) && __STDC__ && __STDC_VERSION__ >= 199901L) || (defined (__WATCOMC__) && (defined (_STDINT_H_INCLUDED) || __WATCOMC__ >= 1250)) || (defined(__GNUC__) && (defined(_STDINT_H) || defined(_STDINT_H_) || defined (__UINT_FAST64_TYPE__)) )) && !defined (_PSTDINT_H_INCLUDED)
-#include <stdint.h>
-#define _PSTDINT_H_INCLUDED
-# ifndef PRINTF_INT64_MODIFIER
-# define PRINTF_INT64_MODIFIER "ll"
-# endif
-# ifndef PRINTF_INT32_MODIFIER
-# define PRINTF_INT32_MODIFIER "l"
-# endif
-# ifndef PRINTF_INT16_MODIFIER
-# define PRINTF_INT16_MODIFIER "h"
-# endif
-# ifndef PRINTF_INTMAX_MODIFIER
-# define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER
-# endif
-# ifndef PRINTF_INT64_HEX_WIDTH
-# define PRINTF_INT64_HEX_WIDTH "16"
-# endif
-# ifndef PRINTF_INT32_HEX_WIDTH
-# define PRINTF_INT32_HEX_WIDTH "8"
-# endif
-# ifndef PRINTF_INT16_HEX_WIDTH
-# define PRINTF_INT16_HEX_WIDTH "4"
-# endif
-# ifndef PRINTF_INT8_HEX_WIDTH
-# define PRINTF_INT8_HEX_WIDTH "2"
-# endif
-# ifndef PRINTF_INT64_DEC_WIDTH
-# define PRINTF_INT64_DEC_WIDTH "20"
-# endif
-# ifndef PRINTF_INT32_DEC_WIDTH
-# define PRINTF_INT32_DEC_WIDTH "10"
-# endif
-# ifndef PRINTF_INT16_DEC_WIDTH
-# define PRINTF_INT16_DEC_WIDTH "5"
-# endif
-# ifndef PRINTF_INT8_DEC_WIDTH
-# define PRINTF_INT8_DEC_WIDTH "3"
-# endif
-# ifndef PRINTF_INTMAX_HEX_WIDTH
-# define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT64_HEX_WIDTH
-# endif
-# ifndef PRINTF_INTMAX_DEC_WIDTH
-# define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT64_DEC_WIDTH
-# endif
-
-/*
- * Something really weird is going on with Open Watcom. Just pull some of
- * these duplicated definitions from Open Watcom's stdint.h file for now.
- */
-
-# if defined (__WATCOMC__) && __WATCOMC__ >= 1250
-# if !defined (INT64_C)
-# define INT64_C(x) (x + (INT64_MAX - INT64_MAX))
-# endif
-# if !defined (UINT64_C)
-# define UINT64_C(x) (x + (UINT64_MAX - UINT64_MAX))
-# endif
-# if !defined (INT32_C)
-# define INT32_C(x) (x + (INT32_MAX - INT32_MAX))
-# endif
-# if !defined (UINT32_C)
-# define UINT32_C(x) (x + (UINT32_MAX - UINT32_MAX))
-# endif
-# if !defined (INT16_C)
-# define INT16_C(x) (x)
-# endif
-# if !defined (UINT16_C)
-# define UINT16_C(x) (x)
-# endif
-# if !defined (INT8_C)
-# define INT8_C(x) (x)
-# endif
-# if !defined (UINT8_C)
-# define UINT8_C(x) (x)
-# endif
-# if !defined (UINT64_MAX)
-# define UINT64_MAX 18446744073709551615ULL
-# endif
-# if !defined (INT64_MAX)
-# define INT64_MAX 9223372036854775807LL
-# endif
-# if !defined (UINT32_MAX)
-# define UINT32_MAX 4294967295UL
-# endif
-# if !defined (INT32_MAX)
-# define INT32_MAX 2147483647L
-# endif
-# if !defined (INTMAX_MAX)
-# define INTMAX_MAX INT64_MAX
-# endif
-# if !defined (INTMAX_MIN)
-# define INTMAX_MIN INT64_MIN
-# endif
-# endif
-#endif
-
-#ifndef _PSTDINT_H_INCLUDED
-#define _PSTDINT_H_INCLUDED
-
-#ifndef SIZE_MAX
-# define SIZE_MAX (~(size_t)0)
-#endif
-
-/*
- * Deduce the type assignments from limits.h under the assumption that
- * integer sizes in bits are powers of 2, and follow the ANSI
- * definitions.
- */
-
-#ifndef UINT8_MAX
-# define UINT8_MAX 0xff
-#endif
-#ifndef uint8_t
-# if (UCHAR_MAX == UINT8_MAX) || defined (S_SPLINT_S)
- typedef unsigned char uint8_t;
-# define UINT8_C(v) ((uint8_t) v)
-# else
-# error "Platform not supported"
-# endif
-#endif
-
-#ifndef INT8_MAX
-# define INT8_MAX 0x7f
-#endif
-#ifndef INT8_MIN
-# define INT8_MIN INT8_C(0x80)
-#endif
-#ifndef int8_t
-# if (SCHAR_MAX == INT8_MAX) || defined (S_SPLINT_S)
- typedef signed char int8_t;
-# define INT8_C(v) ((int8_t) v)
-# else
-# error "Platform not supported"
-# endif
-#endif
-
-#ifndef UINT16_MAX
-# define UINT16_MAX 0xffff
-#endif
-#ifndef uint16_t
-#if (UINT_MAX == UINT16_MAX) || defined (S_SPLINT_S)
- typedef unsigned int uint16_t;
-# ifndef PRINTF_INT16_MODIFIER
-# define PRINTF_INT16_MODIFIER ""
-# endif
-# define UINT16_C(v) ((uint16_t) (v))
-#elif (USHRT_MAX == UINT16_MAX)
- typedef unsigned short uint16_t;
-# define UINT16_C(v) ((uint16_t) (v))
-# ifndef PRINTF_INT16_MODIFIER
-# define PRINTF_INT16_MODIFIER "h"
-# endif
-#else
-#error "Platform not supported"
-#endif
-#endif
-
-#ifndef INT16_MAX
-# define INT16_MAX 0x7fff
-#endif
-#ifndef INT16_MIN
-# define INT16_MIN INT16_C(0x8000)
-#endif
-#ifndef int16_t
-#if (INT_MAX == INT16_MAX) || defined (S_SPLINT_S)
- typedef signed int int16_t;
-# define INT16_C(v) ((int16_t) (v))
-# ifndef PRINTF_INT16_MODIFIER
-# define PRINTF_INT16_MODIFIER ""
-# endif
-#elif (SHRT_MAX == INT16_MAX)
- typedef signed short int16_t;
-# define INT16_C(v) ((int16_t) (v))
-# ifndef PRINTF_INT16_MODIFIER
-# define PRINTF_INT16_MODIFIER "h"
-# endif
-#else
-#error "Platform not supported"
-#endif
-#endif
-
-#ifndef UINT32_MAX
-# define UINT32_MAX (0xffffffffUL)
-#endif
-#ifndef uint32_t
-#if (ULONG_MAX == UINT32_MAX) || defined (S_SPLINT_S)
- typedef unsigned long uint32_t;
-# define UINT32_C(v) v ## UL
-# ifndef PRINTF_INT32_MODIFIER
-# define PRINTF_INT32_MODIFIER "l"
-# endif
-#elif (UINT_MAX == UINT32_MAX)
- typedef unsigned int uint32_t;
-# ifndef PRINTF_INT32_MODIFIER
-# define PRINTF_INT32_MODIFIER ""
-# endif
-# define UINT32_C(v) v ## U
-#elif (USHRT_MAX == UINT32_MAX)
- typedef unsigned short uint32_t;
-# define UINT32_C(v) ((unsigned short) (v))
-# ifndef PRINTF_INT32_MODIFIER
-# define PRINTF_INT32_MODIFIER ""
-# endif
-#else
-#error "Platform not supported"
-#endif
-#endif
-
-#ifndef INT32_MAX
-# define INT32_MAX (0x7fffffffL)
-#endif
-#ifndef INT32_MIN
-# define INT32_MIN INT32_C(0x80000000)
-#endif
-#ifndef int32_t
-#if (LONG_MAX == INT32_MAX) || defined (S_SPLINT_S)
- typedef signed long int32_t;
-# define INT32_C(v) v ## L
-# ifndef PRINTF_INT32_MODIFIER
-# define PRINTF_INT32_MODIFIER "l"
-# endif
-#elif (INT_MAX == INT32_MAX)
- typedef signed int int32_t;
-# define INT32_C(v) v
-# ifndef PRINTF_INT32_MODIFIER
-# define PRINTF_INT32_MODIFIER ""
-# endif
-#elif (SHRT_MAX == INT32_MAX)
- typedef signed short int32_t;
-# define INT32_C(v) ((short) (v))
-# ifndef PRINTF_INT32_MODIFIER
-# define PRINTF_INT32_MODIFIER ""
-# endif
-#else
-#error "Platform not supported"
-#endif
-#endif
-
-/*
- * The macro stdint_int64_defined is temporarily used to record
- * whether or not 64 integer support is available. It must be
- * defined for any 64 integer extensions for new platforms that are
- * added.
- */
-
-#undef stdint_int64_defined
-#if (defined(__STDC__) && defined(__STDC_VERSION__)) || defined (S_SPLINT_S)
-# if (__STDC__ && __STDC_VERSION__ >= 199901L) || defined (S_SPLINT_S)
-# define stdint_int64_defined
- typedef long long int64_t;
- typedef unsigned long long uint64_t;
-# define UINT64_C(v) v ## ULL
-# define INT64_C(v) v ## LL
-# ifndef PRINTF_INT64_MODIFIER
-# define PRINTF_INT64_MODIFIER "ll"
-# endif
-# endif
-#endif
-
-#if !defined (stdint_int64_defined)
-# if defined(__GNUC__)
-# define stdint_int64_defined
- __extension__ typedef long long int64_t;
- __extension__ typedef unsigned long long uint64_t;
-# define UINT64_C(v) v ## ULL
-# define INT64_C(v) v ## LL
-# ifndef PRINTF_INT64_MODIFIER
-# define PRINTF_INT64_MODIFIER "ll"
-# endif
-# elif defined(__MWERKS__) || defined (__SUNPRO_C) || defined (__SUNPRO_CC) || defined (__APPLE_CC__) || defined (_LONG_LONG) || defined (_CRAYC) || defined (S_SPLINT_S)
-# define stdint_int64_defined
- typedef long long int64_t;
- typedef unsigned long long uint64_t;
-# define UINT64_C(v) v ## ULL
-# define INT64_C(v) v ## LL
-# ifndef PRINTF_INT64_MODIFIER
-# define PRINTF_INT64_MODIFIER "ll"
-# endif
-# elif (defined(__WATCOMC__) && defined(__WATCOM_INT64__)) || (defined(_MSC_VER) && _INTEGRAL_MAX_BITS >= 64) || (defined (__BORLANDC__) && __BORLANDC__ > 0x460) || defined (__alpha) || defined (__DECC)
-# define stdint_int64_defined
- typedef __int64 int64_t;
- typedef unsigned __int64 uint64_t;
-# define UINT64_C(v) v ## UI64
-# define INT64_C(v) v ## I64
-# ifndef PRINTF_INT64_MODIFIER
-# define PRINTF_INT64_MODIFIER "I64"
-# endif
-# endif
-#endif
-
-#if !defined (LONG_LONG_MAX) && defined (INT64_C)
-# define LONG_LONG_MAX INT64_C (9223372036854775807)
-#endif
-#ifndef ULONG_LONG_MAX
-# define ULONG_LONG_MAX UINT64_C (18446744073709551615)
-#endif
-
-#if !defined (INT64_MAX) && defined (INT64_C)
-# define INT64_MAX INT64_C (9223372036854775807)
-#endif
-#if !defined (INT64_MIN) && defined (INT64_C)
-# define INT64_MIN INT64_C (-9223372036854775808)
-#endif
-#if !defined (UINT64_MAX) && defined (INT64_C)
-# define UINT64_MAX UINT64_C (18446744073709551615)
-#endif
-
-/*
- * Width of hexadecimal for number field.
- */
-
-#ifndef PRINTF_INT64_HEX_WIDTH
-# define PRINTF_INT64_HEX_WIDTH "16"
-#endif
-#ifndef PRINTF_INT32_HEX_WIDTH
-# define PRINTF_INT32_HEX_WIDTH "8"
-#endif
-#ifndef PRINTF_INT16_HEX_WIDTH
-# define PRINTF_INT16_HEX_WIDTH "4"
-#endif
-#ifndef PRINTF_INT8_HEX_WIDTH
-# define PRINTF_INT8_HEX_WIDTH "2"
-#endif
-
-#ifndef PRINTF_INT64_DEC_WIDTH
-# define PRINTF_INT64_DEC_WIDTH "20"
-#endif
-#ifndef PRINTF_INT32_DEC_WIDTH
-# define PRINTF_INT32_DEC_WIDTH "10"
-#endif
-#ifndef PRINTF_INT16_DEC_WIDTH
-# define PRINTF_INT16_DEC_WIDTH "5"
-#endif
-#ifndef PRINTF_INT8_DEC_WIDTH
-# define PRINTF_INT8_DEC_WIDTH "3"
-#endif
-
-/*
- * Ok, lets not worry about 128 bit integers for now. Moore's law says
- * we don't need to worry about that until about 2040 at which point
- * we'll have bigger things to worry about.
- */
-
-#ifdef stdint_int64_defined
- typedef int64_t intmax_t;
- typedef uint64_t uintmax_t;
-# define INTMAX_MAX INT64_MAX
-# define INTMAX_MIN INT64_MIN
-# define UINTMAX_MAX UINT64_MAX
-# define UINTMAX_C(v) UINT64_C(v)
-# define INTMAX_C(v) INT64_C(v)
-# ifndef PRINTF_INTMAX_MODIFIER
-# define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER
-# endif
-# ifndef PRINTF_INTMAX_HEX_WIDTH
-# define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT64_HEX_WIDTH
-# endif
-# ifndef PRINTF_INTMAX_DEC_WIDTH
-# define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT64_DEC_WIDTH
-# endif
-#else
- typedef int32_t intmax_t;
- typedef uint32_t uintmax_t;
-# define INTMAX_MAX INT32_MAX
-# define UINTMAX_MAX UINT32_MAX
-# define UINTMAX_C(v) UINT32_C(v)
-# define INTMAX_C(v) INT32_C(v)
-# ifndef PRINTF_INTMAX_MODIFIER
-# define PRINTF_INTMAX_MODIFIER PRINTF_INT32_MODIFIER
-# endif
-# ifndef PRINTF_INTMAX_HEX_WIDTH
-# define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT32_HEX_WIDTH
-# endif
-# ifndef PRINTF_INTMAX_DEC_WIDTH
-# define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT32_DEC_WIDTH
-# endif
-#endif
-
-/*
- * Because this file currently only supports platforms which have
- * precise powers of 2 as bit sizes for the default integers, the
- * least definitions are all trivial. Its possible that a future
- * version of this file could have different definitions.
- */
-
-#ifndef stdint_least_defined
- typedef int8_t int_least8_t;
- typedef uint8_t uint_least8_t;
- typedef int16_t int_least16_t;
- typedef uint16_t uint_least16_t;
- typedef int32_t int_least32_t;
- typedef uint32_t uint_least32_t;
-# define PRINTF_LEAST32_MODIFIER PRINTF_INT32_MODIFIER
-# define PRINTF_LEAST16_MODIFIER PRINTF_INT16_MODIFIER
-# define UINT_LEAST8_MAX UINT8_MAX
-# define INT_LEAST8_MAX INT8_MAX
-# define UINT_LEAST16_MAX UINT16_MAX
-# define INT_LEAST16_MAX INT16_MAX
-# define UINT_LEAST32_MAX UINT32_MAX
-# define INT_LEAST32_MAX INT32_MAX
-# define INT_LEAST8_MIN INT8_MIN
-# define INT_LEAST16_MIN INT16_MIN
-# define INT_LEAST32_MIN INT32_MIN
-# ifdef stdint_int64_defined
- typedef int64_t int_least64_t;
- typedef uint64_t uint_least64_t;
-# define PRINTF_LEAST64_MODIFIER PRINTF_INT64_MODIFIER
-# define UINT_LEAST64_MAX UINT64_MAX
-# define INT_LEAST64_MAX INT64_MAX
-# define INT_LEAST64_MIN INT64_MIN
-# endif
-#endif
-#undef stdint_least_defined
-
-/*
- * The ANSI C committee pretending to know or specify anything about
- * performance is the epitome of misguided arrogance. The mandate of
- * this file is to *ONLY* ever support that absolute minimum
- * definition of the fast integer types, for compatibility purposes.
- * No extensions, and no attempt to suggest what may or may not be a
- * faster integer type will ever be made in this file. Developers are
- * warned to stay away from these types when using this or any other
- * stdint.h.
- */
-
-typedef int_least8_t int_fast8_t;
-typedef uint_least8_t uint_fast8_t;
-typedef int_least16_t int_fast16_t;
-typedef uint_least16_t uint_fast16_t;
-typedef int_least32_t int_fast32_t;
-typedef uint_least32_t uint_fast32_t;
-#define UINT_FAST8_MAX UINT_LEAST8_MAX
-#define INT_FAST8_MAX INT_LEAST8_MAX
-#define UINT_FAST16_MAX UINT_LEAST16_MAX
-#define INT_FAST16_MAX INT_LEAST16_MAX
-#define UINT_FAST32_MAX UINT_LEAST32_MAX
-#define INT_FAST32_MAX INT_LEAST32_MAX
-#define INT_FAST8_MIN INT_LEAST8_MIN
-#define INT_FAST16_MIN INT_LEAST16_MIN
-#define INT_FAST32_MIN INT_LEAST32_MIN
-#ifdef stdint_int64_defined
- typedef int_least64_t int_fast64_t;
- typedef uint_least64_t uint_fast64_t;
-# define UINT_FAST64_MAX UINT_LEAST64_MAX
-# define INT_FAST64_MAX INT_LEAST64_MAX
-# define INT_FAST64_MIN INT_LEAST64_MIN
-#endif
-
-#undef stdint_int64_defined
-
-/*
- * Whatever piecemeal, per compiler thing we can do about the wchar_t
- * type limits.
- */
-
-#if defined(__WATCOMC__) || defined(_MSC_VER) || defined (__GNUC__)
-# include <wchar.h>
-# ifndef WCHAR_MIN
-# define WCHAR_MIN 0
-# endif
-# ifndef WCHAR_MAX
-# define WCHAR_MAX ((wchar_t)-1)
-# endif
-#endif
-
-/*
- * Whatever piecemeal, per compiler/platform thing we can do about the
- * (u)intptr_t types and limits.
- */
-
-#if defined (_MSC_VER) && defined (_UINTPTR_T_DEFINED)
-# define STDINT_H_UINTPTR_T_DEFINED
-#endif
-
-#ifndef STDINT_H_UINTPTR_T_DEFINED
-# if defined (__alpha__) || defined (__ia64__) || defined (__x86_64__) || defined (_WIN64)
-# define stdint_intptr_bits 64
-# elif defined (__WATCOMC__) || defined (__TURBOC__)
-# if defined(__TINY__) || defined(__SMALL__) || defined(__MEDIUM__)
-# define stdint_intptr_bits 16
-# else
-# define stdint_intptr_bits 32
-# endif
-# elif defined (__i386__) || defined (_WIN32) || defined (WIN32)
-# define stdint_intptr_bits 32
-# elif defined (__INTEL_COMPILER)
-/* TODO -- what did Intel do about x86-64? */
-# endif
-
-# ifdef stdint_intptr_bits
-# define stdint_intptr_glue3_i(a,b,c) a##b##c
-# define stdint_intptr_glue3(a,b,c) stdint_intptr_glue3_i(a,b,c)
-# ifndef PRINTF_INTPTR_MODIFIER
-# define PRINTF_INTPTR_MODIFIER stdint_intptr_glue3(PRINTF_INT,stdint_intptr_bits,_MODIFIER)
-# endif
-# ifndef PTRDIFF_MAX
-# define PTRDIFF_MAX stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX)
-# endif
-# ifndef PTRDIFF_MIN
-# define PTRDIFF_MIN stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN)
-# endif
-# ifndef UINTPTR_MAX
-# define UINTPTR_MAX stdint_intptr_glue3(UINT,stdint_intptr_bits,_MAX)
-# endif
-# ifndef INTPTR_MAX
-# define INTPTR_MAX stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX)
-# endif
-# ifndef INTPTR_MIN
-# define INTPTR_MIN stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN)
-# endif
-# ifndef INTPTR_C
-# define INTPTR_C(x) stdint_intptr_glue3(INT,stdint_intptr_bits,_C)(x)
-# endif
-# ifndef UINTPTR_C
-# define UINTPTR_C(x) stdint_intptr_glue3(UINT,stdint_intptr_bits,_C)(x)
-# endif
- typedef stdint_intptr_glue3(uint,stdint_intptr_bits,_t) uintptr_t;
- typedef stdint_intptr_glue3( int,stdint_intptr_bits,_t) intptr_t;
-# else
-/* TODO -- This following is likely wrong for some platforms, and does
- nothing for the definition of uintptr_t. */
- typedef ptrdiff_t intptr_t;
-# endif
-# define STDINT_H_UINTPTR_T_DEFINED
-#endif
-
-/*
- * Assumes sig_atomic_t is signed and we have a 2s complement machine.
- */
-
-#ifndef SIG_ATOMIC_MAX
-# define SIG_ATOMIC_MAX ((((sig_atomic_t) 1) << (sizeof (sig_atomic_t)*CHAR_BIT-1)) - 1)
-#endif
-
-#endif
-
-#if defined (__TEST_PSTDINT_FOR_CORRECTNESS)
-
-/*
- * Please compile with the maximum warning settings to make sure macros are not
- * defined more than once.
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#define glue3_aux(x,y,z) x ## y ## z
-#define glue3(x,y,z) glue3_aux(x,y,z)
-
-#define DECLU(bits) glue3(uint,bits,_t) glue3(u,bits,=) glue3(UINT,bits,_C) (0);
-#define DECLI(bits) glue3(int,bits,_t) glue3(i,bits,=) glue3(INT,bits,_C) (0);
-
-#define DECL(us,bits) glue3(DECL,us,) (bits)
-
-#define TESTUMAX(bits) glue3(u,bits,=) glue3(~,u,bits); if (glue3(UINT,bits,_MAX) glue3(!=,u,bits)) printf ("Something wrong with UINT%d_MAX\n", bits)
-
-int main () {
- DECL(I,8)
- DECL(U,8)
- DECL(I,16)
- DECL(U,16)
- DECL(I,32)
- DECL(U,32)
-#ifdef INT64_MAX
- DECL(I,64)
- DECL(U,64)
-#endif
- intmax_t imax = INTMAX_C(0);
- uintmax_t umax = UINTMAX_C(0);
- char str0[256], str1[256];
-
- sprintf (str0, "%d %x\n", 0, ~0);
-
- sprintf (str1, "%d %x\n", i8, ~0);
- if (0 != strcmp (str0, str1)) printf ("Something wrong with i8 : %s\n", str1);
- sprintf (str1, "%u %x\n", u8, ~0);
- if (0 != strcmp (str0, str1)) printf ("Something wrong with u8 : %s\n", str1);
- sprintf (str1, "%d %x\n", i16, ~0);
- if (0 != strcmp (str0, str1)) printf ("Something wrong with i16 : %s\n", str1);
- sprintf (str1, "%u %x\n", u16, ~0);
- if (0 != strcmp (str0, str1)) printf ("Something wrong with u16 : %s\n", str1);
- sprintf (str1, "%" PRINTF_INT32_MODIFIER "d %x\n", i32, ~0);
- if (0 != strcmp (str0, str1)) printf ("Something wrong with i32 : %s\n", str1);
- sprintf (str1, "%" PRINTF_INT32_MODIFIER "u %x\n", u32, ~0);
- if (0 != strcmp (str0, str1)) printf ("Something wrong with u32 : %s\n", str1);
-#ifdef INT64_MAX
- sprintf (str1, "%" PRINTF_INT64_MODIFIER "d %x\n", i64, ~0);
- if (0 != strcmp (str0, str1)) printf ("Something wrong with i64 : %s\n", str1);
-#endif
- sprintf (str1, "%" PRINTF_INTMAX_MODIFIER "d %x\n", imax, ~0);
- if (0 != strcmp (str0, str1)) printf ("Something wrong with imax : %s\n", str1);
- sprintf (str1, "%" PRINTF_INTMAX_MODIFIER "u %x\n", umax, ~0);
- if (0 != strcmp (str0, str1)) printf ("Something wrong with umax : %s\n", str1);
-
- TESTUMAX(8);
- TESTUMAX(16);
- TESTUMAX(32);
-#ifdef INT64_MAX
- TESTUMAX(64);
-#endif
-
- return EXIT_SUCCESS;
-}
-
-#endif
diff --git a/include/regchannel.h b/include/regchannel.h
index d05d8c376..ef49d0913 100644
--- a/include/regchannel.h
+++ b/include/regchannel.h
@@ -6,8 +6,7 @@
* Please read COPYING and README for further details.
*/
-#ifndef REGCHANNEL_H
-#define REGCHANNEL_H
+#pragma once
#include "memo.h"
#include "modes.h"
@@ -38,7 +37,7 @@ class CoreExport AutoKick : public Serializable
AutoKick();
~AutoKick();
- void Serialize(Serialize::Data &data) const anope_override;
+ void Serialize(Serialize::Data &data) const override;
static Serializable* Unserialize(Serializable *obj, Serialize::Data &);
};
@@ -93,8 +92,9 @@ class CoreExport ChannelInfo : public Serializable, public Extensible
ChannelInfo(const ChannelInfo &ci);
~ChannelInfo();
+ ChannelInfo& operator=(const ChannelInfo &) = default;
- void Serialize(Serialize::Data &data) const anope_override;
+ void Serialize(Serialize::Data &data) const override;
static Serializable* Unserialize(Serializable *obj, Serialize::Data &);
/** Change the founder of the channel
@@ -248,5 +248,3 @@ class CoreExport ChannelInfo : public Serializable, public Extensible
* @return true or false
*/
extern CoreExport bool IsFounder(const User *user, const ChannelInfo *ci);
-
-#endif // REGCHANNEL_H
diff --git a/include/regexpr.h b/include/regexpr.h
index b42094597..7ddfa9a55 100644
--- a/include/regexpr.h
+++ b/include/regexpr.h
@@ -9,8 +9,7 @@
* Based on the original code of Services by Andy Church.
*/
-#ifndef REGEXPR_H
-#define REGEXPR_H
+#pragma once
#include "services.h"
#include "anope.h"
@@ -21,7 +20,7 @@ class RegexException : public CoreException
public:
RegexException(const Anope::string &reason = "") : CoreException(reason) { }
- virtual ~RegexException() throw() { }
+ virtual ~RegexException() noexcept = default;
};
class CoreExport Regex
@@ -30,7 +29,7 @@ class CoreExport Regex
protected:
Regex(const Anope::string &expr) : expression(expr) { }
public:
- virtual ~Regex() { }
+ virtual ~Regex() = default;
const Anope::string &GetExpression() { return expression; }
virtual bool Matches(const Anope::string &str) = 0;
};
@@ -41,5 +40,3 @@ class CoreExport RegexProvider : public Service
RegexProvider(Module *o, const Anope::string &n) : Service(o, "Regex", n) { }
virtual Regex *Compile(const Anope::string &) = 0;
};
-
-#endif // REGEXPR_H
diff --git a/include/serialize.h b/include/serialize.h
index ca095541c..1cb4bdce5 100644
--- a/include/serialize.h
+++ b/include/serialize.h
@@ -9,8 +9,7 @@
* Based on the original code of Services by Andy Church.
*/
-#ifndef SERIALIZE_H
-#define SERIALIZE_H
+#pragma once
#include <sstream>
@@ -28,7 +27,7 @@ namespace Serialize
DT_INT
};
- virtual ~Data() { }
+ virtual ~Data() = default;
virtual std::iostream& operator[](const Anope::string &key) = 0;
virtual std::set<Anope::string> KeySet() const { throw CoreException("Not supported"); }
@@ -65,9 +64,9 @@ class CoreExport Serializable : public virtual Base
/* Iterator into serializable_items */
std::list<Serializable *>::iterator s_iter;
/* The hash of the last serialized form of this object committed to the database */
- size_t last_commit;
+ size_t last_commit = 0;
/* The last time this object was committed to the database */
- time_t last_commit_time;
+ time_t last_commit_time = 0;
protected:
Serializable(const Anope::string &serialize_type);
@@ -79,10 +78,10 @@ class CoreExport Serializable : public virtual Base
virtual ~Serializable();
/* Unique ID (per type, not globally) for this object */
- uint64_t id;
+ uint64_t id = 0;
/* Only used by redis, to ignore updates */
- unsigned short redis_ignore;
+ unsigned short redis_ignore = 0;
/** Marks the object as potentially being updated "soon".
*/
@@ -127,7 +126,7 @@ class CoreExport Serialize::Type : public Base
* this timestamp. if curtime == timestamp then we have the most up to date
* version of every object of this type.
*/
- time_t timestamp;
+ time_t timestamp = 0;
public:
/* Map of Serializable::id to Serializable objects */
@@ -187,7 +186,7 @@ class Serialize::Checker
{
Anope::string name;
T obj;
- mutable ::Reference<Serialize::Type> type;
+ mutable ::Reference<Serialize::Type> type = nullptr;
inline void Check() const
{
@@ -198,7 +197,7 @@ class Serialize::Checker
}
public:
- Checker(const Anope::string &n) : name(n), type(NULL) { }
+ Checker(const Anope::string &n) : name(n) { }
inline const T* operator->() const
{
@@ -244,12 +243,10 @@ template<typename T>
class Serialize::Reference : public ReferenceBase
{
protected:
- T *ref;
+ T *ref = nullptr;
public:
- Reference() : ref(NULL)
- {
- }
+ Reference() = default;
Reference(T *obj) : ref(obj)
{
@@ -331,5 +328,3 @@ class Serialize::Reference : public ReferenceBase
return NULL;
}
};
-
-#endif // SERIALIZE_H
diff --git a/include/servers.h b/include/servers.h
index 937e31163..442b54f25 100644
--- a/include/servers.h
+++ b/include/servers.h
@@ -9,8 +9,7 @@
* Based on the original code of Services by Andy Church.
*/
-#ifndef SERVERS_H
-#define SERVERS_H
+#pragma once
#include "services.h"
#include "anope.h"
@@ -80,7 +79,7 @@ class CoreExport Server : public Extensible
public:
/* Number of users on the server */
- unsigned users;
+ unsigned users = 0;
/** Delete this server with a reason
* @param reason The reason
@@ -183,5 +182,3 @@ class CoreExport Server : public Extensible
*/
static Server *Find(const Anope::string &name, bool name_only = false);
};
-
-#endif // SERVERS_H
diff --git a/include/service.h b/include/service.h
index c5c5a5881..fd4163675 100644
--- a/include/service.h
+++ b/include/service.h
@@ -9,8 +9,7 @@
* Based on the original code of Services by Andy Church.
*/
-#ifndef SERVICE_H
-#define SERVICE_H
+#pragma once
#include "services.h"
#include "anope.h"
@@ -113,7 +112,7 @@ class CoreExport Service : public virtual Base
}
};
-/** Like Reference, but used to refer to Services.
+/** Like Reference, but used to refer to a Service.
*/
template<typename T>
class ServiceReference : public Reference<T>
@@ -122,7 +121,7 @@ class ServiceReference : public Reference<T>
Anope::string name;
public:
- ServiceReference() { }
+ ServiceReference() = default;
ServiceReference(const Anope::string &t, const Anope::string &n) : type(t), name(n)
{
@@ -138,7 +137,7 @@ class ServiceReference : public Reference<T>
this->invalid = true;
}
- operator bool() anope_override
+ operator bool() override
{
if (this->invalid)
{
@@ -173,5 +172,3 @@ class ServiceAlias
Service::DelAlias(t, f);
}
};
-
-#endif // SERVICE_H
diff --git a/include/services.h b/include/services.h
index 7e3fb2124..1af714563 100644
--- a/include/services.h
+++ b/include/services.h
@@ -9,8 +9,7 @@
* Based on the original code of Services by Andy Church.
*/
-#ifndef SERVICES_H
-#define SERVICES_H
+#pragma once
#include "sysconf.h"
@@ -21,16 +20,15 @@
#include <cstdarg>
#include <stdexcept>
-#include <string.h>
-#if HAVE_STRINGS_H
-# include <strings.h>
-#endif
+#include <cstring>
#ifndef _WIN32
#include <unistd.h>
#endif
/* Pull in the various bits of STL */
+#include <cstdint>
+#include <cstddef>
#include <iostream>
#include <fstream>
#include <sstream>
@@ -48,21 +46,10 @@
#define _(x) x
-#if defined __GXX_EXPERIMENTAL_CXX0X__ || __cplusplus >= 201103L
-# define anope_override override
-# define anope_final final
-#else
-# define anope_override
-# define anope_final
-#endif
-
#ifndef _WIN32
-# define DllExport
-# define CoreExport
-# define MARK_DEPRECATED __attribute((deprecated))
+# define DllExport __attribute__ ((visibility ("default")))
+# define CoreExport __attribute__ ((visibility ("default")))
# define anope_close close
#else
# include "anope_windows.h"
#endif
-
-#endif // SERVICES_H
diff --git a/include/socketengine.h b/include/socketengine.h
index 670115e36..6084aa522 100644
--- a/include/socketengine.h
+++ b/include/socketengine.h
@@ -9,8 +9,7 @@
* Based on the original code of Services by Andy Church.
*/
-#ifndef SOCKETENGINE_H
-#define SOCKETENGINE_H
+#pragma once
#include "services.h"
#include "sockets.h"
@@ -46,5 +45,3 @@ class CoreExport SocketEngine
static bool IgnoreErrno();
};
-
-#endif // SOCKETENGINE_H
diff --git a/include/sockets.h b/include/sockets.h
index d2b0f26f0..63df8c7b3 100644
--- a/include/sockets.h
+++ b/include/sockets.h
@@ -9,17 +9,22 @@
* Based on the original code of Services by Andy Church.
*/
-#ifndef SOCKETS_H
-#define SOCKETS_H
+#pragma once
#ifndef _WIN32
#include <netinet/in.h>
#include <sys/types.h>
#include <sys/socket.h>
+#include <sys/un.h>
#endif
#include "anope.h"
+// This has to be after anope.h
+#ifdef _WIN32
+# include <afunix.h>
+#endif
+
#define NET_BUFSIZE 65535
/** A sockaddr union used to combine IPv4 and IPv6 sockaddrs
@@ -29,6 +34,7 @@ union CoreExport sockaddrs
sockaddr sa;
sockaddr_in sa4;
sockaddr_in6 sa6;
+ sockaddr_un saun;
/** Construct the object, sets everything to 0
*/
@@ -57,6 +63,11 @@ union CoreExport sockaddrs
*/
Anope::string addr() const;
+ /** Gets the endpoint represented by this addr.
+ * @return The endpoint.
+ */
+ Anope::string str() const;
+
/** Get the reverse address represented by this addr
* @return The reverse address
*/
@@ -126,7 +137,7 @@ class SocketException : public CoreException
/** Destructor
* @throws Nothing
*/
- virtual ~SocketException() throw() { }
+ virtual ~SocketException() noexcept = default;
};
enum SocketFlag
@@ -144,7 +155,7 @@ enum SocketFlag
class CoreExport SocketIO
{
public:
- virtual ~SocketIO() { }
+ virtual ~SocketIO() = default;
/** Receive something from the buffer
* @param s The socket
@@ -204,8 +215,9 @@ class CoreExport Socket
protected:
/* Socket FD */
int sock;
- /* Is this an IPv6 socket? */
- bool ipv6;
+
+ /* The family of this socket FD */
+ int family;
public:
std::bitset<SF_SIZE> flags;
@@ -222,25 +234,25 @@ class CoreExport Socket
/** Constructor, possibly creates the socket and adds it to the engine
* @param sock The socket to use, -1 if we need to create our own
- * @param ipv6 true if using ipv6
+ * @param family The family of the socket
* @param type The socket type, defaults to SOCK_STREAM
*/
- Socket(int sock, bool ipv6 = false, int type = SOCK_STREAM);
+ Socket(int sock, int family = AF_INET, int type = SOCK_STREAM);
/** Destructor, closes the socket and removes it from the engine
*/
virtual ~Socket();
+ /** Get the socket family for this socket
+ * @return the family
+ */
+ int GetFamily() const;
+
/** Get the socket FD for this socket
* @return the fd
*/
int GetFD() const;
- /** Check if this socket is IPv6
- * @return true or false
- */
- bool IsIPv6() const;
-
/** Mark a socket as (non)blocking
* @param state true to enable blocking, false to disable blocking
* @return true if the socket is now blocking
@@ -285,18 +297,17 @@ class CoreExport BufferedSocket : public virtual Socket
int recv_len;
public:
- BufferedSocket();
- virtual ~BufferedSocket();
+ virtual ~BufferedSocket() = default;
/** Called when there is something to be received for this socket
* @return true on success, false to drop this socket
*/
- bool ProcessRead() anope_override;
+ bool ProcessRead() override;
/** Called when the socket is ready to be written to
* @return true on success, false to drop this socket
*/
- bool ProcessWrite() anope_override;
+ bool ProcessWrite() override;
/** Gets the new line from the input buffer, if any
*/
@@ -339,18 +350,17 @@ class CoreExport BinarySocket : public virtual Socket
std::deque<DataBlock *> write_buffer;
public:
- BinarySocket();
- virtual ~BinarySocket();
+ virtual ~BinarySocket() = default;
/** Called when there is something to be received for this socket
* @return true on success, false to drop this socket
*/
- bool ProcessRead() anope_override;
+ bool ProcessRead() override;
/** Called when the socket is ready to be written to
* @return true on success, false to drop this socket
*/
- bool ProcessWrite() anope_override;
+ bool ProcessWrite() override;
/** Write data to the socket
* @param buffer The data to write
@@ -377,7 +387,7 @@ class CoreExport ListenSocket : public virtual Socket
* @param ipv6 true for ipv6
*/
ListenSocket(const Anope::string &bindip, int port, bool ipv6);
- virtual ~ListenSocket();
+ virtual ~ListenSocket() = default;
/** Process what has come in from the connection
* @return false to destroy this socket
@@ -408,12 +418,12 @@ class CoreExport ConnectionSocket : public virtual Socket
* Used to determine whether or not this socket is connected yet.
* @return true to continue to call ProcessRead/ProcessWrite, false to not continue
*/
- bool Process() anope_override;
+ bool Process() override;
/** Called when there is an error for this socket
* @return true on success, false to drop this socket
*/
- void ProcessError() anope_override;
+ void ProcessError() override;
/** Called on a successful connect
*/
@@ -443,12 +453,12 @@ class CoreExport ClientSocket : public virtual Socket
* Used to determine whether or not this socket is connected yet.
* @return true to continue to call ProcessRead/ProcessWrite, false to not continue
*/
- bool Process() anope_override;
+ bool Process() override;
/** Called when there is an error for this socket
* @return true on success, false to drop this socket
*/
- void ProcessError() anope_override;
+ void ProcessError() override;
/** Called when a client has been accepted() successfully.
*/
@@ -472,7 +482,7 @@ class CoreExport Pipe : public Socket
/** Called when data is to be read, reads the data then calls OnNotify
*/
- bool ProcessRead() anope_override;
+ bool ProcessRead() override;
/** Write data to this pipe
* @param data The data to write
@@ -507,5 +517,3 @@ class CoreExport Pipe : public Socket
extern CoreExport uint32_t TotalRead;
extern CoreExport uint32_t TotalWritten;
extern CoreExport SocketIO NormalSocketIO;
-
-#endif // SOCKET_H
diff --git a/include/sysconf.h.cmake b/include/sysconf.h.cmake
index 5f0e275c3..72bc5526e 100644
--- a/include/sysconf.h.cmake
+++ b/include/sysconf.h.cmake
@@ -1,47 +1,33 @@
-#ifndef _SYSCONF_H_
-#define _SYSCONF_H_
+/*
+ *
+ * (C) 2003-2023 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.
+ */
-#cmakedefine DEBUG_BUILD
+#pragma once
+// The default umask to use for files.
#cmakedefine DEFUMASK @DEFUMASK@
-#cmakedefine HAVE_CSTDINT 1
-#cmakedefine HAVE_STDINT_H 1
-#cmakedefine HAVE_STDDEF_H 1
-#cmakedefine HAVE_STRCASECMP 1
-#cmakedefine HAVE_STRICMP 1
-#cmakedefine HAVE_STRINGS_H 1
-#cmakedefine HAVE_UMASK 1
-#cmakedefine HAVE_EVENTFD 1
-#cmakedefine HAVE_EPOLL 1
-#cmakedefine HAVE_POLL 1
-#cmakedefine GETTEXT_FOUND 1
-#ifdef HAVE_CSTDINT
-# include <cstdint>
-#else
-# ifdef HAVE_STDINT_H
-# include <stdint.h>
-# else
-# include "pstdint.h"
-# endif
-#endif
-#ifdef HAVE_STDDEF_H
-# include <stddef.h>
-#endif
+// Whether Anope was built in debug mode.
+#cmakedefine01 DEBUG_BUILD
+
+// Whether Anope was built with localization support.
+#cmakedefine01 HAVE_LOCALIZATION
+
+// Whether the umask() function is available.
+#cmakedefine01 HAVE_UMASK
#ifdef _WIN32
# define popen _popen
# define pclose _pclose
-# define ftruncate _chsize
-# ifdef MSVCPP
+# ifdef _MSC_VER
# define PATH_MAX MAX_PATH
# endif
-# define MAXPATHLEN MAX_PATH
-# define bzero(buf, size) memset(buf, 0, size)
-# ifdef MSVCPP
-# define strcasecmp stricmp
-# endif
# define sleep(x) Sleep(x * 1000)
#endif
-
-#endif
diff --git a/include/threadengine.h b/include/threadengine.h
index 19fa53b09..7d7c2dc70 100644
--- a/include/threadengine.h
+++ b/include/threadengine.h
@@ -9,8 +9,7 @@
* Based on the original code of Services by Andy Church.
*/
-#ifndef THREADENGINE_H
-#define THREADENGINE_H
+#pragma once
#include "sockets.h"
#include "extensible.h"
@@ -19,19 +18,15 @@ class CoreExport Thread : public Pipe, public Extensible
{
private:
/* Set to true to tell the thread to finish and we are waiting for it */
- bool exit;
+ bool exit = false;
public:
/* Handle for this thread */
pthread_t handle;
- /** Threads constructor
- */
- Thread();
-
/** Threads destructor
*/
- virtual ~Thread();
+ virtual ~Thread() = default;
/** Join to the thread, sets the exit state to true
*/
@@ -116,5 +111,3 @@ class CoreExport Condition : public Mutex
*/
void Wait();
};
-
-#endif // THREADENGINE_H
diff --git a/include/timers.h b/include/timers.h
index 6ba33ca7c..d3a5b9532 100644
--- a/include/timers.h
+++ b/include/timers.h
@@ -9,8 +9,7 @@
* Based on the original code of Services by Andy Church.
*/
-#ifndef TIMERS_H
-#define TIMERS_H
+#pragma once
#include "anope.h"
@@ -127,5 +126,3 @@ class CoreExport TimerManager
*/
static void DeleteTimersFor(Module *m);
};
-
-#endif // TIMERS_H
diff --git a/include/uplink.h b/include/uplink.h
index b0fe4b0f8..c14c5fda8 100644
--- a/include/uplink.h
+++ b/include/uplink.h
@@ -9,8 +9,7 @@
* Based on the original code of Services by Andy Church.
*/
-#ifndef UPLINK_H
-#define UPLINK_H
+#pragma once
#include "sockets.h"
#include "protocol.h"
@@ -27,9 +26,9 @@ class UplinkSocket : public ConnectionSocket, public BufferedSocket
bool error;
UplinkSocket();
~UplinkSocket();
- bool ProcessRead() anope_override;
- void OnConnect() anope_override;
- void OnError(const Anope::string &) anope_override;
+ bool ProcessRead() override;
+ void OnConnect() override;
+ void OnError(const Anope::string &) override;
/* A message sent over the uplink socket */
class CoreExport Message
@@ -49,5 +48,3 @@ class UplinkSocket : public ConnectionSocket, public BufferedSocket
};
};
extern CoreExport UplinkSocket *UplinkSock;
-
-#endif // UPLINK_H
diff --git a/include/users.h b/include/users.h
index 31f5cf97c..6e94e24f0 100644
--- a/include/users.h
+++ b/include/users.h
@@ -9,8 +9,7 @@
* Based on the original code of Services by Andy Church.
*/
-#ifndef USERS_H
-#define USERS_H
+#pragma once
#include "anope.h"
#include "modes.h"
@@ -190,7 +189,7 @@ class CoreExport User : public virtual Base, public Extensible, public CommandRe
* @param ... any number of parameters
*/
void SendMessage(BotInfo *source, const char *fmt, ...);
- void SendMessage(BotInfo *source, const Anope::string &msg) anope_override;
+ void SendMessage(BotInfo *source, const Anope::string &msg) override;
/** Identify the user to a nick.
* updates last_seen, logs the user in,
@@ -226,6 +225,11 @@ class CoreExport User : public virtual Base, public Extensible, public CommandRe
*/
bool IsRecognized(bool check_secure = true) const;
+ /** Check if the user is connected securely.
+ * @return True if the user is connected securely; otherwise, false.
+ */
+ bool IsSecurelyConnected() const;
+
/** Check if the user is a services oper
* @return true if they are an oper
*/
@@ -370,5 +374,3 @@ class CoreExport User : public virtual Base, public Extensible, public CommandRe
*/
static void QuitUsers();
};
-
-#endif // USERS_H
diff --git a/include/version.cpp b/include/version.cpp
index af7993a36..9cb16d78e 100644
--- a/include/version.cpp
+++ b/include/version.cpp
@@ -105,8 +105,9 @@ static bool write_build_h(const std::string &buildh, const std::string &git_vers
return false;
}
- fd << "/* This file is automatically generated by version.cpp - do not edit it! */" << std::endl;
- fd << build << std::endl;
+ fd << "/* This file is automatically generated by version.cpp - do not edit it! */" << std::endl
+ << "#pragma once" << std::endl
+ << build << std::endl;
if (!git_version.empty())
fd << "#define VERSION_GIT \"" << git_version << "\"" << std::endl;
fd.close();
@@ -144,9 +145,10 @@ static bool write_version_h(const std::string &versionh, const std::map<std::str
if (!fd.is_open())
return false;
- for (std::map<std::string, std::string>::const_iterator it = versions.begin(); it != versions.end(); ++it)
+ fd << "#pragma once" << std::endl;
+ for (const auto &[key, value] : versions)
{
- fd << "#define " << it->first << " " << it->second << std::endl;
+ fd << "#define " << key << " " << value << std::endl;
}
fd.close();
diff --git a/include/xline.h b/include/xline.h
index b9cd8b791..951f74563 100644
--- a/include/xline.h
+++ b/include/xline.h
@@ -6,8 +6,7 @@
* Please read COPYING and README for further details.
*/
-#ifndef XLINE_H
-#define XLINE_H
+#pragma once
#include "serialize.h"
#include "service.h"
@@ -23,8 +22,8 @@ class CoreExport XLine : public Serializable
Anope::string mask;
Regex *regex;
Anope::string by;
- time_t created;
- time_t expires;
+ time_t created = 0;
+ time_t expires = 0;
Anope::string reason;
XLineManager *manager;
Anope::string id;
@@ -44,7 +43,7 @@ class CoreExport XLine : public Serializable
bool HasNickOrReal() const;
bool IsRegex() const;
- void Serialize(Serialize::Data &data) const anope_override;
+ void Serialize(Serialize::Data &data) const override;
static Serializable* Unserialize(Serializable *obj, Serialize::Data &data);
};
@@ -180,5 +179,3 @@ class CoreExport XLineManager : public Service
*/
virtual void SendDel(XLine *x) = 0;
};
-
-#endif // XLINE_H