Mercurial > cpython-lru_cache-weakref
annotate Python/importdl.c @ 3216:d00a79ebb027 legacy-trunk
Added missing imgpbm and imgsgi modules
| author | Jack Jansen <jack.jansen@cwi.nl> |
|---|---|
| date | Thu, 12 Oct 1995 10:23:27 +0000 |
| parents | 8d92a3bb9c1f |
| children | 2fb398ab3e6a |
| rev | line source |
|---|---|
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1 /*********************************************************** |
|
2062
d0d0a69b5ca3
Added 1995 to copyright message.
Guido van Rossum <guido@python.org>
parents:
2052
diff
changeset
|
2 Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, |
|
d0d0a69b5ca3
Added 1995 to copyright message.
Guido van Rossum <guido@python.org>
parents:
2052
diff
changeset
|
3 The Netherlands. |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
4 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
5 All Rights Reserved |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
6 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
7 Permission to use, copy, modify, and distribute this software and its |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
8 documentation for any purpose and without fee is hereby granted, |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
9 provided that the above copyright notice appear in all copies and that |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
10 both that copyright notice and this permission notice appear in |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
11 supporting documentation, and that the names of Stichting Mathematisch |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
12 Centrum or CWI not be used in advertising or publicity pertaining to |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
13 distribution of the software without specific, written prior permission. |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
14 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
15 STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
16 THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
17 FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
18 FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
19 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
20 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
21 OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
22 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
23 ******************************************************************/ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
24 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
25 /* Support for dynamic loading of extension modules */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
26 /* If no dynamic linking is supported, this file still generates some code! */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
27 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
28 #include "allobjects.h" |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
29 #include "osdefs.h" |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
30 #include "importdl.h" |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
31 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
32 extern int verbose; /* Defined in pythonrun.c */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
33 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
34 /* Explanation of some of the the various #defines used by dynamic linking... |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
35 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
36 symbol -- defined for: |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
37 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
38 DYNAMIC_LINK -- any kind of dynamic linking |
|
2733
dc64df7f1ad6
re-enabled NeXT dynamic linking (#ifdef NeXT)
Guido van Rossum <guido@python.org>
parents:
2729
diff
changeset
|
39 USE_RLD -- NeXT dynamic linking |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
40 USE_DL -- Jack's dl for IRIX 4 or GNU dld with emulation for Jack's dl |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
41 USE_SHLIB -- SunOS or IRIX 5 (SVR4?) shared libraries |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
42 _AIX -- AIX style dynamic linking |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
43 NT -- NT style dynamic linking (using DLLs) |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
44 _DL_FUNCPTR_DEFINED -- if the typedef dl_funcptr has been defined |
|
2729
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
45 USE_MAC_DYNAMIC_LOADING -- Mac CFM shared libraries |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
46 SHORT_EXT -- short extension for dynamic module, e.g. ".so" |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
47 LONG_EXT -- long extension, e.g. "module.so" |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
48 hpux -- HP-UX Dynamic Linking - defined by the compiler |
|
2199
f4671b681ab9
added changes for NetBSD dynamic linking; removed shared linking for NeXT
Guido van Rossum <guido@python.org>
parents:
2094
diff
changeset
|
49 __NetBSD__ -- NetBSD shared libraries (not quite SVR4 compatible) |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
50 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
51 (The other WITH_* symbols are used only once, to set the |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
52 appropriate symbols.) |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
53 */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
54 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
55 /* Configure dynamic linking */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
56 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
57 #ifdef hpux |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
58 #define DYNAMIC_LINK |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
59 #include <errno.h> |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
60 typedef void (*dl_funcptr)(); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
61 #define _DL_FUNCPTR_DEFINED 1 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
62 #define SHORT_EXT ".sl" |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
63 #define LONG_EXT "module.sl" |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
64 #endif |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
65 |
|
2199
f4671b681ab9
added changes for NetBSD dynamic linking; removed shared linking for NeXT
Guido van Rossum <guido@python.org>
parents:
2094
diff
changeset
|
66 #ifdef __NetBSD__ |
|
f4671b681ab9
added changes for NetBSD dynamic linking; removed shared linking for NeXT
Guido van Rossum <guido@python.org>
parents:
2094
diff
changeset
|
67 #define DYNAMIC_LINK |
|
f4671b681ab9
added changes for NetBSD dynamic linking; removed shared linking for NeXT
Guido van Rossum <guido@python.org>
parents:
2094
diff
changeset
|
68 #define USE_SHLIB |
|
f4671b681ab9
added changes for NetBSD dynamic linking; removed shared linking for NeXT
Guido van Rossum <guido@python.org>
parents:
2094
diff
changeset
|
69 |
|
f4671b681ab9
added changes for NetBSD dynamic linking; removed shared linking for NeXT
Guido van Rossum <guido@python.org>
parents:
2094
diff
changeset
|
70 #define dlerror() "error in dynamic linking" |
|
f4671b681ab9
added changes for NetBSD dynamic linking; removed shared linking for NeXT
Guido van Rossum <guido@python.org>
parents:
2094
diff
changeset
|
71 #endif |
|
f4671b681ab9
added changes for NetBSD dynamic linking; removed shared linking for NeXT
Guido van Rossum <guido@python.org>
parents:
2094
diff
changeset
|
72 |
| 2435 | 73 #ifdef __WIN32__ |
| 74 #define NT | |
| 75 #endif | |
| 76 | |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
77 #ifdef NT |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
78 #define DYNAMIC_LINK |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
79 #include <windows.h> |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
80 typedef FARPROC dl_funcptr; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
81 #define _DL_FUNCPTR_DEFINED |
|
2085
8921a2881fc7
NT dlls have .pyd extension instead of .dll
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
82 #define SHORT_EXT ".pyd" |
|
8921a2881fc7
NT dlls have .pyd extension instead of .dll
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
83 #define LONG_EXT "module.pyd" |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
84 #endif |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
85 |
|
2733
dc64df7f1ad6
re-enabled NeXT dynamic linking (#ifdef NeXT)
Guido van Rossum <guido@python.org>
parents:
2729
diff
changeset
|
86 #ifdef NeXT |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
87 #define DYNAMIC_LINK |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
88 #define USE_RLD |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
89 #endif |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
90 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
91 #ifdef WITH_SGI_DL |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
92 #define DYNAMIC_LINK |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
93 #define USE_DL |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
94 #endif |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
95 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
96 #ifdef WITH_DL_DLD |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
97 #define DYNAMIC_LINK |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
98 #define USE_DL |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
99 #endif |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
100 |
|
2374
397478bca0c4
ported to 68K Mac; changed suffix to .slb
Guido van Rossum <guido@python.org>
parents:
2331
diff
changeset
|
101 #ifdef __CFM68K__ |
|
2729
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
102 #define USE_MAC_DYNAMIC_LOADING |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
103 #endif |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
104 |
|
2729
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
105 #ifdef USE_MAC_DYNAMIC_LOADING |
|
2331
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
106 #define DYNAMIC_LINK |
|
2374
397478bca0c4
ported to 68K Mac; changed suffix to .slb
Guido van Rossum <guido@python.org>
parents:
2331
diff
changeset
|
107 #define SHORT_EXT ".slb" |
|
397478bca0c4
ported to 68K Mac; changed suffix to .slb
Guido van Rossum <guido@python.org>
parents:
2331
diff
changeset
|
108 #define LONG_EXT "module.slb" |
|
2331
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
109 #ifndef _DL_FUNCPTR_DEFINED |
|
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
110 typedef void (*dl_funcptr)(); |
|
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
111 #endif |
|
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
112 #endif |
|
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
113 |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
114 #if !defined(DYNAMIC_LINK) && defined(HAVE_DLFCN_H) && defined(HAVE_DLOPEN) |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
115 #define DYNAMIC_LINK |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
116 #define USE_SHLIB |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
117 #endif |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
118 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
119 #ifdef _AIX |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
120 #define DYNAMIC_LINK |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
121 #include <sys/ldr.h> |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
122 typedef void (*dl_funcptr)(); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
123 #define _DL_FUNCPTR_DEFINED |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
124 static void aix_loaderror(char *name); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
125 #endif |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
126 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
127 #ifdef DYNAMIC_LINK |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
128 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
129 #ifdef USE_SHLIB |
|
2724
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
130 #include <sys/types.h> |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
131 #include <sys/stat.h> |
|
2199
f4671b681ab9
added changes for NetBSD dynamic linking; removed shared linking for NeXT
Guido van Rossum <guido@python.org>
parents:
2094
diff
changeset
|
132 #ifdef __NetBSD__ |
|
f4671b681ab9
added changes for NetBSD dynamic linking; removed shared linking for NeXT
Guido van Rossum <guido@python.org>
parents:
2094
diff
changeset
|
133 #include <nlist.h> |
|
f4671b681ab9
added changes for NetBSD dynamic linking; removed shared linking for NeXT
Guido van Rossum <guido@python.org>
parents:
2094
diff
changeset
|
134 #include <link.h> |
|
f4671b681ab9
added changes for NetBSD dynamic linking; removed shared linking for NeXT
Guido van Rossum <guido@python.org>
parents:
2094
diff
changeset
|
135 #else |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
136 #include <dlfcn.h> |
|
2199
f4671b681ab9
added changes for NetBSD dynamic linking; removed shared linking for NeXT
Guido van Rossum <guido@python.org>
parents:
2094
diff
changeset
|
137 #endif |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
138 #ifndef _DL_FUNCPTR_DEFINED |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
139 typedef void (*dl_funcptr)(); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
140 #endif |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
141 #ifndef RTLD_LAZY |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
142 #define RTLD_LAZY 1 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
143 #endif |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
144 #define SHORT_EXT ".so" |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
145 #define LONG_EXT "module.so" |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
146 #endif /* USE_SHLIB */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
147 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
148 #if defined(USE_DL) || defined(hpux) |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
149 #include "dl.h" |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
150 #endif |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
151 |
|
2729
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
152 #ifdef USE_MAC_DYNAMIC_LOADING |
|
2331
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
153 #include <CodeFragments.h> |
| 2793 | 154 #ifdef SYMANTEC__CFM68K__ /* Really just an older version of Universal Headers */ |
|
2374
397478bca0c4
ported to 68K Mac; changed suffix to .slb
Guido van Rossum <guido@python.org>
parents:
2331
diff
changeset
|
155 #define CFragConnectionID ConnectionID |
|
397478bca0c4
ported to 68K Mac; changed suffix to .slb
Guido van Rossum <guido@python.org>
parents:
2331
diff
changeset
|
156 #define kLoadCFrag 0x01 |
|
397478bca0c4
ported to 68K Mac; changed suffix to .slb
Guido van Rossum <guido@python.org>
parents:
2331
diff
changeset
|
157 #endif |
|
2331
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
158 #include <Files.h> |
|
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
159 #include "macdefs.h" |
|
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
160 #include "macglue.h" |
|
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
161 #endif |
|
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
162 |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
163 #ifdef USE_RLD |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
164 #include <mach-o/rld.h> |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
165 #define FUNCNAME_PATTERN "_init%.200s" |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
166 #ifndef _DL_FUNCPTR_DEFINED |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
167 typedef void (*dl_funcptr)(); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
168 #endif |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
169 #endif /* USE_RLD */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
170 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
171 extern char *getprogramname(); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
172 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
173 #ifndef FUNCNAME_PATTERN |
| 2435 | 174 #if defined(__hp9000s300) || defined(__NetBSD__) || defined(__BORLANDC__) |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
175 #define FUNCNAME_PATTERN "_init%.200s" |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
176 #else |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
177 #define FUNCNAME_PATTERN "init%.200s" |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
178 #endif |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
179 #endif |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
180 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
181 #if !defined(SHORT_EXT) && !defined(LONG_EXT) |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
182 #define SHORT_EXT ".o" |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
183 #define LONG_EXT "module.o" |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
184 #endif /* !SHORT_EXT && !LONG_EXT */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
185 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
186 #endif /* DYNAMIC_LINK */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
187 |
|
2374
397478bca0c4
ported to 68K Mac; changed suffix to .slb
Guido van Rossum <guido@python.org>
parents:
2331
diff
changeset
|
188 /* Max length of module suffix searched for -- accommodates "module.slb" */ |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
189 #ifndef MAXSUFFIXSIZE |
|
2331
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
190 #define MAXSUFFIXSIZE 12 |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
191 #endif |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
192 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
193 /* Pass it on to import.c */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
194 int import_maxsuffixsize = MAXSUFFIXSIZE; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
195 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
196 struct filedescr import_filetab[] = { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
197 #ifdef SHORT_EXT |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
198 {SHORT_EXT, "rb", C_EXTENSION}, |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
199 #endif /* !SHORT_EXT */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
200 #ifdef LONG_EXT |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
201 {LONG_EXT, "rb", C_EXTENSION}, |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
202 #endif /* !LONG_EXT */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
203 {".py", "r", PY_SOURCE}, |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
204 {".pyc", "rb", PY_COMPILED}, |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
205 {0, 0} |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
206 }; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
207 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
208 object * |
|
2724
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
209 load_dynamic_module(name, pathname, fp) |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
210 char *name; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
211 char *pathname; |
|
2724
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
212 FILE *fp; |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
213 { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
214 #ifndef DYNAMIC_LINK |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
215 err_setstr(ImportError, "dynamically linked modules not supported"); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
216 return NULL; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
217 #else |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
218 object *m; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
219 char funcname[258]; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
220 dl_funcptr p = NULL; |
|
2724
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
221 #ifdef USE_SHLIB |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
222 static struct { |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
223 dev_t dev; |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
224 ino_t ino; |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
225 void *handle; |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
226 } handles[128]; |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
227 static int nhandles = 0; |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
228 #endif |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
229 sprintf(funcname, FUNCNAME_PATTERN, name); |
|
2724
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
230 #ifdef USE_SHLIB |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
231 if (fp != NULL) { |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
232 int i; |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
233 struct stat statb; |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
234 fstat(fileno(fp), &statb); |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
235 for (i = 0; i < nhandles; i++) { |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
236 if (statb.st_dev == handles[i].dev && |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
237 statb.st_ino == handles[i].ino) { |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
238 p = (dl_funcptr) dlsym(handles[i].handle, |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
239 funcname); |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
240 goto got_it; |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
241 } |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
242 } |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
243 if (nhandles < 128) { |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
244 handles[nhandles].dev = statb.st_dev; |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
245 handles[nhandles].ino = statb.st_ino; |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
246 } |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
247 } |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
248 #endif /* USE_SHLIB */ |
|
2729
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
249 #ifdef USE_MAC_DYNAMIC_LOADING |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
250 /* |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
251 ** Dynamic loading of CFM shared libraries on the Mac. |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
252 ** The code has become more convoluted than it was, because we want to be able |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
253 ** to put multiple modules in a single file. For this reason, we have to determine |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
254 ** the fragment name, and we cannot use the library entry point but we have to locate |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
255 ** the correct init routine "by hand". |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
256 */ |
|
2331
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
257 { |
|
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
258 FSSpec libspec; |
|
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
259 CFragConnectionID connID; |
|
2374
397478bca0c4
ported to 68K Mac; changed suffix to .slb
Guido van Rossum <guido@python.org>
parents:
2331
diff
changeset
|
260 Ptr mainAddr; |
|
397478bca0c4
ported to 68K Mac; changed suffix to .slb
Guido van Rossum <guido@python.org>
parents:
2331
diff
changeset
|
261 Str255 errMessage; |
|
397478bca0c4
ported to 68K Mac; changed suffix to .slb
Guido van Rossum <guido@python.org>
parents:
2331
diff
changeset
|
262 OSErr err; |
|
2729
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
263 Boolean isfolder, didsomething; |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
264 char buf[512]; |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
265 Str63 fragname; |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
266 Ptr symAddr; |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
267 CFragSymbolClass class; |
|
2331
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
268 |
|
2729
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
269 /* First resolve any aliases to find the real file */ |
|
2331
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
270 (void)FSMakeFSSpec(0, 0, Pstring(pathname), &libspec); |
| 2793 | 271 #if !(defined(__MWERKS__) && defined(__CFM68K__)) |
| 272 /* Bug: not in library */ | |
|
2729
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
273 err = ResolveAliasFile(&libspec, 1, &isfolder, &didsomething); |
| 2793 | 274 #endif |
|
2729
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
275 if ( err ) { |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
276 sprintf(buf, "%s: %s", pathname, PyMac_StrError(err)); |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
277 err_setstr(ImportError, buf); |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
278 return NULL; |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
279 } |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
280 /* Next, determine the fragment name, by stripping '.slb' and 'module' */ |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
281 memcpy(fragname+1, libspec.name+1, libspec.name[0]); |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
282 fragname[0] = libspec.name[0]; |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
283 if( strncmp((char *)(fragname+1+fragname[0]-4), ".slb", 4) == 0 ) |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
284 fragname[0] -= 4; |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
285 if ( strncmp((char *)(fragname+1+fragname[0]-6), "module", 6) == 0 ) |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
286 fragname[0] -= 6; |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
287 /* Load the fragment (or return the connID if it is already loaded */ |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
288 err = GetDiskFragment(&libspec, 0, 0, fragname, |
|
2374
397478bca0c4
ported to 68K Mac; changed suffix to .slb
Guido van Rossum <guido@python.org>
parents:
2331
diff
changeset
|
289 kLoadCFrag, &connID, &mainAddr, |
|
397478bca0c4
ported to 68K Mac; changed suffix to .slb
Guido van Rossum <guido@python.org>
parents:
2331
diff
changeset
|
290 errMessage); |
|
2331
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
291 if ( err ) { |
|
2420
6beef17871f9
change ifdefs and fix "%#s" format
Guido van Rossum <guido@python.org>
parents:
2374
diff
changeset
|
292 sprintf(buf, "%.*s: %s", errMessage[0], errMessage+1, PyMac_StrError(err)); |
|
2331
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
293 err_setstr(ImportError, buf); |
|
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
294 return NULL; |
|
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
295 } |
|
2729
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
296 /* Locate the address of the correct init function */ |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
297 err = FindSymbol(connID, Pstring(funcname), &symAddr, &class); |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
298 if ( err ) { |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
299 sprintf(buf, "%s: %s", funcname, PyMac_StrError(err)); |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
300 err_setstr(ImportError, buf); |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
301 return NULL; |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
302 } |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
303 p = (dl_funcptr)symAddr; |
|
2331
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
304 } |
|
2729
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
305 #endif /* USE_MAC_DYNAMIC_LOADING */ |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
306 #ifdef USE_SHLIB |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
307 { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
308 #ifdef RTLD_NOW |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
309 /* RTLD_NOW: resolve externals now |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
310 (i.e. core dump now if some are missing) */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
311 void *handle = dlopen(pathname, RTLD_NOW); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
312 #else |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
313 void *handle; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
314 if (verbose) |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
315 printf("dlopen(\"%s\", %d);\n", pathname, RTLD_LAZY); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
316 handle = dlopen(pathname, RTLD_LAZY); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
317 #endif /* RTLD_NOW */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
318 if (handle == NULL) { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
319 err_setstr(ImportError, dlerror()); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
320 return NULL; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
321 } |
|
2724
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
322 if (fp != NULL && nhandles < 128) |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
323 handles[nhandles++].handle = handle; |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
324 p = (dl_funcptr) dlsym(handle, funcname); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
325 } |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
326 #endif /* USE_SHLIB */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
327 #ifdef _AIX |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
328 p = (dl_funcptr) load(pathname, 1, 0); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
329 if (p == NULL) { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
330 aix_loaderror(pathname); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
331 return NULL; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
332 } |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
333 #endif /* _AIX */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
334 #ifdef NT |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
335 { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
336 HINSTANCE hDLL; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
337 hDLL = LoadLibrary(pathname); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
338 if (hDLL==NULL){ |
|
2843
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
339 char errBuf[256]; |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
340 unsigned int errorCode; |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
341 |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
342 /* Get an error string from Win32 error code */ |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
343 char theInfo[256]; /* Pointer to error text from system */ |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
344 int theLength; /* Length of error text */ |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
345 |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
346 errorCode = GetLastError(); |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
347 |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
348 theLength = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, /* flags */ |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
349 NULL, /* message source */ |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
350 errorCode, /* the message (error) ID */ |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
351 0, /* default language environment */ |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
352 (LPTSTR) theInfo, /* the buffer */ |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
353 sizeof(theInfo), /* the buffer size */ |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
354 NULL); /* no additional format args. */ |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
355 |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
356 /* Problem: could not get the error message. This should not happen if called correctly. */ |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
357 if (theLength == 0) { |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
358 sprintf(errBuf, "DLL load failed with error code %d", errorCode); |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
359 } else { |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
360 int len; |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
361 /* For some reason a \r\n is appended to the text */ |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
362 if (theLength >= 2 && theInfo[theLength-2] == '\r' && theInfo[theLength-1] == '\n') { |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
363 theLength -= 2; |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
364 theInfo[theLength] = '\0'; |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
365 } |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
366 strcpy(errBuf, "DLL load failed: "); |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
367 len = strlen(errBuf); |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
368 strncpy(errBuf+len, theInfo, sizeof(errBuf)-len); |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
369 errBuf[sizeof(errBuf)-1] = '\0'; |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
370 } |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
371 err_setstr(ImportError, errBuf); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
372 return NULL; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
373 } |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
374 p = GetProcAddress(hDLL, funcname); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
375 } |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
376 #endif /* NT */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
377 #ifdef USE_DL |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
378 p = dl_loadmod(getprogramname(), pathname, funcname); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
379 #endif /* USE_DL */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
380 #ifdef USE_RLD |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
381 { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
382 NXStream *errorStream; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
383 struct mach_header *new_header; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
384 const char *filenames[2]; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
385 long ret; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
386 unsigned long ptr; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
387 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
388 errorStream = NXOpenMemory(NULL, 0, NX_WRITEONLY); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
389 filenames[0] = pathname; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
390 filenames[1] = NULL; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
391 ret = rld_load(errorStream, &new_header, |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
392 filenames, NULL); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
393 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
394 /* extract the error messages for the exception */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
395 if(!ret) { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
396 char *streamBuf; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
397 int len, maxLen; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
398 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
399 NXPutc(errorStream, (char)0); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
400 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
401 NXGetMemoryBuffer(errorStream, |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
402 &streamBuf, &len, &maxLen); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
403 err_setstr(ImportError, streamBuf); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
404 } |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
405 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
406 if(ret && rld_lookup(errorStream, funcname, &ptr)) |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
407 p = (dl_funcptr) ptr; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
408 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
409 NXCloseMemory(errorStream, NX_FREEBUFFER); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
410 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
411 if(!ret) |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
412 return NULL; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
413 } |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
414 #endif /* USE_RLD */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
415 #ifdef hpux |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
416 { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
417 shl_t lib; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
418 int flags; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
419 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
420 flags = BIND_DEFERRED; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
421 if (verbose) |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
422 { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
423 flags = BIND_IMMEDIATE | BIND_NONFATAL | BIND_VERBOSE; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
424 printf("shl_load %s\n",pathname); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
425 } |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
426 lib = shl_load(pathname, flags, 0); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
427 if (lib == NULL) |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
428 { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
429 char buf[256]; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
430 if (verbose) |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
431 perror(pathname); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
432 sprintf(buf, "Failed to load %.200s", pathname); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
433 err_setstr(ImportError, buf); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
434 return NULL; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
435 } |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
436 if (verbose) |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
437 printf("shl_findsym %s\n", funcname); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
438 shl_findsym(&lib, funcname, TYPE_UNDEFINED, (void *) &p); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
439 if (p == NULL && verbose) |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
440 perror(funcname); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
441 } |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
442 #endif /* hpux */ |
|
2724
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
443 got_it: |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
444 if (p == NULL) { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
445 err_setstr(ImportError, |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
446 "dynamic module does not define init function"); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
447 return NULL; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
448 } |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
449 (*p)(); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
450 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
451 m = dictlookup(import_modules, name); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
452 if (m == NULL) { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
453 if (err_occurred() == NULL) |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
454 err_setstr(SystemError, |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
455 "dynamic module not initialized properly"); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
456 return NULL; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
457 } |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
458 if (verbose) |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
459 fprintf(stderr, |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
460 "import %s # dynamically loaded from %s\n", |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
461 name, pathname); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
462 INCREF(m); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
463 return m; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
464 #endif /* DYNAMIC_LINK */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
465 } |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
466 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
467 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
468 #ifdef _AIX |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
469 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
470 #include <ctype.h> /* for isdigit() */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
471 #include <errno.h> /* for global errno */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
472 #include <string.h> /* for strerror() */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
473 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
474 void aix_loaderror(char *pathname) |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
475 { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
476 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
477 char *message[8], errbuf[1024]; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
478 int i,j; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
479 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
480 struct errtab { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
481 int errno; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
482 char *errstr; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
483 } load_errtab[] = { |
|
2724
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
484 {L_ERROR_TOOMANY, "too many errors, rest skipped."}, |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
485 {L_ERROR_NOLIB, "can't load library:"}, |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
486 {L_ERROR_UNDEF, "can't find symbol in library:"}, |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
487 {L_ERROR_RLDBAD, |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
488 "RLD index out of range or bad relocation type:"}, |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
489 {L_ERROR_FORMAT, "not a valid, executable xcoff file:"}, |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
490 {L_ERROR_MEMBER, |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
491 "file not an archive or does not contain requested member:"}, |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
492 {L_ERROR_TYPE, "symbol table mismatch:"}, |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
493 {L_ERROR_ALIGN, "text allignment in file is wrong."}, |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
494 {L_ERROR_SYSTEM, "System error:"}, |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
495 {L_ERROR_ERRNO, NULL} |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
496 }; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
497 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
498 #define LOAD_ERRTAB_LEN (sizeof(load_errtab)/sizeof(load_errtab[0])) |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
499 #define ERRBUF_APPEND(s) strncat(errbuf, s, sizeof(errbuf)-strlen(errbuf)-1) |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
500 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
501 sprintf(errbuf, " from module %.200s ", pathname); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
502 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
503 if (!loadquery(1, &message[0], sizeof(message))) |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
504 ERRBUF_APPEND(strerror(errno)); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
505 for(i = 0; message[i] && *message[i]; i++) { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
506 int nerr = atoi(message[i]); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
507 for (j=0; j<LOAD_ERRTAB_LEN ; j++) { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
508 if (nerr == load_errtab[i].errno && load_errtab[i].errstr) |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
509 ERRBUF_APPEND(load_errtab[i].errstr); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
510 } |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
511 while (isdigit(*message[i])) message[i]++ ; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
512 ERRBUF_APPEND(message[i]); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
513 ERRBUF_APPEND("\n"); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
514 } |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
515 errbuf[strlen(errbuf)-1] = '\0'; /* trim off last newline */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
516 err_setstr(ImportError, errbuf); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
517 return; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
518 } |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
519 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
520 #endif /* _AIX */ |
