aboutsummaryrefslogtreecommitdiff
path: root/lib/const_strings.h
diff options
context:
space:
mode:
authorspl3g <spleefer6@yandex.ru>2025-03-11 22:37:43 +0300
committerspl3g <spleefer6@yandex.ru>2025-03-11 22:37:43 +0300
commita854e4cfa450590753171fbbe4dde8da4f504abd (patch)
treefb1d91910e5a86a6460654af289fbb4b3ef707b7 /lib/const_strings.h
parent74ab2f6b89ceb2af34524386d6003746570d2b03 (diff)
Move everything to the lib folder
Diffstat (limited to 'lib/const_strings.h')
-rw-r--r--lib/const_strings.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/const_strings.h b/lib/const_strings.h
new file mode 100644
index 0000000..987c6f6
--- /dev/null
+++ b/lib/const_strings.h
@@ -0,0 +1,29 @@
+#ifndef CONST_STRINGS_H_
+#define CONST_STRINGS_H_
+
+#include <string.h>
+#include <stdio.h>
+#include <stdbool.h>
+
+typedef struct {
+ char* data;
+ int len;
+} const_string;
+
+
+const_string cs_from_parts(char* data, int len);
+const_string cs_from_cstr(char* cstr);
+const_string cs_slice(const_string src, int from, int to);
+const_string cs_chop_delim(const_string *src, char delim);
+int cs_find_delim(const_string str, char delim);
+bool cs_eq(const_string str1, const_string str2);
+void cs_print(char *format, const_string str);
+
+#define CS(cstr) cs_from_parts(cstr, sizeof(cstr) - 1)
+#define CS_STATIC(cstr) {.data = cstr, .len = sizeof(cstr) - 1}
+
+#endif // STRINGS_H_
+
+
+#ifdef CONST_STRINGS_IMPLEMENTATION
+#endif // STRINGS_IMPLEMENTATION