// sb.h --- String Builder -*- C -*- // // Copyright (c) 2026 Martin Michalec // // SPDX-License-Identifier: MIT // // This file is part of COSMOS Codebase. // // Commentary: // // MAYBE(cmmm): include as extension in da.h // // Code: #ifndef INCLUDED_COSMOS_SB_H #define INCLUDED_COSMOS_SB_H #include "da.h" #include "mv.h" struct sb { struct da_hdr hdr; char *arr; }; /* */ char *sb_cstr (struct sb *); struct ms sb_ms (struct sb); // specialized pushing struct ms sb_push_mv (struct sb *, struct mv ); struct ms sb_push_mv_arr (struct sb *, struct mv_arr); struct ms sb_pad (struct sb *, int n, char ); #ifndef SB_NO_FEAT_STDIO // FORMAT_PRINTF (2, 3) __attribute__ ((__format__ (__printf__, 2, 3))) int sb_printf (struct sb *, const char *fmt, ... ); int sb_vprintf (struct sb *, const char *fmt, va_list); #endif // SB_NO_FEAT_STDIO #ifndef SB_NO_FEAT_UNISTD struct ms sb_read_until_eof (struct sb *, int fd); #ifndef IOBUF_NO_FEAT_UNISTD #include "iobuf.h" struct ms sb_read_until (struct sb *, int fd, u8 del, struct iobuf *); struct ms sb_read_until_any (struct sb *, int fd, struct mv set, struct iobuf *); struct ms sb_read_until_seq (struct sb *, int fd, struct mv seq, struct iobuf *); #endif // IOBUF_NO_FEAT_UNISTD #endif // SB_NO_FEAT_UNISTD #endif // INCLUDED_COSMOS_SB_H // sb.h ends here