diff options
Diffstat (limited to 'include/pkgit_string.h')
| -rw-r--r-- | include/pkgit_string.h | 27 |
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 |
