Import API
Posted: 29.01.2006, 21:43
Hmm. Well, The feature request is under users, but this seems more like dev, so I'm posting it here. If I'm wrong, please move the post to its appropriate location :p
I would like to make a feature request. A library API for dynamically linking libraries at runtime. I realize that this is not an easy task. The reason is because I've seen some libraries like NOVAS and SOFA (and others) would add features to Celestia that would make it more robust, but including them directly creates more problems than they would solve. What I'm proposing is an API like Apache, where you can load a dynamic library at run time. Benefits include extensibility, flexibility, and robustness without being tied to external source. Detriments include building a new API, shared object bugs corrupting the running executable, and a point for buffer overflow / shared object attacks.
I suppose the question that comes to mind is "Why?". I know I thought about that before posting this. The reason is that are many people out there don't know C++ but would like to add "xyz", and others that hate to maintain local changes but want to stay current with the application (me). I wouldn't mind writing a translator library, but I at shun maintaining changes that are useless to the majority of users. An import API would allow people to extend Celestia without maintaining a separate source tree, and allow the extensions to be used by anyone without requiring them to duplicate the work.
As I see the API, it would be configured in celestia.cfg, with something like:
SharedObjects = "true"/"false"
SharedObjectsDir="path"
SharedObjectsAllowed="name"[[,]"name"]/"all"/"none"
SharedObjects would designate if any were allowed.
SharedObjectsDir designates the directory for the .SOs or .DLLs.
SharedObjectsAllowed designates either a list of .sos/.dlls to load, or all in the directory, or none in the directory. This way 3rd party libraries wouldn't be confused with Celestia libraries.
The person that wanted to use a 3rd party library would then write a translator, and store it in the SharedObjects directory. The translator library would be responsible for setting up any required buffers or stack frames, registering the public routines with Celestia, and calling the intended 3rd party routine. This could be simply calling the function, or as complex as converting data types and post processing the results.
The API itself would parse the config, find the libraries (if any), load the library, and call the initialization function for it. The translator library would then verify and set up anything it needed from the initialization function, and register it's public functions. It would call Celestia with a prefix/pseudo class name to register the functions with. Celestia could then return a status designating if the pseudo class name is OK or already in use. If it is available, the translator library would then register each of its public pseudo members with Celestia. Celestia would check to see if the pseudo class has been set up, and if so attempt to add the function to the pseudo class. Celestia would return a status of the pseudo member, either OK or not OK (possible failures would be already registered, not able to add the name to the export list, etc.)
Once this was complete, the library would be available through pseudo_class:pseudo_member from the LUA interface. This would allow maximum extensibility while requiring minimum dependence on 3rd party modifications, and maximizing portability.
I would like to make a feature request. A library API for dynamically linking libraries at runtime. I realize that this is not an easy task. The reason is because I've seen some libraries like NOVAS and SOFA (and others) would add features to Celestia that would make it more robust, but including them directly creates more problems than they would solve. What I'm proposing is an API like Apache, where you can load a dynamic library at run time. Benefits include extensibility, flexibility, and robustness without being tied to external source. Detriments include building a new API, shared object bugs corrupting the running executable, and a point for buffer overflow / shared object attacks.
I suppose the question that comes to mind is "Why?". I know I thought about that before posting this. The reason is that are many people out there don't know C++ but would like to add "xyz", and others that hate to maintain local changes but want to stay current with the application (me). I wouldn't mind writing a translator library, but I at shun maintaining changes that are useless to the majority of users. An import API would allow people to extend Celestia without maintaining a separate source tree, and allow the extensions to be used by anyone without requiring them to duplicate the work.
As I see the API, it would be configured in celestia.cfg, with something like:
SharedObjects = "true"/"false"
SharedObjectsDir="path"
SharedObjectsAllowed="name"[[,]"name"]/"all"/"none"
SharedObjects would designate if any were allowed.
SharedObjectsDir designates the directory for the .SOs or .DLLs.
SharedObjectsAllowed designates either a list of .sos/.dlls to load, or all in the directory, or none in the directory. This way 3rd party libraries wouldn't be confused with Celestia libraries.
The person that wanted to use a 3rd party library would then write a translator, and store it in the SharedObjects directory. The translator library would be responsible for setting up any required buffers or stack frames, registering the public routines with Celestia, and calling the intended 3rd party routine. This could be simply calling the function, or as complex as converting data types and post processing the results.
The API itself would parse the config, find the libraries (if any), load the library, and call the initialization function for it. The translator library would then verify and set up anything it needed from the initialization function, and register it's public functions. It would call Celestia with a prefix/pseudo class name to register the functions with. Celestia could then return a status designating if the pseudo class name is OK or already in use. If it is available, the translator library would then register each of its public pseudo members with Celestia. Celestia would check to see if the pseudo class has been set up, and if so attempt to add the function to the pseudo class. Celestia would return a status of the pseudo member, either OK or not OK (possible failures would be already registered, not able to add the name to the export list, etc.)
Once this was complete, the library would be available through pseudo_class:pseudo_member from the LUA interface. This would allow maximum extensibility while requiring minimum dependence on 3rd party modifications, and maximizing portability.