Remove building with NOCRYPTO option
[minix.git] / external / bsd / nvi / dist / common / dldb.c
blob2aaf5681701c22afbcb5a0979d625f66b74f2d79
1 /* $NetBSD: dldb.c,v 1.2 2013/11/22 15:52:05 christos Exp $ */
2 #include "config.h"
4 #include <dlfcn.h>
6 #include "common.h"
7 #include "pathnames.h"
9 static void relocate __P(());
11 #define RELOC(func,returntype,args,proto,types) \
12 static returntype reloc_##func __P(proto); \
13 returntype (*nvi_##func) __P(proto) = reloc_##func; \
14 static returntype reloc_##func args \
15 types \
16 { \
17 relocate(); \
18 return nvi_##func args; \
21 RELOC(db_create,int,(a,b,c),(DB **, DB_ENV *, u_int32_t),
22 DB**a;DB_ENV*b;u_int32_t c;)
23 RELOC(db_env_create,int,(a,b),(DB_ENV **, u_int32_t),DB_ENV ** a;u_int32_t b;);
24 RELOC(db_strerror,char *,(a),(int),int a;)
26 #define LOADSYM(func) \
27 if ((nvi_##func = dlsym(handle, #func)) == NULL) \
28 goto error;
30 static void
31 relocate()
33 void *handle = dlopen(_PATH_DB3, RTLD_LAZY);
35 if (!handle)
36 goto error;
38 LOADSYM(db_create)
39 LOADSYM(db_env_create)
40 LOADSYM(db_strerror)
42 return;
43 error:
44 fprintf(stderr, "Relocation error: %s\n", dlerror());
45 abort();