Fix the return type of felem_is_zero_int which should be int.
[oweals/openssl.git] / apps / s_server.c
index a835db00811db6136d8ce1d71526e10df4ea0a68..98ffc09314a3027a574b5b80c314dc713eabbf15 100644 (file)
@@ -197,11 +197,6 @@ typedef unsigned int u_int;
 #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
@@ -333,9 +328,7 @@ static char *keymatexportlabel = NULL;
 static int keymatexportlen = 20;
 
 static int hack = 0;
-#ifndef OPENSSL_NO_ENGINE
 static char *engine_id = NULL;
-#endif
 static const char *session_id_prefix = NULL;
 
 static int enable_timeouts = 0;
@@ -489,9 +482,7 @@ static void s_server_init(void)
     s_quiet = 0;
     s_brief = 0;
     hack = 0;
-# ifndef OPENSSL_NO_ENGINE
     engine_id = NULL;
-# endif
 }
 #endif
 
@@ -1608,9 +1599,7 @@ int MAIN(int argc, char *argv[])
     SSL_load_error_strings();
     OpenSSL_add_ssl_algorithms();
 
-#ifndef OPENSSL_NO_ENGINE
     e = setup_engine(bio_err, engine_id, 1);
-#endif
 
     if (!app_passwd(bio_err, passarg, dpassarg, &pass, &dpass)) {
         BIO_printf(bio_err, "Error getting password\n");
@@ -2134,6 +2123,7 @@ int MAIN(int argc, char *argv[])
     if (jpake_secret && psk_key)
         OPENSSL_free(psk_key);
 #endif
+    release_engine(e);
     if (bio_s_out != NULL) {
         BIO_free(bio_s_out);
         bio_s_out = NULL;
@@ -2142,6 +2132,7 @@ int MAIN(int argc, char *argv[])
         BIO_free(bio_s_msg);
         bio_s_msg = NULL;
     }
+    SSL_COMP_free_compression_methods();
     apps_shutdown();
     OPENSSL_EXIT(ret);
 }
@@ -2192,10 +2183,6 @@ static int sv_body(char *hostname, 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
 
     if ((buf = OPENSSL_malloc(bufsize)) == NULL) {
         BIO_printf(bio_err, "out of memory\n");
@@ -2203,19 +2190,7 @@ static int sv_body(char *hostname, int s, int stype, unsigned char *context)
     }
 #ifdef FIONBIO
     if (s_nbio) {
-#    if defined(OPENSSL_SYS_VMS) && defined(__VMS_VER) && (__VMS_VER >= 70000000)               
-        /* For 64-bit --> 32-bit restricted APIs (IOCTL) */             
-#       if __INITIAL_POINTER_SIZE == 64                 
-#           pragma __required_pointer_size __save               
-#           pragma __required_pointer_size 32           
-#   endif               
-        unsigned int sl =1; 
-#       if __INITIAL_POINTER_SIZE == 64                 
-#           pragma __required_pointer_size __restore            
-#       endif           
-#    else               
         unsigned long sl = 1;
-#    endif /* OPENSSL_SYS_VMS */
 
         if (!s_quiet)
             BIO_printf(bio_err, "turning on non blocking io\n");
@@ -2328,15 +2303,10 @@ static int sv_body(char *hostname, int s, int stype, unsigned char *context)
     }
 #endif
 
-
-#if defined(OPENSSL_SYS_VMS)   
-        if (stdin_sock > s)    
-            width = stdin_sock + 1;             
-    else                       
-        width=s+1;             
-#else                 
-    width=s+1;                 
-#endif
+    if (fileno_stdin() > s)
+        width = fileno_stdin() + 1;
+    else
+        width = s + 1;
     for (;;) {
         int read_from_terminal;
         int read_from_sslcon;
@@ -2347,11 +2317,7 @@ static int sv_body(char *hostname, int s, int stype, unsigned char *context)
         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(stdin),&readfds);
-    #endif
+            openssl_fdset(fileno_stdin(), &readfds);
 #endif
             openssl_fdset(s, &readfds);
             /*
@@ -2379,13 +2345,13 @@ static int sv_body(char *hostname, int s, int stype, unsigned char *context)
             /* 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))
@@ -2402,11 +2368,7 @@ static int sv_body(char *hostname, int s, int stype, unsigned char *context)
 
             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))
@@ -2416,12 +2378,8 @@ static int sv_body(char *hostname, int s, int stype, unsigned char *context)
             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;
+                i = raw_read_stdin(buf, bufsize / 2);
+                lf_num = 0;
                 /* both loops are skipped when i <= 0 */
                 for (j = 0; j < i; j++)
                     if (buf[j] == '\n')
@@ -2436,11 +2394,8 @@ static int sv_body(char *hostname, int s, int stype, unsigned char *context)
                 }
                 assert(lf_num == 0);
             } else
-#if defined(OPENSSL_SYS_VMS)            
-                                i=recv(stdin_sock,buf,bufsize, 0);
-#else
-                               i = raw_read_stdin(buf, bufsize);
-#endif 
+                i = raw_read_stdin(buf, bufsize);
+
             if (!s_quiet && !s_brief) {
                 if ((i <= 0) || (buf[0] == 'Q')) {
                     BIO_printf(bio_s_out, "DONE\n");
@@ -2521,7 +2476,7 @@ static int sv_body(char *hostname, int s, int stype, unsigned char *context)
                     srp_callback_parm.user =
                         SRP_VBASE_get1_by_user(srp_callback_parm.vb,
                                                srp_callback_parm.login);
-                     if (srp_callback_parm.user)
+                    if (srp_callback_parm.user)
                         BIO_printf(bio_s_out, "LOOKUP done %s\n",
                                    srp_callback_parm.user->info);
                     else
@@ -2630,9 +2585,6 @@ static int sv_body(char *hostname, int s, int stype, unsigned char *context)
     }
     if (ret >= 0)
         BIO_printf(bio_s_out, "ACCEPT\n");
-#if defined(OPENSSL_SYS_VMS)            
-        TerminalSocket (TERM_SOCK_DELETE, &stdin_sock);                 
-#endif
     return (ret);
 }
 
@@ -2850,20 +2802,8 @@ static int www_body(char *hostname, int s, int stype, unsigned char *context)
 
 #ifdef FIONBIO
     if (s_nbio) {
+        unsigned long sl = 1;
 
-#    if defined(OPENSSL_SYS_VMS) && defined(__VMS_VER) && (__VMS_VER >= 70000000)               
-        /* For 64-bit --> 32-bit restricted APIs (IOCTL) */             
-#       if __INITIAL_POINTER_SIZE == 64                 
-#           pragma __required_pointer_size __save               
-#           pragma __required_pointer_size 32           
-#   endif               
-        unsigned int sl ;
-#       if __INITIAL_POINTER_SIZE == 64                 
-#           pragma __required_pointer_size __restore            
-#       endif           
-#    else               
-        unsigned long sl=1;             
-#    endif /* OPENSSL_SYS_VMS */
         if (!s_quiet)
             BIO_printf(bio_err, "turning on non blocking io\n");
         if (BIO_socket_ioctl(s, FIONBIO, &sl) < 0)
@@ -3077,7 +3017,7 @@ static int www_body(char *hostname, int s, int stype, unsigned char *context)
                 PEM_write_bio_X509(io, peer);
             } else
                 BIO_puts(io, "no client certificate available\n");
-            BIO_puts(io, "</BODY></HTML>\r\n\r\n");
+            BIO_puts(io, "</pre></BODY></HTML>\r\n\r\n");
             break;
         } else if ((www == 2 || www == 3)
                    && (strncmp("GET /", buf, 5) == 0)) {