Previous: , Up: Library   [Contents][Index]

5.44 Mfmod Interface Functions

The calls described in this section provide interface for invoking functions defined in a dynamically loaded library and retrieving their return values. For a detailed description of this interface and a discussion of its use, see mfmod.

Built-in Function: number dlopen (filename)

Loads the dynamically loaded library filename and returns a numeric handle that can be used to call functions from that library.

Unless filename is an absolute pathname, it will be looked up in mfmod search path, defined by the configuration variable runtime.mfmod-path (see mfmod-path).

Maximum number of dynamic libraries that can be loaded simultaneously is limited by the configuration variable runtime.max-mfmods.

Once open, the library remains loaded until mailfromd exits. There is no dlclose function, since it is not deemed necessary (at the time of this writing, at least). Therefore, the common practice is to call this function in a begin section (see begin/end) and assign its return value to a global or static variable, which will then be used by further dl* calls in this module.

Built-in Function: any dlcall (number dlh, string symbol, string types, ...)

Calls a mfmod function symbol from the library identified by handle dlh (a value returned by a previous call to dlopen). The types parameter defines types of the remaining arguments. It is a list of type letters, one for each argument:

s

String value.

n
d

Numeric value.

m

Message.

An example usage:

set dlh dlopen("mfmod_test.so")
string x dlcall(dlh, "runtest", "sn", "input string", 3)

This example calls the function ‘runtest’ from the mfmod_test.so library with two arguments: a string ‘input string’ and numeric value ‘3’ and assings the return value to the variable x.

Type of the return value from dlcall is determined by the value of retval.type upon return from the underlying library function. See Loadable Library, for a detailed description.

For more details about using this function, Interface Module.


Previous: , Up: Library   [Contents][Index]