18 char *os2error(int rc);
23 dlopen(const char *path, int mode)
27 const char *beg, *dot;
31 if ((rc = DosLoadModule(fail, sizeof fail, (char*)path, &handle)) == 0)
32 return (void *)handle;
36 if (strlen(path) >= sizeof(tmp))
39 /* Not found. Check for non-FAT name and try truncated name. */
40 /* Don't know if this helps though... */
41 for (beg = dot = path + strlen(path);
42 beg > path && !strchr(":/\\", *(beg-1));
49 memmove(tmp, path, n);
50 memmove(tmp+n, dot, strlen(dot)+1);
51 if (DosLoadModule(fail, sizeof fail, tmp, &handle) == 0)
52 return (void *)handle;
59 dlsym(void *handle, const char *symbol)
65 rc = DosQueryProcAddr((HMODULE)handle, 0, symbol, &addr);
67 rc = DosQueryProcType((HMODULE)handle, 0, symbol, &type);
68 if (rc == 0 && type == PT_32BIT)
70 rc = ERROR_CALL_NOT_IMPLEMENTED;
85 err = os2error(retcode);
87 if (len > sizeof(buf) - 1)
88 len = sizeof(buf) - 1;
89 strncpy(buf, err, len+1);
90 if (fail[0] && len < 300)
91 sprintf(buf + len, ", possible problematic module: '%s'", fail);
101 if ((rc = DosFreeModule((HMODULE)handle)) == 0) return 0;