19#ifndef E8CAA280_1C10_4862_B560_47F74D754175
20#define E8CAA280_1C10_4862_B560_47F74D754175
37#define STREAM_ASSERT(x) assert(x)
39#define STREAM_ASSERT(x) ((void)0)
57bool readline(
const char* prompt,
char* buffer,
size_t buffer_len);
69int getpassword(
const char* prompt,
char* buffer,
size_t buffer_len);
101typedef ssize_t stream_result_t;
size_t file_stream_read(stream_t s, void *restrict ptr, size_t size, size_t count)
Read up to count objects of size bytes from a file stream into ptr, rewinding to the beginning first.
void stream_destroy(stream_t stream)
Destroy a stream and release all connected resources.
int stream_seek(stream_t stream, long offset, int whence)
Seek within a stream exactly matching POSIX fseek(3) semantics.
const char * string_stream_data(stream_t stream)
Fetch a read-only view of the underlying strictly NUL-terminated string data.
bool readline(const char *prompt, char *buffer, size_t buffer_len)
Read a line from stdin, optionally printing a prompt first.
struct stream * stream_t
Opaque stream handle.
int string_stream_write(stream_t stream, const char *str)
Append the NUL-terminated string str to stream.
int getpassword(const char *prompt, char *buffer, size_t buffer_len)
Read a password from the terminal with echo disabled.
int string_stream_write_len(stream_t stream, const char *str, size_t n)
Append the NUL-terminated string str to stream. This is faster than string_stream_write when the leng...
unsigned long io_copy_n(stream_t writer, stream_t reader, size_t n)
Copy tightly capped chunk up to n bytes.
stream_t create_file_stream(FILE *fp)
Wrap an existing FILE* in a standardized stream context.
unsigned long string_stream_copy_fast(stream_t dst, stream_t src)
Direct memory-bound string to string copy without generic dispatch.
unsigned long io_copy(stream_t writer, stream_t reader)
Copy contents universally from reader into writer.
stream_t create_string_stream(size_t initial_capacity)
Allocate a new in-memory string stream.
ssize_t read_until(stream_t stream, int delim, char *buffer, size_t buffer_size)
Read from stream into buffer until delim is found.
String stream internal state structure.