Progress
External Program
Interfaces


Mapping Routine Identifiers Using PRODSP()

You map routine identifiers to C functions in the PRODSP() dispatch routine. Progress provides a prototype PRODSP() in the C source file, hlprodsp.c.

NOTE: The $DLC/probuild/hlc directory on UNIX and the %DLC%\probuild\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 Progress 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():

hlprodsp.c 
#define FUNCTEST(nam, rout)  \
        if (strcmp(nam, pfunnam) == 0) \
            return rout(argc,argv);

/* PROGRAM: PRODSP
 * 
 *   This is the interface to all C routines that 
 *   Progress has associated ’CALL’ statements to. 
 */

long
PRODSP(pfunnam, argc, argv)

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

{
    
    FUNCTEST("HLCROUTINE", hlcfunc);
    
    return 1;   /* Non-zero return code causes Progress 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():

FUNCTEST("HLCROUTINE1", hlcfunc1);
FUNCTEST("HLCROUTINE2", hlcfunc2); 

NOTE: The CALL statement and FUNCTEST declaration must use the same letter case for the routine identifier.

The FUNCTEST macro in hlprodsp.c has the following syntax:

SYNTAX
FUNCTEST ( "routine-identifier" , function-name ) ; 

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 function name can have the same name:

FUNCTEST("hlcfunc", hlcfunc); 

When you compile hlprodsp.c, the C compiler translates the FUNCTEST macro references to C code. For example:

FUNCTEST("HLCROUTINE", hlcfunc); 

translates to:

if (strcmp("HLCROUTINE", pfunnam) == 0)
    return hlcfunc(argc,argv); 

Therefore, when Progress invokes PRODSP() with the argument HLCROUTINE, it runs hlcfunc.


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095