Working in C, on top of unix, I download and use the shared library somewhat as follows:
...
handle = dlopen("nameOfLib");
...
libInit();
...
libGoToState1();
libGoToState2();
....
libTerminate();
...
dlclose(handle);
...
I would like my application to allow "plugins" that take the form of dynamically loaded libraries that adhere to this API.
The tricky part is that I want to load the plug-in after the call libInit(), and I want the plug-in to be able to call libGoToSomeOtherState()by changing the state of the library, but using the same “session” as the application that downloaded it.
Any thoughts on how I need to code are appreciated.
In particular, what needs to be done in the .c files for the plugin and the main program so that they can share the library instance, state and all?