[JDEV] Scripting/Modules/Rant

Aaron Brady (insomnike) rewt at clubi.ie
Wed Aug 11 18:47:51 CDT 1999


: Again, excellent idea.  I'm not terribly familiar with the issues on the
: *nix end, but it's certainly been done successfully before (cf zlib,
: info-zip, etc).  In C/C++, it's all done with the smoke and mirrors of the
: preprocessor and platform-specific makefiles.
: 
: Writing a Win32 interface to handle plugin DLLs is no big deal; what is
: involved in *nix?

>From what I know of the Win32 end, the Unix one is a *lot* simpler.

And example of how procedures are run from a .so file:

void main(void) {
 void *phoe = dlopen ("mod_filetrans.so", RTLD_LAZY);
 int (*funk)(int) = dlsym(phoe, "handle_prefs");
 printf ("[%d]\n", (*funk)(1));
 dlclose(phoe);
}

Thats the Linux libdl way of doing it, there are *isms for other Unix,
and of course a lot don't support modules at all, but it should be
possible to structure Makefiles to link the modules statically
into executables on platforms without support.

For examples of how this is done, see the eggdrop IRC bot, and Apache.


-- 
 "I don't really love computers, I just say that to get them
  into bed with me" -- Terry Pratchet




More information about the JDev mailing list