stream: Introduce PIPE type

Main reason to have this at all is to make char-by-char reading
feasible.  This occurs at `stream_chunk`, and previously if we passed
in STDIN for `stream_init_file`, STDIN will only terminate once
STREAM_DEFAULT_CHUNK number of characters have been fed into the pipe.

This isn't desirable for STDIN (we really want to read char-by-char
for expressions), nor would it necessarily be desirable in network
applications.  So any stream marked STREAM_TYPE_PIPE will only chunk
character-by-character rather than genuine chunks.
This commit is contained in:
2025-10-19 22:22:23 +01:00
parent 030a289497
commit cbfcf24ca2
2 changed files with 49 additions and 10 deletions

View File

@@ -100,6 +100,7 @@ void sym_table_cleanup(sym_table_t *);
typedef enum
{
STREAM_TYPE_STRING,
STREAM_TYPE_PIPE,
STREAM_TYPE_FILE,
} stream_type_t;
@@ -133,6 +134,7 @@ typedef struct
#define STREAM_DEFAULT_CHUNK 64
stream_err_t stream_init_string(stream_t *, char *, sv_t);
stream_err_t stream_init_pipe(stream_t *, char *, FILE *);
stream_err_t stream_init_file(stream_t *, char *, FILE *);
void stream_stop(stream_t *);