This is probably the cleanest way to do it. Renaming all of the function calls to reference struct members shouldn't be too hard. I believe that you could instead load in the symbols for each function one at a time, but then it's not clear that you're working with an external symbol within the code. Since some people also suggested being able to use a different sql database for auth a storage, the struct would make it much easier to separate them.
Don't forget to define a versioning scheme. The library should export a dbmail_api_version symbol with some kind of major.minor.micro scheme or rev.compat scheme so that before you import the structure with all of the functions you know that it will be the size and signature you're expecting. Aaron Dan Weber <[EMAIL PROTECTED]> said: > > The most cleanly and effective way to approach this is make a large > struct called dbtype_api which includes all the functions. Each will > provide a plugin_api struct which will return the values needed. > Something like this. > > struct db_api { > int (*db_open)(char *); > void (*db_close)(void); > ... > }; > > struct db_api plugin_functions = { > db_open, /* Provided function from dbmysql.c */ > db_close > ... > }; > > Where ever the hell this thing is loaded > > lt_dlinit(); > lt_dlhandle handle = lt_dlopen((value spit out from GetConfigValue)); > struct db_api *foo; > foo = lt_dlsym(handle, "plugin_functions"); > > so, 'foo' is your ticket to all the functions in the module > then since itd be a pretty hefty job to do all that rename to > foo->db_open. We could just provide generic functions that just call > foo->db_*. > > Dan Weber > > > --------------enigD043B5B9548428749AF8550A > Content-Type: application/pgp-signature; name="signature.asc" > Content-Description: OpenPGP digital signature > Content-Disposition: attachment; filename="signature.asc" > > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.2.4 (GNU/Linux) > Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org > > iD8DBQFAt8HcF6i3K/AxoQERAst5AKDI2qmlNNy1v9a1uJPNEOK9cHlaoQCfXjXv > YrVhQXO1cUXYw9gpu8C0gK4= > =KdEM > -----END PGP SIGNATURE----- > > --------------enigD043B5B9548428749AF8550A-- > > --===============1486043274== --