diff options
author | Richard Levitte <levitte@openssl.org> | 2016-09-15 09:45:57 +0200 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2016-09-15 23:23:06 +0200 |
commit | d6d04b64f5a98ebc07b3f529830724e4fb443708 (patch) | |
tree | 4b0e1be442be282d940908365880dda7f13b7dc6 /apps/s_client.c | |
parent | b50826727e77f2736fc2cf5b4a4f646ee0d67182 (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/s_client.c')
-rw-r--r-- | apps/s_client.c | 55 |
1 files changed, 13 insertions, 42 deletions
diff --git a/apps/s_client.c b/apps/s_client.c index c87451ff3f..41a326fbb8 100644 --- a/apps/s_client.c +++ b/apps/s_client.c @@ -145,9 +145,6 @@ # define APPS_WIN16 #endif -#ifdef OPENSSL_SYS_VMS -# include "vms_term_sock.h" -#endif /* * With IPv6, it looks like Digital has mixed up the proper order of * recursive header file inclusion, resulting in the compiler complaining @@ -748,10 +745,6 @@ int MAIN(int argc, char **argv) int crl_download = 0; STACK_OF(X509_CRL) *crls = NULL; int prot_opt = 0, no_prot_opt = 0; -#if defined(OPENSSL_SYS_VMS) - int stdin_sock; - TerminalSocket(TERM_SOCK_CREATE, &stdin_sock); -#endif meth = SSLv23_client_method(); @@ -1465,7 +1458,6 @@ int MAIN(int argc, char **argv) #ifdef FIONBIO if (c_nbio) { unsigned long l = 1; - BIO_printf(bio_c_out, "turning on non blocking io\n"); if (BIO_socket_ioctl(s, FIONBIO, &l) < 0) { ERR_print_errors(bio_err); @@ -1569,14 +1561,11 @@ int MAIN(int argc, char **argv) SSL_set_connect_state(con); /* ok, lets connect */ -#if defined(OPENSSL_SYS_VMS) - if (stdin_sock > SSL_get_fd(con)) - width = stdin_sock + 1; + if (fileno_stdin() > SSL_get_fd(con)) + width = fileno_stdin() + 1; else width = SSL_get_fd(con) + 1; -#else - width = SSL_get_fd(con) + 1; -#endif + read_tty = 1; write_tty = 0; tty_on = 0; @@ -1757,15 +1746,11 @@ int MAIN(int argc, char **argv) if (!ssl_pending) { #if !defined(OPENSSL_SYS_WINDOWS) && !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_NETWARE) && !defined (OPENSSL_SYS_BEOS_R5) if (tty_on) { - -#if defined(OPENSSL_SYS_VMS) - if (read_tty) - openssl_fdset(stdin_sock, &readfds); -#else if (read_tty) - openssl_fdset(fileno(stdin), &readfds); + openssl_fdset(fileno_stdin(), &readfds); +#if !defined(OPENSSL_SYS_VMS) if (write_tty) - openssl_fdset(fileno(stdout), &writefds); + openssl_fdset(fileno_stdout(), &writefds); #endif } if (read_ssl) @@ -1836,14 +1821,14 @@ int MAIN(int argc, char **argv) /* Under BeOS-R5 the situation is similar to DOS */ i = 0; stdin_set = 0; - (void)fcntl(fileno(stdin), F_SETFL, O_NONBLOCK); + (void)fcntl(fileno_stdin(), F_SETFL, O_NONBLOCK); if (!write_tty) { if (read_tty) { tv.tv_sec = 1; tv.tv_usec = 0; i = select(width, (void *)&readfds, (void *)&writefds, NULL, &tv); - if (read(fileno(stdin), sbuf, 0) >= 0) + if (read(fileno_stdin(), sbuf, 0) >= 0) stdin_set = 1; if (!i && (stdin_set != 1 || !read_tty)) continue; @@ -1851,7 +1836,7 @@ int MAIN(int argc, char **argv) i = select(width, (void *)&readfds, (void *)&writefds, NULL, timeoutp); } - (void)fcntl(fileno(stdin), F_SETFL, 0); + (void)fcntl(fileno_stdin(), F_SETFL, 0); #else i = select(width, (void *)&readfds, (void *)&writefds, NULL, timeoutp); @@ -1931,7 +1916,7 @@ int MAIN(int argc, char **argv) /* Assume Windows/DOS/BeOS can always write */ else if (!ssl_pending && write_tty) #else - else if (!ssl_pending && FD_ISSET(fileno(stdout), &writefds)) + else if (!ssl_pending && FD_ISSET(fileno_stdout(), &writefds)) #endif { #ifdef CHARSET_EBCDIC @@ -2028,21 +2013,14 @@ int MAIN(int argc, char **argv) else if (_kbhit()) #elif defined(OPENSSL_SYS_BEOS_R5) else if (stdin_set) -#elif defined(OPENSSL_SYS_VMS) - else if (FD_ISSET(stdin_sock, &readfds)) #else - else if (FD_ISSET(fileno(stdin), &readfds)) + else if (FD_ISSET(fileno_stdin(), &readfds)) #endif { if (crlf) { int j, lf_num; -#if defined(OPENSSL_SYS_VMS) - i = recv(stdin_sock, cbuf, BUFSIZZ / 2, 0); -#else i = raw_read_stdin(cbuf, BUFSIZZ / 2); -#endif - lf_num = 0; /* both loops are skipped when i <= 0 */ for (j = 0; j < i; j++) @@ -2057,13 +2035,9 @@ int MAIN(int argc, char **argv) } } assert(lf_num == 0); - } else { -#if defined(OPENSSL_SYS_VMS) - i = recv(stdin_sock, cbuf, BUFSIZZ, 0); -#else + } else i = raw_read_stdin(cbuf, BUFSIZZ); -#endif - } + if ((!c_ign_eof) && ((i <= 0) || (cbuf[0] == 'Q'))) { BIO_printf(bio_err, "DONE\n"); ret = 0; @@ -2157,9 +2131,6 @@ int MAIN(int argc, char **argv) BIO_free(bio_c_msg); bio_c_msg = NULL; } -#if defined(OPENSSL_SYS_VMS) - TerminalSocket(TERM_SOCK_DELETE, &stdin_sock); -#endif apps_shutdown(); OPENSSL_EXIT(ret); } |