aboutsummaryrefslogtreecommitdiff
path: root/include/sb.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/sb.h')
-rw-r--r--include/sb.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/include/sb.h b/include/sb.h
new file mode 100644
index 0000000..1dbed9a
--- /dev/null
+++ b/include/sb.h
@@ -0,0 +1,58 @@
1// sb.h --- String Builder -*- C -*-
2//
3// Copyright (c) 2026 Martin Michalec <martin@michalec.dev>
4//
5// SPDX-License-Identifier: MIT
6//
7// This file is part of COSMOS Codebase.
8//
9// Commentary:
10//
11// MAYBE(cmmm): include as extension in da.h
12//
13// Code:
14
15#ifndef INCLUDED_COSMOS_SB_H
16#define INCLUDED_COSMOS_SB_H
17
18#include "da.h"
19#include "mv.h"
20
21struct sb {
22 struct da_hdr hdr;
23 char *arr;
24};
25
26/* */ char *sb_cstr (struct sb *);
27struct ms sb_ms (struct sb);
28
29// specialized pushing
30struct ms sb_push_mv (struct sb *, struct mv );
31struct ms sb_push_mv_arr (struct sb *, struct mv_arr);
32struct ms sb_pad (struct sb *, int n, char );
33
34#ifndef SB_NO_FEAT_STDIO
35
36// FORMAT_PRINTF (2, 3)
37__attribute__ ((__format__ (__printf__, 2, 3)))
38int sb_printf (struct sb *, const char *fmt, ... );
39int sb_vprintf (struct sb *, const char *fmt, va_list);
40
41#endif // SB_NO_FEAT_STDIO
42
43#ifndef SB_NO_FEAT_UNISTD
44
45struct ms sb_read_until_eof (struct sb *, int fd);
46
47#ifndef IOBUF_NO_FEAT_UNISTD
48#include "iobuf.h"
49struct ms sb_read_until (struct sb *, int fd, u8 del, struct iobuf *);
50struct ms sb_read_until_any (struct sb *, int fd, struct mv set, struct iobuf *);
51struct ms sb_read_until_seq (struct sb *, int fd, struct mv seq, struct iobuf *);
52#endif // IOBUF_NO_FEAT_UNISTD
53
54#endif // SB_NO_FEAT_UNISTD
55
56#endif // INCLUDED_COSMOS_SB_H
57
58// sb.h ends here