diff options
author | Richard Levitte <levitte@openssl.org> | 2016-09-15 11:20:18 +0200 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2016-09-15 23:24:06 +0200 |
commit | 51e5133d551b4c132f72fc2ff5bbe076f5a3e052 (patch) | |
tree | 10ce1fe9b7f3c2f444c8226fc8499c5a5125a9a3 /apps/apps.c | |
parent | c7bdb6a31ff0fcae66b451d3f80a684ad77f4966 (diff) |
Refactor to avoid unnecessary preprocessor logic
Reviewed-by: Andy Polyakov <appro@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
Diffstat (limited to 'apps/apps.c')
-rw-r--r-- | apps/apps.c | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/apps/apps.c b/apps/apps.c index 522db71322..6ca0f2b1bc 100644 --- a/apps/apps.c +++ b/apps/apps.c @@ -2300,6 +2300,36 @@ int app_isdir(const char *name) #endif /* raw_read|write section */ +#if defined(__VMS) +# include "vms_term_sock.h" +static int stdin_sock = -1; + +static void close_stdin_sock(void) +{ + TerminalSocket (TERM_SOCK_DELETE, &stdin_sock); +} + +int fileno_stdin(void) +{ + if (stdin_sock == -1) { + TerminalSocket(TERM_SOCK_CREATE, &stdin_sock); + atexit(close_stdin_sock); + } + + return stdin_sock; +} +#else +int fileno_stdin(void) +{ + return fileno(stdin); +} +#endif + +int fileno_stdout(void) +{ + return fileno(stdout); +} + #if defined(_WIN32) && defined(STD_INPUT_HANDLE) int raw_read_stdin(void *buf, int siz) { @@ -2309,10 +2339,15 @@ int raw_read_stdin(void *buf, int siz) else return (-1); } +#elif defined(__VMS) +int raw_read_stdin(void *buf, int siz) +{ + return recv(fileno_stdin(), buf, siz, 0); +} #else int raw_read_stdin(void *buf, int siz) { - return read(fileno(stdin), buf, siz); + return read(fileno_stdin(), buf, siz); } #endif @@ -2328,7 +2363,7 @@ int raw_write_stdout(const void *buf, int siz) #else int raw_write_stdout(const void *buf, int siz) { - return write(fileno(stdout), buf, siz); + return write(fileno_stdout(), buf, siz); } #endif |