Using the Callout Gateway
The InterSystems Callout Gateway allows InterSystems IRIS™ 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 InterSystems IRIS $ZF
This chapter discusses the following topics:
Here are some important concepts that you should understand before reading the rest of this book:
Individual functions in the $ZF
suite are identified by the first argument of the function call, which will be a negative number, -100
. For example, the function that calls an operating system command has the form $ZF(-100, <oscommand>)
, where <oscommand>
is a string containing the command to be executed. When this function is discussed, it will be referred to as $ZF(-100)
. In the same way, the other functions will be referred to as $ZF(-3)
, 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)
Callout library interfaces
All of the $ZF
functions except $ZF(-100)
are used to provide some form of access to Callout libraries. The $ZF(-3)
, and $ZF(-6)
functions provide three different interfaces for invoking Callout library functions, and $ZF(-4)
is a container for various utility functions used with the $ZF(-5)
function suite includes the following functions:
The $ZF(-100) function
function is used to run shell commands and operating system service calls. It is not used to access Callout libraries, and can be called without any previous setup.
The $ZF(-3) function
function is a simple way to load a Callout library and invoke a library function with a single statement. Both the library and its functions are specified by name, and the library remains in memory until replaced by a call to a different library.
The $ZF(-4) function
The $ZF(-5) function interface
function and its utility functions allow multiple libraries to be handled efficiently. Both the library and its functions are identified by system-defined ID values. Several libraries can be in virtual memory at the same time. The following $ZF(-4)
functions are used to load and unload libraries, and to obtain library and function ID values:
The $ZF(-6) function interface
function and its utility functions provide a way to write Callout applications that do not require hard-coded library names. Instead, the actual library filenames are contained in a separate index table, where each library is associated with a unique, user-defined index number. Once the index table is defined, it is available to all processes in an instance of InterSystems IRIS. Callout applications identify a library by index number and load it by reading the index table. Several libraries can be in memory at the same time. The following functions are used to manage indexes and load or unload libraries:
Using the Callout Gateway you can call routines written in languages other than ObjectScript. On all platforms that support InterSystems IRIS 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 InterSystems IRIS.
InterSystems supports using the same C compiler that we use to generate InterSystems IRIS on all platforms:
||IBM XL C for AIX
|Mac OS X (Darwin)
||Microsoft Visual Studio
|Linux (all variants)
||GNU Project GCC C
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.
Content Date/Time: 2019-07-19 06:02:41