#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)
{
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
#else
int raw_write_stdout(const void *buf, int siz)
{
- return write(fileno(stdout), buf, siz);
+ return write(fileno_stdout(), buf, siz);
}
#endif
# define SERIAL_RAND_BITS 64
int app_isdir(const char *);
+int fileno_stdin(void);
+int fileno_stdout(void);
int raw_read_stdin(void *, int);
int raw_write_stdout(const void *, int);
# 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
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();
#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);
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;
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)
/* 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;
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);
/* 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
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++)
}
}
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;
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);
}
#include "s_apps.h"
#include "timeouts.h"
-#ifdef OPENSSL_SYS_VMS
-# include "vms_term_sock.h"
-#endif
-
-
#if (defined(OPENSSL_SYS_VMS) && __VMS_VER < 70000000)
/* FIONBIO used as a switch to enable ioctl, and that isn't in VMS < 7.0 */
# undef FIONBIO
#else
struct timeval *timeoutp;
#endif
-#if defined(OPENSSL_SYS_VMS)
- int stdin_sock;
- TerminalSocket (TERM_SOCK_CREATE, &stdin_sock);
-#endif
if ((buf = OPENSSL_malloc(bufsize)) == NULL) {
BIO_printf(bio_err, "out of memory\n");
}
#endif
-
-#if defined(OPENSSL_SYS_VMS)
- if (stdin_sock > s)
- width = stdin_sock + 1;
+ if (fileno_stdin() > s)
+ width = fileno_stdin() + 1;
else
width = s + 1;
-#else
- width = s + 1;
-#endif
for (;;) {
int read_from_terminal;
int read_from_sslcon;
if (!read_from_sslcon) {
FD_ZERO(&readfds);
#if !defined(OPENSSL_SYS_WINDOWS) && !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_NETWARE) && !defined(OPENSSL_SYS_BEOS_R5)
-# if defined(OPENSSL_SYS_VMS)
- openssl_fdset(stdin_sock, &readfds);
-# else
- openssl_fdset(fileno(stdin), &readfds);
-# endif
+ openssl_fdset(fileno_stdin(), &readfds);
#endif
openssl_fdset(s, &readfds);
/*
/* Under BeOS-R5 the situation is similar to DOS */
tv.tv_sec = 1;
tv.tv_usec = 0;
- (void)fcntl(fileno(stdin), F_SETFL, O_NONBLOCK);
+ (void)fcntl(fileno_stdin(), F_SETFL, O_NONBLOCK);
i = select(width, (void *)&readfds, NULL, NULL, &tv);
- if ((i < 0) || (!i && read(fileno(stdin), buf, 0) < 0))
+ if ((i < 0) || (!i && read(fileno_stdin(), buf, 0) < 0))
continue;
- if (read(fileno(stdin), buf, 0) >= 0)
+ if (read(fileno_stdin(), buf, 0) >= 0)
read_from_terminal = 1;
- (void)fcntl(fileno(stdin), F_SETFL, 0);
+ (void)fcntl(fileno_stdin(), F_SETFL, 0);
#else
if ((SSL_version(con) == DTLS1_VERSION) &&
DTLSv1_get_timeout(con, &timeout))
if (i <= 0)
continue;
-# if defined(OPENSSL_SYS_VMS)
- if (FD_ISSET(stdin_sock, &readfds))
-# else
- if (FD_ISSET(fileno(stdin), &readfds))
-# endif
+ if (FD_ISSET(fileno_stdin(), &readfds))
read_from_terminal = 1;
#endif
if (FD_ISSET(s, &readfds))
if (s_crlf) {
int j, lf_num;
-#if defined(OPENSSL_SYS_VMS)
- i=recv(stdin_sock, buf, bufsize / 2, 0);
-#else
i = raw_read_stdin(buf, bufsize / 2);
-#endif
lf_num = 0;
/* both loops are skipped when i <= 0 */
for (j = 0; j < i; j++)
}
}
assert(lf_num == 0);
- } else {
-#if defined(OPENSSL_SYS_VMS)
- i = recv(stdin_sock, buf, bufsize, 0);
-#else
+ } else
i = raw_read_stdin(buf, bufsize);
-#endif
- }
+
if (!s_quiet && !s_brief) {
if ((i <= 0) || (buf[0] == 'Q')) {
BIO_printf(bio_s_out, "DONE\n");
}
if (ret >= 0)
BIO_printf(bio_s_out, "ACCEPT\n");
-#if defined(OPENSSL_SYS_VMS)
- TerminalSocket (TERM_SOCK_DELETE, &stdin_sock);
-#endif
return (ret);
}