Commit | Line | Data |
1d84e8df |
1 | /* |
2 | * Author: Mark Klein (mklein@dis.com) |
3 | * Version: 2.1, 1996/07/25 |
4 | * Version: 2.2, 1997/09/25 Mark Bixby (markb@cccd.edu) |
9d7f10f2 |
5 | * Version: 2.3, 1998/11/19 Mark Bixby (markb@cccd.edu) |
1d84e8df |
6 | */ |
7 | |
8 | #include "EXTERN.h" |
9 | #include "perl.h" |
10 | #include "XSUB.h" |
11 | |
12 | #ifdef __GNUC__ |
13 | extern void HPGETPROCPLABEL( int parms, |
14 | char * procname, |
15 | int * plabel, |
16 | int * status, |
17 | char * firstfile, |
18 | int casesensitive, |
19 | int symboltype, |
20 | int * datasize, |
21 | int position, |
22 | int searchpath, |
23 | int binding); |
24 | #else |
25 | #pragma intrinsic HPGETPROCPLABEL |
26 | #endif |
27 | #include "dlutils.c" /* for SaveError() etc */ |
28 | |
29 | typedef struct { |
30 | char filename[PATH_MAX + 3]; |
31 | } t_mpe_dld, *p_mpe_dld; |
32 | |
1d84e8df |
33 | static void |
cea2e8a9 |
34 | dl_private_init(pTHX) |
1d84e8df |
35 | { |
cea2e8a9 |
36 | (void)dl_generic_private_init(aTHX); |
1d84e8df |
37 | } |
38 | |
39 | MODULE = DynaLoader PACKAGE = DynaLoader |
40 | |
41 | BOOT: |
cea2e8a9 |
42 | (void)dl_private_init(aTHX); |
1d84e8df |
43 | |
44 | void * |
45 | dl_load_file(filename, flags=0) |
46 | char * filename |
47 | int flags |
48 | PREINIT: |
49 | char buf[PATH_MAX + 3]; |
50 | p_mpe_dld obj = NULL; |
d05c1ba0 |
51 | |
1d84e8df |
52 | CODE: |
bf49b057 |
53 | DLDEBUG(1,PerlIO_printf(Perl_debug_log, "dl_load_file(%s,%x):\n", filename, |
1d84e8df |
54 | flags)); |
55 | if (flags & 0x01) |
cea2e8a9 |
56 | Perl_warn(aTHX_ "Can't make loaded symbols global on this platform while loading %s |
1d84e8df |
57 | ",filename); |
58 | obj = (p_mpe_dld) safemalloc(sizeof(t_mpe_dld)); |
59 | memzero(obj, sizeof(t_mpe_dld)); |
9d7f10f2 |
60 | if (filename[0] != '/') |
1d84e8df |
61 | { |
62 | getcwd(buf,sizeof(buf)); |
9d7f10f2 |
63 | sprintf(obj->filename," %s/%s ",buf,filename); |
1d84e8df |
64 | } |
65 | else |
9d7f10f2 |
66 | sprintf(obj->filename," %s ",filename); |
1d84e8df |
67 | |
bf49b057 |
68 | DLDEBUG(2,PerlIO_printf(Perl_debug_log," libref=%x\n", obj)); |
1d84e8df |
69 | |
70 | ST(0) = sv_newmortal() ; |
71 | if (obj == NULL) |
cea2e8a9 |
72 | SaveError(aTHX_"%s",Strerror(errno)); |
1d84e8df |
73 | else |
3175b8cd |
74 | sv_setiv( ST(0), PTR2IV(obj) ); |
1d84e8df |
75 | |
76 | void * |
77 | dl_find_symbol(libhandle, symbolname) |
78 | void * libhandle |
79 | char * symbolname |
80 | CODE: |
81 | int datalen; |
82 | p_mpe_dld obj = (p_mpe_dld) libhandle; |
83 | char symname[PATH_MAX + 3]; |
84 | void * symaddr = NULL; |
85 | int status; |
bf49b057 |
86 | DLDEBUG(2,PerlIO_printf(Perl_debug_log,"dl_find_symbol(handle=%x, symbol=%s)\n", |
1d84e8df |
87 | libhandle, symbolname)); |
88 | ST(0) = sv_newmortal() ; |
89 | errno = 0; |
90 | |
9d7f10f2 |
91 | sprintf(symname, " %s ", symbolname); |
1d84e8df |
92 | HPGETPROCPLABEL(8, symname, &symaddr, &status, obj->filename, 1, |
93 | 0, &datalen, 1, 0, 0); |
94 | |
bf49b057 |
95 | DLDEBUG(2,PerlIO_printf(Perl_debug_log," symbolref(PROCEDURE) = %x, status=%x\n", symaddr, status)); |
1d84e8df |
96 | |
97 | if (status != 0) { |
cea2e8a9 |
98 | SaveError(aTHX_"%s",(errno) ? Strerror(errno) : "Symbol not found") ; |
1d84e8df |
99 | } else { |
3175b8cd |
100 | sv_setiv( ST(0), PTR2IV(symaddr) ); |
1d84e8df |
101 | } |
102 | |
103 | void |
104 | dl_undef_symbols() |
105 | PPCODE: |
106 | |
107 | # These functions should not need changing on any platform: |
108 | |
109 | void |
110 | dl_install_xsub(perl_name, symref, filename="$Package") |
111 | char * perl_name |
112 | void * symref |
113 | char * filename |
114 | CODE: |
bf49b057 |
115 | DLDEBUG(2,PerlIO_printf(Perl_debug_log,"dl_install_xsub(name=%s, symref=%x)\n", |
1d84e8df |
116 | perl_name, symref)); |
cea2e8a9 |
117 | ST(0) = sv_2mortal(newRV((SV*)newXS(perl_name, |
118 | (void(*)(pTHX_ CV *))symref, |
119 | filename))); |
1d84e8df |
120 | |
121 | char * |
122 | dl_error() |
123 | CODE: |
cdc73a10 |
124 | dMY_CXT; |
125 | RETVAL = dl_last_error ; |
1d84e8df |
126 | OUTPUT: |
127 | RETVAL |
128 | |
129 | # end. |