diff options
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/util.c | 19 | ||||
-rw-r--r-- | src/common/util.h | 2 |
2 files changed, 21 insertions, 0 deletions
diff --git a/src/common/util.c b/src/common/util.c index 75eb233bef..1b0603a469 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -4461,6 +4461,25 @@ tor_split_lines(smartlist_t *sl, char *buf, int len) return smartlist_len(sl); } +/** Return a string corresponding to <b>stream_status</b>. */ +const char * +stream_status_to_string(enum stream_status stream_status) +{ + switch (stream_status) { + case IO_STREAM_OKAY: + return "okay"; + case IO_STREAM_EAGAIN: + return "temporarily unavailable"; + case IO_STREAM_TERM: + return "terminated"; + case IO_STREAM_CLOSED: + return "closed"; + default: + tor_fragile_assert(); + return "unknown"; + } +} + #ifdef _WIN32 /** Return a smartlist containing lines outputted from diff --git a/src/common/util.h b/src/common/util.h index aa2087b013..fabfdb19fd 100644 --- a/src/common/util.h +++ b/src/common/util.h @@ -307,6 +307,8 @@ enum stream_status { IO_STREAM_CLOSED }; +const char *stream_status_to_string(enum stream_status stream_status); + enum stream_status get_string_from_pipe(FILE *stream, char *buf, size_t count); /** Return values from file_status(); see that function's documentation |