aboutsummaryrefslogtreecommitdiff
path: root/include/pkgit_string.h
diff options
context:
space:
mode:
authordacctal <donotcontactmevia@email.invalid>2026-06-29 18:29:38 +0000
committerdacctal <donotcontactmevia@email.invalid>2026-06-29 18:29:38 +0000
commitb8a96b5fa7ccb6b170b1fb40c5ea4efe4519e568 (patch)
treedf85e5ad0cbfcc78da3e7450672e1a753b7cd9b0 /include/pkgit_string.h
parentd85350854dca4c6495cb78c89ff4934c7a908509 (diff)
initialized rewrite
Diffstat (limited to 'include/pkgit_string.h')
-rw-r--r--include/pkgit_string.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/include/pkgit_string.h b/include/pkgit_string.h
new file mode 100644
index 0000000..ae6098c
--- /dev/null
+++ b/include/pkgit_string.h
@@ -0,0 +1,27 @@
+#ifndef PKGIT_STRING_H
+#define PKGIT_STRING_H
+#include <stddef.h>
+
+typedef struct {
+ char* data;
+ size_t len;
+} str_s;
+
+typedef struct {
+ char* data;
+ size_t cap;
+ size_t len;
+} str;
+
+#define format_string(s) (int)((s).len), (s).data
+// Usage: printf("%.*s", format_string(ss));
+
+void print_slice(str_s s);
+str_s slice_from_cstr(char* cstr);
+int slice_eq(str_s a, str_s b);
+int slice_starts_with(str_s slice, str_s prefix);
+str_s slice_take(str_s slice, size_t n);
+str_s slice_drop(str_s slice, size_t n);
+str_s slice_trim(str_s slice);
+
+#endif