5 #include "mach-o/rld.h"
6 #include "streams/streams.h"
8 static char *lastError
= NULL
;
13 return NXOpenMemory(NULL
, 0, NX_WRITEONLY
);
17 CloseError(NXStream
* s
)
20 NXCloseMemory(s
, NX_FREEBUFFER
);
24 TransferError(NXStream
* s
)
32 NXGetMemoryBuffer(s
, &buffer
, &len
, &maxlen
);
33 lastError
= malloc(len
+ 1);
34 strcpy(lastError
, buffer
);
38 next_dlopen(char *name
)
41 NXStream
*errorStream
;
45 errorStream
= OpenError();
46 p
= calloc(2, sizeof(void *));
48 rld_success
= rld_load(errorStream
, NULL
, p
, NULL
);
53 TransferError(errorStream
);
56 CloseError(errorStream
);
61 next_dlclose(void *handle
)
67 next_dlsym(void *handle
, char *symbol
)
69 NXStream
*errorStream
= OpenError();
71 unsigned long symref
= 0;
73 snprintf(symbuf
, sizeof(symbuf
), "_%s", symbol
);
74 if (!rld_lookup(errorStream
, symbuf
, &symref
))
75 TransferError(errorStream
);
76 CloseError(errorStream
);
77 return (void *) symref
;