64 #ifdef OPENSSL_SYS_VMS
65 #pragma message disable DOLLARID
67 #include <lib$routines.h>
75 #if __INITIAL_POINTER_SIZE && defined _ANSI_C_SOURCE
76 # if __INITIAL_POINTER_SIZE == 64
77 # pragma pointer_size save
78 # pragma pointer_size 32
79 void * _malloc32 (__size_t);
80 # pragma pointer_size restore
85 #ifndef OPENSSL_SYS_VMS
91 #pragma message disable DOLLARID
93 static int vms_load(
DSO *dso);
94 static int vms_unload(
DSO *dso);
95 static void *vms_bind_var(
DSO *dso,
const char *symname);
98 static int vms_unbind_var(
DSO *dso,
char *symname,
void *symptr);
100 static int vms_init(
DSO *dso);
101 static int vms_finish(
DSO *dso);
102 static long vms_ctrl(
DSO *dso,
int cmd,
long larg,
void *parg);
104 static char *vms_name_converter(
DSO *dso,
const char *
filename);
105 static char *vms_merger(
DSO *dso,
const char *filespec1,
106 const char *filespec2);
109 "OpenSSL 'VMS' shared library method",
131 typedef struct dso_internal_st
135 struct dsc$descriptor_s filename_dsc;
139 struct dsc$descriptor_s imagename_dsc;
145 return(&dso_meth_vms);
148 static int vms_load(
DSO *dso)
155 #if __INITIAL_POINTER_SIZE == 64
156 # define DSO_MALLOC _malloc32
157 # pragma pointer_size save
158 # pragma pointer_size 32
160 # define DSO_MALLOC OPENSSL_malloc
163 DSO_VMS_INTERNAL *
p = NULL;
165 #if __INITIAL_POINTER_SIZE == 64
166 # pragma pointer_size restore
169 const char *sp1, *sp2;
195 sp1 = strrchr(filename,
']');
196 sp2 = strrchr(filename,
'>');
197 if (sp1 == NULL) sp1 = sp2;
198 if (sp2 != NULL && sp2 > sp1) sp1 = sp2;
199 if (sp1 == NULL) sp1 = strrchr(filename,
':');
205 sp2 = strchr(sp1,
'.');
208 if (sp2 == NULL) sp2 = strchr(sp1,
';');
211 if (sp2 == NULL) sp2 = sp1 + strlen(sp1);
214 if (sp2 - sp1 > FILENAME_MAX
215 || (sp1 - filename) + strlen(sp2) > FILENAME_MAX)
221 p = DSO_MALLOC(
sizeof(DSO_VMS_INTERNAL));
228 strncpy(p->filename, sp1, sp2-sp1);
229 p->filename[sp2-sp1] =
'\0';
231 strncpy(p->imagename, filename, sp1-filename);
233 strcat(p->imagename, sp2);
235 p->filename_dsc.dsc$w_length = strlen(p->filename);
236 p->filename_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
237 p->filename_dsc.dsc$b_class = DSC$K_CLASS_S;
238 p->filename_dsc.dsc$a_pointer = p->filename;
239 p->imagename_dsc.dsc$w_length = strlen(p->imagename);
240 p->imagename_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
241 p->imagename_dsc.dsc$b_class = DSC$K_CLASS_S;
242 p->imagename_dsc.dsc$a_pointer = p->imagename;
266 static int vms_unload(
DSO *dso)
276 p = (DSO_VMS_INTERNAL *)
sk_void_pop(dso->meth_data);
289 static int do_find_symbol(DSO_VMS_INTERNAL *ptr,
290 struct dsc$descriptor_s *symname_dsc,
void **sym,
296 lib$establish(lib$sig_to_ret);
298 if(ptr->imagename_dsc.dsc$w_length)
299 return lib$find_image_symbol(&ptr->filename_dsc,
301 &ptr->imagename_dsc, flags);
303 return lib$find_image_symbol(&ptr->filename_dsc,
308 void vms_bind_sym(
DSO *dso,
const char *symname,
void **sym)
310 DSO_VMS_INTERNAL *
ptr;
318 struct dsc$descriptor_s symname_dsc;
321 #if __INITIAL_POINTER_SIZE == 64
322 # define SYMNAME symname_32p
323 # pragma pointer_size save
324 # pragma pointer_size 32
326 # pragma pointer_size restore
329 # define SYMNAME ((char *) symname)
334 if((dso == NULL) || (symname == NULL))
340 #if __INITIAL_POINTER_SIZE == 64
342 symname_32p = symname_32;
343 strcpy( symname_32p, symname);
346 symname_dsc.dsc$w_length = strlen(SYMNAME);
347 symname_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
348 symname_dsc.dsc$b_class = DSC$K_CLASS_S;
349 symname_dsc.dsc$a_pointer = SYMNAME;
366 status = do_find_symbol(ptr, &symname_dsc, sym, flags);
368 if(!$VMS_STATUS_SUCCESS(status))
372 struct dsc$descriptor_s errstring_dsc;
374 errstring_dsc.dsc$w_length =
sizeof(errstring);
375 errstring_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
376 errstring_dsc.dsc$b_class = DSC$K_CLASS_S;
377 errstring_dsc.dsc$a_pointer = errstring;
381 status = sys$getmsg(status, &length, &errstring_dsc, 1, 0);
383 if (!$VMS_STATUS_SUCCESS(status))
390 if (ptr->imagename_dsc.dsc$w_length)
393 " in ", ptr->filename,
394 " (", ptr->imagename,
")",
399 " in ", ptr->filename,
407 static void *vms_bind_var(
DSO *dso,
const char *symname)
410 vms_bind_sym(dso, symname, &sym);
417 vms_bind_sym(dso, symname, (
void **)&sym);
422 static char *vms_merger(
DSO *dso,
const char *filespec1,
const char *filespec2)
425 int filespec1len, filespec2len;
432 #if __INITIAL_POINTER_SIZE == 64
433 # define FILESPEC1 filespec1_32p;
434 # define FILESPEC2 filespec2_32p;
435 # pragma pointer_size save
436 # pragma pointer_size 32
439 # pragma pointer_size restore
443 # define FILESPEC1 ((char *) filespec1)
444 # define FILESPEC2 ((char *) filespec2)
447 if (!filespec1) filespec1 =
"";
448 if (!filespec2) filespec2 =
"";
449 filespec1len = strlen(filespec1);
450 filespec2len = strlen(filespec2);
452 #if __INITIAL_POINTER_SIZE == 64
454 filespec1_32p = filespec1_32;
455 filespec2_32p = filespec2_32;
456 strcpy( filespec1_32p, filespec1);
457 strcpy( filespec2_32p, filespec2);
463 FAB_OR_NAML( fab, nam).FAB_OR_NAML_FNA = FILESPEC1;
464 FAB_OR_NAML( fab, nam).FAB_OR_NAML_FNS = filespec1len;
465 FAB_OR_NAML( fab, nam).FAB_OR_NAML_DNA = FILESPEC2;
466 FAB_OR_NAML( fab, nam).FAB_OR_NAML_DNS = filespec2len;
471 nam.
NAMX_NOP = NAM$M_SYNCHK | NAM$M_PWD;
476 status = sys$parse(&fab, 0, 0);
478 if(!$VMS_STATUS_SUCCESS(status))
482 struct dsc$descriptor_s errstring_dsc;
484 errstring_dsc.dsc$w_length =
sizeof(errstring);
485 errstring_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
486 errstring_dsc.dsc$b_class = DSC$K_CLASS_S;
487 errstring_dsc.dsc$a_pointer = errstring;
489 status = sys$getmsg(status, &length, &errstring_dsc, 1, 0);
491 if (!$VMS_STATUS_SUCCESS(status))
499 "filespec \"", filespec1,
"\", ",
500 "defaults \"", filespec2,
"\": ",
509 strncpy( merged, nam.NAMX_ESA, nam.NAMX_ESL);
510 merged[ nam.NAMX_ESL] =
'\0';
517 static char *vms_name_converter(
DSO *dso,
const char *filename)
519 int len = strlen(filename);
521 strcpy(not_translated,filename);
522 return(not_translated);