stream: stream_reset

We can reuse the same stream by resetting it.  We don't delete the
cached data.
This commit is contained in:
2026-02-09 08:33:35 +00:00
committed by oreodave
parent 2238f348e1
commit f164427b47
2 changed files with 8 additions and 0 deletions

View File

@@ -56,6 +56,7 @@ stream_err_t stream_init_pipe(stream_t *, const char *, FILE *);
// NOTE: stream_init_file will attempt to read all content from the FILE
// descriptor. Use with caution.
stream_err_t stream_init_file(stream_t *, const char *, FILE *);
void stream_reset(stream_t *);
void stream_stop(stream_t *);
// End of Content (i.e. we've consumed all cached content/file)

View File

@@ -100,6 +100,13 @@ stream_err_t stream_init_file(stream_t *stream, const char *name, FILE *pipe)
return STREAM_ERR_OK;
}
void stream_reset(stream_t *stream)
{
if (!stream)
return;
stream->position = 0;
}
void stream_stop(stream_t *stream)
{
if (!stream)