blob: d660e27501ae5c39caac4c94ae631cb7a07debff [file] [log] [blame]
Guido van Rossum22a1d361999-12-20 21:18:49 +00001
2/* Support for dynamic loading of extension modules */
3
4#define INCL_DOSERRORS
5#define INCL_DOSMODULEMGR
6#include <os2.h>
7
8#include "Python.h"
9#include "importdl.h"
10
11
12const struct filedescr _PyImport_DynLoadFiletab[] = {
13 {".pyd", "rb", C_EXTENSION},
14 {".dll", "rb", C_EXTENSION},
15 {0, 0}
16};
17
Guido van Rossum96a8fb71999-12-22 14:09:35 +000018dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname,
Guido van Rossum22a1d361999-12-20 21:18:49 +000019 const char *pathname, FILE *fp)
20{
21 dl_funcptr p;
22 APIRET rc;
23 HMODULE hDLL;
24 char failreason[256];
Guido van Rossum96a8fb71999-12-22 14:09:35 +000025 char funcname[258];
Guido van Rossum22a1d361999-12-20 21:18:49 +000026
27 rc = DosLoadModule(failreason,
28 sizeof(failreason),
29 pathname,
30 &hDLL);
31
32 if (rc != NO_ERROR) {
33 char errBuf[256];
Jeremy Hylton518ab1c2001-11-28 20:42:20 +000034 PyOS_snprintf(errBuf, sizeof(errBuf),
35 "DLL load failed, rc = %d: %.200s",
36 rc, failreason);
Guido van Rossum22a1d361999-12-20 21:18:49 +000037 PyErr_SetString(PyExc_ImportError, errBuf);
38 return NULL;
39 }
40
Jeremy Hylton518ab1c2001-11-28 20:42:20 +000041 PyOS_snprintf(funcname, sizeof(funcname), "init%.200s", shortname);
Guido van Rossum22a1d361999-12-20 21:18:49 +000042 rc = DosQueryProcAddr(hDLL, 0L, funcname, &p);
43 if (rc != NO_ERROR)
44 p = NULL; /* Signify Failure to Acquire Entrypoint */
45 return p;
46}