summaryrefslogtreecommitdiff
path: root/prb_string.h
blob: 7df824665d7faaa18a70df9604ed2eb6c0ee7dd0 (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
34
35
36
37
38
39
40
#ifndef PRB_STRING_H
#define PRB_STRING_H

/* NOTE(pryazha): I don't know wheter it's a good idea
 * to keep regular and fixed-length strings together, but
 * seems reasonable at the time.
 */

/* NOTE(pryazha): Null-terminated strings */

void	sys_vprintf(const char *fmt, va_list args);
void	sys_printf(const char *fmt, ...);

/* NOTE(pryazha): Fixed-length strings */

#define FLSLIT(s) fls((U8 *)(s), sizeof(s)-1)
#define FLSEXP(s) (int)((s).len), ((s).p)

FLS	fls(U8 *p, U64 len);

FLS	flsfromcstr(const char *cstr);
char	*flstocstr(Arena *a, FLS s);

FLS	flsrange(U8 *start, U8 *end);
FLS	flschopend(FLS s, U64 cnt);
FLS	flschopstart(FLS s, U64 cnt);

FLS	flspushfv(Arena *a, const char *fmt, va_list args);
FLS	flspushf(Arena *a, const char *fmt, ...);

void	flsprint(FLS s);

FLSList	*flslist(Arena *a);

void	flslistpush(Arena *a, FLSList *l, FLS s, B32 front);
void	flslistpushf(Arena *a, FLSList *l, B32 front, const char *fmt, ...);

void	flslistprint(FLSList *l);

#endif /* PRB_STRING_H */