25#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 202300L
26# warning including threads.h to have thread_local before C23
31static thread_local bool keep_reading =
true;
43 const ssize_t result = read(file->
descriptor, buffer, room);
46 log_error(
"read returned %zi: %s", result, strerror(errno));
47 else if (result > 0 and not
queue_push_n(queue, buffer, result))
102 keep_reading =
false;
Simplistic logging utilities.
#define log_error(...)
Report a condition causing the current operation to abort.
size_t queue_capacity(const queue_t *self)
Number of elements that can be stored in the queue.
bool queue_push_n(queue_t *self, const void *elements, size_t count)
Add count elements to the queue.
size_t queue_count(const queue_t *self)
Number of elements currently in the queue.
size_t queue_room(const queue_t *self)
Number of elements that can be added.
deque_t queue_t
A queue is First In First Out.
void file_default_signal_handler(int, siginfo_t *, void *)
Default signal handler.
void file_resume_reading(void)
Resume calling read in this thread.
void file_stop_reading(void)
Prevent the accumulate function from calling read in this thread.
bool file_accumulate_infinite(ifstream_t *file, size_t count)
If possible, accumulate count bytes before returning.
bool file_accumulate(ifstream_t *file, size_t count)
If possible, accumulate count bytes before returning.
ssize_t file_single_read(ifstream_t *file)
Read as much as possible.
Dynamic string implementation.
int descriptor
Underlying file.
istream_t stream
Inherit from input stream.
queue_t buffer
Circular buffer of bytes.