summaryrefslogtreecommitdiff
path: root/src/util.cpp
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-05-08 18:40:14 +0200
committerHampusM <hampus@hampusmat.com>2022-05-08 18:41:25 +0200
commit3a11866cb6a8fd46d86cb6e04dc1022344ea8d45 (patch)
tree1cd2b3739e8fc53cecc1b68da9ad989233773f4f /src/util.cpp
parent6546ff00988635608c0b3d5e53bb7387e680478c (diff)
feat: add connecting to wifi
Diffstat (limited to 'src/util.cpp')
-rw-r--r--src/util.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/util.cpp b/src/util.cpp
new file mode 100644
index 0000000..f587781
--- /dev/null
+++ b/src/util.cpp
@@ -0,0 +1,35 @@
+#include "util.hpp"
+
+namespace util
+{
+
+bool str_ends_with(const char *str, const char *other_str) noexcept
+{
+ if (str == nullptr || other_str == nullptr)
+ {
+ return false;
+ }
+
+ auto str_length = strlen(str);
+ auto other_str_length = strlen(other_str);
+
+ if (other_str_length > str_length)
+ {
+ return false;
+ }
+
+ return strncmp(str + str_length - other_str_length, other_str, other_str_length) == 0;
+}
+
+void substr(const char *str, const char *end, char *dest) noexcept
+{
+ auto *dest_head = dest;
+
+ for (const char *char_ptr = str; char_ptr + 1 != end; ++char_ptr)
+ {
+ *dest_head = *char_ptr;
+ dest_head++;
+ }
+}
+
+} // namespace util