11 char *os2error(int rc);
14 dlopen(char *path, int mode)
17 char tmp[260], *beg, *dot;
21 if ((rc = DosLoadModule(fail, sizeof fail, path, &handle)) == 0)
22 return (void *)handle;
26 /* Not found. Check for non-FAT name and try truncated name. */
27 /* Don't know if this helps though... */
28 for (beg = dot = path + strlen(path);
29 beg > path && !strchr(":/\\", *(beg-1));
35 memmove(tmp, path, n);
36 memmove(tmp+n, dot, strlen(dot)+1);
37 if (DosLoadModule(fail, sizeof fail, tmp, &handle) == 0)
38 return (void *)handle;
45 dlsym(void *handle, char *symbol)
51 rc = DosQueryProcAddr((HMODULE)handle, 0, symbol, &addr);
53 rc = DosQueryProcType((HMODULE)handle, 0, symbol, &type);
54 if (rc == 0 && type == PT_32BIT)
56 rc = ERROR_CALL_NOT_IMPLEMENTED;
71 err = os2error(retcode);
73 if (len > sizeof(buf) - 1)
74 len = sizeof(buf) - 1;
75 strncpy(buf, err, len+1);
76 if (fail[0] && len < 300)
77 sprintf(buf + len, ", possible problematic module: '%s'", fail);
87 if ((rc = DosFreeModule((HMODULE)handle)) == 0) return 0;