srv_regwatch

Description

Add a client thread to the notification list for a specified procedure.

Syntax

CS_RETCODE srv_regwatch(spp, proc_namep, namelen, 
                    options, infop)
SRV_PROC         *spp;
CS_CHAR           *proc_namep;
CS_INT                namelen;
CS_INT                options;
CS_INT              *infop;

Parameters

spp

A pointer to an internal thread control structure.

proc_namep

The name of the procedure.

namelen

The length of the procedure name. If the procedure name is null terminated, namelen can be CS_NULLTERM.

options

A flag that specifies whether this is a one-time notification request, or a permanent request. Table 3-103 describes the legal values for options:

Table 3-103:  Values for options (srv_regwatch)

Value

Description

SRV_NOTIFY_ONCE

After the first notification, the client thread is removed from the notification list for the procedure.

SRV_NOTIFY_ALWAYS

The client thread will be notified each time the procedure executes until srv_regnowatch is used to remove the thread from the procedure’s notification list.

infop

Table 3-104 describes the possible values returned in *infop if srv_regwatch returns CS_FAIL:

Table 3-104:  Values for infop (srv_regwatch)

Value

Description

SRV_I_PNOTKNOWN

The procedure is not known to the Open Server application. The thread was not added to the notification list.

SRV_I_PINVOPT

An invalid options value was specified. The thread was not added to the notification list.

SRV_I_PNOTCLIENT

A non-client thread was specified. The thread was not added to the notification list.

SRV_I_PNOTIFYEXISTS

The thread is al&ready on the notification list for the specified procedure.

Returns

Table 3-105:  Return values (srv_regwatch)

Returns

To indicate

CS_SUCCEED

The routine completed successfully.

CS_FAIL

The routine failed.

Examples

Example 1

#include     <ospublic.h>

/*
** Local Prototype.
*/
CS_INT      ex_srv_regwatch PROTOTYPE((
SRV_PROC    *sproc,
CS_CHAR     *procedure_name
));

/*
** EX_SRV_REGWATCH
**   An example routine to add a client thread to the
**   notification list for a specified procedure.
**
** Arguments:

**   sproc              A pointer to an internal thread control
**                      structure.
**   procedure_name     The null terminated procedure name.
**
** Returns:
**   CS_SUCCEED            If the thread was added to the 
**                         notification list.
**   SRV_I_PNOTKNOWN       The procedure is not known to the Open
**                         Server application.
**   SRV_I_PNOTCLIENT      A non-client thread was specified.
**   SRV_I_PNOTIFYEXISTS   The thread is al&ready on the
**                         notification list for the specified
**                         procedure.
**   CS_FAIL               The attempt to add the thread to the 
**                         notification failed due to other
**                         errors.
*/
CS_INT      ex_srv_regwatch(sproc, procedure_name)
SRV_PROC    *sproc;
CS_CHAR     *procedure_name;
{
      CS_INT    info;

      if ( srv_regwatch(sproc, procedure_name, CS_NULLTERM, 
            SRV_NOTIFY_ALWAYS, &info) == CS_FAIL )
      {
            if ( (info == SRV_I_PNOTKNOWN)
            || (info == SRV_I_PNOTCLIENT)
            || (info == SRV_I_PNOTIFYEXISTS) )
            {
                return(info);
           }
           else
           {
                return((CS_INT)CS_FAIL);
           }
      }

      return((CS_INT)CS_SUCCEED);
}

Usage

See also

srv_regnowatch, srv_regwatchlist