Add a client thread to the notification list for a specified procedure.
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;
A pointer to an internal thread control structure.
The name of the procedure.
The length of the procedure name. If the procedure name is null terminated, namelen can be CS_NULLTERM.
A flag that specifies whether this is a one-time notification request, or a permanent request. The following table describes the legal values for options:
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. |
The following table describes the possible values returned in *infop if srv_regwatch returns CS_FAIL:
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 |
To indicate |
---|---|
CS_SUCCEED |
The routine completed successfully. |
CS_FAIL |
The routine failed. |
#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);
}
srv_regwatch adds a thread to the list of threads to notify when the specified procedure executes.
The options flag specifies whether the thread is notified every time the procedure executes or just once—the next time the procedure executes.
Use srv_regnowatch to cancel a notification request.