aboutsummaryrefslogtreecommitdiff
path: root/lib/cstr/cstr.h
blob: 049c86792faf20f89fae999e58f1835555810049 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#ifndef CSTR_H
#define CSTR_H

#include "../sys/sizes.h"

typedef struct {
	char *begin;
	char *end;
} substr_t;

u64        cstr_length(const char *);
i8         cstr_compare(const char *a, const char *b);
u64        cstr_split(char *cstr, char split);
u64        cstr_split_with_cancel(char *cstr, char split, char cancel);
const char *next_split(const char *previous);
u64        strip_front(char *cstr, char strip);
u64        strip_back(char *cstr, char strip);
u64        strip_cstr(char *cstr, char strip);
u64        number_of_lines(const char *cstr);

substr_t   getline(const char *cstr, u64 n);
substr_t   nextline(substr_t line);

u64 cstr_utf8_length(const char *);
u8  next_utf8(const char **);
u8  previous_utf8(const char **);

void u64_to_cstr(u64 n, char *cstr, u64 length);
void i64_to_cstr(i64 n, char *cstr, u64 length);
u64  cstr_to_u64(const char *cstr);
i64  cstr_to_i64(const char *cstr);

#endif