aboutsummaryrefslogtreecommitdiff
path: root/src/net/host.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/host.h')
-rw-r--r--src/net/host.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/net/host.h b/src/net/host.h
new file mode 100644
index 000000000..c96a7b434
--- /dev/null
+++ b/src/net/host.h
@@ -0,0 +1,20 @@
+#pragma once
+
+#include <string>
+
+namespace net
+{
+ /*!
+ * \brief Canonicalize a hostname by converting letters to lowercase.
+ *
+ * \param host Hostname to canonicalize in-place.
+ */
+ inline void canonicalize_host(std::string& host) noexcept
+ {
+ for (char& c : host)
+ {
+ if ('A' <= c && c <= 'Z')
+ c = static_cast<char>(c - 'A' + 'a');
+ }
+ }
+}