summaryrefslogtreecommitdiff
path: root/backend/stringmanip.h
diff options
context:
space:
mode:
authorMatthew Kosarek <matthew.kosarek@vention.cc>2021-02-20 14:24:43 -0500
committerMatthew Kosarek <matthew.kosarek@vention.cc>2021-02-20 14:24:43 -0500
commit61f537c0bc9ff6b73fc7e837e08a5c7867f16832 (patch)
tree10f78a9b684deab67bd133bd7b28c015db40b60c /backend/stringmanip.h
parent5c409f04470e319f0a57e8791bc96cd724ee601c (diff)
Multithreading requests on the backend, and removing unnecessary files
Diffstat (limited to 'backend/stringmanip.h')
-rw-r--r--backend/stringmanip.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/backend/stringmanip.h b/backend/stringmanip.h
new file mode 100644
index 0000000..c5a32dc
--- /dev/null
+++ b/backend/stringmanip.h
@@ -0,0 +1,27 @@
+#pragma once
+#include <string.h>
+
+void copyUntilStr(char* destination, char* source, const char* cmpstr) {
+ int index = 0;
+ char* ptr = source;
+ int cmpStrLen = strlen(cmpstr);
+ while (strncmp(ptr, cmpstr, cmpStrLen) != 0) {
+ destination[index++] = *ptr;
+ ptr++;
+ }
+
+ destination[index] = '\0';
+}
+
+int endsWith(const char *str, const char *suffix) {
+ size_t str_len = strlen(str);
+ size_t suffix_len = strlen(suffix);
+
+ return (str_len >= suffix_len) &&
+ (!memcmp(str + str_len - suffix_len, suffix, suffix_len));
+}
+
+void getCurrentDateStr(char* text) {
+ time_t now = time(NULL);
+ sprintf(text, "%s GMT", ctime(&now));
+} \ No newline at end of file