diff options
author | akiyoshi <akiyoshi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-08-19 02:09:51 +0000 |
---|---|---|
committer | akiyoshi <akiyoshi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-08-19 02:09:51 +0000 |
commit | a23bc676658106e96a00bd294e64ce53249b1392 (patch) | |
tree | 0c3749224d162e2e3fa0c95efed18e04ab1f92c8 /dln.c | |
parent | c2d20d7f8cf99d58678c007731c51a3ffa7324fa (diff) |
Update for VMS ports.
* dln.c (dln_load): Modify to call lib$find_image_symbol for VMS.
* io.c (rb_io_fwrite): Use fputc() for VMS non-stream file.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@6793 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'dln.c')
-rw-r--r-- | dln.c | 71 |
1 files changed, 64 insertions, 7 deletions
@@ -1261,6 +1261,19 @@ aix_loaderror(const char *pathname) } #endif +#if defined(__VMS) +#include <starlet.h> +#include <rms.h> +#include <stsdef.h> +#include <unixlib.h> +#include <descrip.h> +#include <lib$routines.h> + +static char *vms_filespec; +static int vms_fileact(char *filespec, int type); +static long vms_fisexh(long *sigarr, long *mecarr); +#endif + void* dln_load(file) const char *file; @@ -1561,9 +1574,16 @@ dln_load(file) #if defined(__VMS) #define DLN_DEFINED { - void *handle, (*init_fct)(); + long status; + void (*init_fct)(); char *fname, *p1, *p2; + $DESCRIPTOR(fname_d, ""); + $DESCRIPTOR(image_d, ""); + $DESCRIPTOR(buf_d, ""); + + decc$to_vms(file, vms_fileact, 0, 0); + fname = (char *)__alloca(strlen(file)+1); strcpy(fname,file); if (p1 = strrchr(fname,'/')) @@ -1571,19 +1591,35 @@ dln_load(file) if (p2 = strrchr(fname,'.')) *p2 = '\0'; - if ((handle = (void*)dlopen(fname, 0)) == NULL) { + fname_d.dsc$w_length = strlen(fname); + fname_d.dsc$a_pointer = fname; + image_d.dsc$w_length = strlen(vms_filespec); + image_d.dsc$a_pointer = vms_filespec; + buf_d.dsc$w_length = strlen(buf); + buf_d.dsc$a_pointer = buf; + + lib$establish(vms_fisexh); + + status = lib$find_image_symbol ( + &fname_d, + &buf_d, + &init_fct, + &image_d); + + lib$establish(0); + + if (status == RMS$_FNF) { error = dln_strerror(); goto failed; - } - - if ((init_fct = (void (*)())dlsym(handle, buf)) == NULL) { + } else if (!$VMS_STATUS_SUCCESS(status)) { error = DLN_ERROR(); - dlclose(handle); goto failed; } + /* Call the init code */ (*init_fct)(); - return handle; + + return 1; } #endif /* __VMS */ @@ -1824,3 +1860,24 @@ dln_find_1(fname, path, exe_flag) /* otherwise try the next component in the search path */ } } + +#if defined(__VMS) + +/* action routine for decc$to_vms */ +static int vms_fileact(char *filespec, int type) +{ + if (vms_filespec) + free(vms_filespec); + vms_filespec = malloc(strlen(filespec)+1); + strcpy(vms_filespec, filespec); + return 1; +} + +/* exception handler for LIB$FIND_IMAGE_SYMBOL */ +static long vms_fisexh(long *sigarr, long *mecarr) +{ + sys$unwind(1, 0); + return 1; +} + +#endif /* __VMS */ |