diff --git a/include/alisp/stream.h b/include/alisp/stream.h index 8a049af..5156055 100644 --- a/include/alisp/stream.h +++ b/include/alisp/stream.h @@ -29,6 +29,8 @@ typedef enum STREAM_ERR_OK = 0, } stream_err_t; +const char *stream_err_to_cstr(stream_err_t); + typedef struct { vec_t cache; diff --git a/src/stream.c b/src/stream.c index bafe4d5..606d0a3 100644 --- a/src/stream.c +++ b/src/stream.c @@ -10,6 +10,30 @@ #include +const char *stream_err_to_cstr(stream_err_t err) +{ + switch (err) + { + case STREAM_ERR_INVALID_PTR: + return "INVALID PTR"; + break; + case STREAM_ERR_FILE_NONEXISTENT: + return "FILE NONEXISTENT"; + break; + case STREAM_ERR_FILE_READ: + return "FILE READ"; + break; + case STREAM_ERR_PIPE_NONEXISTENT: + return "PIPE NONEXISTENT"; + break; + case STREAM_ERR_OK: + return "OK"; + break; + default: + FAIL("Unreachable"); + } +} + stream_err_t stream_init_string(stream_t *stream, char *name, sv_t contents) { if (!stream)