Returns a function pointer to a COBOL program, subprogram or entry point.
Restriction: This function is supported for native COBOL only.
Syntax:
#include "cobcall.h"
PFR cobgetfuncaddr(int type, const cobchar_t *name);
Parameters:
- type
- Indicates what is returned if the specified program is not found.
Bit
|
Description
|
0
|
Can be either 0 or 1, where
- 0 means a null pointer is returned
- 1 means the address of an error function is returned
|
1-31
|
Reserved
|
- name
- A null terminated string that specifies the name of the COBOL program to be found.
Equivalent COBOL Syntax:
set procedure-pointer to entry "name"
Example:
The following C code calls a COBOL program cobprog with two arguments, coping with any error condition:
PFR cobprog;
if ((cobprog = cobgetfuncaddr(0, "cobprog")) == NULL)
{
/* Error case */
}
else
{
/* Loaded */
(*cobprog)(arg1, arg2); /* Call it! */
}
Comments:
This function returns a function pointer to the COBOL program of the specified name.
If the specified name is an entry point of an already loaded COBOL program, that program is used. Alternatively, if the specified name is a C function, then that is used. Otherwise, a program with a basename of the specified name is searched for on disk using the standard COBOL search order and paths. To change the program search order use the program_search_order run-time tunable.
If an error function is returned (bit 0 set to 1) and it is subsequently called then a run-time error is produced, as for cobcall().
This function only loads the program of the specified name; it does not call it. This enables programs to be preloaded. This is especially useful if you want to call an entry point within the program, but not the main entry point of the program.