Guido van Rossum | 22a1d36 | 1999-12-20 21:18:49 +0000 | [diff] [blame] | 1 | /*********************************************************** |
Guido van Rossum | fd71b9e | 2000-06-30 23:50:40 +0000 | [diff] [blame] | 2 | Copyright (c) 2000, BeOpen.com. |
| 3 | Copyright (c) 1995-2000, Corporation for National Research Initiatives. |
| 4 | Copyright (c) 1990-1995, Stichting Mathematisch Centrum. |
| 5 | All rights reserved. |
Guido van Rossum | 22a1d36 | 1999-12-20 21:18:49 +0000 | [diff] [blame] | 6 | |
Guido van Rossum | fd71b9e | 2000-06-30 23:50:40 +0000 | [diff] [blame] | 7 | See the file "Misc/COPYRIGHT" for information on usage and |
| 8 | redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
Guido van Rossum | 22a1d36 | 1999-12-20 21:18:49 +0000 | [diff] [blame] | 9 | ******************************************************************/ |
| 10 | |
| 11 | /* Support for dynamic loading of extension modules */ |
| 12 | |
| 13 | #define INCL_DOSERRORS |
| 14 | #define INCL_DOSMODULEMGR |
| 15 | #include <os2.h> |
| 16 | |
| 17 | #include "Python.h" |
| 18 | #include "importdl.h" |
| 19 | |
| 20 | |
| 21 | const struct filedescr _PyImport_DynLoadFiletab[] = { |
| 22 | {".pyd", "rb", C_EXTENSION}, |
| 23 | {".dll", "rb", C_EXTENSION}, |
| 24 | {0, 0} |
| 25 | }; |
| 26 | |
Guido van Rossum | 96a8fb7 | 1999-12-22 14:09:35 +0000 | [diff] [blame] | 27 | dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname, |
Guido van Rossum | 22a1d36 | 1999-12-20 21:18:49 +0000 | [diff] [blame] | 28 | const char *pathname, FILE *fp) |
| 29 | { |
| 30 | dl_funcptr p; |
| 31 | APIRET rc; |
| 32 | HMODULE hDLL; |
| 33 | char failreason[256]; |
Guido van Rossum | 96a8fb7 | 1999-12-22 14:09:35 +0000 | [diff] [blame] | 34 | char funcname[258]; |
Guido van Rossum | 22a1d36 | 1999-12-20 21:18:49 +0000 | [diff] [blame] | 35 | |
| 36 | rc = DosLoadModule(failreason, |
| 37 | sizeof(failreason), |
| 38 | pathname, |
| 39 | &hDLL); |
| 40 | |
| 41 | if (rc != NO_ERROR) { |
| 42 | char errBuf[256]; |
| 43 | sprintf(errBuf, |
| 44 | "DLL load failed, rc = %d: %s", |
| 45 | rc, failreason); |
| 46 | PyErr_SetString(PyExc_ImportError, errBuf); |
| 47 | return NULL; |
| 48 | } |
| 49 | |
Guido van Rossum | 96a8fb7 | 1999-12-22 14:09:35 +0000 | [diff] [blame] | 50 | sprintf(funcname, "init%.200s", shortname); |
Guido van Rossum | 22a1d36 | 1999-12-20 21:18:49 +0000 | [diff] [blame] | 51 | rc = DosQueryProcAddr(hDLL, 0L, funcname, &p); |
| 52 | if (rc != NO_ERROR) |
| 53 | p = NULL; /* Signify Failure to Acquire Entrypoint */ |
| 54 | return p; |
| 55 | } |