You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.1 KiB

  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 char *_PyImport_DynLoadFiletab[] = {".pyd", ".dll", NULL};
  8. dl_funcptr _PyImport_GetDynLoadFunc(const char *shortname,
  9. const char *pathname, FILE *fp)
  10. {
  11. dl_funcptr p;
  12. APIRET rc;
  13. HMODULE hDLL;
  14. char failreason[256];
  15. char funcname[258];
  16. rc = DosLoadModule(failreason,
  17. sizeof(failreason),
  18. pathname,
  19. &hDLL);
  20. if (rc != NO_ERROR) {
  21. char errBuf[256];
  22. PyOS_snprintf(errBuf, sizeof(errBuf),
  23. "DLL load failed, rc = %d: %.200s",
  24. rc, failreason);
  25. PyErr_SetString(PyExc_ImportError, errBuf);
  26. return NULL;
  27. }
  28. PyOS_snprintf(funcname, sizeof(funcname), "PyInit_%.200s", shortname);
  29. rc = DosQueryProcAddr(hDLL, 0L, funcname, &p);
  30. if (rc != NO_ERROR)
  31. p = NULL; /* Signify Failure to Acquire Entrypoint */
  32. return p;
  33. }