At 4:49 PM -0500 1999/12/06, Joe Nardone wrote:
>Is there any generic way to call into CW shared libraries
>w/out knowing the shared libs at compile time?
>
>I know we can look up libraries and load them (via SysLibLoad, etc.)
>but the SYS_TRAP macros seem to make it hard to define a generic
>prototype to use with all shared libs.
>
>Assume that we know the order of the functions in the shared
>lib (i.e. Open, Close, Sleep, Wake, Custom #1, Custom #2, etc.)
>and can use that info during runtime.  We just can't compile anything
>into the executable that came from the shared lib.
>
>Has anyone done this?  Anyone know how?  

You must compile against header files for each library which define the parameter list 
and return value of each API in the shared library, however, exactly which 
implementation is called is determined at run time by the library reference number, 
passed as the first parameter to each function in the shared library. For example:

Library A contains void Foo(UInt16 libRefnum) and Err Bar(UInt16 libRefnum, char * 
name).

Library B contains void Who(UInt16 libRefnum) and Err Hey(UInt16 libRefnum, char * 
name).

As long as the parameter list and return value is identical for both implementations, 
which presumes the functionality of each of these functions in the library is also 
identical, then you can get by with a single generic header file:

void Generic1(UInt16 libRefnum) and Err Generic2(UInt16 libRefnum, char * name)

Does that answer your question?

Regards,

Jim Schram
3Com/Palm Computing
Partner Engineering


Reply via email to