Fix xslt_process() to ensure that it inserts a NULL terminator after the
[PostgreSQL.git] / src / backend / port / dynloader / bsdi.c
blob1ce61b8b826ea2f814c8db1ed80d9691938803ec
1 /*-------------------------------------------------------------------------
3 * dynloader.c
4 * Dynamic Loader for Postgres for Linux, generated from those for
5 * Ultrix.
7 * You need to install the dld library on your Linux system!
9 * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
10 * Portions Copyright (c) 1994, Regents of the University of California
13 * IDENTIFICATION
14 * $PostgreSQL$
16 *-------------------------------------------------------------------------
18 #include "postgres.h"
19 #ifndef HAVE_DLOPEN
21 extern char my_exec_path[];
23 void *
24 pg_dlopen(char *filename)
26 static int dl_initialized = 0;
29 * initializes the dynamic loader with the executable's pathname. (only
30 * needs to do this the first time pg_dlopen is called.)
32 if (!dl_initialized)
34 if (dld_init(dld_find_executable(my_exec_path)))
35 return NULL;
38 * if there are undefined symbols, we want dl to search from the
39 * following libraries also.
41 dl_initialized = 1;
45 * link the file, then check for undefined symbols!
47 if (dld_link(filename))
48 return NULL;
51 * If undefined symbols: try to link with the C and math libraries! This
52 * could be smarter, if the dynamic linker was able to handle shared libs!
54 if (dld_undefined_sym_count > 0)
56 if (dld_link("/usr/lib/libc.a"))
58 elog(WARNING, "could not link C library");
59 return NULL;
61 if (dld_undefined_sym_count > 0)
63 if (dld_link("/usr/lib/libm.a"))
65 elog(WARNING, "could not link math library");
66 return NULL;
68 if (dld_undefined_sym_count > 0)
70 int count = dld_undefined_sym_count;
71 char **list = dld_list_undefined_sym();
73 /* list the undefined symbols, if any */
76 elog(WARNING, "\"%s\" is undefined", *list);
77 list++;
78 count--;
79 } while (count > 0);
81 dld_unlink_by_file(filename, 1);
82 return NULL;
87 return (void *) strdup(filename);
90 char *
91 pg_dlerror()
93 return dld_strerror(dld_errno);
96 #endif /* not HAVE_DLOPEN */