1 #ifndef _API_INITIALIZER_H_ 2 #define _API_INITIALIZER_H_ 3 #include <stdlib.h> 4 #include <dlfcn.h> 5 6 class ApiInitializer { 7 public: 8 ApiInitializer(void *dso) : 9 m_dso(dso) { 10 } 11 static void *s_getProc(const char *name, void *userData) { 12 ApiInitializer *self = (ApiInitializer *)userData; 13 return self->getProc(name); 14 } 15 private: 16 void *m_dso; 17 void *getProc(const char *name) { 18 void *symbol = NULL; 19 if (m_dso) { 20 symbol = dlsym(m_dso, name); 21 } 22 return symbol; 23 } 24 }; 25 26 #endif 27