-/* dso_vms.c -*- mode:C; c-file-style: "eay" -*- */
/*
* Written by Richard Levitte (richard@levitte.org) for the OpenSSL project
* 2000.
#include <stdio.h>
#include <string.h>
#include <errno.h>
-#include "cryptlib.h"
+#include "internal/cryptlib.h"
#include <openssl/dso.h>
#ifndef OPENSSL_SYS_VMS
# include <stsdef.h>
# include <descrip.h>
# include <starlet.h>
-# include "vms_rms.h"
+# include "../vms_rms.h"
/* Some compiler options may mask the declaration of "_malloc32". */
# if __INITIAL_POINTER_SIZE && defined _ANSI_C_SOURCE
static int vms_unload(DSO *dso);
static void *vms_bind_var(DSO *dso, const char *symname);
static DSO_FUNC_TYPE vms_bind_func(DSO *dso, const char *symname);
-# if 0
-static int vms_unbind_var(DSO *dso, char *symname, void *symptr);
-static int vms_unbind_func(DSO *dso, char *symname, DSO_FUNC_TYPE symptr);
-static int vms_init(DSO *dso);
-static int vms_finish(DSO *dso);
-static long vms_ctrl(DSO *dso, int cmd, long larg, void *parg);
-# endif
static char *vms_name_converter(DSO *dso, const char *filename);
static char *vms_merger(DSO *dso, const char *filespec1,
const char *filespec2);
NULL, /* unload */
vms_bind_var,
vms_bind_func,
-/* For now, "unbind" doesn't exist */
-# if 0
- NULL, /* unbind_var */
- NULL, /* unbind_func */
-# endif
NULL, /* ctrl */
vms_name_converter,
vms_merger,
# endif /* __INITIAL_POINTER_SIZE == 64 */
const char *sp1, *sp2; /* Search result */
+ const char *ext = NULL; /* possible extension to add */
if (filename == NULL) {
DSOerr(DSO_F_VMS_LOAD, DSO_R_NO_FILENAME);
goto err;
}
- /*-
- * A file specification may look like this:
- *
- * node::dev:[dir-spec]name.type;ver
- *
- * or (for compatibility with TOPS-20):
- *
- * node::dev:<dir-spec>name.type;ver
- *
- * and the dir-spec uses '.' as separator. Also, a dir-spec
- * may consist of several parts, with mixed use of [] and <>:
- *
- * [dir1.]<dir2>
- *
- * We need to split the file specification into the name and
- * the rest (both before and after the name itself).
- */
+ /*-
+ * A file specification may look like this:
+ *
+ * node::dev:[dir-spec]name.type;ver
+ *
+ * or (for compatibility with TOPS-20):
+ *
+ * node::dev:<dir-spec>name.type;ver
+ *
+ * and the dir-spec uses '.' as separator. Also, a dir-spec
+ * may consist of several parts, with mixed use of [] and <>:
+ *
+ * [dir1.]<dir2>
+ *
+ * We need to split the file specification into the name and
+ * the rest (both before and after the name itself).
+ */
/*
* Start with trying to find the end of a dir-spec, and save the position
* of the byte after in sp1
sp1++; /* The byte after the found character */
/* Now, let's see if there's a type, and save the position in sp2 */
sp2 = strchr(sp1, '.');
+ /*
+ * If there is a period and the next character is a semi-colon,
+ * we need to add an extension
+ */
+ if (sp2 != NULL && sp2[1] == ';')
+ ext = ".EXE";
/*
* If we found it, that's where we'll cut. Otherwise, look for a version
* number and save the position in sp2
*/
- if (sp2 == NULL)
+ if (sp2 == NULL) {
sp2 = strchr(sp1, ';');
+ ext = ".EXE";
+ }
/*
* If there was still nothing to find, set sp2 to point at the end of the
* string
goto err;
}
- p = DSO_MALLOC(sizeof(DSO_VMS_INTERNAL));
+ p = DSO_MALLOC(sizeof(*p));
if (p == NULL) {
DSOerr(DSO_F_VMS_LOAD, ERR_R_MALLOC_FAILURE);
goto err;
strncpy(p->imagename, filename, sp1 - filename);
p->imagename[sp1 - filename] = '\0';
+ if (ext) {
+ strcat(p->imagename, ext);
+ if (*sp2 == '.')
+ sp2++;
+ }
strcat(p->imagename, sp2);
p->filename_dsc.dsc$w_length = strlen(p->filename);
return (1);
err:
/* Cleanup! */
- if (p != NULL)
- OPENSSL_free(p);
- if (filename != NULL)
- OPENSSL_free(filename);
+ OPENSSL_free(p);
+ OPENSSL_free(filename);
return (0);
}
}
merged = OPENSSL_malloc(nam.NAMX_ESL + 1);
- if (!merged)
+ if (merged == NULL)
goto malloc_err;
strncpy(merged, nam.NAMX_ESA, nam.NAMX_ESL);
merged[nam.NAMX_ESL] = '\0';
{
int len = strlen(filename);
char *not_translated = OPENSSL_malloc(len + 1);
- strcpy(not_translated, filename);
+ if (not_translated != NULL)
+ strcpy(not_translated, filename);
return (not_translated);
}