annotate src/sysdll.c @ 1295:064ef1d07d63

[xemacs-hg @ 2003-02-14 07:54:27 by ben] no specifier crashes under Windows, please scrollbar.c: Don't generate fallbacks for TTY's when not HAVE_TTY.
author ben
date Fri, 14 Feb 2003 07:54:29 +0000
parents df61d2b1d4c3
children 517919955e3f
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>
1272
df61d2b1d4c3 [xemacs-hg @ 2003-02-07 21:40:22 by james]
james
parents: 880
diff changeset
27 #include "lisp.h"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 #include "sysdll.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 /* This whole file is conditional upon HAVE_SHLIB */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 #ifdef HAVE_SHLIB
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 /* Thankfully, most systems follow the ELFish dlopen() method.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 */
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 442
diff changeset
35 #if defined(HAVE_DLOPEN)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 #include <dlfcn.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 #ifndef RTLD_LAZY
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 # define RTLD_LAZY 1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 #endif /* RTLD_LAZY isn't defined under FreeBSD - ick */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41
863
42375619fa45 [xemacs-hg @ 2002-06-04 06:03:59 by andyp]
andyp
parents: 452
diff changeset
42 #ifndef RTLD_NOW
42375619fa45 [xemacs-hg @ 2002-06-04 06:03:59 by andyp]
andyp
parents: 452
diff changeset
43 # define RTLD_NOW 2
42375619fa45 [xemacs-hg @ 2002-06-04 06:03:59 by andyp]
andyp
parents: 452
diff changeset
44 #endif
42375619fa45 [xemacs-hg @ 2002-06-04 06:03:59 by andyp]
andyp
parents: 452
diff changeset
45
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 int
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
47 dll_init (const char *arg)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 return 0;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 dll_handle
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
53 dll_open (const char *fname)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 {
880
beddd25fe24a [xemacs-hg @ 2002-06-24 22:00:17 by youngs]
youngs
parents: 863
diff changeset
55 return (dll_handle) dlopen (fname, RTLD_NOW);
428
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 dll_close (dll_handle h)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
61 return dlclose ((void *) h);
428
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 dll_func
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
65 dll_function (dll_handle h, const char *n)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 #ifdef DLSYM_NEEDS_UNDERSCORE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 char *buf = alloca_array (char, strlen (n) + 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 *buf = '_';
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
70 strcpy (buf + 1, n);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 n = buf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 #endif
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
73 return (dll_func) dlsym ((void *) h, n);
428
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 dll_var
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
77 dll_variable (dll_handle h, const char *n)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 #ifdef DLSYM_NEEDS_UNDERSCORE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 char *buf = alloca_array (char, strlen (n) + 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 *buf = '_';
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
82 strcpy (buf + 1, n);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 n = buf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 return (dll_var)dlsym ((void *)h, n);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
88 const char *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 dll_error (dll_handle h)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 #if defined(HAVE_DLERROR) || defined(dlerror)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
92 return (const char *) dlerror ();
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 #elif defined(HAVE__DLERROR)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
94 return (const char *) _dlerror();
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 return "Shared library error";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 #endif
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 #elif defined(HAVE_SHL_LOAD)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 /* This is the HP/UX version */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 #include <dl.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 int
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
104 dll_init (const char *arg)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 return 0;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 dll_handle
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
110 dll_open (const char *fname)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
112 /* shl_load will hang hard if passed a NULL fname. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
113 if (fname == NULL) return NULL;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
115 return (dll_handle) shl_load (fname, BIND_DEFERRED,0L);
428
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 dll_close (dll_handle h)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
121 return shl_unload ((shl_t) h);
428
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 dll_func
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
125 dll_function (dll_handle h, const char *n)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 long handle = 0L;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
129 if (shl_findsym ((shl_t *) &h, n, TYPE_PROCEDURE, &handle))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
132 return (dll_func) handle;
428
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 dll_var
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
136 dll_variable (dll_handle h, const char *n)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138 long handle = 0L;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
140 if (shl_findsym ((shl_t *) &h, n, TYPE_DATA, &handle))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
143 return (dll_var) handle;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
146 const char *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 dll_error (dll_handle h)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 /* #### WTF?! Shouldn't this at least attempt to get strerror or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 something? --hniksic */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 return "Generic shared library error";
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 #elif defined(HAVE_INIT_DLD)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 #include <dld.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 int
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
157 dll_init (const char *arg)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 char *real_exe = dld_find_executable (arg);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 int rc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 rc = dld_init (real_exe);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 if (rc)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 dld_perror (exe);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 return -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 return 0;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 dll_handle
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
172 dll_open (const char *fname)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 rc = dld_link (fname);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 if (rc)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
178 return (dll_handle) 1;
428
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 dll_close (dll_handle h)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 /* *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
185 ** 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
186 ** use that as the unlinker. We should eventually keep a linked list
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 ** 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
188 ** for the shared library. Wheeee. But not now.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 return 1;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 DLL_FUNC
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
194 dll_function (dll_handle h, const char *n)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
196 return dld_get_func (n);
428
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 DLL_FUNC
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
200 dll_variable (dll_handle h, const char *n)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
202 return dld_get_symbol (n);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
204 #elif defined (WIN32_NATIVE)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
205
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
206 #define WIN32_LEAN_AND_MEAN
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
207 #include <windows.h>
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
208 #undef WIN32_LEAN_AND_MEAN
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
209
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 int
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
211 dll_init (const char *arg)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 return 0;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 dll_handle
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
217 dll_open (const char *fname)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
219 return (dll_handle) LoadLibrary (fname);
428
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 dll_close (dll_handle h)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 return FreeLibrary (h);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228 dll_func
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
229 dll_function (dll_handle h, const char *n)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
231 return (dll_func) GetProcAddress (h, n);
428
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 dll_func
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
235 dll_variable (dll_handle h, const char *n)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
237 return (dll_func) GetProcAddress (h, n);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
240 const char *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 dll_error (dll_handle h)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 return "Windows DLL Error";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 /* 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
247 int
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
248 dll_init (const char *arg)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 return -1;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 dll_handle
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
254 dll_open (const char *fname)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 return NULL;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 dll_close (dll_handle h)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 return 0;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 dll_func
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
266 dll_function (dll_handle h, const char *n)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 return NULL;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 dll_func
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
272 dll_variable (dll_handle h, const char *n)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
277 const char *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 dll_error (dll_handle h)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 return "Shared libraries not implemented on this system";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 #endif /* System conditionals */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 #endif /* HAVE_SHLIB */