11 char *os2error(int rc);
14 dlopen(const char *path, int mode)
17 char tmp[260], *beg, *dot;
21 if ((rc = DosLoadModule(fail, sizeof fail, (char*)path, &handle)) == 0)
22 return (void *)handle;
26 if (strlen(path) >= sizeof(tmp))
29 /* Not found. Check for non-FAT name and try truncated name. */
30 /* Don't know if this helps though... */
31 for (beg = dot = path + strlen(path);
32 beg > path && !strchr(":/\\", *(beg-1));
39 memmove(tmp, path, n);
40 memmove(tmp+n, dot, strlen(dot)+1);
41 if (DosLoadModule(fail, sizeof fail, tmp, &handle) == 0)
42 return (void *)handle;
49 dlsym(void *handle, const char *symbol)
55 rc = DosQueryProcAddr((HMODULE)handle, 0, symbol, &addr);
57 rc = DosQueryProcType((HMODULE)handle, 0, symbol, &type);
58 if (rc == 0 && type == PT_32BIT)
60 rc = ERROR_CALL_NOT_IMPLEMENTED;
75 err = os2error(retcode);
77 if (len > sizeof(buf) - 1)
78 len = sizeof(buf) - 1;
79 strncpy(buf, err, len+1);
80 if (fail[0] && len < 300)
81 sprintf(buf + len, ", possible problematic module: '%s'", fail);
91 if ((rc = DosFreeModule((HMODULE)handle)) == 0) return 0;