srv_regparam

Description

Describe a parameter for a registered procedure being defined, or supply data for the execution of a registered procedure.

Syntax

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;

Parameters

spp

A pointer to an internal thread control structure.

param_namep

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.

namelen

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

type

The datatype of the parameter. See “Types” for a list of Open Server datatypes.

datalen

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.

datap

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

Table 3-102:  Return values (srv_regparam)

Returns

To indicate

CS_SUCCEED

The routine completed successfully.

CS_FAIL

The routine failed.

Examples

Example 1

#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 *)&param);

      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 *)&param);
      
      return (result);
}

Usage

See also

srv_regcreate, srv_regdefine, srv_reginit, srv_regexec, “Types”