The Caché Callout Gateway allows Caché applications to invoke shell or operating system commands, run external programs in spawned processes, and call functions from specially written shared libraries. The Callout Gateway is implemented as a suite of related functions contained in the Caché $ZF
Individual functions in the $ZF
suite are identified by the first argument of the function call, which will be a negative number from -1
. For example, the function that calls an operating system command has the form $ZF(-1, <oscommand>)
, where <oscommand>
is a string containing the command to be executed. When this function is discussed, it will be referred to as $ZF(-1)
. In the same way, the other functions will be referred to as $ZF(-2)
, using only the first parameter of the actual function call.
function is a special case, since it is actually just a container for eight utility functions that are identified by the first two parameters: $ZF(-4,1)
In this book, the term shared library
refers to a dynamically linked file (a DLL
file on Windows, an SO
file on UNIX® and related operating systems, or a shareable image file on OpenVMS). A Callout library
is a shared library that includes hooks to the Callout Gateway, allowing various $ZF
functions to load it at runtime and invoke its functions. Callout libraries are usually written in C (seeCompatible Languages and Compilers
), but could potentially be written in any other compiled language that uses a calling convention understood by your C compiler.
Callout library interfaces
The $ZF(-1) and $ZF(-2) functions
The $ZF(-5) function interface
The $ZF(-6) function interface
Using the Callout Gateway you can call routines written in languages other than Caché ObjectScript. On all platforms that support Caché you can call routines written in the C language. In theory you should be able to call routines written in any compiled language that is compatible with C. Two compatibility issues arise. First, the compiler must use an Application Binary Interface (ABI) that is compatible with C. Second, the compiler must generate code that does not rely on any runtime library features that are not compatible with Caché.
Most platforms have a standardized Application Binary Interface (ABI), making most compilers compatible. The Intel x86-32 and x86-64 platforms are major exceptions, Multiple calling conventions exist for these platforms. See (http://en.wikipedia.org/wiki/X86_calling_conventions
) for a discussion of calling conventions on these platforms.
Calling languages that use different calling conventions may be possible, as many C compilers allow declaring an external routine to have another calling convention. Therefore is it often possible to call routines written in other languages if one is willing to write a C wrapper routine.