stream: stream_reset
We can reuse the same stream by resetting it. We don't delete the cached data.
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user