1*2139Sjp161948 /* dso_vms.c -*- mode:C; c-file-style: "eay" -*- */
20Sstevel@tonic-gate /* Written by Richard Levitte (richard@levitte.org) for the OpenSSL
30Sstevel@tonic-gate * project 2000.
40Sstevel@tonic-gate */
50Sstevel@tonic-gate /* ====================================================================
60Sstevel@tonic-gate * Copyright (c) 2000 The OpenSSL Project. All rights reserved.
70Sstevel@tonic-gate *
80Sstevel@tonic-gate * Redistribution and use in source and binary forms, with or without
90Sstevel@tonic-gate * modification, are permitted provided that the following conditions
100Sstevel@tonic-gate * are met:
110Sstevel@tonic-gate *
120Sstevel@tonic-gate * 1. Redistributions of source code must retain the above copyright
130Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer.
140Sstevel@tonic-gate *
150Sstevel@tonic-gate * 2. Redistributions in binary form must reproduce the above copyright
160Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer in
170Sstevel@tonic-gate * the documentation and/or other materials provided with the
180Sstevel@tonic-gate * distribution.
190Sstevel@tonic-gate *
200Sstevel@tonic-gate * 3. All advertising materials mentioning features or use of this
210Sstevel@tonic-gate * software must display the following acknowledgment:
220Sstevel@tonic-gate * "This product includes software developed by the OpenSSL Project
230Sstevel@tonic-gate * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
240Sstevel@tonic-gate *
250Sstevel@tonic-gate * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
260Sstevel@tonic-gate * endorse or promote products derived from this software without
270Sstevel@tonic-gate * prior written permission. For written permission, please contact
280Sstevel@tonic-gate * licensing@OpenSSL.org.
290Sstevel@tonic-gate *
300Sstevel@tonic-gate * 5. Products derived from this software may not be called "OpenSSL"
310Sstevel@tonic-gate * nor may "OpenSSL" appear in their names without prior written
320Sstevel@tonic-gate * permission of the OpenSSL Project.
330Sstevel@tonic-gate *
340Sstevel@tonic-gate * 6. Redistributions of any form whatsoever must retain the following
350Sstevel@tonic-gate * acknowledgment:
360Sstevel@tonic-gate * "This product includes software developed by the OpenSSL Project
370Sstevel@tonic-gate * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
380Sstevel@tonic-gate *
390Sstevel@tonic-gate * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
400Sstevel@tonic-gate * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
410Sstevel@tonic-gate * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
420Sstevel@tonic-gate * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
430Sstevel@tonic-gate * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
440Sstevel@tonic-gate * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
450Sstevel@tonic-gate * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
460Sstevel@tonic-gate * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
470Sstevel@tonic-gate * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
480Sstevel@tonic-gate * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
490Sstevel@tonic-gate * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
500Sstevel@tonic-gate * OF THE POSSIBILITY OF SUCH DAMAGE.
510Sstevel@tonic-gate * ====================================================================
520Sstevel@tonic-gate *
530Sstevel@tonic-gate * This product includes cryptographic software written by Eric Young
540Sstevel@tonic-gate * (eay@cryptsoft.com). This product includes software written by Tim
550Sstevel@tonic-gate * Hudson (tjh@cryptsoft.com).
560Sstevel@tonic-gate *
570Sstevel@tonic-gate */
580Sstevel@tonic-gate
590Sstevel@tonic-gate #include <stdio.h>
600Sstevel@tonic-gate #include <string.h>
610Sstevel@tonic-gate #include <errno.h>
620Sstevel@tonic-gate #include "cryptlib.h"
630Sstevel@tonic-gate #include <openssl/dso.h>
640Sstevel@tonic-gate #ifdef OPENSSL_SYS_VMS
650Sstevel@tonic-gate #pragma message disable DOLLARID
66*2139Sjp161948 #include <rms.h>
670Sstevel@tonic-gate #include <lib$routines.h>
680Sstevel@tonic-gate #include <stsdef.h>
690Sstevel@tonic-gate #include <descrip.h>
700Sstevel@tonic-gate #include <starlet.h>
710Sstevel@tonic-gate #endif
720Sstevel@tonic-gate
730Sstevel@tonic-gate #ifndef OPENSSL_SYS_VMS
DSO_METHOD_vms(void)740Sstevel@tonic-gate DSO_METHOD *DSO_METHOD_vms(void)
750Sstevel@tonic-gate {
760Sstevel@tonic-gate return NULL;
770Sstevel@tonic-gate }
780Sstevel@tonic-gate #else
790Sstevel@tonic-gate #pragma message disable DOLLARID
800Sstevel@tonic-gate
810Sstevel@tonic-gate static int vms_load(DSO *dso);
820Sstevel@tonic-gate static int vms_unload(DSO *dso);
830Sstevel@tonic-gate static void *vms_bind_var(DSO *dso, const char *symname);
840Sstevel@tonic-gate static DSO_FUNC_TYPE vms_bind_func(DSO *dso, const char *symname);
850Sstevel@tonic-gate #if 0
860Sstevel@tonic-gate static int vms_unbind_var(DSO *dso, char *symname, void *symptr);
870Sstevel@tonic-gate static int vms_unbind_func(DSO *dso, char *symname, DSO_FUNC_TYPE symptr);
880Sstevel@tonic-gate static int vms_init(DSO *dso);
890Sstevel@tonic-gate static int vms_finish(DSO *dso);
900Sstevel@tonic-gate static long vms_ctrl(DSO *dso, int cmd, long larg, void *parg);
910Sstevel@tonic-gate #endif
920Sstevel@tonic-gate static char *vms_name_converter(DSO *dso, const char *filename);
93*2139Sjp161948 static char *vms_merger(DSO *dso, const char *filespec1,
94*2139Sjp161948 const char *filespec2);
950Sstevel@tonic-gate
960Sstevel@tonic-gate static DSO_METHOD dso_meth_vms = {
970Sstevel@tonic-gate "OpenSSL 'VMS' shared library method",
980Sstevel@tonic-gate vms_load,
990Sstevel@tonic-gate NULL, /* unload */
1000Sstevel@tonic-gate vms_bind_var,
1010Sstevel@tonic-gate vms_bind_func,
1020Sstevel@tonic-gate /* For now, "unbind" doesn't exist */
1030Sstevel@tonic-gate #if 0
1040Sstevel@tonic-gate NULL, /* unbind_var */
1050Sstevel@tonic-gate NULL, /* unbind_func */
1060Sstevel@tonic-gate #endif
1070Sstevel@tonic-gate NULL, /* ctrl */
1080Sstevel@tonic-gate vms_name_converter,
109*2139Sjp161948 vms_merger,
1100Sstevel@tonic-gate NULL, /* init */
1110Sstevel@tonic-gate NULL /* finish */
1120Sstevel@tonic-gate };
1130Sstevel@tonic-gate
1140Sstevel@tonic-gate /* On VMS, the only "handle" is the file name. LIB$FIND_IMAGE_SYMBOL depends
1150Sstevel@tonic-gate * on the reference to the file name being the same for all calls regarding
1160Sstevel@tonic-gate * one shared image, so we'll just store it in an instance of the following
1170Sstevel@tonic-gate * structure and put a pointer to that instance in the meth_data stack.
1180Sstevel@tonic-gate */
1190Sstevel@tonic-gate typedef struct dso_internal_st
1200Sstevel@tonic-gate {
1210Sstevel@tonic-gate /* This should contain the name only, no directory,
1220Sstevel@tonic-gate * no extension, nothing but a name. */
1230Sstevel@tonic-gate struct dsc$descriptor_s filename_dsc;
1240Sstevel@tonic-gate char filename[FILENAME_MAX+1];
1250Sstevel@tonic-gate /* This contains whatever is not in filename, if needed.
1260Sstevel@tonic-gate * Normally not defined. */
1270Sstevel@tonic-gate struct dsc$descriptor_s imagename_dsc;
1280Sstevel@tonic-gate char imagename[FILENAME_MAX+1];
1290Sstevel@tonic-gate } DSO_VMS_INTERNAL;
1300Sstevel@tonic-gate
1310Sstevel@tonic-gate
DSO_METHOD_vms(void)1320Sstevel@tonic-gate DSO_METHOD *DSO_METHOD_vms(void)
1330Sstevel@tonic-gate {
1340Sstevel@tonic-gate return(&dso_meth_vms);
1350Sstevel@tonic-gate }
1360Sstevel@tonic-gate
vms_load(DSO * dso)1370Sstevel@tonic-gate static int vms_load(DSO *dso)
1380Sstevel@tonic-gate {
1390Sstevel@tonic-gate void *ptr = NULL;
1400Sstevel@tonic-gate /* See applicable comments in dso_dl.c */
1410Sstevel@tonic-gate char *filename = DSO_convert_filename(dso, NULL);
1420Sstevel@tonic-gate DSO_VMS_INTERNAL *p;
1430Sstevel@tonic-gate const char *sp1, *sp2; /* Search result */
1440Sstevel@tonic-gate
1450Sstevel@tonic-gate if(filename == NULL)
1460Sstevel@tonic-gate {
147*2139Sjp161948 DSOerr(DSO_F_VMS_LOAD,DSO_R_NO_FILENAME);
1480Sstevel@tonic-gate goto err;
1490Sstevel@tonic-gate }
1500Sstevel@tonic-gate
1510Sstevel@tonic-gate /* A file specification may look like this:
1520Sstevel@tonic-gate *
1530Sstevel@tonic-gate * node::dev:[dir-spec]name.type;ver
1540Sstevel@tonic-gate *
1550Sstevel@tonic-gate * or (for compatibility with TOPS-20):
1560Sstevel@tonic-gate *
1570Sstevel@tonic-gate * node::dev:<dir-spec>name.type;ver
1580Sstevel@tonic-gate *
1590Sstevel@tonic-gate * and the dir-spec uses '.' as separator. Also, a dir-spec
1600Sstevel@tonic-gate * may consist of several parts, with mixed use of [] and <>:
1610Sstevel@tonic-gate *
1620Sstevel@tonic-gate * [dir1.]<dir2>
1630Sstevel@tonic-gate *
1640Sstevel@tonic-gate * We need to split the file specification into the name and
1650Sstevel@tonic-gate * the rest (both before and after the name itself).
1660Sstevel@tonic-gate */
1670Sstevel@tonic-gate /* Start with trying to find the end of a dir-spec, and save the
1680Sstevel@tonic-gate position of the byte after in sp1 */
1690Sstevel@tonic-gate sp1 = strrchr(filename, ']');
1700Sstevel@tonic-gate sp2 = strrchr(filename, '>');
1710Sstevel@tonic-gate if (sp1 == NULL) sp1 = sp2;
1720Sstevel@tonic-gate if (sp2 != NULL && sp2 > sp1) sp1 = sp2;
1730Sstevel@tonic-gate if (sp1 == NULL) sp1 = strrchr(filename, ':');
1740Sstevel@tonic-gate if (sp1 == NULL)
1750Sstevel@tonic-gate sp1 = filename;
1760Sstevel@tonic-gate else
1770Sstevel@tonic-gate sp1++; /* The byte after the found character */
1780Sstevel@tonic-gate /* Now, let's see if there's a type, and save the position in sp2 */
1790Sstevel@tonic-gate sp2 = strchr(sp1, '.');
1800Sstevel@tonic-gate /* If we found it, that's where we'll cut. Otherwise, look for a
1810Sstevel@tonic-gate version number and save the position in sp2 */
1820Sstevel@tonic-gate if (sp2 == NULL) sp2 = strchr(sp1, ';');
1830Sstevel@tonic-gate /* If there was still nothing to find, set sp2 to point at the end of
1840Sstevel@tonic-gate the string */
1850Sstevel@tonic-gate if (sp2 == NULL) sp2 = sp1 + strlen(sp1);
1860Sstevel@tonic-gate
1870Sstevel@tonic-gate /* Check that we won't get buffer overflows */
1880Sstevel@tonic-gate if (sp2 - sp1 > FILENAME_MAX
1890Sstevel@tonic-gate || (sp1 - filename) + strlen(sp2) > FILENAME_MAX)
1900Sstevel@tonic-gate {
1910Sstevel@tonic-gate DSOerr(DSO_F_VMS_LOAD,DSO_R_FILENAME_TOO_BIG);
1920Sstevel@tonic-gate goto err;
1930Sstevel@tonic-gate }
1940Sstevel@tonic-gate
1950Sstevel@tonic-gate p = (DSO_VMS_INTERNAL *)OPENSSL_malloc(sizeof(DSO_VMS_INTERNAL));
1960Sstevel@tonic-gate if(p == NULL)
1970Sstevel@tonic-gate {
1980Sstevel@tonic-gate DSOerr(DSO_F_VMS_LOAD,ERR_R_MALLOC_FAILURE);
1990Sstevel@tonic-gate goto err;
2000Sstevel@tonic-gate }
2010Sstevel@tonic-gate
2020Sstevel@tonic-gate strncpy(p->filename, sp1, sp2-sp1);
2030Sstevel@tonic-gate p->filename[sp2-sp1] = '\0';
2040Sstevel@tonic-gate
2050Sstevel@tonic-gate strncpy(p->imagename, filename, sp1-filename);
2060Sstevel@tonic-gate p->imagename[sp1-filename] = '\0';
2070Sstevel@tonic-gate strcat(p->imagename, sp2);
2080Sstevel@tonic-gate
2090Sstevel@tonic-gate p->filename_dsc.dsc$w_length = strlen(p->filename);
2100Sstevel@tonic-gate p->filename_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
2110Sstevel@tonic-gate p->filename_dsc.dsc$b_class = DSC$K_CLASS_S;
2120Sstevel@tonic-gate p->filename_dsc.dsc$a_pointer = p->filename;
2130Sstevel@tonic-gate p->imagename_dsc.dsc$w_length = strlen(p->imagename);
2140Sstevel@tonic-gate p->imagename_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
2150Sstevel@tonic-gate p->imagename_dsc.dsc$b_class = DSC$K_CLASS_S;
2160Sstevel@tonic-gate p->imagename_dsc.dsc$a_pointer = p->imagename;
2170Sstevel@tonic-gate
2180Sstevel@tonic-gate if(!sk_push(dso->meth_data, (char *)p))
2190Sstevel@tonic-gate {
2200Sstevel@tonic-gate DSOerr(DSO_F_VMS_LOAD,DSO_R_STACK_ERROR);
2210Sstevel@tonic-gate goto err;
2220Sstevel@tonic-gate }
2230Sstevel@tonic-gate
2240Sstevel@tonic-gate /* Success (for now, we lie. We actually do not know...) */
2250Sstevel@tonic-gate dso->loaded_filename = filename;
2260Sstevel@tonic-gate return(1);
2270Sstevel@tonic-gate err:
2280Sstevel@tonic-gate /* Cleanup! */
2290Sstevel@tonic-gate if(p != NULL)
2300Sstevel@tonic-gate OPENSSL_free(p);
2310Sstevel@tonic-gate if(filename != NULL)
2320Sstevel@tonic-gate OPENSSL_free(filename);
2330Sstevel@tonic-gate return(0);
2340Sstevel@tonic-gate }
2350Sstevel@tonic-gate
2360Sstevel@tonic-gate /* Note that this doesn't actually unload the shared image, as there is no
2370Sstevel@tonic-gate * such thing in VMS. Next time it get loaded again, a new copy will
2380Sstevel@tonic-gate * actually be loaded.
2390Sstevel@tonic-gate */
vms_unload(DSO * dso)2400Sstevel@tonic-gate static int vms_unload(DSO *dso)
2410Sstevel@tonic-gate {
2420Sstevel@tonic-gate DSO_VMS_INTERNAL *p;
2430Sstevel@tonic-gate if(dso == NULL)
2440Sstevel@tonic-gate {
2450Sstevel@tonic-gate DSOerr(DSO_F_VMS_UNLOAD,ERR_R_PASSED_NULL_PARAMETER);
2460Sstevel@tonic-gate return(0);
2470Sstevel@tonic-gate }
2480Sstevel@tonic-gate if(sk_num(dso->meth_data) < 1)
2490Sstevel@tonic-gate return(1);
2500Sstevel@tonic-gate p = (DSO_VMS_INTERNAL *)sk_pop(dso->meth_data);
2510Sstevel@tonic-gate if(p == NULL)
2520Sstevel@tonic-gate {
2530Sstevel@tonic-gate DSOerr(DSO_F_VMS_UNLOAD,DSO_R_NULL_HANDLE);
2540Sstevel@tonic-gate return(0);
2550Sstevel@tonic-gate }
2560Sstevel@tonic-gate /* Cleanup */
2570Sstevel@tonic-gate OPENSSL_free(p);
2580Sstevel@tonic-gate return(1);
2590Sstevel@tonic-gate }
2600Sstevel@tonic-gate
2610Sstevel@tonic-gate /* We must do this in a separate function because of the way the exception
2620Sstevel@tonic-gate handler works (it makes this function return */
do_find_symbol(DSO_VMS_INTERNAL * ptr,struct dsc$descriptor_s * symname_dsc,void ** sym,unsigned long flags)2630Sstevel@tonic-gate static int do_find_symbol(DSO_VMS_INTERNAL *ptr,
2640Sstevel@tonic-gate struct dsc$descriptor_s *symname_dsc, void **sym,
2650Sstevel@tonic-gate unsigned long flags)
2660Sstevel@tonic-gate {
2670Sstevel@tonic-gate /* Make sure that signals are caught and returned instead of
2680Sstevel@tonic-gate aborting the program. The exception handler gets unestablished
2690Sstevel@tonic-gate automatically on return from this function. */
2700Sstevel@tonic-gate lib$establish(lib$sig_to_ret);
2710Sstevel@tonic-gate
2720Sstevel@tonic-gate if(ptr->imagename_dsc.dsc$w_length)
2730Sstevel@tonic-gate return lib$find_image_symbol(&ptr->filename_dsc,
2740Sstevel@tonic-gate symname_dsc, sym,
2750Sstevel@tonic-gate &ptr->imagename_dsc, flags);
2760Sstevel@tonic-gate else
2770Sstevel@tonic-gate return lib$find_image_symbol(&ptr->filename_dsc,
2780Sstevel@tonic-gate symname_dsc, sym,
2790Sstevel@tonic-gate 0, flags);
2800Sstevel@tonic-gate }
2810Sstevel@tonic-gate
vms_bind_sym(DSO * dso,const char * symname,void ** sym)2820Sstevel@tonic-gate void vms_bind_sym(DSO *dso, const char *symname, void **sym)
2830Sstevel@tonic-gate {
2840Sstevel@tonic-gate DSO_VMS_INTERNAL *ptr;
2850Sstevel@tonic-gate int status;
2860Sstevel@tonic-gate #if 0
2870Sstevel@tonic-gate int flags = (1<<4); /* LIB$M_FIS_MIXEDCASE, but this symbol isn't
2880Sstevel@tonic-gate defined in VMS older than 7.0 or so */
2890Sstevel@tonic-gate #else
2900Sstevel@tonic-gate int flags = 0;
2910Sstevel@tonic-gate #endif
2920Sstevel@tonic-gate struct dsc$descriptor_s symname_dsc;
2930Sstevel@tonic-gate *sym = NULL;
2940Sstevel@tonic-gate
2950Sstevel@tonic-gate symname_dsc.dsc$w_length = strlen(symname);
2960Sstevel@tonic-gate symname_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
2970Sstevel@tonic-gate symname_dsc.dsc$b_class = DSC$K_CLASS_S;
2980Sstevel@tonic-gate symname_dsc.dsc$a_pointer = (char *)symname; /* The cast is needed */
2990Sstevel@tonic-gate
3000Sstevel@tonic-gate if((dso == NULL) || (symname == NULL))
3010Sstevel@tonic-gate {
302*2139Sjp161948 DSOerr(DSO_F_VMS_BIND_SYM,ERR_R_PASSED_NULL_PARAMETER);
3030Sstevel@tonic-gate return;
3040Sstevel@tonic-gate }
3050Sstevel@tonic-gate if(sk_num(dso->meth_data) < 1)
3060Sstevel@tonic-gate {
307*2139Sjp161948 DSOerr(DSO_F_VMS_BIND_SYM,DSO_R_STACK_ERROR);
3080Sstevel@tonic-gate return;
3090Sstevel@tonic-gate }
3100Sstevel@tonic-gate ptr = (DSO_VMS_INTERNAL *)sk_value(dso->meth_data,
3110Sstevel@tonic-gate sk_num(dso->meth_data) - 1);
3120Sstevel@tonic-gate if(ptr == NULL)
3130Sstevel@tonic-gate {
314*2139Sjp161948 DSOerr(DSO_F_VMS_BIND_SYM,DSO_R_NULL_HANDLE);
3150Sstevel@tonic-gate return;
3160Sstevel@tonic-gate }
3170Sstevel@tonic-gate
3180Sstevel@tonic-gate if(dso->flags & DSO_FLAG_UPCASE_SYMBOL) flags = 0;
3190Sstevel@tonic-gate
3200Sstevel@tonic-gate status = do_find_symbol(ptr, &symname_dsc, sym, flags);
3210Sstevel@tonic-gate
3220Sstevel@tonic-gate if(!$VMS_STATUS_SUCCESS(status))
3230Sstevel@tonic-gate {
3240Sstevel@tonic-gate unsigned short length;
3250Sstevel@tonic-gate char errstring[257];
3260Sstevel@tonic-gate struct dsc$descriptor_s errstring_dsc;
3270Sstevel@tonic-gate
3280Sstevel@tonic-gate errstring_dsc.dsc$w_length = sizeof(errstring);
3290Sstevel@tonic-gate errstring_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
3300Sstevel@tonic-gate errstring_dsc.dsc$b_class = DSC$K_CLASS_S;
3310Sstevel@tonic-gate errstring_dsc.dsc$a_pointer = errstring;
3320Sstevel@tonic-gate
3330Sstevel@tonic-gate *sym = NULL;
3340Sstevel@tonic-gate
3350Sstevel@tonic-gate status = sys$getmsg(status, &length, &errstring_dsc, 1, 0);
3360Sstevel@tonic-gate
3370Sstevel@tonic-gate if (!$VMS_STATUS_SUCCESS(status))
3380Sstevel@tonic-gate lib$signal(status); /* This is really bad. Abort! */
3390Sstevel@tonic-gate else
3400Sstevel@tonic-gate {
3410Sstevel@tonic-gate errstring[length] = '\0';
3420Sstevel@tonic-gate
343*2139Sjp161948 DSOerr(DSO_F_VMS_BIND_SYM,DSO_R_SYM_FAILURE);
3440Sstevel@tonic-gate if (ptr->imagename_dsc.dsc$w_length)
3450Sstevel@tonic-gate ERR_add_error_data(9,
3460Sstevel@tonic-gate "Symbol ", symname,
3470Sstevel@tonic-gate " in ", ptr->filename,
3480Sstevel@tonic-gate " (", ptr->imagename, ")",
3490Sstevel@tonic-gate ": ", errstring);
3500Sstevel@tonic-gate else
3510Sstevel@tonic-gate ERR_add_error_data(6,
3520Sstevel@tonic-gate "Symbol ", symname,
3530Sstevel@tonic-gate " in ", ptr->filename,
3540Sstevel@tonic-gate ": ", errstring);
3550Sstevel@tonic-gate }
3560Sstevel@tonic-gate return;
3570Sstevel@tonic-gate }
3580Sstevel@tonic-gate return;
3590Sstevel@tonic-gate }
3600Sstevel@tonic-gate
vms_bind_var(DSO * dso,const char * symname)3610Sstevel@tonic-gate static void *vms_bind_var(DSO *dso, const char *symname)
3620Sstevel@tonic-gate {
3630Sstevel@tonic-gate void *sym = 0;
3640Sstevel@tonic-gate vms_bind_sym(dso, symname, &sym);
3650Sstevel@tonic-gate return sym;
3660Sstevel@tonic-gate }
3670Sstevel@tonic-gate
vms_bind_func(DSO * dso,const char * symname)3680Sstevel@tonic-gate static DSO_FUNC_TYPE vms_bind_func(DSO *dso, const char *symname)
3690Sstevel@tonic-gate {
3700Sstevel@tonic-gate DSO_FUNC_TYPE sym = 0;
3710Sstevel@tonic-gate vms_bind_sym(dso, symname, (void **)&sym);
3720Sstevel@tonic-gate return sym;
3730Sstevel@tonic-gate }
3740Sstevel@tonic-gate
vms_merger(DSO * dso,const char * filespec1,const char * filespec2)375*2139Sjp161948 static char *vms_merger(DSO *dso, const char *filespec1, const char *filespec2)
376*2139Sjp161948 {
377*2139Sjp161948 int status;
378*2139Sjp161948 int filespec1len, filespec2len;
379*2139Sjp161948 struct FAB fab;
380*2139Sjp161948 #ifdef NAML$C_MAXRSS
381*2139Sjp161948 struct NAML nam;
382*2139Sjp161948 char esa[NAML$C_MAXRSS];
383*2139Sjp161948 #else
384*2139Sjp161948 struct NAM nam;
385*2139Sjp161948 char esa[NAM$C_MAXRSS];
386*2139Sjp161948 #endif
387*2139Sjp161948 char *merged;
388*2139Sjp161948
389*2139Sjp161948 if (!filespec1) filespec1 = "";
390*2139Sjp161948 if (!filespec2) filespec2 = "";
391*2139Sjp161948 filespec1len = strlen(filespec1);
392*2139Sjp161948 filespec2len = strlen(filespec2);
393*2139Sjp161948
394*2139Sjp161948 fab = cc$rms_fab;
395*2139Sjp161948 #ifdef NAML$C_MAXRSS
396*2139Sjp161948 nam = cc$rms_naml;
397*2139Sjp161948 #else
398*2139Sjp161948 nam = cc$rms_nam;
399*2139Sjp161948 #endif
400*2139Sjp161948
401*2139Sjp161948 fab.fab$l_fna = (char *)filespec1;
402*2139Sjp161948 fab.fab$b_fns = filespec1len;
403*2139Sjp161948 fab.fab$l_dna = (char *)filespec2;
404*2139Sjp161948 fab.fab$b_dns = filespec2len;
405*2139Sjp161948 #ifdef NAML$C_MAXRSS
406*2139Sjp161948 if (filespec1len > NAM$C_MAXRSS)
407*2139Sjp161948 {
408*2139Sjp161948 fab.fab$l_fna = 0;
409*2139Sjp161948 fab.fab$b_fns = 0;
410*2139Sjp161948 nam.naml$l_long_filename = (char *)filespec1;
411*2139Sjp161948 nam.naml$l_long_filename_size = filespec1len;
412*2139Sjp161948 }
413*2139Sjp161948 if (filespec2len > NAM$C_MAXRSS)
414*2139Sjp161948 {
415*2139Sjp161948 fab.fab$l_dna = 0;
416*2139Sjp161948 fab.fab$b_dns = 0;
417*2139Sjp161948 nam.naml$l_long_defname = (char *)filespec2;
418*2139Sjp161948 nam.naml$l_long_defname_size = filespec2len;
419*2139Sjp161948 }
420*2139Sjp161948 nam.naml$l_esa = esa;
421*2139Sjp161948 nam.naml$b_ess = NAM$C_MAXRSS;
422*2139Sjp161948 nam.naml$l_long_expand = esa;
423*2139Sjp161948 nam.naml$l_long_expand_alloc = sizeof(esa);
424*2139Sjp161948 nam.naml$b_nop = NAM$M_SYNCHK | NAM$M_PWD;
425*2139Sjp161948 nam.naml$v_no_short_upcase = 1;
426*2139Sjp161948 fab.fab$l_naml = &nam;
427*2139Sjp161948 #else
428*2139Sjp161948 nam.nam$l_esa = esa;
429*2139Sjp161948 nam.nam$b_ess = NAM$C_MAXRSS;
430*2139Sjp161948 nam.nam$b_nop = NAM$M_SYNCHK | NAM$M_PWD;
431*2139Sjp161948 fab.fab$l_nam = &nam;
432*2139Sjp161948 #endif
433*2139Sjp161948
434*2139Sjp161948 status = sys$parse(&fab, 0, 0);
435*2139Sjp161948
436*2139Sjp161948 if(!$VMS_STATUS_SUCCESS(status))
437*2139Sjp161948 {
438*2139Sjp161948 unsigned short length;
439*2139Sjp161948 char errstring[257];
440*2139Sjp161948 struct dsc$descriptor_s errstring_dsc;
441*2139Sjp161948
442*2139Sjp161948 errstring_dsc.dsc$w_length = sizeof(errstring);
443*2139Sjp161948 errstring_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
444*2139Sjp161948 errstring_dsc.dsc$b_class = DSC$K_CLASS_S;
445*2139Sjp161948 errstring_dsc.dsc$a_pointer = errstring;
446*2139Sjp161948
447*2139Sjp161948 status = sys$getmsg(status, &length, &errstring_dsc, 1, 0);
448*2139Sjp161948
449*2139Sjp161948 if (!$VMS_STATUS_SUCCESS(status))
450*2139Sjp161948 lib$signal(status); /* This is really bad. Abort! */
451*2139Sjp161948 else
452*2139Sjp161948 {
453*2139Sjp161948 errstring[length] = '\0';
454*2139Sjp161948
455*2139Sjp161948 DSOerr(DSO_F_VMS_MERGER,DSO_R_FAILURE);
456*2139Sjp161948 ERR_add_error_data(7,
457*2139Sjp161948 "filespec \"", filespec1, "\", ",
458*2139Sjp161948 "defaults \"", filespec2, "\": ",
459*2139Sjp161948 errstring);
460*2139Sjp161948 }
461*2139Sjp161948 return(NULL);
462*2139Sjp161948 }
463*2139Sjp161948 #ifdef NAML$C_MAXRSS
464*2139Sjp161948 if (nam.naml$l_long_expand_size)
465*2139Sjp161948 {
466*2139Sjp161948 merged = OPENSSL_malloc(nam.naml$l_long_expand_size + 1);
467*2139Sjp161948 if(!merged)
468*2139Sjp161948 goto malloc_err;
469*2139Sjp161948 strncpy(merged, nam.naml$l_long_expand,
470*2139Sjp161948 nam.naml$l_long_expand_size);
471*2139Sjp161948 merged[nam.naml$l_long_expand_size] = '\0';
472*2139Sjp161948 }
473*2139Sjp161948 else
474*2139Sjp161948 {
475*2139Sjp161948 merged = OPENSSL_malloc(nam.naml$b_esl + 1);
476*2139Sjp161948 if(!merged)
477*2139Sjp161948 goto malloc_err;
478*2139Sjp161948 strncpy(merged, nam.naml$l_esa,
479*2139Sjp161948 nam.naml$b_esl);
480*2139Sjp161948 merged[nam.naml$b_esl] = '\0';
481*2139Sjp161948 }
482*2139Sjp161948 #else
483*2139Sjp161948 merged = OPENSSL_malloc(nam.nam$b_esl + 1);
484*2139Sjp161948 if(!merged)
485*2139Sjp161948 goto malloc_err;
486*2139Sjp161948 strncpy(merged, nam.nam$l_esa,
487*2139Sjp161948 nam.nam$b_esl);
488*2139Sjp161948 merged[nam.nam$b_esl] = '\0';
489*2139Sjp161948 #endif
490*2139Sjp161948 return(merged);
491*2139Sjp161948 malloc_err:
492*2139Sjp161948 DSOerr(DSO_F_VMS_MERGER,
493*2139Sjp161948 ERR_R_MALLOC_FAILURE);
494*2139Sjp161948 }
495*2139Sjp161948
vms_name_converter(DSO * dso,const char * filename)4960Sstevel@tonic-gate static char *vms_name_converter(DSO *dso, const char *filename)
4970Sstevel@tonic-gate {
4980Sstevel@tonic-gate int len = strlen(filename);
4990Sstevel@tonic-gate char *not_translated = OPENSSL_malloc(len+1);
5000Sstevel@tonic-gate strcpy(not_translated,filename);
5010Sstevel@tonic-gate return(not_translated);
5020Sstevel@tonic-gate }
5030Sstevel@tonic-gate
5040Sstevel@tonic-gate #endif /* OPENSSL_SYS_VMS */
505