blob: 6c149b9f55e0c68a30b8c7f6f23d0da72041b3de (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
/*
* These routines were taken from the Apache source, but were made
* available with a PostgreSQL-compatible license. Kudos Wilfredo
* S�nchez <wsanchez@apple.com>.
*
* $Header: /cvsroot/pgsql/src/backend/port/dynloader/darwin.c,v 1.4 2000/12/11 00:49:54 tgl Exp $
*/
#include "postgres.h"
#include <mach-o/dyld.h>
#include "dynloader.h"
void *pg_dlopen(char *filename)
{
NSObjectFileImage image;
if (NSCreateObjectFileImageFromFile(filename, &image) !=
NSObjectFileImageSuccess)
return NULL;
return NSLinkModule(image, filename, TRUE);
}
void pg_dlclose(void *handle)
{
NSUnLinkModule(handle,FALSE);
return;
}
PGFunction pg_dlsym(void *handle, char *funcname)
{
NSSymbol symbol;
char *symname = (char*)malloc(strlen(funcname)+2);
sprintf(symname, "_%s", funcname);
if (NSIsSymbolNameDefined(symname))
{
symbol = NSLookupAndBindSymbol(symname);
free(symname);
return (PGFunction) NSAddressOfSymbol(symbol);
}
else
{
free(symname);
return (PGFunction)NULL;
}
}
char *pg_dlerror(void)
{
return "no error message available";
}
|