Summary Files Commits Branches @commit @diff @stats
path: root / src / utils / strings.c
diff options
context:
space:
mode:
Commit74630b4bfe1aa887ef57ee57b22241d030b38d76 (patch)
Author
 Syndamia <kamen@syndamia.com>
2025-11-15 21:37:37 +0200
Committer
 Syndamia <kamen@syndamia.com>
2025-11-15 21:37:37 +0200
Files3d39c585df1551d69fdb83980c010ec4b579f211 /src/utils/strings.c
tergiv-74630b4bfe1aa887ef57ee57b22241d030b38d76.tar
tergiv-74630b4bfe1aa887ef57ee57b22241d030b38d76.tar.gz
tergiv-74630b4bfe1aa887ef57ee57b22241d030b38d76.zip
Parent3bca23eaaa49fa01f60ecbc5e0a329d29f088506 (diff)
feat!: Initial web server base implementation
1 files changed, 32 insertions, 0 deletions
-rw-r--r--src/utils/strings.c32
diff --git a/src/utils/strings.c b/src/utils/strings.c
new file mode 100644
index 0000000..02b33f1
--- /dev/null
+++ b/src/utils/strings.c
@@ -0,0 +1,32 @@
+#include "strings.h"
+#include <stdlib.h>
+
+int strprefix(const char* prefix, const char* str) {
+ return strncmp(prefix, str, strlen(prefix)) == 0;
+}
+
+int streq(const char* a, const char* b) {
+ return strncmp(a, b, strlen(a)) == 0;
+}
+
+char* concat_array(const char** array, size_t size, size_t *output_size) {
+ if (array == NULL || size == 0) return NULL;
+
+ size_t total_size = 0;
+ for (size_t i = 0; i < size; i++)
+ total_size += strlen(array[i]);
+
+ if (total_size == 0) return NULL;
+
+ char* result = malloc(total_size + 1);
+ size_t current_index = 0;
+
+ for (size_t i = 0; i < size; i++) {
+ size_t curr_len = strlen(array[i]);
+ strncpy(result + current_index, array[i], curr_len);
+ current_index += curr_len;
+ }
+
+ if (output_size != NULL) *output_size = total_size;
+ return result;
+}