1 /* $OpenBSD: foo.c,v 1.1.1.1 2008/01/02 18:36:59 matthieu Exp $ */ 2 /* Public domain. 2008, Matthieu Herrb */ 3 4 #include <dlfcn.h> 5 #include <stdio.h> 6 7 static void *h = NULL; 8 9 void 10 foo_init(void) 11 { 12 printf("loading %s\n", BAR); 13 h = dlopen(BAR, RTLD_LAZY|RTLD_GLOBAL); 14 if (h == NULL) 15 errx(1, "dlopen %s: %s\n", BAR, dlerror()); 16 printf("loaded: %s\n", BAR); 17 } 18 19 int 20 foo(void) 21 { 22 if (h == NULL) 23 foo_init(); 24 25 return bar(); 26 } 27