Fix no-sock

Misc fixes for no-sock

Reviewed-by: Richard Levitte <levitte@openssl.org>
diff --git a/apps/apps.c b/apps/apps.c
index 694d090..b430742 100644
--- a/apps/apps.c
+++ b/apps/apps.c
@@ -640,7 +640,7 @@
     return ret;
 }
 
-#ifndef OPENSSL_NO_OCSP
+#if !defined(OPENSSL_NO_OCSP) && !defined(OPENSSL_NO_SOCK)
 static int load_cert_crl_http(const char *url, X509 **pcert, X509_CRL **pcrl)
 {
     char *host = NULL, *port = NULL, *path = NULL;
@@ -695,7 +695,7 @@
     BIO *cert;
 
     if (format == FORMAT_HTTP) {
-#ifndef OPENSSL_NO_OCSP
+#if !defined(OPENSSL_NO_OCSP) && !defined(OPENSSL_NO_SOCK)
         load_cert_crl_http(file, &x, NULL);
 #endif
         return x;
@@ -736,7 +736,7 @@
     BIO *in = NULL;
 
     if (format == FORMAT_HTTP) {
-#ifndef OPENSSL_NO_OCSP
+#if !defined(OPENSSL_NO_OCSP) && !defined(OPENSSL_NO_SOCK)
         load_cert_crl_http(infile, NULL, &x);
 #endif
         return x;
diff --git a/apps/ocsp.c b/apps/ocsp.c
index dc2a11f..574ed8c 100644
--- a/apps/ocsp.c
+++ b/apps/ocsp.c
@@ -117,10 +117,13 @@
 static BIO *init_responder(const char *port);
 static int do_responder(OCSP_REQUEST **preq, BIO **pcbio, BIO *acbio);
 static int send_ocsp_response(BIO *cbio, OCSP_RESPONSE *resp);
+
+# ifndef OPENSSL_NO_SOCK
 static OCSP_RESPONSE *query_responder(BIO *cbio, const char *host,
                                       const char *path,
                                       const STACK_OF(CONF_VALUE) *headers,
                                       OCSP_REQUEST *req, int req_timeout);
+# endif
 
 typedef enum OPTION_choice {
     OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
@@ -244,7 +247,10 @@
     int noCAfile = 0, noCApath = 0;
     int accept_count = -1, add_nonce = 1, noverify = 0, use_ssl = -1;
     int vpmtouched = 0, badsig = 0, i, ignore_err = 0, nmin = 0, ndays = -1;
-    int req_text = 0, resp_text = 0, req_timeout = -1, ret = 1;
+    int req_text = 0, resp_text = 0, ret = 1;
+#ifndef OPENSSL_NO_SOCK
+    int req_timeout = -1;
+#endif
     long nsec = MAX_VALIDITY_PERIOD, maxage = -1;
     unsigned long sign_flags = 0, verify_flags = 0, rflags = 0;
     OPTION_CHOICE o;
@@ -275,7 +281,9 @@
             outfile = opt_arg();
             break;
         case OPT_TIMEOUT:
+#ifndef OPENSSL_NO_SOCK
             req_timeout = atoi(opt_arg());
+#endif
             break;
         case OPT_URL:
             OPENSSL_free(thost);
@@ -1170,6 +1178,7 @@
     return 1;
 }
 
+# ifndef OPENSSL_NO_SOCK
 static OCSP_RESPONSE *query_responder(BIO *cbio, const char *host,
                                       const char *path,
                                       const STACK_OF(CONF_VALUE) *headers,
@@ -1300,5 +1309,6 @@
     SSL_CTX_free(ctx);
     return resp;
 }
+# endif
 
 #endif
diff --git a/apps/s_cb.c b/apps/s_cb.c
index 66b2a50..b75ff31 100644
--- a/apps/s_cb.c
+++ b/apps/s_cb.c
@@ -131,8 +131,10 @@
 int verify_quiet = 0;
 int verify_error = X509_V_OK;
 int verify_return_error = 0;
+#ifndef OPENSSL_NO_SOCK
 static unsigned char cookie_secret[COOKIE_SECRET_LENGTH];
 static int cookie_initialized = 0;
+#endif
 
 static const char *lookup(int val, const STRINT_PAIR* list, const char* def)
 {
@@ -741,6 +743,7 @@
     (void)BIO_flush(bio);
 }
 
+#ifndef OPENSSL_NO_SOCK
 int generate_cookie_callback(SSL *ssl, unsigned char *cookie,
                              unsigned int *cookie_len)
 {
@@ -803,6 +806,7 @@
 
     return 0;
 }
+#endif
 
 /*
  * Example of extended certificate handling. Where the standard support of
diff --git a/apps/s_client.c b/apps/s_client.c
index 6f22e6e..5b4cd48 100644
--- a/apps/s_client.c
+++ b/apps/s_client.c
@@ -141,6 +141,8 @@
 #include <errno.h>
 #include <openssl/e_os2.h>
 
+#ifndef OPENSSL_NO_SOCK
+
 /*
  * With IPv6, it looks like Digital has mixed up the proper order of
  * recursive header file inclusion, resulting in the compiler complaining
@@ -2757,3 +2759,5 @@
     OCSP_RESPONSE_free(rsp);
     return 1;
 }
+
+#endif
diff --git a/apps/s_server.c b/apps/s_server.c
index e660eec..b33d768 100644
--- a/apps/s_server.c
+++ b/apps/s_server.c
@@ -147,6 +147,8 @@
 
 #include <openssl/e_os2.h>
 
+#ifndef OPENSSL_NO_SOCK
+
 /*
  * With IPv6, it looks like Digital has mixed up the proper order of
  * recursive header file inclusion, resulting in the compiler complaining
@@ -3363,3 +3365,5 @@
     }
     first = NULL;
 }
+
+#endif
diff --git a/apps/s_socket.c b/apps/s_socket.c
index 00556bc..4653217 100644
--- a/apps/s_socket.c
+++ b/apps/s_socket.c
@@ -109,6 +109,7 @@
 #include <string.h>
 #include <errno.h>
 #include <signal.h>
+#include <openssl/opensslconf.h>
 
 /*
  * With IPv6, it looks like Digital has mixed up the proper order of
diff --git a/apps/s_time.c b/apps/s_time.c
index f68002a..6890bc1 100644
--- a/apps/s_time.c
+++ b/apps/s_time.c
@@ -66,6 +66,10 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include <openssl/opensslconf.h>
+
+#ifndef OPENSSL_NO_SOCK
+
 #define USE_SOCKETS
 #include "apps.h"
 #include <openssl/x509.h>
@@ -474,3 +478,4 @@
 
     return serverCon;
 }
+#endif /* OPENSSL_NO_SOCK */