srv_options

Description

Send option information to a client or receive option information from a client.

Syntax

CS_RETCODE srv_options(spp, cmd, optcmdp, optionp,
    bufp, bufsize, outlenp)
SRV_PROC    *spp;
CS_INT           cmd;
CS_INT           *optcmdp;
CS_INT           *optionp;
CS_CHAR       *bufp;
CS_INT           bufsize;
CS_INT          *outlenp;

Parameters

spp

A pointer to an internal thread control structure.

cmd

Indicates whether the application is calling srv_options to send or receive option information. Table 3-74 describes the legal values for cmd:

Table 3-74: Values for cmd (srv_options)

Value

Description

CS_SET

The Open Server application is sending an option command to a client.

CS_GET

The Open Server application is receiving an option command from a client.

optcmdp

A pointer either to the program variable that will contain a client’s option command (CS_GET) or to the program variable that contains the Open Server application’s option command (CS_SET). Table 3-75 summarizes the legal values for *optcmdp:

Table 3-75: Values for optcmdp (srv_options)

Value

Description

Cmd

SRV_SETOPTION

The client is requesting that the option be set. The value associated with optionp is returned in *bufp. Open Server will set bufsize to the size, in bytes, of the data returned. If *bufp is not large enough to hold the data, the function will return CS_FAIL, the actual size of the option value, in bytes, is returned in *outlenp, and the values of optionp and bufp will remain undefined.

CS_GET

SRV_CLEAROPTION

The client is requesting that optionp be set to its default value. The bufp and optionp values will remain undefined.

CS_GET

SRV_GETOPTION

A client is requesting information on the current value in *optionp. The bufp and optionp values will remain undefined.

CS_GET

SRV_SENDOPTION

The application is sending the current option value to the client in response to a SRV_GETOPTION command. bufp points to the argument associated with the option, and bufsize holds the size, in bytes, of the data in *bufp.

CS_SET

optionp

A pointer either to the client’s requested option (CS_GET) or to the option with which the Open Server application is responding (CS_SET).

bufp

A pointer to a buffer that will contain either the value associated with the option (CS_GET) or the value of the option to be sent to the requestor (CS_SET). The *optionp contains the option in question and *bufp contains its value (on a CS_SET). For a complete list of options and their legal values, see below.

bufsize

The length of the *bufp buffer. When sending an option that takes a character string option value, if the value in bufp is null terminated, pass bufsize as CS_NULLTERM.

outlenp

A pointer to a program variable which is set to the size, in bytes, of the option value returned in *bufp. This parameter is only used when cmd is set to CS_GET, and is optional.

Returns

Table 3-76: Return values (srv_options)

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_options PROTOTYPE((
SRV_PROC      *spp,
CS_INT        *rowcount
));

/* 
** EX_SRV_OPTIONS
**
**    Example routine to recieve option information for the
 **    maximum number of regular rows to return (CS_OPT_ROWCOUNT)
 **    from a client.
**
** Arguments:
**   spp       A pointer to an internal thread control structure.
**   rowcount  Return pointer for the number of rows to return.
**
** Returns:
**
**    CS_SUCCEED   Successfully retrieved option.
**    CS_FAIL      An error was detected.
*/
CS_RETCODE       ex_srv_options(spp, rowcount)
SRV_PROC         *spp;
CS_INT           *rowcount;
{
    CS_INT       optcmdp;    /* The client’s option command. */
    CS_INT       optionp;    /* The client’s option request. */

    /* Initialization. */
    optcmdp = SRV_GETOPTION;
    optionp = CS_OPT_ROWCOUNT;

    /*
    ** Get the maximum number of rows to return.
    */
    if (srv_options(spp, CS_GET, &optcmdp, &optionp, (CS_VOID
         *)rowcount, CS_SIZEOF(CS_INT), (CS_INT *)NULL) !=
         CS_SUCCEED)
    {
        return(CS_FAIL);
    }
    return(CS_SUCCEED);
}

Usage

See also

srv_senddone, “Options”