openvms: Link tests with the shared image of the library

$!
$! Copyright 2014, John Malmberg
$! Copyright 2016, Alexander Saprykin
$!
$! Permission to use, copy, modify, and/or distribute this software for any
$! purpose with or without fee is hereby granted, provided that the above
$! copyright notice and this permission notice appear in all copies.
$!
$! THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
$! WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
$! MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
$! ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
$! WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
$! ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
$! OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
$!
$!===========================================================================
$! Command-line options:
$!
$!    32            Compile with 32-bit pointers.
$!    CCQUAL=x      Add "x" to the C compiler qualifiers.
$!    DEBUG         Build in debug mode.
$!    CLEAN         Only perform clean after the previous build.
$!    TESTS=(x)     Build library tests. Comma separated test names or leave
$!                  empty to build all the tests.
$!                  Example 1 (curtain tests): TESTS=(pmem_test,puthread_test)
$!                  Example 2 (all tests): TESTS
$!    BOOST_ROOT=x  Boost root directory.
$!                  Example: BOOST_ROOT=/SYS$COMMON/boost_1_43_1
$!    NOLIB         Skip library buidling. Useful when you want to rebuild
$!                  particular tests.
$!===========================================================================
$!
$!
$! Save the original default dev:[dir], and arrange for its restoration
$! at exit.
$!---------------------------------------------------------------------
$ orig_def = f$environment("DEFAULT")
$ on error then goto common_exit
$ on control_y then goto common_exit
$!
$ ctrl_y       = 1556
$ proc         = f$environment("PROCEDURE")
$ proc_fid     = f$file_attributes(proc, "FID")
$ proc_dev     = f$parse(proc, , , "DEVICE")
$ proc_dir     = f$parse(proc, , , "DIRECTORY")
$ proc_name    = f$parse(proc, , , "NAME")
$ proc_type    = f$parse(proc, , , "TYPE")
$ proc_dev_dir = proc_dev + proc_dir
$!
$! Have to manually parse the device for a search list.
$! Can not use the f$parse() as it will return the first name
$! in the search list.
$!
$ orig_def_dev = f$element(0, ":", orig_def) + ":"
$ if orig_def_dev .eqs. "::" then orig_def_dev = "sys$disk:"
$ test_proc = orig_def_dev + proc_dir + proc_name + proc_type
$!
$! If we can find this file using the default directory
$! then we know that we should use the original device from the
$! default directory which could be a search list.
$!
$ test_proc_fid = f$file_attributes(test_proc, "FID")
$!
$ if (test_proc_fid .eq. proc_fid)
$ then
$     proc_dev_dir = orig_def_dev + proc_dir
$ endif
$!
$! Verbose output message stuff. Define symbol to "write sys$output".
$! vo_c - verbose output for compile
$!
$ vo_c := "write sys$output"
$!
$! Determine the main distribution directory ("[--]") in an
$! ODS5-tolerant (case-insensitive) way.  (We do assume that the only
$! "]" or ">" is the one at the end.)
$!
$! Some non-US VMS installations report ">" for the directory delimiter
$! so do not assume that it is "]".
$!
$ orig_def_len = f$length(orig_def)
$ delim = f$extract(orig_def_len - 1, 1, orig_def)
$!
$ set default 'proc_dev_dir'
$ set default [--.src]
$ base_src_dir = f$environment("default")
$ set default 'proc_dev_dir'
$!
$! Define the architecture-specific destination directory name
$! -----------------------------------------------------------
$!
$ if (f$getsyi("HW_MODEL") .lt. 1024)
$ then
$      'vo_c' "%PLIBSYS-F-NOTSUP, VAX platform is not supported, sorry :("
$      goto common_exit
$ else
$      arch_name = ""
$      arch_name = arch_name + f$edit(f$getsyi("ARCH_NAME"), "UPCASE")
$!
$      if (arch_name .eqs. "") then arch_name = "UNK"
$!
$      node_swvers   = f$getsyi("node_swvers")
$      version_patch = f$extract(1, f$length(node_swvers), node_swvers)
$      maj_ver       = f$element(0, ".", version_patch)
$      min_ver_patch = f$element(1, ".", version_patch)
$      min_ver       = f$element(0, "-", min_ver_patch)
$      patch         = f$element(1, "-", min_ver_patch)
$!
$      if maj_ver .lts. "8" .or. min_ver .lts. "4"
$      then
$          'vo_c' "%PLIBSYS-F-NOTSUP, only OpenVMS 8.4 and above are supported, sorry :("
$          goto common_exit
$      endif
$ endif
$!
$ objdir = proc_dev_dir - delim + ".''arch_name'" + delim
$!
$! Parse input arguments
$! ---------------------
$! Allow arguments to be grouped together with comma or separated by spaces
$! Do no know if we will need more than 8.
$ args = "," + p1 + "," + p2 + "," + p3 + "," + p4 + ","
$ args = args + p5 + "," + p6 + "," + p7 + "," + p8 + ","
$!
$! Provide lower case version to simplify parsing.
$ args_lower = f$edit(args, "LOWERCASE,COLLAPSE")
$!
$ args_len = f$length(args)
$ args_lower_len = f$length(args_lower)
$!
$ if f$locate(",clean,", args_lower) .lt. args_lower_len
$ then
$     'vo_c' "Cleaning up previous build..."
$     set default 'proc_dev_dir'
$     @deltree.com 'arch_name'
$     goto common_exit
$ endif
$!
$ build_64 = 1
$ if f$locate(",32,", args_lower) .lt. args_lower_len
$ then
$     build_64 = 0
$ endif
$!
$ cc_extra = ""
$ args_loc = f$locate(",ccqual=", args_lower)
$ if args_loc .lt. args_lower_len
$ then
$     arg = f$extract(args_loc + 1, args_lower_len, args_lower)
$     arg_val = f$element(0, ",", arg)
$     cc_extra = f$element(1, "=", arg_val)
$ endif
$!
$ is_debug = 0
$ if f$locate(",debug,", args_lower) .lt. args_lower_len
$ then
$     is_debug = 1
$ endif
$!
$ is_tests = 0
$ test_list = ""
$ if f$locate(",tests,", args_lower) .lt. args_lower_len
$ then
$     is_tests = 1
$ else
$     args_loc = f$locate(",tests=(", args_lower)
$     if args_loc .lt. args_lower_len
$     then
$         is_tests          = 1
$         arg               = f$extract(args_loc + 1, args_lower_len, args_lower)
$         arg_val           = f$element(0, ")", arg)
$         test_list_val     = f$element(1, "=", arg_val) - "(" - ")"
$         test_list_val     = f$edit(test_list_val, "COLLAPSE")
$         test_list_counter = 0
$
$ test_list_loop:
$         next_test_val = f$element (test_list_counter, ",", test_list_val)
$         if next_test_val .nes. "" .and. next_test_val .nes. ","
$         then
$             test_list         = test_list + next_test_val + " "
$             test_list_counter = test_list_counter + 1
$             goto test_list_loop
$         endif
$     endif
$ endif
$!
$ boost_root = ""
$ args_loc = f$locate(",boost_root=", args_lower)
$ if args_loc .lt. args_lower_len
$ then
$     arg = f$extract(args_loc + 1, args_lower_len, args_lower)
$     arg_val = f$element(0, ",", arg)
$     boost_root = f$element(1, "=", arg_val)
$ endif
$!
$ if is_tests .eqs. "1" .and. boost_root .eqs. ""
$ then
$     'vo_c' "%PLIBSYS-I-NOTESTS, tests couldn't be built without BOOST_ROOT parameter, disabling."
$     is_tests = 0
$ endif
$!
$ if is_tests .eqs. "0" .and. boost_root .nes. ""
$ then
$     'vo_c' "%PLIBSYS-I-BOOSTIGN, BOOST_ROOT parameter will be ignored without tests enabled."
$ endif
$!
$! Prepare build directory
$! -----------------------
$!
$! When building on a search list, need to do a create to make sure that
$! the output directory exists, since the clean procedure tries to delete
$! it.
$!
$ create/dir 'objdir'/prot=o:rwed
$ set default 'objdir'
$ @[-]deltree CXX_REPOSITORY
$!
$ if f$locate(",nolib,", args_lower) .lt. args_lower_len
$ then
$     goto build_tests
$ endif
$!
$! Generate platform-specific config file
$! --------------------------------------
$!
$ if f$search("plibsysconfig.h") .nes. "" then delete/log plibsysconfig.h;*
$!
$! Get the version number
$! ----------------------
$!
$ i = 0
$ open/read/error=version_loop_end vhf [---]CMakeLists.txt
$ version_loop:
$     read/end=version_loop_end vhf line_in
$!
$     if line_in .eqs. "" then goto version_loop
$!
$     if f$locate("set (PLIBSYS_VERSION_MAJOR ", line_in) .eq. 0
$     then
$         plibsys_vmajor = f$element(2, " ", line_in) - ")"
$         i = i + 1
$     endif
$!
$     if f$locate("set (PLIBSYS_VERSION_MINOR ", line_in) .eq. 0
$     then
$         plibsys_vminor = f$element(2, " ", line_in) - ")"
$         i = i + 1
$     endif
$!
$     if f$locate("set (PLIBSYS_VERSION_PATCH ", line_in) .eq. 0
$     then
$         plibsys_vpatch = f$element(2, " ", line_in) - ")"
$         i = i + 1
$     endif
$!
$     if f$locate("set (PLIBSYS_VERSION_NUM ", line_in) .eq. 0
$     then
$         plibsys_vnum = f$element(2, " ", line_in) - ")"
$         i = i + 1
$     endif
$!
$     if i .lt 4 then goto version_loop
$ version_loop_end:
$ close vhf
$!
$! Write config file
$! -----------------
$!
$ open/write/error=config_write_end chf plibsysconfig.h
$ write chf "#ifndef PLIBSYS_HEADER_PLIBSYSCONFIG_H"
$ write chf "#define PLIBSYS_HEADER_PLIBSYSCONFIG_H"
$ write chf ""
$ write chf "#define PLIBSYS_VERSION_MAJOR ''plibsys_vmajor'"
$ write chf "#define PLIBSYS_VERSION_MINOR ''plibsys_vminor'"
$ write chf "#define PLIBSYS_VERSION_PATCH ''plibsys_vpatch'"
$ write chf "#define PLIBSYS_VERSION_STR ""''plibsys_vmajor'.''plibsys_vminor'.''plibsys_vpatch'"""
$ write chf "#define PLIBSYS_VERSION ''plibsys_vnum'"
$ write chf ""
$ write chf "#define PLIBSYS_SIZEOF_SAFAMILY_T 1"
$ write chf ""
$ write chf "#include <pmacros.h>"
$ write chf ""
$ write chf "#include <float.h>"
$ write chf "#include <limits.h>"
$ write chf ""
$ write chf "P_BEGIN_DECLS"
$ write chf ""
$ write chf "#define P_MINFLOAT    FLT_MIN"
$ write chf "#define P_MAXFLOAT    FLT_MAX"
$ write chf "#define P_MINDOUBLE   DBL_MIN"
$ write chf "#define P_MAXDOUBLE   DBL_MAX"
$ write chf "#define P_MINSHORT    SHRT_MIN"
$ write chf "#define P_MAXSHORT    SHRT_MAX"
$ write chf "#define P_MAXUSHORT   USHRT_MAX"
$ write chf "#define P_MININT      INT_MIN"
$ write chf "#define P_MAXINT      INT_MAX"
$ write chf "#define P_MAXUINT     UINT_MAX"
$ write chf "#define P_MINLONG     LONG_MIN"
$ write chf "#define P_MAXLONG     LONG_MAX"
$ write chf "#define P_MAXULONG    ULONG_MAX"
$ write chf ""
$ write chf "#define PLIBSYS_MMAP_HAS_MAP_ANONYMOUS"
$ write chf "#define PLIBSYS_HAS_NANOSLEEP"
$ write chf "#define PLIBSYS_HAS_GETADDRINFO"
$ write chf "#define PLIBSYS_HAS_POSIX_SCHEDULING"
$ write chf "#define PLIBSYS_HAS_POSIX_STACKSIZE"
$ write chf "#define PLIBSYS_HAS_SOCKADDR_STORAGE"
$ write chf "#define PLIBSYS_SOCKADDR_HAS_SA_LEN"
$ write chf "#define PLIBSYS_SOCKADDR_IN6_HAS_SCOPEID"
$ write chf "#define PLIBSYS_SOCKADDR_IN6_HAS_FLOWINFO"
$ write chf ""
$!
$ if build_64 .eqs. "1"
$ then
$     write chf "#define PLIBSYS_SIZEOF_VOID_P 8"
$     write chf "#define PLIBSYS_SIZEOF_SIZE_T 8"
$ else
$     write chf "#define PLIBSYS_SIZEOF_VOID_P 4"
$     write chf "#define PLIBSYS_SIZEOF_SIZE_T 4"
$ endif
$!
$ write chf "#define PLIBSYS_SIZEOF_LONG 4"
$ write chf ""
$ write chf "#define P_BYTE_ORDER P_LITTLE_ENDIAN"
$ write chf ""
$ write chf "P_END_DECLS"
$ write chf ""
$ write chf "#endif /* PLIBSYS_HEADER_PLIBSYSCONFIG_H */"
$ config_write_end:
$     close chf
$!
$! Prepare sources for compilation
$! -------------------------------
$!
$ cc_link_params = ""
$ cc_params = "/NAMES=(AS_IS,SHORTENED)"
$ cc_params = cc_params + "/DEFINE=(PLIBSYS_COMPILATION,_REENTRANT,_POSIX_EXIT)"
$ cc_params = cc_params + "/INCLUDE_DIRECTORY=(''objdir',''base_src_dir')"
$ cc_params = cc_params + "/FLOAT=IEEE/IEEE_MODE=DENORM_RESULTS"
$!
$ if build_64 .eqs. "1"
$ then
$     cc_params = cc_params + "/POINTER_SIZE=64"
$ else
$     cc_params = cc_params + "/POINTER_SIZE=32"
$ endif
$!
$ if cc_extra .nes. ""
$ then
$     cc_params = cc_params + " " + cc_extra
$ endif
$!
$ if is_debug .eqs. "1"
$ then
$     cc_params = cc_params + "/DEBUG/NOOPTIMIZE/LIST/SHOW=ALL"
$     cc_link_params = "/DEBUG/TRACEBACK"
$ else
$     cc_link_params = "/NODEBUG/NOTRACEBACK"
$ endif
$!
$ plibsys_src = "patomic-sim.c pcondvariable-posix.c pcryptohash-gost3411.c pcryptohash-md5.c"
$ plibsys_src = plibsys_src + " pcryptohash-sha1.c pcryptohash-sha2-256.c pcryptohash-sha2-512.c"
$ plibsys_src = plibsys_src + " pcryptohash-sha3.c pcryptohash.c pdir-posix.c pdir.c"
$ plibsys_src = plibsys_src + " perror.c pfile.c phashtable.c pinifile.c pipc.c plibraryloader.c"
$ plibsys_src = plibsys_src + " plist.c pmain.c pmem.c pmutex-posix.c pprocess.c prwlock-posix.c"
$ plibsys_src = plibsys_src + " psemaphore-posix.c pshm-posix.c pshmbuffer.c psocket.c"
$ plibsys_src = plibsys_src + " psocketaddress.c pspinlock-sim.c pstring.c psysclose-unix.c"
$ plibsys_src = plibsys_src + " ptimeprofiler-posix.c ptimeprofiler.c ptree-avl.c ptree-bst.c"
$ plibsys_src = plibsys_src + " ptree-rb.c ptree.c puthread-posix.c puthread.c"
$!
$! Inform about building
$! ---------------------
$!
$ if build_64 .eqs. "1"
$ then
$     'vo_c' "Building for ''arch_name' (64-bit)"
$ else
$     'vo_c' "Building for ''arch_name' (32-bit)"
$ endif
$!
$! Compile library modules
$! -----------------------
$!
$ 'vo_c' "Compiling object modules..."
$ src_counter = 0
$ plibsys_src = f$edit(plibsys_src, "COMPRESS")
$ plibsys_objs = ""
$!
$ src_loop:
$     next_src = f$element (src_counter, " ", plibsys_src)
$     if next_src .nes. "" .and. next_src .nes. " "
$     then
$         'vo_c' "[CC] ''next_src'"
$         cc [---.src]'next_src' 'cc_params'
$!
$         src_counter = src_counter + 1
$!
$         obj_file = f$extract (0, f$length (next_src) - 1, next_src) + "obj"
$         plibsys_objs = plibsys_objs + "''obj_file',"
$!
$         goto src_loop
$     endif
$!
$ plibsys_objs = f$extract (0, f$length (plibsys_objs) - 1, plibsys_objs)
$
$!
$! Create library
$! --------------
$!
$ 'vo_c' "Creating object library..."
$ library/CREATE/INSERT/REPLACE /LIST=PLIBSYS.LIST PLIBSYS.OLB 'plibsys_objs'
$ library/COMPRESS PLIBSYS.OLB
$ purge PLIBSYS.OLB
$!
$ 'vo_c' "Creating shared library..."
$ link/SHAREABLE=PLIBSYS.EXE /MAP=PLIBSYS.MAP 'cc_link_params' 'plibsys_objs', [-]plibsys.opt/OPTION
$!
$! Testing area
$! ------------
$!
$ build_tests:
$ if is_tests .eqs. "0"
$ then
$     goto build_done
$ endif
$!
$! Write link options file
$! -----------------------
$!
$ if f$search("plibsys_link.opt") .nes. "" then delete/log plibsys_link.opt;*
$!
$ open/write/error=link_write_end lhf plibsys_link.opt
$ write lhf "''objdir'PLIBSYS.EXE/SHARE"
$ write lhf ""
$ link_write_end:
$     close lhf
$!
$! Compile tests
$! -------------------------
$!
$ if test_list .nes. ""
$ then
$     plibsys_tests = f$edit(test_list, "TRIM")
$ else
$     plibsys_tests = "patomic_test pcondvariable_test pcryptohash_test pdir_test"
$     plibsys_tests = plibsys_tests + " perror_test pfile_test phashtable_test"
$     plibsys_tests = plibsys_tests + " pinifile_test plibraryloader_test plist_test"
$     plibsys_tests = plibsys_tests + " pmacros_test pmain_test pmem_test pmutex_test"
$     plibsys_tests = plibsys_tests + " pprocess_test prwlock_test psemaphore_test"
$     plibsys_tests = plibsys_tests + " pshm_test pshmbuffer_test psocket_test"
$     plibsys_tests = plibsys_tests + " psocketaddress_test pspinlock_test pstring_test"
$     plibsys_tests = plibsys_tests + " ptimeprofiler_test ptree_test ptypes_test"
$     plibsys_tests = plibsys_tests + " puthread_test"
$ endif
$!
$ 'vo_c' "Compiling test executables..."
$ test_counter = 0
$ plibsys_tests = f$edit(plibsys_tests, "COMPRESS")
$!
$ cxx_params = "/INCLUDE=(''objdir',''base_src_dir',""''boost_root'"")"
$ cxx_params = cxx_params + "/DEFINE=(__USE_STD_IOSTREAM,PLIBSYS_TESTS_STATIC)/NAMES=(AS_IS, SHORTENED)"
$ cxx_params = cxx_params + "/FLOAT=IEEE/IEEE_MODE=DENORM_RESULTS"
$!
$ if build_64 .eqs. "1"
$ then
$     cxx_params = cxx_params + "/POINTER_SIZE=64"
$ else
$     cxx_params = cxx_params + "/POINTER_SIZE=32"
$ endif
$!
$ if is_debug .eqs. "1"
$ then
$     cxx_params = cxx_params + "/DEBUG/NOOPTIMIZE/LIST/SHOW=ALL"
$ endif
$!
$ test_loop:
$     next_test = f$element (test_counter, " ", plibsys_tests)
$     if next_test .nes. "" .and. next_test .nes. " "
$     then
$         'vo_c' "[CXX] ''next_test'.cpp"
$         cxx [---.tests]'next_test'.cpp 'cxx_params'
$!
$         'vo_c' "[CXXLINK] ''next_test'.obj"
$          cxxlink 'next_test'.obj,'objdir'plibsys_link.opt/OPTION /THREADS_ENABLE
$!
$         @[-]deltree CXX_REPOSITORY
$ next_test:
$         test_counter = test_counter + 1
$         goto test_loop
$     endif
$!
$ build_done:
$     'vo_c' "Build done."
$!
$ common_exit:
$     set default 'orig_def'
$     exit

$!
$! Copyright 2014, John Malmberg
$! Copyright 2016, Alexander Saprykin
$!
$! Permission to use, copy, modify, and/or distribute this software for any
$! purpose with or without fee is hereby granted, provided that the above
$! copyright notice and this permission notice appear in all copies.
$!
$! THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
$! WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
$! MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
$! ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
$! WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
$! ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
$! OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
$!
$!===========================================================================
$! Command-line options:
$!
$!    32            Compile with 32-bit pointers.
$!    CCQUAL=x      Add "x" to the C compiler qualifiers.
$!    DEBUG         Build in debug mode.
$!    CLEAN         Only perform clean after the previous build.
$!    TESTS=(x)     Build library tests. Comma separated test names or leave
$!                  empty to build all the tests.
$!                  Example 1 (curtain tests): TESTS=(pmem_test,puthread_test)
$!                  Example 2 (all tests): TESTS
$!    BOOST_ROOT=x  Boost root directory.
$!                  Example: BOOST_ROOT=/SYS$COMMON/boost_1_43_1
$!    NOLIB         Skip library buidling. Useful when you want to rebuild
$!                  particular tests.
$!===========================================================================
$!
$!
$! Save the original default dev:[dir], and arrange for its restoration
$! at exit.
$!---------------------------------------------------------------------
$ orig_def = f$environment("DEFAULT")
$ on error then goto common_exit
$ on control_y then goto common_exit
$!
$ ctrl_y       = 1556
$ proc         = f$environment("PROCEDURE")
$ proc_fid     = f$file_attributes(proc, "FID")
$ proc_dev     = f$parse(proc, , , "DEVICE")
$ proc_dir     = f$parse(proc, , , "DIRECTORY")
$ proc_name    = f$parse(proc, , , "NAME")
$ proc_type    = f$parse(proc, , , "TYPE")
$ proc_dev_dir = proc_dev + proc_dir
$!
$! Have to manually parse the device for a search list.
$! Can not use the f$parse() as it will return the first name
$! in the search list.
$!
$ orig_def_dev = f$element(0, ":", orig_def) + ":"
$ if orig_def_dev .eqs. "::" then orig_def_dev = "sys$disk:"
$ test_proc = orig_def_dev + proc_dir + proc_name + proc_type
$!
$! If we can find this file using the default directory
$! then we know that we should use the original device from the
$! default directory which could be a search list.
$!
$ test_proc_fid = f$file_attributes(test_proc, "FID")
$!
$ if (test_proc_fid .eq. proc_fid)
$ then
$     proc_dev_dir = orig_def_dev + proc_dir
$ endif
$!
$! Verbose output message stuff. Define symbol to "write sys$output".
$! vo_c - verbose output for compile
$!
$ vo_c := "write sys$output"
$!
$! Determine the main distribution directory ("[--]") in an
$! ODS5-tolerant (case-insensitive) way.  (We do assume that the only
$! "]" or ">" is the one at the end.)
$!
$! Some non-US VMS installations report ">" for the directory delimiter
$! so do not assume that it is "]".
$!
$ orig_def_len = f$length(orig_def)
$ delim = f$extract(orig_def_len - 1, 1, orig_def)
$!
$ set default 'proc_dev_dir'
$ set default [--.src]
$ base_src_dir = f$environment("default")
$ set default 'proc_dev_dir'
$!
$! Define the architecture-specific destination directory name
$! -----------------------------------------------------------
$!
$ if (f$getsyi("HW_MODEL") .lt. 1024)
$ then
$      'vo_c' "%PLIBSYS-F-NOTSUP, VAX platform is not supported, sorry :("
$      goto common_exit
$ else
$      arch_name = ""
$      arch_name = arch_name + f$edit(f$getsyi("ARCH_NAME"), "UPCASE")
$!
$      if (arch_name .eqs. "") then arch_name = "UNK"
$!
$      node_swvers   = f$getsyi("node_swvers")
$      version_patch = f$extract(1, f$length(node_swvers), node_swvers)
$      maj_ver       = f$element(0, ".", version_patch)
$      min_ver_patch = f$element(1, ".", version_patch)
$      min_ver       = f$element(0, "-", min_ver_patch)
$      patch         = f$element(1, "-", min_ver_patch)
$!
$      if maj_ver .lts. "8" .or. min_ver .lts. "4"
$      then
$          'vo_c' "%PLIBSYS-F-NOTSUP, only OpenVMS 8.4 and above are supported, sorry :("
$          goto common_exit
$      endif
$ endif
$!
$ objdir = proc_dev_dir - delim + ".''arch_name'" + delim
$!
$! Parse input arguments
$! ---------------------
$! Allow arguments to be grouped together with comma or separated by spaces
$! Do no know if we will need more than 8.
$ args = "," + p1 + "," + p2 + "," + p3 + "," + p4 + ","
$ args = args + p5 + "," + p6 + "," + p7 + "," + p8 + ","
$!
$! Provide lower case version to simplify parsing.
$ args_lower = f$edit(args, "LOWERCASE,COLLAPSE")
$!
$ args_len = f$length(args)
$ args_lower_len = f$length(args_lower)
$!
$ if f$locate(",clean,", args_lower) .lt. args_lower_len
$ then
$     'vo_c' "Cleaning up previous build..."
$     set default 'proc_dev_dir'
$     @deltree.com 'arch_name'
$     goto common_exit
$ endif
$!
$ build_64 = 1
$ if f$locate(",32,", args_lower) .lt. args_lower_len
$ then
$     build_64 = 0
$ endif
$!
$ cc_extra = ""
$ args_loc = f$locate(",ccqual=", args_lower)
$ if args_loc .lt. args_lower_len
$ then
$     arg = f$extract(args_loc + 1, args_lower_len, args_lower)
$     arg_val = f$element(0, ",", arg)
$     cc_extra = f$element(1, "=", arg_val)
$ endif
$!
$ is_debug = 0
$ if f$locate(",debug,", args_lower) .lt. args_lower_len
$ then
$     is_debug = 1
$ endif
$!
$ is_tests = 0
$ test_list = ""
$ if f$locate(",tests,", args_lower) .lt. args_lower_len
$ then
$     is_tests = 1
$ else
$     args_loc = f$locate(",tests=(", args_lower)
$     if args_loc .lt. args_lower_len
$     then
$         is_tests          = 1
$         arg               = f$extract(args_loc + 1, args_lower_len, args_lower)
$         arg_val           = f$element(0, ")", arg)
$         test_list_val     = f$element(1, "=", arg_val) - "(" - ")"
$         test_list_val     = f$edit(test_list_val, "COLLAPSE")
$         test_list_counter = 0
$
$ test_list_loop:
$         next_test_val = f$element (test_list_counter, ",", test_list_val)
$         if next_test_val .nes. "" .and. next_test_val .nes. ","
$         then
$             test_list         = test_list + next_test_val + " "
$             test_list_counter = test_list_counter + 1
$             goto test_list_loop
$         endif
$     endif
$ endif
$!
$ boost_root = ""
$ args_loc = f$locate(",boost_root=", args_lower)
$ if args_loc .lt. args_lower_len
$ then
$     arg = f$extract(args_loc + 1, args_lower_len, args_lower)
$     arg_val = f$element(0, ",", arg)
$     boost_root = f$element(1, "=", arg_val)
$ endif
$!
$ if is_tests .eqs. "1" .and. boost_root .eqs. ""
$ then
$     'vo_c' "%PLIBSYS-I-NOTESTS, tests couldn't be built without BOOST_ROOT parameter, disabling."
$     is_tests = 0
$ endif
$!
$ if is_tests .eqs. "0" .and. boost_root .nes. ""
$ then
$     'vo_c' "%PLIBSYS-I-BOOSTIGN, BOOST_ROOT parameter will be ignored without tests enabled."
$ endif
$!
$! Prepare build directory
$! -----------------------
$!
$! When building on a search list, need to do a create to make sure that
$! the output directory exists, since the clean procedure tries to delete
$! it.
$!
$ create/dir 'objdir'/prot=o:rwed
$ set default 'objdir'
$ @[-]deltree CXX_REPOSITORY
$!
$ if f$locate(",nolib,", args_lower) .lt. args_lower_len
$ then
$     goto build_tests
$ endif
$!
$! Generate platform-specific config file
$! --------------------------------------
$!
$ if f$search("plibsysconfig.h") .nes. "" then delete/log plibsysconfig.h;*
$!
$! Get the version number
$! ----------------------
$!
$ i = 0
$ open/read/error=version_loop_end vhf [---]CMakeLists.txt
$ version_loop:
$     read/end=version_loop_end vhf line_in
$!
$     if line_in .eqs. "" then goto version_loop
$!
$     if f$locate("set (PLIBSYS_VERSION_MAJOR ", line_in) .eq. 0
$     then
$         plibsys_vmajor = f$element(2, " ", line_in) - ")"
$         i = i + 1
$     endif
$!
$     if f$locate("set (PLIBSYS_VERSION_MINOR ", line_in) .eq. 0
$     then
$         plibsys_vminor = f$element(2, " ", line_in) - ")"
$         i = i + 1
$     endif
$!
$     if f$locate("set (PLIBSYS_VERSION_PATCH ", line_in) .eq. 0
$     then
$         plibsys_vpatch = f$element(2, " ", line_in) - ")"
$         i = i + 1
$     endif
$!
$     if f$locate("set (PLIBSYS_VERSION_NUM ", line_in) .eq. 0
$     then
$         plibsys_vnum = f$element(2, " ", line_in) - ")"
$         i = i + 1
$     endif
$!
$     if i .lt 4 then goto version_loop
$ version_loop_end:
$ close vhf
$!
$! Write config file
$! -----------------
$!
$ open/write/error=config_write_end chf plibsysconfig.h
$ write chf "#ifndef PLIBSYS_HEADER_PLIBSYSCONFIG_H"
$ write chf "#define PLIBSYS_HEADER_PLIBSYSCONFIG_H"
$ write chf ""
$ write chf "#define PLIBSYS_VERSION_MAJOR ''plibsys_vmajor'"
$ write chf "#define PLIBSYS_VERSION_MINOR ''plibsys_vminor'"
$ write chf "#define PLIBSYS_VERSION_PATCH ''plibsys_vpatch'"
$ write chf "#define PLIBSYS_VERSION_STR ""''plibsys_vmajor'.''plibsys_vminor'.''plibsys_vpatch'"""
$ write chf "#define PLIBSYS_VERSION ''plibsys_vnum'"
$ write chf ""
$ write chf "#define PLIBSYS_SIZEOF_SAFAMILY_T 1"
$ write chf ""
$ write chf "#include <pmacros.h>"
$ write chf ""
$ write chf "#include <float.h>"
$ write chf "#include <limits.h>"
$ write chf ""
$ write chf "P_BEGIN_DECLS"
$ write chf ""
$ write chf "#define P_MINFLOAT    FLT_MIN"
$ write chf "#define P_MAXFLOAT    FLT_MAX"
$ write chf "#define P_MINDOUBLE   DBL_MIN"
$ write chf "#define P_MAXDOUBLE   DBL_MAX"
$ write chf "#define P_MINSHORT    SHRT_MIN"
$ write chf "#define P_MAXSHORT    SHRT_MAX"
$ write chf "#define P_MAXUSHORT   USHRT_MAX"
$ write chf "#define P_MININT      INT_MIN"
$ write chf "#define P_MAXINT      INT_MAX"
$ write chf "#define P_MAXUINT     UINT_MAX"
$ write chf "#define P_MINLONG     LONG_MIN"
$ write chf "#define P_MAXLONG     LONG_MAX"
$ write chf "#define P_MAXULONG    ULONG_MAX"
$ write chf ""
$ write chf "#define PLIBSYS_MMAP_HAS_MAP_ANONYMOUS"
$ write chf "#define PLIBSYS_HAS_NANOSLEEP"
$ write chf "#define PLIBSYS_HAS_GETADDRINFO"
$ write chf "#define PLIBSYS_HAS_POSIX_SCHEDULING"
$ write chf "#define PLIBSYS_HAS_POSIX_STACKSIZE"
$ write chf "#define PLIBSYS_HAS_SOCKADDR_STORAGE"
$ write chf "#define PLIBSYS_SOCKADDR_HAS_SA_LEN"
$ write chf "#define PLIBSYS_SOCKADDR_IN6_HAS_SCOPEID"
$ write chf "#define PLIBSYS_SOCKADDR_IN6_HAS_FLOWINFO"
$ write chf ""
$!
$ if build_64 .eqs. "1"
$ then
$     write chf "#define PLIBSYS_SIZEOF_VOID_P 8"
$     write chf "#define PLIBSYS_SIZEOF_SIZE_T 8"
$ else
$     write chf "#define PLIBSYS_SIZEOF_VOID_P 4"
$     write chf "#define PLIBSYS_SIZEOF_SIZE_T 4"
$ endif
$!
$ write chf "#define PLIBSYS_SIZEOF_LONG 4"
$ write chf ""
$ write chf "#define P_BYTE_ORDER P_LITTLE_ENDIAN"
$ write chf ""
$ write chf "P_END_DECLS"
$ write chf ""
$ write chf "#endif /* PLIBSYS_HEADER_PLIBSYSCONFIG_H */"
$ config_write_end:
$     close chf
$!
$! Prepare sources for compilation
$! -------------------------------
$!
$ cc_link_params = ""
$ cc_params = "/NAMES=(AS_IS,SHORTENED)"
$ cc_params = cc_params + "/DEFINE=(PLIBSYS_COMPILATION,_REENTRANT,_POSIX_EXIT)"
$ cc_params = cc_params + "/INCLUDE_DIRECTORY=(''objdir',''base_src_dir')"
$ cc_params = cc_params + "/FLOAT=IEEE/IEEE_MODE=DENORM_RESULTS"
$!
$ if build_64 .eqs. "1"
$ then
$     cc_params = cc_params + "/POINTER_SIZE=64"
$ else
$     cc_params = cc_params + "/POINTER_SIZE=32"
$ endif
$!
$ if cc_extra .nes. ""
$ then
$     cc_params = cc_params + " " + cc_extra
$ endif
$!
$ if is_debug .eqs. "1"
$ then
$     cc_params = cc_params + "/DEBUG/NOOPTIMIZE/LIST/SHOW=ALL"
$     cc_link_params = "/DEBUG/TRACEBACK"
$ else
$     cc_link_params = "/NODEBUG/NOTRACEBACK"
$ endif
$!
$ plibsys_src = "patomic-sim.c pcondvariable-posix.c pcryptohash-gost3411.c pcryptohash-md5.c"
$ plibsys_src = plibsys_src + " pcryptohash-sha1.c pcryptohash-sha2-256.c pcryptohash-sha2-512.c"
$ plibsys_src = plibsys_src + " pcryptohash-sha3.c pcryptohash.c pdir-posix.c pdir.c"
$ plibsys_src = plibsys_src + " perror.c pfile.c phashtable.c pinifile.c pipc.c plibraryloader.c"
$ plibsys_src = plibsys_src + " plist.c pmain.c pmem.c pmutex-posix.c pprocess.c prwlock-posix.c"
$ plibsys_src = plibsys_src + " psemaphore-posix.c pshm-posix.c pshmbuffer.c psocket.c"
$ plibsys_src = plibsys_src + " psocketaddress.c pspinlock-sim.c pstring.c psysclose-unix.c"
$ plibsys_src = plibsys_src + " ptimeprofiler-posix.c ptimeprofiler.c ptree-avl.c ptree-bst.c"
$ plibsys_src = plibsys_src + " ptree-rb.c ptree.c puthread-posix.c puthread.c"
$!
$! Inform about building
$! ---------------------
$!
$ if build_64 .eqs. "1"
$ then
$     'vo_c' "Building for ''arch_name' (64-bit)"
$ else
$     'vo_c' "Building for ''arch_name' (32-bit)"
$ endif
$!
$! Compile library modules
$! -----------------------
$!
$ 'vo_c' "Compiling object modules..."
$ src_counter = 0
$ plibsys_src = f$edit(plibsys_src, "COMPRESS")
$ plibsys_objs = ""
$!
$ src_loop:
$     next_src = f$element (src_counter, " ", plibsys_src)
$     if next_src .nes. "" .and. next_src .nes. " "
$     then
$         'vo_c' "[CC] ''next_src'"
$         cc [---.src]'next_src' 'cc_params'
$!
$         src_counter = src_counter + 1
$!
$         obj_file = f$extract (0, f$length (next_src) - 1, next_src) + "obj"
$         plibsys_objs = plibsys_objs + "''obj_file',"
$!
$         goto src_loop
$     endif
$!
$ plibsys_objs = f$extract (0, f$length (plibsys_objs) - 1, plibsys_objs)
$
$!
$! Create library
$! --------------
$!
$ 'vo_c' "Creating object library..."
$ library/CREATE/INSERT/REPLACE /LIST=PLIBSYS.LIST PLIBSYS.OLB 'plibsys_objs'
$ library/COMPRESS PLIBSYS.OLB
$ purge PLIBSYS.OLB
$!
$ 'vo_c' "Creating shared library..."
$ link/SHAREABLE=PLIBSYS.EXE /MAP=PLIBSYS.MAP 'cc_link_params' 'plibsys_objs', [-]plibsys.opt/OPTION
$!
$! Compile tests
$! -------------------------
$ build_tests:
$!
$ if is_tests .eqs. "0"
$ then
$     goto build_done
$ endif
$!
$ if test_list .nes. ""
$ then
$     plibsys_tests = f$edit(test_list, "TRIM")
$ else
$     plibsys_tests = "patomic_test pcondvariable_test pcryptohash_test pdir_test"
$     plibsys_tests = plibsys_tests + " perror_test pfile_test phashtable_test"
$     plibsys_tests = plibsys_tests + " pinifile_test plibraryloader_test plist_test"
$     plibsys_tests = plibsys_tests + " pmacros_test pmain_test pmem_test pmutex_test"
$     plibsys_tests = plibsys_tests + " pprocess_test prwlock_test psemaphore_test"
$     plibsys_tests = plibsys_tests + " pshm_test pshmbuffer_test psocket_test"
$     plibsys_tests = plibsys_tests + " psocketaddress_test pspinlock_test pstring_test"
$     plibsys_tests = plibsys_tests + " ptimeprofiler_test ptree_test ptypes_test"
$     plibsys_tests = plibsys_tests + " puthread_test"
$ endif
$!
$ 'vo_c' "Compiling test executables..."
$ test_counter = 0
$ plibsys_tests = f$edit(plibsys_tests, "COMPRESS")
$!
$ cxx_params = "/INCLUDE=(''objdir',''base_src_dir',""''boost_root'"")"
$ cxx_params = cxx_params + "/DEFINE=(__USE_STD_IOSTREAM,PLIBSYS_TESTS_STATIC)/NAMES=(AS_IS, SHORTENED)"
$ cxx_params = cxx_params + "/FLOAT=IEEE/IEEE_MODE=DENORM_RESULTS"
$!
$ if build_64 .eqs. "1"
$ then
$     cxx_params = cxx_params + "/POINTER_SIZE=64"
$ else
$     cxx_params = cxx_params + "/POINTER_SIZE=32"
$ endif
$!
$ if is_debug .eqs. "1"
$ then
$     cxx_params = cxx_params + "/DEBUG/NOOPTIMIZE/LIST/SHOW=ALL"
$ endif
$!
$ test_loop:
$     next_test = f$element (test_counter, " ", plibsys_tests)
$     if next_test .nes. "" .and. next_test .nes. " "
$     then
$         'vo_c' "[CXX] ''next_test'.cpp"
$         cxx [---.tests]'next_test'.cpp 'cxx_params'
$!
$         'vo_c' "[CXXLINK] ''next_test'.obj"
$          cxxlink 'next_test'.obj,'objdir'PLIBSYS.OLB/LIBRARY /THREADS_ENABLE
$!
$         @[-]deltree CXX_REPOSITORY
$ next_test:
$         test_counter = test_counter + 1
$         goto test_loop
$     endif
$!
$ build_done:
$     'vo_c' "Build done."
$!
$ common_exit:
$     set default 'orig_def'
$     exit


The actual whirlpool test was missing on VMS...

$! TESTS.COM  --  Performs the necessary tests
$!
$! P1	tests to be performed.  Empty means all.
$
$	__proc = f$element(0,";",f$environment("procedure"))
$	__here = f$parse(f$parse("A.;",__proc) - "A.;","[]A.;") - "A.;"
$	__save_default = f$environment("default")
$	__arch := VAX
$	if f$getsyi("cpu") .ge. 128 then __arch := AXP
$	texe_dir := sys$disk:[-.'__arch'.exe.test]
$	exe_dir := sys$disk:[-.'__arch'.exe.apps]
$
$	set default '__here'
$	on control_y then goto exit
$	on error then goto exit
$
$	if p1 .nes. ""
$	then
$	    tests = p1
$	else
$	    tests := -
	test_des,test_idea,test_sha,test_md4,test_md5,test_hmac,-
	test_md2,test_mdc2,test_wp,-
	test_rmd,test_rc2,test_rc4,test_rc5,test_bf,test_cast,test_aes,-
	test_rand,test_bn,test_ec,test_ecdsa,test_ecdh,-
	test_enc,test_x509,test_rsa,test_crl,test_sid,-
	test_gen,test_req,test_pkcs7,test_verify,test_dh,test_dsa,-
	test_ss,test_ca,test_engine,test_evp,test_ssl,test_tsa
$	endif
$	tests = f$edit(tests,"COLLAPSE")
$
$	BNTEST :=	bntest
$	ECTEST :=	ectest
$	ECDSATEST :=	ecdsatest
$	ECDHTEST :=	ecdhtest
$	EXPTEST :=	exptest
$	IDEATEST :=	ideatest
$	SHATEST :=	shatest
$	SHA1TEST :=	sha1test
$	MDC2TEST :=	mdc2test
$	RMDTEST :=	rmdtest
$	MD2TEST :=	md2test
$	MD4TEST :=	md4test
$	MD5TEST :=	md5test
$	HMACTEST :=	hmactest
$	WPTEST :=	wp_test
$	RC2TEST :=	rc2test
$	RC4TEST :=	rc4test
$	RC5TEST :=	rc5test
$	BFTEST :=	bftest
$	CASTTEST :=	casttest
$	DESTEST :=	destest
$	RANDTEST :=	randtest
$	DHTEST :=	dhtest
$	DSATEST :=	dsatest
$	METHTEST :=	methtest
$	SSLTEST :=	ssltest
$	RSATEST :=	rsa_test
$	ENGINETEST :=	enginetest
$	EVPTEST :=	evp_test
$
$	tests_i = 0
$ loop_tests:
$	tests_e = f$element(tests_i,",",tests)
$	tests_i = tests_i + 1
$	if tests_e .eqs. "," then goto exit
$	gosub 'tests_e'
$	goto loop_tests
$
$ test_evp:
$	mcr 'texe_dir''evptest' evptests.txt
$	return
$ test_des:
$	mcr 'texe_dir''destest'
$	return
$ test_idea:
$	mcr 'texe_dir''ideatest'
$	return
$ test_sha:
$	mcr 'texe_dir''shatest'
$	mcr 'texe_dir''sha1test'
$	return
$ test_mdc2:
$	mcr 'texe_dir''mdc2test'
$	return
$ test_md5:
$	mcr 'texe_dir''md5test'
$	return
$ test_md4:
$	mcr 'texe_dir''md4test'
$	return
$ test_hmac:
$	mcr 'texe_dir''hmactest'
$	return
$ test_wp:
$	mcr 'texe_dir''wptest'
$	return
$ test_md2:
$	mcr 'texe_dir''md2test'
$	return
$ test_rmd:
$	mcr 'texe_dir''rmdtest'
$	return
$ test_bf:
$	mcr 'texe_dir''bftest'
$	return
$ test_cast:
$	mcr 'texe_dir''casttest'
$	return
$ test_rc2:
$	mcr 'texe_dir''rc2test'
$	return
$ test_rc4:
$	mcr 'texe_dir''rc4test'
$	return
$ test_rc5:
$	mcr 'texe_dir''rc5test'
$	return
$ test_rand:
$	mcr 'texe_dir''randtest'
$	return
$ test_enc:
$	@testenc.com
$	return
$ test_x509:
$	define sys$error nla0:
$	write sys$output "test normal x509v1 certificate"
$	@tx509.com
$	write sys$output "test first x509v3 certificate"
$	@tx509.com v3-cert1.pem
$	write sys$output "test second x509v3 certificate"
$	@tx509.com v3-cert2.pem
$	deassign sys$error
$	return
$ test_rsa:
$	define sys$error nla0:
$	@trsa.com
$	deassign sys$error
$	mcr 'texe_dir''rsatest'
$	return
$ test_crl:
$	define sys$error nla0:
$	@tcrl.com
$	deassign sys$error
$	return
$ test_sid:
$	define sys$error nla0:
$	@tsid.com
$	deassign sys$error
$	return
$ test_req:
$	define sys$error nla0:
$	@treq.com
$	@treq.com testreq2.pem
$	deassign sys$error
$	return
$ test_pkcs7:
$	define sys$error nla0:
$	@tpkcs7.com
$	@tpkcs7d.com
$	deassign sys$error
$	return
$ test_bn:
$	write sys$output "starting big number library test, could take a while..."
$	create bntest-vms.fdl
FILE
	ORGANIZATION	sequential
RECORD
	FORMAT		stream_lf
$	create/fdl=bntest-vms.fdl bntest-vms.sh
$	open/append foo bntest-vms.sh
$	type/output=foo: sys$input:
<< __FOO__ sh -c "`sh ./bctest`" | perl -e '$i=0; while (<STDIN>) {if (/^test (.*)/) {print STDERR "\nverify $1";} elsif (!/^0$/) {die "\nFailed! bc: $_";} else {print STDERR "."; $i++;}} print STDERR "\n$i tests passed\n"'
$	define/user sys$output bntest-vms.tmp
$	mcr 'texe_dir''bntest'
$	copy bntest-vms.tmp foo:
$	delete bntest-vms.tmp;*
$	type/output=foo: sys$input:
__FOO__
$	close foo
$	write sys$output "-- copy the [.test]bntest-vms.sh and [.test]bctest files to a Unix system and"
$	write sys$output "-- run bntest-vms.sh through sh or bash to verify that the bignum operations"
$	write sys$output "-- went well."
$	write sys$output ""
$	write sys$output "test a^b%c implementations"
$	mcr 'texe_dir''exptest'
$	return
$ test_ec:
$	write sys$output "test elliptic curves"
$	mcr 'texe_dir''ectest'
$	return
$ test_ecdsa:
$	write sys$output "test ecdsa"
$	mcr 'texe_dir''ecdsatest'
$	return
$ test_ecdh:
$	write sys$output "test ecdh"
$	mcr 'texe_dir''ecdhtest'
$	return
$ test_verify:
$	write sys$output "The following command should have some OK's and some failures"
$	write sys$output "There are definitly a few expired certificates"
$	@tverify.com
$	return
$ test_dh:
$	write sys$output "Generate a set of DH parameters"
$	mcr 'texe_dir''dhtest'
$	return
$ test_dsa:
$	write sys$output "Generate a set of DSA parameters"
$	mcr 'texe_dir''dsatest'
$	return
$ test_gen:
$	write sys$output "Generate and verify a certificate request"
$	@testgen.com
$	return
$ maybe_test_ss:
$	testss_RDT = f$cvtime(f$file_attributes("testss.com","RDT"))
$	if f$cvtime(f$file_attributes("keyU.ss","RDT")) .les. testss_RDT then -
		goto test_ss
$	if f$cvtime(f$file_attributes("certU.ss","RDT")) .les. testss_RDT then -
		goto test_ss
$	if f$cvtime(f$file_attributes("certCA.ss","RDT")) .les. testss_RDT then -
		goto test_ss
$	return
$ test_ss:
$	write sys$output "Generate and certify a test certificate"
$	@testss.com
$	return
$ test_engine:
$	write sys$output "Manipulate the ENGINE structures"
$	mcr 'texe_dir''enginetest'
$	return
$ test_ssl:
$	write sys$output "test SSL protocol"
$	gosub maybe_test_ss
$	@testssl.com keyU.ss certU.ss certCA.ss
$	return
$ test_ca:
$	set noon
$	define/user sys$output nla0:
$	mcr 'exe_dir'openssl no-rsa
$	save_severity=$SEVERITY
$	set on
$	if save_severity
$	then
$	    write sys$output "skipping CA.com test -- requires RSA"
$	else
$	    write sys$output "Generate and certify a test certificate via the 'ca' program"
$	    @testca.com
$	endif
$	return
$ test_aes:
$!	write sys$output "test AES"
$!	!mcr 'texe_dir''aestest'
$	return
$ test_tsa:
$	set noon
$	define/user sys$output nla0:
$	mcr 'exe_dir'openssl no-rsa
$	save_severity=$SEVERITY
$	set on
$	if save_severity
$	then
$	    write sys$output "skipping testtsa.com test -- requires RSA"
$	else
$	    @testtsa.com
$	endif
$	return
$
$
$ exit:
$	set default '__save_default'
$	exit

$! TESTS.COM  --  Performs the necessary tests
$!
$! P1	tests to be performed.  Empty means all.
$
$	__proc = f$element(0,";",f$environment("procedure"))
$	__here = f$parse(f$parse("A.;",__proc) - "A.;","[]A.;") - "A.;"
$	__save_default = f$environment("default")
$	__arch := VAX
$	if f$getsyi("cpu") .ge. 128 then __arch := AXP
$	texe_dir := sys$disk:[-.'__arch'.exe.test]
$	exe_dir := sys$disk:[-.'__arch'.exe.apps]
$
$	set default '__here'
$	on control_y then goto exit
$	on error then goto exit
$
$	if p1 .nes. ""
$	then
$	    tests = p1
$	else
$	    tests := -
	test_des,test_idea,test_sha,test_md4,test_md5,test_hmac,-
	test_md2,test_mdc2,test_wp,-
	test_rmd,test_rc2,test_rc4,test_rc5,test_bf,test_cast,test_aes,-
	test_rand,test_bn,test_ec,test_ecdsa,test_ecdh,-
	test_enc,test_x509,test_rsa,test_crl,test_sid,-
	test_gen,test_req,test_pkcs7,test_verify,test_dh,test_dsa,-
	test_ss,test_ca,test_engine,test_evp,test_ssl,test_tsa
$	endif
$	tests = f$edit(tests,"COLLAPSE")
$
$	BNTEST :=	bntest
$	ECTEST :=	ectest
$	ECDSATEST :=	ecdsatest
$	ECDHTEST :=	ecdhtest
$	EXPTEST :=	exptest
$	IDEATEST :=	ideatest
$	SHATEST :=	shatest
$	SHA1TEST :=	sha1test
$	MDC2TEST :=	mdc2test
$	RMDTEST :=	rmdtest
$	MD2TEST :=	md2test
$	MD4TEST :=	md4test
$	MD5TEST :=	md5test
$	HMACTEST :=	hmactest
$	RC2TEST :=	rc2test
$	RC4TEST :=	rc4test
$	RC5TEST :=	rc5test
$	BFTEST :=	bftest
$	CASTTEST :=	casttest
$	DESTEST :=	destest
$	RANDTEST :=	randtest
$	DHTEST :=	dhtest
$	DSATEST :=	dsatest
$	METHTEST :=	methtest
$	SSLTEST :=	ssltest
$	RSATEST :=	rsa_test
$	ENGINETEST :=	enginetest
$	EVPTEST :=	evp_test
$
$	tests_i = 0
$ loop_tests:
$	tests_e = f$element(tests_i,",",tests)
$	tests_i = tests_i + 1
$	if tests_e .eqs. "," then goto exit
$	gosub 'tests_e'
$	goto loop_tests
$
$ test_evp:
$	mcr 'texe_dir''evptest' evptests.txt
$	return
$ test_des:
$	mcr 'texe_dir''destest'
$	return
$ test_idea:
$	mcr 'texe_dir''ideatest'
$	return
$ test_sha:
$	mcr 'texe_dir''shatest'
$	mcr 'texe_dir''sha1test'
$	return
$ test_mdc2:
$	mcr 'texe_dir''mdc2test'
$	return
$ test_md5:
$	mcr 'texe_dir''md5test'
$	return
$ test_md4:
$	mcr 'texe_dir''md4test'
$	return
$ test_hmac:
$	mcr 'texe_dir''hmactest'
$	return
$ test_md2:
$	mcr 'texe_dir''md2test'
$	return
$ test_rmd:
$	mcr 'texe_dir''rmdtest'
$	return
$ test_bf:
$	mcr 'texe_dir''bftest'
$	return
$ test_cast:
$	mcr 'texe_dir''casttest'
$	return
$ test_rc2:
$	mcr 'texe_dir''rc2test'
$	return
$ test_rc4:
$	mcr 'texe_dir''rc4test'
$	return
$ test_rc5:
$	mcr 'texe_dir''rc5test'
$	return
$ test_rand:
$	mcr 'texe_dir''randtest'
$	return
$ test_enc:
$	@testenc.com
$	return
$ test_x509:
$	define sys$error nla0:
$	write sys$output "test normal x509v1 certificate"
$	@tx509.com
$	write sys$output "test first x509v3 certificate"
$	@tx509.com v3-cert1.pem
$	write sys$output "test second x509v3 certificate"
$	@tx509.com v3-cert2.pem
$	deassign sys$error
$	return
$ test_rsa:
$	define sys$error nla0:
$	@trsa.com
$	deassign sys$error
$	mcr 'texe_dir''rsatest'
$	return
$ test_crl:
$	define sys$error nla0:
$	@tcrl.com
$	deassign sys$error
$	return
$ test_sid:
$	define sys$error nla0:
$	@tsid.com
$	deassign sys$error
$	return
$ test_req:
$	define sys$error nla0:
$	@treq.com
$	@treq.com testreq2.pem
$	deassign sys$error
$	return
$ test_pkcs7:
$	define sys$error nla0:
$	@tpkcs7.com
$	@tpkcs7d.com
$	deassign sys$error
$	return
$ test_bn:
$	write sys$output "starting big number library test, could take a while..."
$	create bntest-vms.fdl
FILE
	ORGANIZATION	sequential
RECORD
	FORMAT		stream_lf
$	create/fdl=bntest-vms.fdl bntest-vms.sh
$	open/append foo bntest-vms.sh
$	type/output=foo: sys$input:
<< __FOO__ sh -c "`sh ./bctest`" | perl -e '$i=0; while (<STDIN>) {if (/^test (.*)/) {print STDERR "\nverify $1";} elsif (!/^0$/) {die "\nFailed! bc: $_";} else {print STDERR "."; $i++;}} print STDERR "\n$i tests passed\n"'
$	define/user sys$output bntest-vms.tmp
$	mcr 'texe_dir''bntest'
$	copy bntest-vms.tmp foo:
$	delete bntest-vms.tmp;*
$	type/output=foo: sys$input:
__FOO__
$	close foo
$	write sys$output "-- copy the [.test]bntest-vms.sh and [.test]bctest files to a Unix system and"
$	write sys$output "-- run bntest-vms.sh through sh or bash to verify that the bignum operations"
$	write sys$output "-- went well."
$	write sys$output ""
$	write sys$output "test a^b%c implementations"
$	mcr 'texe_dir''exptest'
$	return
$ test_ec:
$	write sys$output "test elliptic curves"
$	mcr 'texe_dir''ectest'
$	return
$ test_ecdsa:
$	write sys$output "test ecdsa"
$	mcr 'texe_dir''ecdsatest'
$	return
$ test_ecdh:
$	write sys$output "test ecdh"
$	mcr 'texe_dir''ecdhtest'
$	return
$ test_verify:
$	write sys$output "The following command should have some OK's and some failures"
$	write sys$output "There are definitly a few expired certificates"
$	@tverify.com
$	return
$ test_dh:
$	write sys$output "Generate a set of DH parameters"
$	mcr 'texe_dir''dhtest'
$	return
$ test_dsa:
$	write sys$output "Generate a set of DSA parameters"
$	mcr 'texe_dir''dsatest'
$	return
$ test_gen:
$	write sys$output "Generate and verify a certificate request"
$	@testgen.com
$	return
$ maybe_test_ss:
$	testss_RDT = f$cvtime(f$file_attributes("testss.com","RDT"))
$	if f$cvtime(f$file_attributes("keyU.ss","RDT")) .les. testss_RDT then -
		goto test_ss
$	if f$cvtime(f$file_attributes("certU.ss","RDT")) .les. testss_RDT then -
		goto test_ss
$	if f$cvtime(f$file_attributes("certCA.ss","RDT")) .les. testss_RDT then -
		goto test_ss
$	return
$ test_ss:
$	write sys$output "Generate and certify a test certificate"
$	@testss.com
$	return
$ test_engine:
$	write sys$output "Manipulate the ENGINE structures"
$	mcr 'texe_dir''enginetest'
$	return
$ test_ssl:
$	write sys$output "test SSL protocol"
$	gosub maybe_test_ss
$	@testssl.com keyU.ss certU.ss certCA.ss
$	return
$ test_ca:
$	set noon
$	define/user sys$output nla0:
$	mcr 'exe_dir'openssl no-rsa
$	save_severity=$SEVERITY
$	set on
$	if save_severity
$	then
$	    write sys$output "skipping CA.com test -- requires RSA"
$	else
$	    write sys$output "Generate and certify a test certificate via the 'ca' program"
$	    @testca.com
$	endif
$	return
$ test_aes:
$!	write sys$output "test AES"
$!	!mcr 'texe_dir''aestest'
$	return
$ test_tsa:
$	set noon
$	define/user sys$output nla0:
$	mcr 'exe_dir'openssl no-rsa
$	save_severity=$SEVERITY
$	set on
$	if save_severity
$	then
$	    write sys$output "skipping testtsa.com test -- requires RSA"
$	else
$	    @testtsa.com
$	endif
$	return
$
$
$ exit:
$	set default '__save_default'
$	exit


Formatting fixed.

Formatting fixed.

#!/usr/bin/env ruby

# TODO (later): Don't force tokens for methods that don't need them.
# TODO (maybe): DBG=ruby/curl/off. Curl would output curl commands.

############
# Helpers. #
############

def log(message)
  STDERR.puts("\x1B[1;30m~ #{message}\x1B[0m") unless ENV['DBG'] == 'off'
end

def dbg(command, arguments, **options)
  log "Terminal.#{command}(" +
    ("#{arguments.inspect[1..-2]}" unless arguments.empty?).to_s +
    (", " if ! arguments.empty? && ! options.empty?).to_s +
    ("#{options.inspect[1..-2]}" unless options.empty?).to_s +
    ")\n"
end

def try_highlight_syntax(json)
  CodeRay.scan(json, :json).term
rescue
  json
end

def print_as_json(data)
  json = JSON.pretty_generate(data)
  puts try_highlight_syntax(json)
end

def api_call(command, arguments, options)
  # Ruby **args expansion doesn't work as I expected, that's why the extra if.
  # pry(main)> def xxx(*args) args; end
  # pry(main)> xxx(**{})
  # => [{}]
  if options
    dbg command, arguments, options
    print_as_json Terminal.send(command, *arguments, **options)
  else
    dbg command, arguments
    print_as_json Terminal.send(command, *arguments)
  end
end

def usage
  if File.exist?(File.expand_path('../docs/help.txt', __dir__))
    # Running locally.
    puts File.read(File.expand_path('../docs/help.txt', __dir__))
  else
    # RubyGems installation.
    spec = Gem::Specification.find_by_name('terminal.com')
    puts File.read(File.join(spec.gem_dir, 'docs', 'help.txt'))
  end
end

#########
# Main. #
#########

require File.expand_path('../../lib/terminal.com', __FILE__)
require 'json'

begin
  require 'coderay'
rescue LoadError
  log "CodeRay is not installed. Syntax highlighting won't be available."
end

# -h | --help
if ARGV.include?('-h') || ARGV.include?('--help')
  puts usage; exit
end

if ARGV.first == 'configure'
  puts <<-EOF
Welcome to the Terminal.com CLI client.

We don't want to bother you with asking for credentials every single time,
so instead we'll ask you for them now and save them to ~/.terminal.com.json.

Alright?

Go to https://www.terminal.com/settings/api

And:
  EOF

  print "1. Paste your user token here: "
  user_token = STDIN.readline.chomp
  print "2. Generate an access token if you don't have one and paste it here: "
  access_token = STDIN.readline.chomp

  File.open(File.expand_path('~/.terminal.com.json'), 'w') do |file|
    file.puts({user_token: user_token, access_token: access_token}.to_json)
  end

  puts "\nYour tokens were saved to ~/.terminal.com.json."
  exit
end

# Tokens.
# TODO: Add --no-config
if File.exist?(File.expand_path('~/.terminal.com.json'))
  config = JSON.parse(File.read(File.expand_path('~/.terminal.com.json')))
  user_token, access_token = config.values_at('user_token', 'access_token')

  if user_token.nil?
    abort("Config file found, but user_token is missing. Add user_token key.")
  end

  if access_token.nil?
    abort("Config file found, but access_token is missing. Add access_token key.")
  end
else
  user_token, access_token = ARGV.shift(2)

  if user_token.nil? || access_token.nil?
    STDERR.puts("Credentials missing.\n\n")
    abort usage
  end
end

if ARGV.empty?
  STDERR.puts("Command missing.\n\n")
  abort usage
else
  command = ARGV.shift

  unless Terminal.respond_to?(command)
    STDERR.puts("Invalid command '#{command}'.\n\n")
    abort usage
  end

  # Not every method requires authentication.
  method_args = Terminal.method(command).parameters.map(&:last)

  if method_args.include?(:options)
    options = ARGV.reduce(Hash.new) do |buffer, argument|
      if argument.match(/^--(.+)=(.+)$/)
        buffer[$1.to_sym] = $2
      elsif argument.match(/^--no-(.+)$/)
        buffer[$1.to_sym] = false
      elsif argument.match(/^--(.+)$/)
        buffer[$1.to_sym] = true
      end

      buffer
    end

    ARGV.delete_if { |argument| argument.start_with?('--') }
  end

  arguments = []
  arguments << user_token if method_args.include?(:user_token)
  arguments << access_token if method_args.include?(:access_token)
  arguments.push(*ARGV)

  begin
    api_call(command, arguments, options)
  rescue Terminal::NetworkError
    abort "It seems that you're offline."
  end
end

#!/usr/bin/env ruby

# TODO (later): Don't force tokens for methods that don't need them.
# TODO (maybe): DBG=ruby/curl/off. Curl would output curl commands.

############
# Helpers. #
############

def log(message)
  STDERR.puts("\x1B[1;30m~ #{message}\x1B[0m") unless ENV['DBG'] == 'off'
end

def dbg(command, arguments, **options)
  log "Terminal.#{command}(" +
    ("#{arguments.inspect[1..-2]}" unless arguments.empty?).to_s +
    (", #{options.inspect[1..-2]}" unless options.empty?).to_s +
    ")\n"
end

def try_highlight_syntax(json)
  CodeRay.scan(json, :json).term
rescue
  json
end

def print_as_json(data)
  json = JSON.pretty_generate(data)
  puts try_highlight_syntax(json)
end

def api_call(command, arguments, options)
  # Ruby **args expansion doesn't work as I expected, that's why the extra if.
  # pry(main)> def xxx(*args) args; end
  # pry(main)> xxx(**{})
  # => [{}]
  if options
    dbg command, arguments, options
    print_as_json Terminal.send(command, *arguments, **options)
  else
    dbg command, arguments
    print_as_json Terminal.send(command, *arguments)
  end
end

def usage
  if File.exist?(File.expand_path('../docs/help.txt', __dir__))
    # Running locally.
    puts File.read(File.expand_path('../docs/help.txt', __dir__))
  else
    # RubyGems installation.
    spec = Gem::Specification.find_by_name('terminal.com')
    puts File.read(File.join(spec.gem_dir, 'docs', 'help.txt'))
  end
end

#########
# Main. #
#########

require File.expand_path('../../lib/terminal.com', __FILE__)
require 'json'

begin
  require 'coderay'
rescue LoadError
  log "CodeRay is not installed. Syntax highlighting won't be available."
end

# -h | --help
if ARGV.include?('-h') || ARGV.include?('--help')
  puts usage; exit
end

if ARGV.first == 'configure'
  puts <<-EOF
Welcome to the Terminal.com CLI client.

We don't want to bother you with asking for credentials every single time,
so instead we'll ask you for them now and save them to ~/.terminal.com.json.

Alright?

Go to https://www.terminal.com/settings/api

And:
  EOF

  print "1. Paste your user token here: "
  user_token = STDIN.readline.chomp
  print "2. Generate an access token if you don't have one and paste it here: "
  access_token = STDIN.readline.chomp

  File.open(File.expand_path('~/.terminal.com.json'), 'w') do |file|
    file.puts({user_token: user_token, access_token: access_token}.to_json)
  end

  puts "\nYour tokens were saved to ~/.terminal.com.json."
  exit
end

# Tokens.
# TODO: Add --no-config
if File.exist?(File.expand_path('~/.terminal.com.json'))
  config = JSON.parse(File.read(File.expand_path('~/.terminal.com.json')))
  user_token, access_token = config.values_at('user_token', 'access_token')

  if user_token.nil?
    abort("Config file found, but user_token is missing. Add user_token key.")
  end

  if access_token.nil?
    abort("Config file found, but access_token is missing. Add access_token key.")
  end
else
  user_token, access_token = ARGV.shift(2)

  if user_token.nil? || access_token.nil?
    STDERR.puts("Credentials missing.\n\n")
    abort usage
  end
end

if ARGV.empty?
  STDERR.puts("Command missing.\n\n")
  abort usage
else
  command = ARGV.shift

  unless Terminal.respond_to?(command)
    STDERR.puts("Invalid command '#{command}'.\n\n")
    abort usage
  end

  # Not every method requires authentication.
  method_args = Terminal.method(command).parameters.map(&:last)

  if method_args.include?(:options)
    options = ARGV.reduce(Hash.new) do |buffer, argument|
      if argument.match(/^--(.+)=(.+)$/)
        buffer[$1.to_sym] = $2
      elsif argument.match(/^--no-(.+)$/)
        buffer[$1.to_sym] = false
      elsif argument.match(/^--(.+)$/)
        buffer[$1.to_sym] = true
      end

      buffer
    end

    ARGV.delete_if { |argument| argument.start_with?('--') }
  end

  arguments = []
  arguments << user_token if method_args.include?(:user_token)
  arguments << access_token if method_args.include?(:access_token)
  arguments.push(*ARGV)

  begin
    api_call(command, arguments, options)
  rescue Terminal::NetworkError
    abort "It seems that you're offline."
  end
end


Fixed comment

Fixed comment


snoyman.com update

snoyman.com update


error: pathspec 'Sources--https/www.tr553.com/InterYield/bindevent.do?e=click' did not match any file(s) known to git