From 219c85249becd19e6b8765c993caf08a4c11bf5d Mon Sep 17 00:00:00 2001
From: John Malmberg <wb8tyw@qsl.net>
Date: Mon, 4 Jan 2016 07:30:19 -0600
Subject: [PATCH] OpenVMS changes needed for 7.46 release

setup-vms.h : HP OpenSSL port missing a routine, case fixup hacks.

build_gnv_curl_pcsi_desc.com: Better fix for installing on VSI OpenVMS.

generate_config_vms_h_curl.com: Disable libraries not yet available.
---
 lib/setup-vms.h                             | 40 +++++++++++++++++++++++++++++
 packages/vms/build_gnv_curl_pcsi_desc.com   | 16 +++++++++---
 packages/vms/generate_config_vms_h_curl.com | 14 +++++++++-
 3 files changed, 65 insertions(+), 5 deletions(-)

diff --git a/lib/setup-vms.h b/lib/setup-vms.h
index 520a35d..0ac95e9 100644
--- a/lib/setup-vms.h
+++ b/lib/setup-vms.h
@@ -355,6 +355,11 @@ char * unix_path;
 #define sk_pop SK_POP
 #define sk_pop_free SK_POP_FREE
 #define sk_value SK_VALUE
+#define ASN1_TIME_print ASN1_TIME_PRINT
+#define BIO_printf BIO_PRINTF
+#define BIO_puts BIO_PUTS
+#define BN_print BN_PRINT
+#define CONF_modules_free CONF_MODULES_FREE
 #ifdef __VAX
 #define OPENSSL_NO_SHA256
 #endif
@@ -439,4 +444,39 @@ char * unix_path;
 #endif
 #endif
 
+#define BIO_write BIO_WRITE
+
+#ifndef __VAX
+#include <openssl/bio.h>
+#define i2a_ASN1_OBJECT hide_i2a_ASN1_OBJECT
+#include <openssl/asn1.h>
+#undef i2a_ASN1_OBJECT
+
+static int i2a_ASN1_OBJECT(BIO *bp, ASN1_OBJECT *a)
+   {
+   char buf[80], *p = buf;
+   int i;
+
+   if ((a == NULL) || (a->data == NULL))
+       return(BIO_write(bp,"NULL",4));
+   i=i2t_ASN1_OBJECT(buf,sizeof buf,a);
+   if (i > (int)(sizeof(buf) - 1))
+       {
+       p = OPENSSL_malloc(i + 1);
+       if (!p)
+           return -1;
+       i2t_ASN1_OBJECT(p,i + 1,a);
+       }
+   if (i <= 0)
+       return BIO_write(bp, "<INVALID>", 9);
+   BIO_write(bp,p,i);
+   if (p != buf)
+       OPENSSL_free(p);
+       return(i);
+   }
+#else
+#define i2a_ASN1_OBJECT I2A_ASN1_OBJECT
+#define CONF_MODULES_FREE()
+#endif
+
 #endif /* HEADER_CURL_SETUP_VMS_H */
diff --git a/packages/vms/build_gnv_curl_pcsi_desc.com b/packages/vms/build_gnv_curl_pcsi_desc.com
index 3b4cd80..3ff7ff9 100644
--- a/packages/vms/build_gnv_curl_pcsi_desc.com
+++ b/packages/vms/build_gnv_curl_pcsi_desc.com
@@ -115,7 +115,6 @@ $ vmsprd = "DEC"
 $ if base .eqs. "I64VMS" then vmsprd = "HP"
 $ vsiprd = "VSI"
 $!
-$ write pdsc "   software ''vmsprd' ''base' VMS ;"
 $ arch_type = f$getsyi("ARCH_NAME")
 $ node_swvers = f$getsyi("node_swvers")
 $ vernum = f$extract(1, f$length(node_swvers), node_swvers)
@@ -128,9 +127,18 @@ $ vmstag = majver + minver + dashver
 $ code = f$extract(0, 1, arch_type)
 $ arch_code = f$extract(0, 1, arch_type)
 $ line_out = -
- "   if ((not <software ''vsiprd' ''base' VMS version minimum" + -
- " ''node_swvers'>) and" + -
- " (not <software ''vmsprd' ''base' VMS version minimum ''node_swvers'>));"
+ "   if ((<software ''vmsprd' ''base' VMS> and"
+$ write pdsc line_out
+$ line_out = -
+ "        (not <software ''vmsprd' ''base' VMS version minimum" + -
+ " ''node_swvers'>)) or"
+$ write pdsc line_out
+$ line_out = -
+ "       (<software ''vsiprd' ''base' VMS>"
+$ write pdsc line_out
+$ line_out = -
+ "        and (not <software ''vsiprd' ''base' VMS version minimum" + -
+ " ''node_swvers'>))) ;"
 $ write pdsc line_out
 $ write pdsc "      error NEED_VMS''vmstag';"
 $ write pdsc "   end if;"
diff --git a/packages/vms/generate_config_vms_h_curl.com b/packages/vms/generate_config_vms_h_curl.com
index 90a83d5..23ab8e9 100644
--- a/packages/vms/generate_config_vms_h_curl.com
+++ b/packages/vms/generate_config_vms_h_curl.com
@@ -346,6 +346,9 @@ $write cvh "#endif"
 $write cvh "#ifdef USE_MANUAL"
 $write cvh "#undef USE_MANUAL"
 $write cvh "#endif"
+$write cvh "#ifdef USE_MBEDTLS"
+$write cvh "#undef USE_MBEDTLS"
+$write cvh "#endif"
 $write cvh "#ifdef USE_NGHTTP2"
 $write cvh "#undef USE_NGHTTP2"
 $write cvh "#endif"
@@ -463,7 +466,6 @@ $   write cvh "#endif"
 $endif
 $!
 $!
-$!
 $if .not. nozlib
 $then
 $   write cvh "#define HAVE_LIBZ 1"
@@ -480,5 +482,15 @@ $write cvh ""
 $write cvh "#endif /* __CONFIG_VMS_H__ */"
 $close cvh
 $!
+$! VAX does not have openssl/ui.h yet.
+$if f$search("openssl:ui.h") .eqs. ""
+$then
+$    create/dir sys$disk:[curl.packages.vms.vax]
+$    open/write sslui_h sys$disk:[curl.packages.vms.vax]ui.h
+$    write sslui_h "#undef HAVE_ENGINE_LOAD_FOUR_ARGS"
+$    close sslui_h
+$    define openssl ssl$include:,sys$disk:[curl.packages.vms.vax]
+$endif
+$!
 $all_exit:
 $exit
-- 
2.1.4

