#include "cobcall.h" PFR cobgetfuncaddr(int type, const cobchar_t *name);
Bit | Description |
---|---|
0 | Can be either 0 or 1, where
|
1-31 | Reserved |
set procedure-pointer to entry "name"
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.
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.