12 dlopen(char *path, int mode)
15 char tmp[260], *beg, *dot;
19 if ((rc = DosLoadModule(fail, sizeof fail, path, &handle)) == 0)
20 return (void *)handle;
24 /* Not found. Check for non-FAT name and try truncated name. */
25 /* Don't know if this helps though... */
26 for (beg = dot = path + strlen(path);
27 beg > path && !strchr(":/\\", *(beg-1));
33 memmove(tmp, path, n);
34 memmove(tmp+n, dot, strlen(dot)+1);
35 if (DosLoadModule(fail, sizeof fail, tmp, &handle) == 0)
36 return (void *)handle;
43 dlsym(void *handle, char *symbol)
49 rc = DosQueryProcAddr((HMODULE)handle, 0, symbol, &addr);
51 rc = DosQueryProcType((HMODULE)handle, 0, symbol, &type);
52 if (rc == 0 && type == PT_32BIT)
54 rc = ERROR_CALL_NOT_IMPLEMENTED;
68 if (DosGetMessage(NULL, 0, buf, sizeof buf - 1, retcode,
69 "OSO001.MSG", &len)) {
72 "OS/2 system error code %lu, possible problematic module: '%s'",
75 sprintf(buf, "OS/2 system error code %lu", retcode);
78 if (len && buf[len - 1] == '\n')
80 if (len && buf[len - 1] == '\r')
82 if (len && buf[len - 1] == '.')
84 if (fail[0] && len < 300)
85 sprintf(buf + len, ", possible problematic module: '%s'",
97 if ((rc = DosFreeModule((HMODULE)handle)) == 0) return 0;