From b8a96b5fa7ccb6b170b1fb40c5ea4efe4519e568 Mon Sep 17 00:00:00 2001 From: dacctal Date: Mon, 29 Jun 2026 18:29:38 +0000 Subject: initialized rewrite --- include/pkgit_string.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 include/pkgit_string.h (limited to 'include/pkgit_string.h') 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 + +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 -- cgit v1.2.3