Hi, everyone.
Working in C, on top of unix, I am loading and using a shared library somewhat as follows:
...
handle = dlopen("nameOfLib");
...
libInit();
...
libGoToState1();
libGoToState2();
....
libTerminate();
...
dlclose(handle);
...
What I would like is for my application to admit 'plugins' which take the form of dynamically loadable libraries that adhere to a given API.
The tricky part is that I want to load a plugin after calling libInit()
and I want the plugin to be able to call libGoToSomeOtherState()
, altering the state of the library, but making use of the same 'session' as the application that loaded it.
Any thoughts on how I need to go about coding this are appreciated.
Specifically, what needs to go into the .c files for the plugin and the main program in order for them to share a library instance, state and all?