/Python/dynload_os2.c

http://unladen-swallow.googlecode.com/ · C · 46 lines · 36 code · 9 blank · 1 comment · 4 complexity · a6bb2fbf25629834ae5c0b7ce1391147 MD5 · raw file

  1. /* Support for dynamic loading of extension modules */
  2. #define INCL_DOSERRORS
  3. #define INCL_DOSMODULEMGR
  4. #include <os2.h>
  5. #include "Python.h"
  6. #include "importdl.h"
  7. const struct filedescr _PyImport_DynLoadFiletab[] = {
  8. {".pyd", "rb", C_EXTENSION},
  9. {".dll", "rb", C_EXTENSION},
  10. {0, 0}
  11. };
  12. dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname,
  13. const char *pathname, FILE *fp)
  14. {
  15. dl_funcptr p;
  16. APIRET rc;
  17. HMODULE hDLL;
  18. char failreason[256];
  19. char funcname[258];
  20. rc = DosLoadModule(failreason,
  21. sizeof(failreason),
  22. pathname,
  23. &hDLL);
  24. if (rc != NO_ERROR) {
  25. char errBuf[256];
  26. PyOS_snprintf(errBuf, sizeof(errBuf),
  27. "DLL load failed, rc = %d: %.200s",
  28. rc, failreason);
  29. PyErr_SetString(PyExc_ImportError, errBuf);
  30. return NULL;
  31. }
  32. PyOS_snprintf(funcname, sizeof(funcname), "init%.200s", shortname);
  33. rc = DosQueryProcAddr(hDLL, 0L, funcname, &p);
  34. if (rc != NO_ERROR)
  35. p = NULL; /* Signify Failure to Acquire Entrypoint */
  36. return p;
  37. }