The branch master has been updated
       via  f3ff481f318b10a223d6157bde9645e1797487c5 (commit)
      from  47852e6ae763a40ddc3538c76a02be06fd0595a5 (commit)


- Log -----------------------------------------------------------------
commit f3ff481f318b10a223d6157bde9645e1797487c5
Author: Richard Levitte <levi...@openssl.org>
Date:   Wed Sep 21 01:47:06 2016 +0200

    VMS: add [.util]shlib_wrap.exe and its build instructions
    
    This is a program for VMS that corresponds to util/shlib_wrap.sh.
    
    Reviewed-by: Rich Salz <rs...@openssl.org>

-----------------------------------------------------------------------

Summary of changes:
 util/build.info                |  10 +++-
 util/shareable_image_wrap.c.in | 113 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 121 insertions(+), 2 deletions(-)
 create mode 100644 util/shareable_image_wrap.c.in

diff --git a/util/build.info b/util/build.info
index 616fbd7..e044d94 100644
--- a/util/build.info
+++ b/util/build.info
@@ -1,2 +1,8 @@
-SCRIPTS_NO_INST=shlib_wrap.sh
-SOURCE[shlib_wrap.sh]=shlib_wrap.sh.in
+IF[{- $target{build_scheme}->[1] eq "VMS" -}]
+ PROGRAMS_NO_INST=shlib_wrap
+ SOURCE[shlib_wrap]=shareable_image_wrap.c
+ GENERATE[shareable_image_wrap.c]=shareable_image_wrap.c.in
+ELSIF[{- $target{build_scheme}->[1] eq "unix" -}]
+ SCRIPTS_NO_INST=shlib_wrap.sh
+ SOURCE[shlib_wrap.sh]=shlib_wrap.sh.in
+ENDIF
diff --git a/util/shareable_image_wrap.c.in b/util/shareable_image_wrap.c.in
new file mode 100644
index 0000000..567e408
--- /dev/null
+++ b/util/shareable_image_wrap.c.in
@@ -0,0 +1,113 @@
+/*
+ * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the OpenSSL license (the "License").  You may not use
+ * this file except in compliance with the License.  You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+/*
+ * This program allows for easy execution of programs in the OpenSSL build
+ * directory, in a manner that's similar to how util/shlib_wrap.sh.  Simply
+ * take the command you want to execute and prefix that with
+ * 'mcr [.util]shlib_wrap', for example:
+ *
+ * $ mcr [.util]shlib_wrap mcr [.apps]openssl s_client -connect 
www.openssl.org:443
+ */
+
+#ifndef __VMS
+# error "VMS ONLY!"
+#endif
+
+#include <stdio.h>
+#include <descrip.h>
+#include <ssdef.h>
+#include <lib$routines.h>
+{-
+    use File::Spec::Functions qw(rel2abs);
+    our $sv = sprintf "%02d%02d", $config{shlib_major}, $config{shlib_minor};
+    our $pz = $config{pointer_size};
+    our $bldd = rel2abs($config{builddir});
+    ""
+-}
+/* The logical name table we check and affect */
+$DESCRIPTOR(lnm_process_table, "LNM$PROCESS_TABLE");
+
+/* The first logical name we deal with, the buffer for its old value,
+ * and its temporary new value
+ */
+const $DESCRIPTOR(lnm1, "OSSL$LIBCRYPTO{- $sv -}_SHR{- $pz -}");
+char lnm1oldbuf[256]; short lnm1oldlen = 0;
+$DESCRIPTOR(lnm1old, lnm1oldbuf);
+const $DESCRIPTOR(lnm1new, "{- $bldd -}OSSL$LIBCRYPTO{- $sv -}_SHR{- $pz 
-}.EXE");
+
+/* The second logical name we deal with, the buffer for its old value,
+ * and its temporary new value
+ */
+const $DESCRIPTOR(lnm2, "OSSL$LIBSSL{- $sv -}_SHR{- $pz -}");
+char lnm2oldbuf[256]; short lnm2oldlen = 0;
+$DESCRIPTOR(lnm2old, lnm2oldbuf);
+const $DESCRIPTOR(lnm2new, "{- $bldd -}OSSL$LIBSSL{- $sv -}_SHR{- $pz -}.EXE");
+
+/* The foreign command we want to run with the logical names above set
+ * to their temporary values
+ */
+char foreign_cmd_buf[4096]; short foreign_cmd_len = 0;
+$DESCRIPTOR(foreign_cmd, foreign_cmd_buf);
+
+int main()
+{
+    int status = 0;
+    int lnm1status = 0, lnm2status = 0;
+
+    /* Fetch the command line.  lib$get_foreign() is nice enough to
+     * strip away the program name, thus only returning the arguments,
+     * which is exactly what we need.
+     */
+    lib$get_foreign(&foreign_cmd, 0, &foreign_cmd_len);
+    foreign_cmd.dsc$w_length = foreign_cmd_len;
+
+#ifdef DEBUG
+    foreign_cmd_buf[foreign_cmd_len] = '\0';
+    printf("[%d] %s\n\n", foreign_cmd_len, foreign_cmd_buf);
+#endif
+
+    /* Fetch the first logical name value and save the status */
+    lnm1status = lib$get_logical(&lnm1, &lnm1old, &lnm1oldlen,
+                                 &lnm_process_table);
+    if (lnm1status == SS$_NORMAL)
+        lnm1old.dsc$w_length = lnm1oldlen;
+    else if (lnm1status != SS$_NOLOGNAM)
+        return lnm1status;
+
+    /* Fetch the first logical name value and save the status */
+    lnm2status = lib$get_logical(&lnm2, &lnm2old, &lnm2oldlen,
+                                 &lnm_process_table);
+    if (lnm2status == SS$_NORMAL)
+        lnm2old.dsc$w_length = lnm2oldlen;
+    else if (lnm2status != SS$_NOLOGNAM)
+        return lnm2status;
+
+    /* Set the temporary new values for both logical names */
+    lib$set_logical(&lnm1, &lnm1new, &lnm_process_table);
+    lib$set_logical(&lnm2, &lnm2new, &lnm_process_table);
+
+    /* Execute the arguments as a command.  The better be a command! */
+    status = lib$spawn(&foreign_cmd);
+
+    /* If the logical names we set had old values, restore them.
+     * Otherwise, simply delete their current values.
+     */
+    if (lnm1status == SS$_NORMAL)
+        lib$set_logical(&lnm1, &lnm1old, &lnm_process_table);
+    else
+        lib$delete_logical(&lnm1, &lnm_process_table);
+    if (lnm2status == SS$_NORMAL)
+        lib$set_logical(&lnm2, &lnm2old, &lnm_process_table);
+    else
+        lib$delete_logical(&lnm2, &lnm_process_table);
+
+    /* Return the status from the execution of the foreign command */
+    return status;
+}
_____
openssl-commits mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-commits

Reply via email to