unix_library.h (398B)
1 #pragma once 2 3 #include <dlfcn.h> 4 5 typedef void * Library; 6 7 Library library_open( const char * path ) { 8 return dlopen( path, RTLD_NOW ); 9 } 10 11 void * library_function( Library lib, const char * name ) { 12 return dlsym( lib, name ); 13 } 14 15 const char * library_last_error() { 16 return dlerror(); 17 } 18 19 void library_close( Library lib ) { 20 if( dlclose( lib ) != 0 ) { 21 errx( 1, "dlclose: %s", dlerror() ); 22 } 23 }