[ Previous | Next | Contents | Glossary | Home | Search ]
The graPHIGS Programming Interface: Technical Reference

Chapter 6. Enabling User Exits for Conferencing

The graPHIGS API provides a set of user exits through which your application display data can be distributed and managed by a conference utility. Conference utilities allow multiple users on separate workstations to participate in a single graPHIGS API application. This is very useful when a team of designers, for example, who work in different locations need to discuss changes to a model they are all using. New users of a graPHIGS API application may also benefit when getting assistance from the help desk through a conference utility.

The graPHIGS API can accommodate a conference utility in the following way. The graPHIGS API application runs on a master workstation while a conference utility controller communicates with the participating workstations. This conference controller must be given information about all participating workstations before the application is started. One way to supply this information is through a conference session manager connected to a user interface. The graPHIGS API supports message facilities that allow this information to flow between the controller and the session manager. The session manager, conference controller, and the application must all run on the same node as the master workstation. See Figure 6screen

Figure 6. The graPHIGS API Running with a Typical Conference Utility



View figure.


As the application renders data to the master workstation, the conference controller renders the same data to each participating workstation, allowing all participants to view the graPHIGS API application. It can also allow control to be passed from the master workstation to any one of the participating workstations for interaction with the application.

In order to render data to the participating workstations, the conference controller must intercept each graPHIGS API function issued by the application. It must then determine which functions to issue to the participating workstations as well as to the master workstation, and which to simply pass along to the master workstation. Further decisions must be made regarding the function parameters: if the controller issues the function to the participating workstations, it may use the same parameters set by the application or it may modify them before issuing them.

The conference controller must define and allocate a separate application anchor block (AAB) for each participating workstation. In this way, the conference controller keeps track of which workstation session has input focus. The conference controller should not allow any session to remain in a state awaiting input, such as a response to a Request Choice (GPRQCH) subroutine. This prevents input focus from being switched among master and participating workstation sessions.

The following sequence of events summarizes the initialization and exchange of data that might be used for a graPHIGS API conference utility: Refer to The graPHIGS Programming Interface: Subroutine Reference for details on the subroutines cited below.

  1. The user starts the conference session manager on the master workstation.
  2. The user inputs information about participating workstations to the session manager.
  3. The user starts the application on the master workstation.
  4. The user starts the conference controller (see "Starting and Stopping the Conference Utility Controller").
  5. The conference controller issues the Inquire Nucleus Specification (GPQNS) subroutine to determine the session manager hostname.
  6. The conference controller issues the Inquire Workstation Type and Options (GPQWTO) subroutine to determine the workstation type and options for the master workstation.
  7. The conference controller uses the Create Workstation (GPCRWS) subroutine with NICKCHK to open participating workstations using the same type and options as the master workstation. See "NICKCHK (Nickname Processing Default)"screen
  8. The conference controller might issue the Inquire Input Device State (GPQID) subroutine to determine input device state of a participating workstation.
  9. Once it has determined the input device state for the participating workstation, the conference controller might then issue one or more of the following Inquire Device State subroutines to determine the state of an input device attached to a specified participating workstation.
  10. The conference controller issues the Set Input Device Mode (GPIDMO) subroutine to set the input device state in order to request input from a specific device without locking out another participating workstation from input focus.
  11. The conference controller intercepts request input subroutine calls from the application. The conference controller manages input focus among participating workstations and ensures that a request to change input focus is honored.

Starting and Stopping the Conference Utility Controller

When the application issues the first graPHIGS API subroutine call, the graPHIGS API attempts to load a user exit facility routine when the environment is set up as follows:

For AIX:

For MVS:

The graPHIGS API always attempts to load a module named AFMEXITscreen

For VM:

The Conference Controller

The conference controller minimally includes the user exit routine and the application intercept exit routine.

The User Exit Routine

Once the user exit routine successfully loads, the address returned by the load service is invoked with the following parameters.

int exit_init (appl_anc, gPFuncListp, exit_anchor)
  int *appl_anc;
  void (*gPFuncListp)();
  int *exit_anchor;
{
}
appl_anc
The graPHIGS API anchors the exit environment in this block. The user exit routines should not modify it. This parameter is provided to the application intercept exit routine for two purposes:
  1. For use with gPSetInterceptExit(C or F) function
  2. For use with error handlers when the application is using the reentrant or non-reentrant interfaces. The application's Application Anchor Block (AAB), not the user exit's internal AAB, must be passed to the application error handler.
gPFuncListp
This parameter is a vector of function pointers. There are six function pointers available to the conference controller. They are:
gPCallThru
The entry point to the function that the application intercept exit routine calls to invoke the graPHIGS API subroutine.
gPSetInterceptExitC
The entry point to the function used to set the application intercept exit routine address that receives control for the application's current and subsequent calls to the graPHIGS APIscreen This function should be used if your conference controller is written in C.
gPSetInterceptExitF
The entry point to the function used to set the application intercept exit routine address that receives control for the application's current and subsequent calls to the graPHIGS APIscreen This function should be used if your conference controller is written in Fortran.
gPInvApplC
The entry point to the conference controller function that must be used to invoke an application routine such as an error handler set by either the Define Error Handling (GPEHND) subroutine or the Specify and Error Exit and Error Threshold (GPEXIT) subroutine. This routine ensures that the application's environment is set up before it is invoked. This entry should be used if your conference controller is written in C.
gPInvApplF
The entry point to the conference controller function that must be used to invoke an application routine such as an error handler set by either the Define Error Handling (GPEHND) subroutine or the Specify and Error Exit and Error Threshold (GPEXIT) subroutine. This routine ensures that the application's environment is set up before it is invoked. This entry should be used if your conference controller is written in Fortran.
gPSetPassthruAAB
The entry point to the function to call prior to disabling the application intercept exit or prior to returning a return code of -1 from the application intercept exit. This function establishes the environment that the passthru application anchor block points to in order to replace the exit environment when it is terminated or disabled.
exit_anchor
A pointer to an 8-byte area that the application intercept exit routine uses to anchor its dynamic storage. This pointer is passed to the application intercept exit routine on each call.

exit_init is invoked immediately after the exit is loaded. It should allocate storage and initialize but make no calls to the graPHIGS API, except to gPSetInterceptExit(C or F) or gPSetPassthruAABscreen

To process the application API call that caused it to be loaded, the user exit routine must make a call to gPSetInterceptExit(C or F) to enable an application intercept exit routine before returning. The graPHIGS API then invokes the specified intercept exit routine prior to returning to the application and on subsequent graPHIGS API subroutine calls.

If exit_init returns non-zero, then the graPHIGS API assumes that the initialization failed. It unloads the exit and proceeds with normal graPHIGS API initialization. If exit_init returns zero, then it loads the application intercept exit routine and processes the API subroutine that caused it to be loaded.

exit_init is also called at termination time. The parameter list is identical for both calls. This makes cleanup symmetrical to initialization.

Due to the possible recursion when error handlers are called, application intercept exit routines must be recursive (no writable statics). For this reason, Fortran is not recommended for a conference controller, although it may work when the application is written in Fortran as well. The only disadvantage to writing all conference controllers in the C programming language is that they require the runtime C library.

An example of how typical declarations might be specified for the initial entry:

/*-----------------------------------------------------------------*/
/* Overlay for function vector (2nd parm on init call).            */
/*-----------------------------------------------------------------*/
struct gPfuncv {
  void (*gPCallThru)();                  /* gPCallThru ptr          */
  void (*gPSetInterceptExitC)();         /* gPSetExit for C exits   */
  void (*gPSetInterceptExitF)();         /* gPSetExit for F exits   */
  void (*gPInvApplC)();                  /* gPInvAppl for C exits   */
  void (*gPInvApplF)();                  /* gPInvAppl for F exits   */
  void (*gPSetPassthruAAB)();            /* gPSetPassthruAAB ptr    */
};
 
/*------------------------------------------------------------------*/
/* Main routine for exit.  This routine is invoked when the exit is */
/* first loaded.  It is invoked only once.                          */
/*------------------------------------------------------------------*/
int exit_init(appl_anc, funclistp, anchor)
  int *appl_anc;                         /* Env anchor (Read/Only)  */
  struct gPfuncv *funclistp;             /* Ptr to function vectors */
  int *anchor;                           /* Anchor for exit storage */
{
}

The Application Intercept Exit Routine

Once the user exit routine has control, it may enable an application intercept exit routine to be given control on the current application request and on subsequent API requests by issuing the gPSetInterceptExit(C or F) function with the address of the intercept exit routine.

If the gPSetInterceptExit(C or F) function is issued with the address of zero in the funcp parameter, then the application intercept exit routine is disabled from being called on each API request. This establishes the environment for the passthru AAB to point to when it replaces the the disabled exit environment. Before disabling an intercept exit, the application must invoke the gPSetPassthruAAB function routine.

A return code of -1 from the application intercept exit routine means that the conference controller will be terminated and replaced by the environment pointed to by the passthru AAB. This allows an exit and its overhead to be removed without terminating an active graPHIGS API application.

For example, for C:

void gPSetInterceptExitC (appl_anc, funcp)
  int *appl_anc;
  int (*funcp)();
{
}
or, for Fortran:
void gPSetInterceptExitF (appl_anc, funcp)
  int *appl_anc;
  int (*funcp)();
{
}
appl_anc
A pointer to the passthru AAB. It must not be modified by the application intercept exit routine. It is the same as the first parameter on the exit_init call.
funcp
The function pointer that identifies which entry point is to serve as the application intercept exit routine. If funcp is null, then the graPHIGS API works in a passthru mode such that all calls are passed from the graPHIGS API using the current passthru AAB.
Invoking the Application Intercept Exit Routine

Any application intercept exit routine that is enabled by the user exit routine through gPSetInterceptExit in response to an API request by the application is invoked as follows:

int intercept_exit(exit_anchor,rcpp,plistp,scbp)
  int *exit_anchor;
  int *rcpp;
  int **plistp;
  struct scb *scbp;
{
}
exit_anchor
A pointer to the 8-byte area that was passed to the exit_init that is used to anchor any storage required by the intercept exit routine.
rcpp
A pointer to the rcp code of the current graPHIGS API subroutine.
plistp
A pointer to the application's parameter list. For the generic binding and the ISO PHIGS Fortran binding, this is a list of pointers, one for each parameter. For the ISO PHIGS C binding this can be pointers or values, depending on the API call itself. Some parameters are passed by value for the C binding.
scbp 
A pointer to a stub communication block that describes some aspects of the API call. The format for scbp is:
struct scb {
  char          ssid;                   /* Sub-system id               */
                                        /* 'T' = TSO (MVS),            */
                                        /* 'V' = VM, 'X' = AIX         */
  unsigned char iftype;                 /* 0=non-ren, 1=ren, 2=SPI     */
  unsigned char binding;                /* 0=generic/Fortran, 2=ANSI C */
  unsigned char rsvd[1[default]
  unsigned char rsvd2;
  void (*erhp)();                       /* ANSI default Exit           */
}
Application Intercept Exit Call Through to the graPHIGS API

The application intercept exit routine calls through to the graPHIGS API to process the API request as follows:

void gPCallThru(aab,rcpp,plistp,scbp)
int *aab
unsigned int *rcpp
int **plistp
struct scb *scbp
{
}
aab
Defined by the graPHIGS API for the reentrant and SPI interfaces. It is an 8-byte area that must be initialized to zero before it is first used to invoke the graPHIGS APIscreen
rcpp
A pointer to the rcp code of the current graPHIGS API subroutine.
plistp
A pointer to the application's parameter list. For the generic binding and the ISO PHIGS Fortran binding this is a list of pointers, one for each parameter. For the ISO PHIGS C binding this is pointers or values, depending on the API call itself. Some parameters are passed by value for the C binding.
scbp
A pointer to a stub communication block that describes some aspects of the API call. The format for scbp is shown above.
Preparing to Disable the Intercept Exit Routine

Before the application intercept exit routine stops processing the API requests, it issues the following:

void gPSetPassthruAAB(appl_anc,aabp)
int *appl_anc
int *aabp
{
}
appl_anc
A pointer to the passthru AAB. It must not be modified by the application intercept exit routine. It is the same as the first parameter on the init call.
aabp
A pointer to an area defined by the application intercept exit routine that is initialized during invocation of the graPHIGS APIscreen This function is used before the intercept is set to be disabled and before -1 is returned from the intercept to establish the AAB that is to be used for subsequent API calls. If the passthru AAB is not set to the AAB used to invoke the graPHIGS API, then a default AAB is used. This results in errors indicating that the graPHIGS API is not open because it will not yet have an AAB. The only current restriction is that passthru mode cannot be mixed with the exit that set error handlers in VM/MVS. If this restriction is not observed, the error handler may be invoked with the incorrect programming language environment, resulting in an abend. This restriction does not apply to AIX.
Passing Error Handler Calls from the graPHIGS API to the Application

The gPInvAppl(C or F) routines must be used by the application intercept exit routine when an error handler call from the graPHIGS API is intercepted and is to be passed on to the actual application error handler. gPCallThru does not apply in this case because the application, not the graPHIGS API, is being called.

For example, for C:

void gPInvApplC(appl_anc,routine_addr,parms)
or for Fortran:
void gPInvApplF(appl_anc,routine_addr,parms)
int *appl_anc
void(*routine_addr)()
parms
{
}

Where

appl_anc
A pointer to the passthru AAB. It must not be modified by the application intercept exit routine. It is the same as the first parameter on the init call.
routine_addr
A pointer to the application's error handler routine.
parms
Any other parameters expected by the receiving error handler routine.

These special entry points are necessary because of the great differences in runtime environments among C, Fortran, Pascal, and other programming languages. In order to ensure that a Fortran application with a Fortran error handler runs correctly, graPHIGS API must invoke the error handler with the same register content as when the application last called the graPHIGS APIscreen this process, the graPHIGS API can no longer act directly since the call that generates the error comes from the exit code and not from the application. Exit routines written in a language different from the application must define their own error handlers and pass them on to those of the application using the gPInvAppl(C or F) routine.

The general flow for a conference utility exit routine is shown in Figure 7screen (A) and (B) show the points at which the runtime environment must be the same (that is, the register contents must be very similar).

Figure 7. User Exit Routine Flow



View figure.




[ Previous | Next | Contents | Glossary | Home | Search ]