* [including the GNU Public Licence.]
*/
-#ifdef APPS_CRLF
-# include <assert.h>
-#endif
+#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <openssl/ssl.h>
#include "s_apps.h"
+#ifdef WINDOWS
+#include <conio.h>
+#endif
+
#if (defined(VMS) && __VMS_VER < 70000000)
/* FIONBIO used as a switch to enable ioctl, and that isn't in VMS < 7.0 */
#undef FIONBIO
static DH *load_dh_param(void );
static DH *get_dh512(void);
#endif
-/* static void s_server_init(void);*/
+#ifdef MONOLITH
+static void s_server_init(void);
+#endif
#ifndef S_ISDIR
# if defined(_S_IFMT) && defined(_S_IFDIR)
static int s_nbio=0;
#endif
static int s_nbio_test=0;
-#ifdef APPS_CRLF
- int s_crlf=0;
-#endif
+int s_crlf=0;
static SSL_CTX *ctx=NULL;
static int www=0;
static int s_debug=0;
static int s_quiet=0;
-#if 0
+static int hack=0;
+
+#ifdef MONOLITH
static void s_server_init(void)
{
+ accept_socket=-1;
cipher=NULL;
s_server_verify=SSL_VERIFY_NONE;
s_dcert_file=NULL;
bio_s_out=NULL;
s_debug=0;
s_quiet=0;
+ hack=0;
}
#endif
BIO_printf(bio_err," -nbio - Run with non-blocking IO\n");
#endif
BIO_printf(bio_err," -nbio_test - test with the non-blocking test bio\n");
-#ifdef APPS_CRLF
BIO_printf(bio_err," -crlf - convert LF from terminal into CRLF\n");
-#endif
BIO_printf(bio_err," -debug - Print more output\n");
BIO_printf(bio_err," -state - Print the SSL states\n");
BIO_printf(bio_err," -CApath arg - PEM format directory of CA's\n");
static int local_argc=0;
static char **local_argv;
-static int hack=0;
#ifdef CHARSET_EBCDIC
static int ebcdic_new(BIO *bi);
local_argv=argv;
apps_startup();
- s_quiet=0;
- s_debug=0;
+#ifdef MONOLITH
+ s_server_init();
+#endif
if (bio_err == NULL)
bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
{ hack=1; }
else if (strcmp(*argv,"-state") == 0)
{ state=1; }
-#ifdef APPS_CRLF
else if (strcmp(*argv,"-crlf") == 0)
{ s_crlf=1; }
-#endif
else if (strcmp(*argv,"-quiet") == 0)
{ s_quiet=1; }
else if (strcmp(*argv,"-bugs") == 0)
SSL_CTX_set_session_id_context(ctx,(void*)&s_server_session_id_context,
sizeof s_server_session_id_context);
- SSL_CTX_set_client_CA_list(ctx,SSL_load_client_CA_file(CAfile));
+ if (CAfile != NULL)
+ SSL_CTX_set_client_CA_list(ctx,SSL_load_client_CA_file(CAfile));
BIO_printf(bio_s_out,"ACCEPT\n");
if (www)
unsigned long l;
SSL *con=NULL;
BIO *sbio;
+#ifdef WINDOWS
+ struct timeval tv;
+#endif
if ((buf=Malloc(bufsize)) == NULL)
{
* the compiler: if you do have a cast then you can either
* go for (int *) or (void *).
*/
- i=select(width,(void *)&readfds,NULL,NULL,NULL);
- if (i <= 0) continue;
- if (FD_ISSET(fileno(stdin),&readfds))
+#ifdef WINDOWS
+ /* Under Windows we can't select on stdin: only
+ * on sockets. As a workaround we timeout the select every
+ * second and check for any keypress. In a proper Windows
+ * application we wouldn't do this because it is inefficient.
+ */
+ tv.tv_sec = 1;
+ tv.tv_usec = 0;
+ i=select(width,(void *)&readfds,NULL,NULL,&tv);
+ if((i < 0) || (!i && !_kbhit() ) )continue;
+ if(_kbhit())
+#else
+ i=select(width,(void *)&readfds,NULL,NULL,NULL);
+ if (i <= 0) continue;
+ if (FD_ISSET(fileno(stdin),&readfds))
+#endif
{
-#ifdef APPS_CRLF
if (s_crlf)
{
int j, lf_num;
assert(lf_num == 0);
}
else
-#endif
i=read(fileno(stdin),buf,bufsize);
if (!s_quiet)
{