#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
int app_isdir(const char *);
int app_access(const char *, int flag);
+int fileno_stdin(void);
+int fileno_stdout(void);
int raw_read_stdin(void *, int);
int raw_write_stdout(const void *, int);
#ifndef OPENSSL_NO_SOCK
-#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 c_nbio = 0, c_msg = 0, c_ign_eof = 0, c_brief = 0;
int c_tlsextdebug = 0, c_status_req = 0;
BIO *bio_c_msg = NULL;
-#if defined(OPENSSL_SYS_VMS)
- int stdin_sock;
- TerminalSocket(TERM_SOCK_CREATE, &stdin_sock);
-#endif
FD_ZERO(&readfds);
FD_ZERO(&writefds);
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;
* and EOF satisfies that. To avoid a CPU-hogging loop,
* set the flag so we exit.
*/
-#if defined(OPENSSL_SYS_VMS)
- if (read_tty && !at_eof)
- openssl_fdset(stdin_sock, &readfds);
-#else
if (read_tty && !at_eof)
- 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)
/* 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
/* OPENSSL_SYS_MSDOS includes OPENSSL_SYS_WINDOWS */
#if defined(OPENSSL_SYS_MSDOS)
else if (has_stdin_waiting())
-#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 !defined(OPENSSL_SYS_WINDOWS) && !defined(OPENSSL_SYS_MSDOS)
if (i == 0)
at_eof = 1;
bio_c_out = NULL;
BIO_free(bio_c_msg);
bio_c_msg = NULL;
-#if defined(OPENSSL_SYS_VMS)
- TerminalSocket(TERM_SOCK_DELETE, &stdin_sock);
-#endif
return (ret);
}
#include <openssl/ebcdic.h>
#endif
-#ifdef OPENSSL_SYS_VMS
-# include "vms_term_sock.h"
-#endif
-
-
static int not_resumable_sess_cb(SSL *s, int is_forward_secure);
static int sv_body(int s, int stype, unsigned char *context);
static int www_body(int s, int stype, unsigned char *context);
#else
struct timeval *timeoutp;
#endif
-#if defined(OPENSSL_SYS_VMS)
- int stdin_sock;
- TerminalSocket (TERM_SOCK_CREATE, &stdin_sock);
-#endif
buf = app_malloc(bufsize, "server buffer");
if (s_nbio) {
SSL_set_tlsext_debug_arg(con, bio_s_out);
}
-
-#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)
-# 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);
/*
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");
OPENSSL_clear_free(buf, bufsize);
if (ret >= 0)
BIO_printf(bio_s_out, "ACCEPT\n");
-#if defined(OPENSSL_SYS_VMS)
- TerminalSocket (TERM_SOCK_DELETE, &stdin_sock);
-#endif
(void)BIO_flush(bio_s_out);
return (ret);
}