From: Alan W. I. <ir...@be...> - 2002-11-24 21:37:50
|
I start with the background information that is required on the dlopen to libltdl API change, then get to my two "simple" numbered questions at the end which any C expert should be able to answer for me. For the AT branch I am in the middle of changing from the dlopen API to the libltdl API to increase cross-platform compatibility. The old API: void * dlopen (const char *filename, int flag) void * dlsym (void *handle, char *name) int dlclose (void *handle) const char * dlerror (void) The new API: lt_dlhandle lt_dlopen (const char *filename) lt_dlhandle lt_dlopenext (const char *filename) lt_ptr_t lt_dlsym (lt_dlhandle handle, const char *name) int lt_dlclose (lt_dlhandle handle) const char * lt_dlerror (void) Note: lt_dlopenext is the same as lt_dlopen except that it tries with alternate suffixes if there is not an exact match to the name. In the new plcore.c there is the following line: driver->dlhand = lt_dlopenext( drvspec); which replaces the old driver->dlhand = dlopen( drvspec, flag); Subsequently driver->dlhand is used as an argument to lt_dlsym So in plplot.h I have changed from typedef struct { char *drvnam; void *dlhand; } PLLoadableDriver; to typedef struct { char *drvnam; lt_dlhandle dlhand; } PLLoadableDriver; With appropriate #include of the libltdl header and protection by #ifdef ENABLE_DYNDRIVERS. (1) Is that change to the struct the correct thing to do for the changed API? (2) The new plcore.c code also has the following fragment: PLDispatchInit dispatch_init = lt_dlsym( driver->dlhand, sym ); where the old disptab.h has typedef void (*PLDispatchInit)( PLDispatchTable *pdt ); What should I change that typedef to? My guess is something like typedef lt_ptr_t (PLDispatchInit)( PLDispatchTable *pdt ); but I am not completely sure so any quick help would be much appreciated. Of course I am going to try some variations on this theme this afternoon and hopefully get something to work, but the definitive answer would be most useful. C typedefs and pointers just plain drive me crazy! Alan email: ir...@be... phone: 250-727-2902 FAX: 250-721-7715 snail-mail: Dr. Alan W. Irwin Department of Physics and Astronomy, University of Victoria, P.O. Box 3055, Victoria, British Columbia, Canada, V8W 3P6 __________________________ Linux-powered astrophysics __________________________ |