aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorGravatar Sadie Powell2024-11-01 14:35:23 +0000
committerGravatar Sadie Powell2024-11-01 15:53:04 +0000
commit8a3aba4044ee10df332631c4c66ed60299566e58 (patch)
treeafb185a313dff83d61c26e3b95f47b62d3ab5694 /include
parentDefault <options:extbanformat> to name. (diff)
parentUse fmtlib instead of iostream in ConvToStr where available. (diff)
Merge branch 'insp4' into master.
Diffstat (limited to 'include')
-rw-r--r--include/compat.h2
-rw-r--r--include/configreader.h2
-rw-r--r--include/convto.h17
-rw-r--r--include/modules/extban.h2
-rw-r--r--include/numeric.h9
-rw-r--r--include/timeutils.h13
-rw-r--r--include/usermanager.h5
7 files changed, 42 insertions, 8 deletions
diff --git a/include/compat.h b/include/compat.h
index 41cf96bb5..16f8ab346 100644
--- a/include/compat.h
+++ b/include/compat.h
@@ -39,10 +39,12 @@
# include <format>
# define FMT std
# define FMT_PTR(PTR) static_cast<void*>(PTR)
+template<typename T> concept fmt_formattable = std::default_initializable<std::formatter<std::remove_cvref_t<T>>>;
#else
# include <fmt/format.h>
# define FMT fmt
# define FMT_PTR(PTR) fmt::ptr(PTR)
+template<typename T> concept fmt_formattable = fmt::formattable<T>;
#endif
/**
diff --git a/include/configreader.h b/include/configreader.h
index 451aecaf3..62efaa404 100644
--- a/include/configreader.h
+++ b/include/configreader.h
@@ -129,7 +129,7 @@ public:
/** Get the value of an option, using def if it does not exist */
bool getBool(const std::string& key, bool def = false) const;
/** Get the value of an option, using def if it does not exist */
- unsigned char getCharacter(const std::string& key, unsigned char def = '\0') const;
+ unsigned char getCharacter(const std::string& key, unsigned char def = '\0', bool emptynul = false) const;
/** Get the value in seconds of a duration that is in the user-friendly "1h2m3s" format,
* using a default value if it does not exist or is out of bounds.
diff --git a/include/convto.h b/include/convto.h
index 15e0788a6..83b52c465 100644
--- a/include/convto.h
+++ b/include/convto.h
@@ -71,17 +71,26 @@ inline std::string ConvToStr(const bool in)
/** Converts a type that to_string is implemented for to a string.
* @param in The value to convert.
*/
-template<typename Stringable>
-inline std::enable_if_t<std::is_arithmetic_v<Stringable>, std::string> ConvToStr(const Stringable& in)
+template<typename Stringable> requires(std::integral<Stringable> || std::floating_point<Stringable>)
+inline std::string ConvToStr(const Stringable& in)
{
return std::to_string(in);
}
+/** Converts a type that fmtlib can format to a string.
+ * @param in The value to convert.
+ */
+template<typename Formattable> requires(!std::integral<Formattable> && !std::floating_point<Formattable> && fmt_formattable<Formattable>)
+inline std::string ConvToStr(const Formattable& in)
+{
+ return FMT::format("{}", in);
+}
+
/** Converts any type to a string.
* @param in The value to convert.
*/
-template <class T>
-inline std::enable_if_t<!std::is_arithmetic_v<T>, std::string> ConvToStr(const T& in)
+template <class T> requires(!std::integral<T> && !std::floating_point<T> && !fmt_formattable<T>)
+inline std::string ConvToStr(const T& in)
{
std::stringstream tmp;
if (!(tmp << in))
diff --git a/include/modules/extban.h b/include/modules/extban.h
index 28f76552a..45b9ebe50 100644
--- a/include/modules/extban.h
+++ b/include/modules/extban.h
@@ -204,7 +204,7 @@ protected:
*/
Base(Module* mod, const std::string& xbname, ExtBan::Letter xbletter)
: ServiceProvider(mod, xbname, SERVICE_CUSTOM)
- , letter(ServerInstance->Config->ConfValue("extbans")->getCharacter(xbname, xbletter))
+ , letter(ServerInstance->Config->ConfValue("extbans")->getCharacter(xbname, xbletter, true))
, manager(mod, "extbanmanager")
{
}
diff --git a/include/numeric.h b/include/numeric.h
index cad708cd7..db03367a8 100644
--- a/include/numeric.h
+++ b/include/numeric.h
@@ -39,8 +39,11 @@ enum
ERR_UNKNOWNCOMMAND = 421,
ERR_NONICKNAMEGIVEN = 431,
ERR_ERRONEUSNICKNAME = 432,
+ ERR_NICKNAMEINUSE = 433,
ERR_USERNOTINCHANNEL = 441,
ERR_NOTONCHANNEL = 442,
+ ERR_NOTREGISTERED = 451,
+ ERR_NEEDMOREPARAMS = 461,
ERR_YOUREBANNEDCREEP = 465,
ERR_UNKNOWNMODE = 472,
ERR_BANNEDFROMCHAN = 474,
@@ -58,11 +61,17 @@ enum
// From irc2?
RPL_SAVENICK = 43,
+ // From ircu.
+ RPL_YOURDISPLAYEDHOST = 396,
+
// From UnrealIRCd.
ERR_CANTCHANGENICK = 447,
// InspIRCd-specific.
ERR_UNKNOWNSNOMASK = 501,
+ RPL_SYNTAX = 650,
+ ERR_LISTMODEALREADYSET = 697,
+ ERR_LISTMODENOTSET = 698,
ERR_CANTUNLOADMODULE = 972,
RPL_UNLOADEDMODULE = 973,
ERR_CANTLOADMODULE = 974,
diff --git a/include/timeutils.h b/include/timeutils.h
index 59312e00d..c5c1fd2c1 100644
--- a/include/timeutils.h
+++ b/include/timeutils.h
@@ -63,11 +63,22 @@ namespace Time
{
/** Converts a UNIX timestamp to a time string.
*
- * e.g.
* @param ts The timestamp to convert to a string.
* @param format A snprintf format string to output the timestamp in.
* @param utc If the timestamp is a UTC timestamp then true or false if the
* timestamp is a local timestamp.
*/
CoreExport std::string ToString(time_t ts, const char* format = nullptr, bool utc = false);
+
+ /** Converts a duration from now to a time string.
+ *
+ * @param duration The duration from now to convert to a string.
+ * @param format A snprintf format string to output the timestamp in.
+ * @param utc If the timestamp is a UTC timestamp then true or false if the
+ * timestamp is a local timestamp.
+ */
+ inline std::string FromNow(unsigned long duration, const char* format = nullptr, bool utc = false)
+ {
+ return ToString(ServerInstance->Time() + duration, format, utc);
+ }
}
diff --git a/include/usermanager.h b/include/usermanager.h
index 9c824f3f7..73da0e3fb 100644
--- a/include/usermanager.h
+++ b/include/usermanager.h
@@ -140,6 +140,9 @@ public:
*/
void RehashCloneCounts();
+ /** Rebuilds the list of services servers. Required when \<services> settings change. */
+ void RehashServices();
+
/** Return the number of local and global clones of this user
* @param user The user to get the clone counts for
* @return The clone counts of this user. The returned reference is volatile - you
@@ -171,7 +174,7 @@ public:
/** Return a count of fully connected connections on the network.
* @return The number of fully connected users on the network.
*/
- size_t GlobalUserCount() const { return this->clientlist.size() - this->UnknownUserCount() - this->ServiceCount(); }
+ size_t GlobalUserCount() const { return this->clientlist.size() - this->UnknownUserCount(); }
/** Get a hash map containing all users, keyed by their nickname
* @return A hash map mapping nicknames to User pointers