Begin executing a registered procedure.
CS_RETCODE srv_reginit(spp, procnamep, namelen, options)
SRV_PROC *spp; CS_CHAR *procnamep; CS_INT namelen; unsigned short options;
A pointer to an internal thread control structure.
A pointer to the name of the registered procedure.
The length of the procedure name. If the name is null terminated, namelen can be CS_NULLTERM.
A flag that determines which threads to notify. Table 3-96 describes the legal values for options:
Value |
Description |
---|---|
SRV_M_PNOTIFYALL |
Notify all waiting threads in the notification list. |
SRV_M_PNOTIFYNEXT |
Notify only the thread that has been waiting the longest. |
Returns |
To indicate |
---|---|
CS_SUCCEED |
The routine completed successfully. |
CS_FAIL |
The routine failed. |
#include <ospublic.h>
/*
** Local Prototype.
*/
CS_RETCODE ex_srv_reginit PROTOTYPE((
SRV_PROC *sp,
CS_CHAR *pname,
CS_INT nlen
));
/*
** EX_SRV_REGINIT
**
** This routine demonstrates how to use srv_reginit to
** initiate the execution of a registered procedure.
**
** Arguments:
** sp A pointer to an internal thread control
structure.
** pname The name of the procedure to execute.
** nlen The length of the procedure name.
** Returns
**
** CS_SUCCEED If the registered procedure began execution.
** CS_FAIL If an error was detected.
**
*/
CS_RETCODE ex_srv_reginit(sp, pname, nlen)
SRV_PROC *sp;
CS_CHAR *pname;
CS_INT nlen;
{
/*
** Call srv_reginit to initiate the execution of this
** registered procedure; ask that all threads waiting for
** notification of this event be notified.
*/
if( srv_reginit(sp, pname, nlen, SRV_M_PNOTIFYALL) ==
CS_FAIL )
{
/*
** An error was al&ready raised.
*/
return CS_FAIL;
}
/*
** All done.
*/
return CS_SUCCEED;
}
srv_reginit is the first step in the process of executing a registered procedure.
The procedure’s parameters are defined with srv_regparam after srv_reginit has been called.
Call srv_regexec to execute the registered procedure.
If the procedure does not exist, the error is detected and reported by srv_regexec.
When a registered procedure is executed, Open Server notifies the threads in the procedure’s notification list. The options parameter specifies whether notifications are sent to all threads in the list, or just the one that has been waiting the longest.
An Open Server application can nest registered procedures up to a maximum of 16 levels.