1 #include "mach-o/rld.h"
2 #include "streams/streams.h"
5 static char *lastError = NULL;
10 return NXOpenMemory(NULL, 0, NX_WRITEONLY);
14 CloseError(NXStream * s)
17 NXCloseMemory(s, NX_FREEBUFFER);
21 TransferError(NXStream * s)
29 NXGetMemoryBuffer(s, &buffer, &len, &maxlen);
30 lastError = malloc(len + 1);
31 strcpy(lastError, buffer);
35 next_dlopen(char *name)
38 NXStream *errorStream;
42 errorStream = OpenError();
43 p = calloc(2, sizeof(void *));
45 rld_success = rld_load(errorStream, NULL, p, NULL);
50 TransferError(errorStream);
53 CloseError(errorStream);
58 next_dlclose(void *handle)
64 next_dlsym(void *handle, char *symbol)
66 NXStream *errorStream = OpenError();
68 unsigned long symref = 0;
70 sprintf(symbuf, "_%s", symbol);
71 if (!rld_lookup(errorStream, symbuf, &symref))
72 TransferError(errorStream);
73 CloseError(errorStream);
74 return (void *) symref;