Margus,
At 07:10 PM 1/5/00 +0200, you wrote:
>Anyway, is it possible to have shared library functions without
>reference number and if so, could anyone send me some working piece of
>code that implements shared library and program that calls it?
I don't believe its possible to have shared library functions that don't
start with the reference number. The reference number is not only used to
access "globals" in the shared library. It is also used to multiplex among
shared library calls. For example, every shared library's "open" function
has a trap id of sysLibTrapOpen. What distinguishes library A's open
function from library B's is the reference number.
You could provide a glue file that hides the reference number ugliness.
Let's take a simple example where we want to implement strcpy in a shared
library. You could define a shared library version:
enum {
sl_strcpyTrap = sysLibTrapCustom
};
SL_strcpy (UInt refNum, CharPtr target, CharPtr source)
SYS_TRAP (sl_strcpyTrap);
Then you would define a glue header and source. The glue file might look
something like this:
#define SL_Type 'libr'
#defiine SL_Creator 'test'
UInt s_refNum = 0;
void SLGlue_Init ()
{
SysLibLoad (SL_Type, SL_Creator, &s_refNum);
}
void SLGlue_Term()
{
SysLibRemove (s_refNum);
}
CharPtr strcpy (CharPtr target, CharPtr source)
{
SL_strcpy (s_refNum, target, source);
return target;
}
Please bear in mind that this code is just to give you an idea of how you
might go about providing the glue. You'd want to add all sorts of error
checking and stuff. You might want to make calls to the shared library's
open and close functions in SLGlue_Init() and SLGlue_Term(), respectively.
Anyhow, once you got the glue source implemented, you would need to
statically link that into your project.
Hope this helps.
Regards,
Greg
Greg Winton
Bachmann Software and Services, LLC
mailto:[EMAIL PROTECTED]
http://www.bachmannsoftware.com