Commit 2ad688ed authored by John Malmberg's avatar John Malmberg Committed by Yang Tse
Browse files

Add in the files needed to build libcurl shared images on VMS.

Update the packages/vms/readme file to be current.

Also some files for the GNV based build were either missing or needed an
update.

curl_crtl_init.c is a special file that is run before main() to
set up the proper C runtime behavior.

generate_vax_transfer.com generates the VAX transfer vector modules from
the gnv_libcurl_symbols.opt file.

gnv_conftest.c_first is a helper file needed for configure scripts to
come up with the expected answers on VMS.

gnv_libcurl_symbols.opt is the public symbols for the libcurl shared
image.

gnv_link_curl.com builds the shared libcurl image and rebuilds other
programs to use it.

macro32_exactcase.patch is a hack to make a local copy of the VMS Macro32
assembler case sensitive, which is needed to build the VAX transfer modules.

report_openssl_version.c is a tool for help verify that the libcurl
shared image is being built for a minium version of openssl.
parent ca786233
Loading
Loading
Loading
Loading
+311 −0
Original line number Diff line number Diff line
/* File: curl_crtl_init.c
 *
 * This file makes sure that the DECC Unix settings are correct for
 * the mode the the program is run in.
 *
 * The CRTL has not been initialized at the time that these routines
 * are called, so many routines can not be called.
 *
 * This is a module that provides a LIB$INITIALIZE routine that
 * will turn on some CRTL features that are not enabled by default.
 *
 * The CRTL features can also be turned on via logical names, but that
 * impacts all programs and some aren't ready, willing, or able to handle
 * those settings.
 *
 * On VMS versions that are too old to use the feature setting API, this
 * module falls back to using logical names.
 *
 * Copyright 2013, John Malmberg
 *
 * 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.
 *
 */

/* Unix headers */
#include <stdio.h>
#include <string.h>

/* VMS specific headers */
#include <descrip.h>
#include <lnmdef.h>
#include <stsdef.h>

#pragma member_alignment save
#pragma nomember_alignment longword
#pragma message save
#pragma message disable misalgndmem
struct itmlst_3 {
  unsigned short int buflen;
  unsigned short int itmcode;
  void *bufadr;
  unsigned short int *retlen;
};
#pragma message restore
#pragma member_alignment restore

#ifdef __VAX
#define ENABLE "ENABLE"
#define DISABLE "DISABLE"
#else

#define ENABLE TRUE
#define DISABLE 0
int   decc$feature_get_index (const char *name);
int   decc$feature_set_value (int index, int mode, int value);
#endif

int   SYS$TRNLNM(
    const unsigned long * attr,
    const struct dsc$descriptor_s * table_dsc,
    struct dsc$descriptor_s * name_dsc,
    const unsigned char * acmode,
    const struct itmlst_3 * item_list);
int   SYS$CRELNM(
    const unsigned long * attr,
    const struct dsc$descriptor_s * table_dsc,
    const struct dsc$descriptor_s * name_dsc,
    const unsigned char * acmode,
    const struct itmlst_3 * item_list);


/* Take all the fun out of simply looking up a logical name */
static int sys_trnlnm
   (const char * logname,
    char * value,
    int value_len)
{
    const $DESCRIPTOR(table_dsc, "LNM$FILE_DEV");
    const unsigned long attr = LNM$M_CASE_BLIND;
    struct dsc$descriptor_s name_dsc;
    int status;
    unsigned short result;
    struct itmlst_3 itlst[2];

    itlst[0].buflen = value_len;
    itlst[0].itmcode = LNM$_STRING;
    itlst[0].bufadr = value;
    itlst[0].retlen = &result;

    itlst[1].buflen = 0;
    itlst[1].itmcode = 0;

    name_dsc.dsc$w_length = strlen(logname);
    name_dsc.dsc$a_pointer = (char *)logname;
    name_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
    name_dsc.dsc$b_class = DSC$K_CLASS_S;

    status = SYS$TRNLNM(&attr, &table_dsc, &name_dsc, 0, itlst);

    if ($VMS_STATUS_SUCCESS(status)) {

         /* Null terminate and return the string */
        /*--------------------------------------*/
        value[result] = '\0';
    }

    return status;
}

/* How to simply create a logical name */
static int sys_crelnm
   (const char * logname,
    const char * value)
{
    int ret_val;
    const char * proc_table = "LNM$PROCESS_TABLE";
    struct dsc$descriptor_s proc_table_dsc;
    struct dsc$descriptor_s logname_dsc;
    struct itmlst_3 item_list[2];

    proc_table_dsc.dsc$a_pointer = (char *) proc_table;
    proc_table_dsc.dsc$w_length = strlen(proc_table);
    proc_table_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
    proc_table_dsc.dsc$b_class = DSC$K_CLASS_S;

    logname_dsc.dsc$a_pointer = (char *) logname;
    logname_dsc.dsc$w_length = strlen(logname);
    logname_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
    logname_dsc.dsc$b_class = DSC$K_CLASS_S;

    item_list[0].buflen = strlen(value);
    item_list[0].itmcode = LNM$_STRING;
    item_list[0].bufadr = (char *)value;
    item_list[0].retlen = NULL;

    item_list[1].buflen = 0;
    item_list[1].itmcode = 0;

    ret_val = SYS$CRELNM(NULL, &proc_table_dsc, &logname_dsc, NULL, item_list);

    return ret_val;
}


 /* Start of DECC RTL Feature handling */

/*
** Sets default value for a feature
*/
#ifdef __VAX
static void set_feature_default(const char *name, const char *value)
{
    sys_crelnm(name, value);
}
#else
static void set_feature_default(const char *name, int value)
{
    int index;

    index = decc$feature_get_index(name);

    if (index > 0)
        decc$feature_set_value (index, 0, value);
}
#endif

static void set_features(void)
{
    int status;
    char unix_shell_name[255];
    int use_unix_settings = 1;

    status = sys_trnlnm("GNV$UNIX_SHELL",
                        unix_shell_name, sizeof unix_shell_name -1);
    if (!$VMS_STATUS_SUCCESS(status)) {
        unix_shell_name[0] = 0;
        use_unix_settings = 0;
    }

    /* ACCESS should check ACLs or it is lying. */
    set_feature_default("DECC$ACL_ACCESS_CHECK", ENABLE);

    /* We always want the new parse style */
    set_feature_default ("DECC$ARGV_PARSE_STYLE" , ENABLE);


    /* Unless we are in POSIX compliant mode, we want the old POSIX root
     * enabled.
     */
    set_feature_default("DECC$DISABLE_POSIX_ROOT", DISABLE);

    /* EFS charset, means UTF-8 support */
    /* VTF-7 support is controlled by a feature setting called UTF8 */
    set_feature_default ("DECC$EFS_CHARSET", ENABLE);
    set_feature_default ("DECC$EFS_CASE_PRESERVE", ENABLE);

    /* Support timestamps when available */
    set_feature_default ("DECC$EFS_FILE_TIMESTAMPS", ENABLE);

    /* Cache environment variables - performance improvements */
    set_feature_default ("DECC$ENABLE_GETENV_CACHE", ENABLE);

    /* Start out with new file attribute inheritance */
#ifdef __VAX
    set_feature_default ("DECC$EXEC_FILEATTR_INHERITANCE", "2");
#else
    set_feature_default ("DECC$EXEC_FILEATTR_INHERITANCE", 2);
#endif

    /* Don't display trailing dot after files without type */
    set_feature_default ("DECC$READDIR_DROPDOTNOTYPE", ENABLE);

    /* For standard output channels buffer output until terminator */
    /* Gets rid of output logs with single character lines in them. */
    set_feature_default ("DECC$STDIO_CTX_EOL", ENABLE);

    /* Fix mv aa.bb aa  */
    set_feature_default ("DECC$RENAME_NO_INHERIT", ENABLE);

    if (use_unix_settings) {

        /* POSIX requires that open files be able to be removed */
        set_feature_default ("DECC$ALLOW_REMOVE_OPEN_FILES", ENABLE);

        /* Default to outputting UNIX filesnames in VMS routines */
        set_feature_default ("DECC$FILENAME_UNIX_ONLY", ENABLE);
        /* FILENAME_UNIX_ONLY Implicitly sets */
        /* decc$disable_to_vms_logname_translation */

        set_feature_default ("DECC$FILE_PERMISSION_UNIX", ENABLE);

        set_feature_default ("DECC$FILE_SHARING", ENABLE);

        set_feature_default ("DECC$FILE_OWNER_UNIX", ENABLE);
        set_feature_default ("DECC$POSIX_SEEK_STREAM_FILE", ENABLE);

    } else {
        set_feature_default("DECC$FILENAME_UNIX_REPORT", ENABLE);
    }

    /* When reporting UNIX filenames, glob the same way */
    set_feature_default ("DECC$GLOB_UNIX_STYLE", ENABLE);

    /* The VMS version numbers on Unix filenames is incompatible with most */
    /* ported packages. */
    set_feature_default("DECC$FILENAME_UNIX_NO_VERSION", ENABLE);

    /* The VMS version numbers on Unix filenames is incompatible with most */
    /* ported packages. */
    set_feature_default("DECC$UNIX_PATH_BEFORE_LOGNAME", ENABLE);

    /* Set strtol to proper behavior */
    set_feature_default("DECC$STRTOL_ERANGE", ENABLE);

    /* Commented here to prevent future bugs:  A program or user should */
    /* never ever enable DECC$POSIX_STYLE_UID. */
    /* It will probably break all code that accesses UIDs */
    /*  do_not_set_default ("DECC$POSIX_STYLE_UID", TRUE); */
}


/* Some boilerplate to force this to be a proper LIB$INITIALIZE section */

#pragma nostandard
#pragma extern_model save
#ifdef __VAX
#pragma extern_model strict_refdef "LIB$INITIALIZE" nowrt, long, nopic
#else
#pragma extern_model strict_refdef "LIB$INITIALIZE" nowrt, long
#    if __INITIAL_POINTER_SIZE
#        pragma __pointer_size __save
#        pragma __pointer_size 32
#    else
#        pragma __required_pointer_size __save
#        pragma __required_pointer_size 32
#    endif
#endif
/* Set our contribution to the LIB$INITIALIZE array */
void (* const iniarray[])(void) = {set_features, } ;
#ifndef __VAX
#    if __INITIAL_POINTER_SIZE
#        pragma __pointer_size __restore
#    else
#        pragma __required_pointer_size __restore
#    endif
#endif


/*
** Force a reference to LIB$INITIALIZE to ensure it
** exists in the image.
*/
int LIB$INITIALIZE(void);
#ifdef __DECC
#pragma extern_model strict_refdef
#endif
    int lib_init_ref = (int) LIB$INITIALIZE;
#ifdef __DECC
#pragma extern_model restore
#pragma standard
#endif
+274 −0
Original line number Diff line number Diff line
$! File: generate_vax_transfer.com
$!
$! $Id$
$!
$! File to generate and compile the VAX transfer vectors from reading in the
$! Alpha/Itanium gnv_libcurl_symbols.opt file.
$!
$! This procedure patches the VAX Macro32 assembler to be case sensitive
$! and then compiles the generated
$!
$! The output of this procedure is:
$!     gnv_libcurl_xfer.mar_exact
$!     gnv_libcurl_xfer.obj
$!     gnv_libcurl_xfer.opt
$!     macro32_exactcase.exe
$!
$! Copyright 2013, John Malmberg
$!
$! 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.
$!
$! 20-Jul-2013  J. Malmberg
$!============================================================================
$!
$! Save this so we can get back.
$ default_dir = f$environment("default")
$!
$ on warning then goto all_exit
$!
$! Want hard tabs in the generated file.
$ tab[0,8] = 9
$!
$! This procedure is used on VAX only
$ if (f$getsyi("HW_MODEL") .ge. 1024)
$ then
$   write sys$output "This procedure is only used on VAX."
$   goto all_exit
$ endif
$!
$!
$! Get the libcurl version to generate the ident string.
$! ident string is max of 31 characters.
$!
$ ident_string = "unknown"
$ open/read cver [-.-.include.curl]curlver.h
$cver_loop:
$ read/end=cver_loop_end cver line_in
$ line_in = f$edit(line_in, "COMPRESS,TRIM")
$ if line_in .eqs. "" then goto cver_loop
$ code = f$extract(0, 1, line_in)
$ if code .nes. "#" then goto cver_loop
$ directive = f$element(0, " ", line_in)
$ if directive .nes. "#define" then goto cver_loop
$ name = f$element(1, " ", line_in)
$ if name .nes. "LIBCURL_VERSION" then goto cver_loop
$ ident_string = f$element(2, " ", line_in) - "" - ""
$cver_loop_end:
$ close cver
$!
$ open/read aopt gnv_libcurl_symbols.opt
$!
$! Write out the header
$ gosub do_header
$!
$ open/append vopt gnv_libcurl_xfer.mar_exact
$ write vopt tab,".IDENT /", ident_string, "/"
$!
$ write vopt tab, ".PSECT LIBCURL_XFERVECTORS  -"
$ write vopt tab,tab,tab, "PIC,USR,CON,REL,GBL,SHR,EXE,RD,NOWRT,QUAD"
$ write vopt ""
$ write vopt tab, "SPARE", tab, "; never delete this spare"
$ write vopt ";"
$ write vopt ";", tab, "Exact case and upper case transfer vectors"
$!
$ alias_count = 0
$vector_loop:
$!
$!  Read in symbol_vector
$!
$   read/end=vector_loop_end aopt line_in
$   line = f$edit(line_in, "UNCOMMENT,COMPRESS,TRIM")
$   if line .eqs. "" then goto vector_loop
$!
$   line_u = f$edit(line, "UPCASE")
$   key = f$element(0, "=", line_u)
$   if (key .eqs. "SYMBOL_VECTOR")
$   then
$       symbol_string = f$element(1, "=", line) - "("
$       symbol_type = f$element(2, "=", line_u) - ")"
$       symbol_name = f$element(1, "/", symbol_string)
$       if symbol_type .nes. "PROCEDURE"
$       then
$           write sys$output "%CURLBUILD-W-NOTPROC, " + -
$                            "This procedure can only handle procedure vectors"
$           write sys$output -
"Data vectors require manual construction for which this procedure or"
$           write sys$output -
"the shared library needs to be updated to resolve."
$           write sys$output -
"the preferred solution is to have a procedure return the address of the "
$           write sys$output -
"the variable instead of having a variable, as if the size of the variable "
            write sys$output -
"changes, the symbol vector is no longer backwards compatible."
$       endif
$       if (symbol_name .eqs. "/")
$       then
$           symbol_name = symbol_string
$           write vopt tab, symbol_type, tab, symbol_name
$       else
$           alias_count = alias_count + 1
$           symbol_alias = f$element(0, "/", symbol_string)
$           write vopt -
                  tab, "''symbol_type_U", tab, symbol_name, tab, symbol_alias
$       endif
$   endif
$   goto vector_loop
$vector_loop_end:
$!
$! End of pass one, second pass needed if aliases exist
$ close aopt
$!
$ if alias_count .eq. 0 then goto finish_file
$!
$! Start pass 2, write stub routine header
$!
$ open/read aopt gnv_libcurl_symbols.opt
$!
$alias_loop:
$!
$!  Read in symbol_vector
$!
$   read/end=alias_loop_end aopt line_in
$   line = f$edit(line_in, "UNCOMMENT,COMPRESS,TRIM")
$   if line .eqs. "" then goto alias_loop
$!
$   line_u = f$edit(line, "UPCASE")
$   key = f$element(0, "=", line_u)
$   if (key .eqs. "SYMBOL_VECTOR")
$   then
$       symbol_string = f$element(1, "=", line) - "("
$       symbol_type = f$element(2, "=", line_u) - ")"
$       symbol_name = f$element(1, "/", symbol_string)
$       if (symbol_name .eqs. "/")
$       then
$           symbol_name = symbol_string
$       else
$           alias_count = alias_count + 1
$           symbol_alias = f$element(0, "/", symbol_string)
$           write vopt tab, ".ENTRY", tab, symbol_alias, ", ^M<>"
$       endif
$   endif
$   goto alias_loop
$! read in symbol_vector
$! if not alias, then loop
$! write out subroutine name
$!
$alias_loop_end:
$!
$ write vopt tab, "MOVL #1, R0"
$ write vopt tab, "RET"
$!
$finish_file:
$!
$ write vopt ""
$ write vopt tab, ".END"
$!
$ close aopt
$ close vopt
$!
$! Patch the Macro32 compiler
$!----------------------------
$ patched_macro = "sys$disk:[]macro32_exactcase.exe"
$ if f$search(patched_macro) .eqs. ""
$ then
$   copy sys$system:macro32.exe 'patched_macro'
$   patch @macro32_exactcase.patch
$ endif
$ define/user macro32 'patched_macro'
$ macro/object=gnv_libcurl_xfer.obj gnv_libcurl_xfer.mar_exact
$!
$! Create the option file for linking the shared image.
$ create gnv_libcurl_xfer.opt
$ open/append lco gnv_libcurl_xfer.opt
$ write lco "gsmatch=lequal,1,1"
$ write lco "cluster=transfer_vector,,,''default_dir'gnv_libcurl_xfer"
$ write lco "collect=libcurl_global, libcurl_xfervectors"
$ close lco
$!
$!
$ goto all_exit
$!
$! Process the header
$do_header:
$!
$! Force the mode of the file to same as text editor generated.
$ create gnv_libcurl_xfer.mar_exact
$deck
; File: gnv_libcurl_xfer.mar_exact
;
; VAX transfer vectors
;
; This needs to be compiled with a specialized patch on Macro32 to make it
; preserve the case of symbols instead of converting it to uppercase.
;
; This patched Macro32 requires all directives to be in upper case.
;
; There are three sets of symbols for transfer vectors here.
;
; The first for upper case which matches the tradition method of generating
; VAX transfer vectors.
;
; The second is the exact case for compatibilty with open source C programs
; that expect exact case symbols in images.  These are separated because a
; previous kit had only upper case symbols.
;
; The third is the routine stub that is used to resolve part of the upper
; case transfer vectors, with exact case entry symbols.
;
; When you add routines, you need to add them after the second set of transfer
; vectors for both upper and exact case, and then additional entry points
; in upper case added to stub routines.
;
;*************************************************************************

        .TITLE libcurl_xfer - Transfer vector for libcurl
        .DISABLE GLOBAL

;
; Macro to generate a transfer vector entry
;
        .MACRO  PROCEDURE       NAME
        .EXTRN          'NAME
        .ALIGN  QUAD
        .TRANSFER       'NAME
        .MASK           'NAME
        JMP             'NAME+2
        .ENDM

        .MACRO  PROCEDUREU      NAME    NAMEU
        .EXTRN          'NAME
        .ALIGN  QUAD
        .TRANSFER       'NAMEU
        .MASK           'NAME
        JMP             'NAME+2

        .ENDM
;
;
; Macro to reserve a spare entry.
;
        .MACRO  SPARE
        .ALIGN QUAD
        .ALIGN QUAD
        .QUAD   0
        .ENDM

$EOD
$!
$!
$ return
$!
$all_exit:
$set def 'default_dir'
$exit '$status'
+61 −0
Original line number Diff line number Diff line
/* File: GNV$CONFTEST.C_FIRST
 *
 * $Id$
 *
 * Copyright 2009, John Malmberg
 *
 * 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.
 *
 */

/* This is needed for Configure tests to get the correct exit status */
void __posix_exit(int __status);
#define exit(__p1) __posix_exit(__p1)

/* Fake pass the test to find a standard ldap routine that we know is */
/* present on VMS, but with the wrong case for the symbol */
char ldap_url_parse(void) {return 0;}

/* These are to pass the test that does not use headers */
/* Because configure does an #undef which keeps us from using #define */
/* char CRYPTO_add_lock(void) {return 0;} */
char SSL_connnect(void) {return 0;}
char ENGINE_init(void) {return 0;}
char RAND_status(void) {return 0;}
/* char RAND_screen(void) {return 0;} In headers, but not present */
char RAND_egd(void) {return 0;}
char CRYPTO_cleanup_all_ex_data(void) {return 0;}
char SSL_get_shutdown(void) {return 0;}
char ENGINE_load_builtin_engines (void) {return 0;}

/* And these are to pass the test that uses headers. */
/* Because the HP OpenSSL transfer vectors are currently in Upper case only */
#pragma message disable macroredef
#define CRYPTO_add_lock CRYPTO_ADD_LOCK
#define SSL_connect SSL_CONNECT
#define ENGINE_init ENGINE_INIT
#define RAND_status RAND_STATUS
/* #define RAND_screen RAND_SCREEN */
#define RAND_egd RAND_EGD
#define CRYPTO_cleanup_all_ex_data CRYPTO_CLEANUP_ALL_EX_DATA
#define SSL_get_shutdown SSL_GET_SHUTDOWN
#define ENGINE_load_builtin_engines ENGINE_LOAD_BUILTIN_ENGINES

/* Can not use the #define macro to fix the case on CRYPTO_lock because */
/* there is a macro CRYPTO_LOCK that is a number */

/* After all the work to get configure to pass the CRYPTO_LOCK tests,
 * it turns out that VMS does not have the CRYPTO_LOCK symbol in the
 * transfer vector, even though it is in the header file.
 */
+181 −0

File added.

Preview size limit exceeded, changes collapsed.

+845 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading