Try OpenEdge Now
skip to main content
Programming Interfaces
External Program Interfaces : Host Language Call Interface : Overview of HLC : Mapping routine identifiers using PRODSP()
Mapping routine identifiers using PRODSP()
You map routine identifiers to C functions in the PRODSP() dispatch routine. ABL provides a prototype PRODSP() in the C source file, hlprodsp.c.
Note: The $DLC/oebuild/hlc directory on UNIX and the %DLC%\oebuild\hlc directory in Windows contain a prototype hlprodsp.c file. Do not modify this file. To make changes, copy it to a working directory and modify the copy.
Because ABL calls the PRODSP() dispatch routine, it must have the following declaration:
PRODSP(pfunnam, argc, argv)

char *pfunnam, /* Name of function to call */
int *argc, /* CALL statement argument count */
char *argv[], /* CALL statement argument list */
The hlprodsp.c file shows routine-identifier hlcroutine being mapped to the C function hlcfunc() in PRODSP():
#define FUNCTEST(nam, rout) \
if (strcmp(nam, pfunnam) == 0) \
return rout(argc,argv);

* This is the interface to all C routines that
* ABL has associated 'CALL' statements to.

PRODSP(pfunnam, argc, argv)

char *pfunnam; /* Name of function to call */
int argc; /* CALL statement argument count */
char *argv[]; /* CALL statement argument list */

return 1; /* Non-zero return code causes OpenEdge error */
} /* condition if CALLed routine not found. */
For each routine you add, you must include a call to the FUNCTEST macro. For example, to map two routine names, such as HLCROUTINE1 and HLCROUTINE2, to two corresponding C functions, such as hlcfunc1() and hlcfunc2(), you must include the following lines in PRODSP():
Note: The CALL statement and FUNCTEST declaration must use the same letter case for the routine identifier.


FUNCTEST ( "routine-identifier" , function-name ) ;
This is the syntax for the FUNCTEST macro in hlprodsp.c:
The routine-identifier is the name referenced by a CALL statement that identifies your C function. Enter the routine identifier as a character string surrounded by quotes. Since FUNCTEST does not convert case for the routine identifier, the case is significant.
The function-name is the name of the C function that the routine-identifier references.
The routine identifier and the function name can have the same name, for example:
FUNCTEST("hlcfunc", hlcfunc);
When you compile hlprodsp.c, the C compiler translates the FUNCTEST macro references to C code, for example:
Translates to:
if (strcmp("HLCROUTINE", pfunnam) == 0)
return hlcfunc(argc,argv);
Therefore, when ABL invokes PRODSP() with the argument HLCROUTINE, it runs hlcfunc.