-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmidasloadimage.c
60 lines (47 loc) · 1.36 KB
/
midasloadimage.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifdef VAX
#include <lnmdef.h>
#include descrip
typedef struct dsc$descriptor_s string;
#endif
MidasLoadImage(name)
char *name;
/*
The VAX version of MidasLoadImage looks for a shareable using the SLD
dynamic loading convention.
*/
{
#ifdef VAX
int Iss, lr;
string LogicalName, RoutineName = {0,0,0,0}, ImageName = {0,0,0,0};
char *p;
$DESCRIPTOR(FileDev,"LNM$FILE_DEV");
void (*Routine)();
char result[80] = "SHR_";
struct {
short BufLen;
short ItmCod;
int BufAdr;
int RetAdr;
} ItmLst[] = {{80, LNM$_STRING, result, 0},
{4 , LNM$_LENGTH, &lr, 0},
{0,0,0,0}};
strcat(result,name);
LogicalName.dsc$a_pointer = result;
LogicalName.dsc$w_length = strlen(result);
Iss = Sys$TrnLnm(&LNM$M_CASE_BLIND,&FileDev,&LogicalName,0,ItmLst);
if ((Iss & 1) == 0) MidasError("Could not load image %s",name);
p = &result + lr;
*p = '\0';
p = strstr(result,"/IMAGE=");
if (p == 0) MidasError("Could not load image %s",name);
*p = '\0';
p += 7;
ImageName.dsc$a_pointer = p;
ImageName.dsc$w_length = strlen(p);
RoutineName.dsc$a_pointer = &result;
RoutineName.dsc$w_length = strlen(result);
Iss = Lib$Find_Image_Symbol(&ImageName,&RoutineName,&Routine);
if ((Iss & 1) == 0) MidasError("Could not load image %s",name);
Routine();
#endif
}