Describe a parameter for a registered procedure being defined, or supply data for the execution of a registered procedure.
CS_RETCODE srv_regparam(spp, param_namep, namelen, type, datalen, datap)
SRV_PROC *spp; CS_CHAR *param_namep; CS_INT namelen; CS_INT type; CS_INT datalen; CS_BYTE *datap;
A pointer to an internal thread control structure.
A pointer to the name of the parameter. When registering the procedure, this parameter is mandatory. When invoking the procedure, this parameter can be null if the parameters are given in the same sequence they were defined when the procedure was registered.
The length of the parameter name. If the param_namep is null terminated, namelen can be CS_NULLTERM.
The datatype of the parameter. See “Types” for a list of Open Server datatypes.
The length of the parameter’s data. This parameter is ignored for fixed length datatypes. Set datalen to 0 to indicate a null data value. If a client fails to provide parameter values, the Open Server application can set the length of a default value here. To define a parameter with no default value, set datalen to SRV_NODEFAULT.
A pointer to the data. If registering the procedure, the value in *datap is the default value for future invocations of the procedure. If invoking the procedure, set datap to NULL to accept the default value.
Returns |
To indicate |
---|---|
CS_SUCCEED |
The routine completed successfully. |
CS_FAIL |
The routine failed. |
#include <ospublic.h>
/*
** Local prototype.
*/
CS_RETCODE ex_srv_regparam PROTOTYPE((
SRV_PROC *spp
));
/*
** Local defines.
*/
#define PARAMNAME (CS_CHAR *)”myparam” /* Parameter name. */
#define PARAMDEFAULT (CS_INT)100
/*
**The default value for the parameter.
*/
#define PARAMVAL (CS_INT)20 /* The value for this invocation. */
/*
** EX_SRV_REGPARAM
**
** Example routine to describe a parameter for a registered
** procedure.
**
** Arguments:
** spp A pointer to an internal thread control structure.
**
** Returns:
** CS_SUCCEED If we were able to describe the parameter.
** CS_FAIL If an error was detected.
*/
CS_RETCODE ex_srv_regparam(spp)
SRV_PROC *spp;
{
CS_RETCODE result;
CS_INT param;
/* Define the parameter with a default. */
param = PARAMDEFAULT;
result = srv_regparam(spp, PARAMNAME, CS_NULLTERM,
CS_INT_TYPE, sizeof(CS_INT), (CS_BYTE *)¶m);
if (result == CS_FAIL)
{
return (CS_FAIL);
}
/* Define the parameter with no default. */
result = srv_regparam(spp, PARAMNAME, CS_NULLTERM,
CS_INT_TYPE, SRV_NODEFAULT, (CS_BYTE *)NULL);
if (result == CS_FAIL)
{
return (CS_FAIL);
}
/* Give a non-default value for the parameter. */
param = PARAMVAL;
result = srv_regparam(spp, PARAMNAME, CS_NULLTERM,
CS_INT_TYPE, sizeof(CS_INT), (CS_BYTE *)¶m);
return (result);
}
srv_regparam specifies a procedure parameter for an invocation of, or the registration of, a procedure. A call to srv_reginit or srv_regdefine must precede srv_regparam.
A registered procedure can have a maximum of 1024 parameters.
When registering a procedure, use srv_regparam to define the properties of the procedure’s parameters and any default values.
When invoking a procedure, call srv_regparam for each parameter except those with acceptable default values.
To indicate a null data value, set datalen to 0.
To accept the default value for a parameter when executing a procedure, set datap to NULL.
It is not necessary to call srv_regparam for a parameter if a default value has been provided and that value is to be used for the execution of the procedure.
srv_regcreate, srv_regdefine, srv_reginit, srv_regexec, “Types”