annotate src/sysdll.c @ 980:2ec85ed291da

[xemacs-hg @ 2002-08-30 08:05:30 by youngs] 2002-08-29 Jerry James <james@xemacs.org> * lisp.h: structrures -> structures.
author youngs
date Fri, 30 Aug 2002 08:05:32 +0000
parents beddd25fe24a
children df61d2b1d4c3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 /* sysdll.c --- system dependent support for dynamic linked libraries
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 Copyright (C) 1998 Free Software Foundation, Inc.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 Author: William Perry <wmperry@aventail.com>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5 This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 Free Software Foundation; either version 2, or (at your option) any
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 along with XEmacs; see the file COPYING. If not, write to the Free
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 02111-1307, USA. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 #ifdef HAVE_CONFIG_H
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23 #include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
26 #include <stdlib.h>
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 #include "sysdll.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 /* This whole file is conditional upon HAVE_SHLIB */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 #ifdef HAVE_SHLIB
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 /* Thankfully, most systems follow the ELFish dlopen() method.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 */
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 442
diff changeset
34 #if defined(HAVE_DLOPEN)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 #include <dlfcn.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 #ifndef RTLD_LAZY
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 # define RTLD_LAZY 1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 #endif /* RTLD_LAZY isn't defined under FreeBSD - ick */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40
863
42375619fa45 [xemacs-hg @ 2002-06-04 06:03:59 by andyp]
andyp
parents: 452
diff changeset
41 #ifndef RTLD_NOW
42375619fa45 [xemacs-hg @ 2002-06-04 06:03:59 by andyp]
andyp
parents: 452
diff changeset
42 # define RTLD_NOW 2
42375619fa45 [xemacs-hg @ 2002-06-04 06:03:59 by andyp]
andyp
parents: 452
diff changeset
43 #endif
42375619fa45 [xemacs-hg @ 2002-06-04 06:03:59 by andyp]
andyp
parents: 452
diff changeset
44
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 int
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
46 dll_init (const char *arg)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 dll_handle
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
52 dll_open (const char *fname)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 {
880
beddd25fe24a [xemacs-hg @ 2002-06-24 22:00:17 by youngs]
youngs
parents: 863
diff changeset
54 return (dll_handle) dlopen (fname, RTLD_NOW);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 dll_close (dll_handle h)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
60 return dlclose ((void *) h);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 dll_func
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
64 dll_function (dll_handle h, const char *n)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 #ifdef DLSYM_NEEDS_UNDERSCORE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 char *buf = alloca_array (char, strlen (n) + 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 *buf = '_';
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
69 strcpy (buf + 1, n);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 n = buf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 #endif
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
72 return (dll_func) dlsym ((void *) h, n);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 dll_var
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
76 dll_variable (dll_handle h, const char *n)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 #ifdef DLSYM_NEEDS_UNDERSCORE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 char *buf = alloca_array (char, strlen (n) + 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 *buf = '_';
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
81 strcpy (buf + 1, n);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 n = buf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 return (dll_var)dlsym ((void *)h, n);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
87 const char *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 dll_error (dll_handle h)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 #if defined(HAVE_DLERROR) || defined(dlerror)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
91 return (const char *) dlerror ();
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 #elif defined(HAVE__DLERROR)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
93 return (const char *) _dlerror();
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 return "Shared library error";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 #elif defined(HAVE_SHL_LOAD)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 /* This is the HP/UX version */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 #include <dl.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 int
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
103 dll_init (const char *arg)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 dll_handle
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
109 dll_open (const char *fname)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
111 /* shl_load will hang hard if passed a NULL fname. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
112 if (fname == NULL) return NULL;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
114 return (dll_handle) shl_load (fname, BIND_DEFERRED,0L);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 dll_close (dll_handle h)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
120 return shl_unload ((shl_t) h);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 dll_func
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
124 dll_function (dll_handle h, const char *n)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 long handle = 0L;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
128 if (shl_findsym ((shl_t *) &h, n, TYPE_PROCEDURE, &handle))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
131 return (dll_func) handle;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 dll_var
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
135 dll_variable (dll_handle h, const char *n)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137 long handle = 0L;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
139 if (shl_findsym ((shl_t *) &h, n, TYPE_DATA, &handle))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
142 return (dll_var) handle;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
145 const char *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 dll_error (dll_handle h)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 /* #### WTF?! Shouldn't this at least attempt to get strerror or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 something? --hniksic */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 return "Generic shared library error";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 #elif defined(HAVE_INIT_DLD)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 #include <dld.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 int
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
156 dll_init (const char *arg)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 char *real_exe = dld_find_executable (arg);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 int rc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 rc = dld_init (real_exe);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 if (rc)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 dld_perror (exe);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 return -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 dll_handle
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
171 dll_open (const char *fname)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 rc = dld_link (fname);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 if (rc)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
177 return (dll_handle) 1;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 dll_close (dll_handle h)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 /* *sigh* DLD is pretty lame and doesn't return a handle that you can use
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 ** later on to free the file - you have to remember the filename and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 ** use that as the unlinker. We should eventually keep a linked list
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 ** of loaded modules and then use the node pointer as the unique id
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 ** for the shared library. Wheeee. But not now.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 return 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 DLL_FUNC
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
193 dll_function (dll_handle h, const char *n)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
195 return dld_get_func (n);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 DLL_FUNC
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
199 dll_variable (dll_handle h, const char *n)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
201 return dld_get_symbol (n);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
203 #elif defined (WIN32_NATIVE)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
204
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
205 #define WIN32_LEAN_AND_MEAN
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
206 #include <windows.h>
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
207 #undef WIN32_LEAN_AND_MEAN
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
208
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 int
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
210 dll_init (const char *arg)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 dll_handle
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
216 dll_open (const char *fname)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
218 return (dll_handle) LoadLibrary (fname);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 dll_close (dll_handle h)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 return FreeLibrary (h);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 dll_func
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
228 dll_function (dll_handle h, const char *n)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
230 return (dll_func) GetProcAddress (h, n);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233 dll_func
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
234 dll_variable (dll_handle h, const char *n)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
236 return (dll_func) GetProcAddress (h, n);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
239 const char *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 dll_error (dll_handle h)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 return "Windows DLL Error";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 /* Catchall if we don't know about this systems method of dynamic loading */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 int
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
247 dll_init (const char *arg)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249 return -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 dll_handle
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
253 dll_open (const char *fname)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 dll_close (dll_handle h)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 dll_func
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
265 dll_function (dll_handle h, const char *n)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 dll_func
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
271 dll_variable (dll_handle h, const char *n)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
276 const char *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 dll_error (dll_handle h)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 return "Shared libraries not implemented on this system";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 #endif /* System conditionals */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 #endif /* HAVE_SHLIB */