srv_props

Description

Define and retrieve Open Server properties.

Syntax

CS_RETCODE srv_props(cp, cmd, property, bufp, buflen,
                 outlenp)
CS_CONTEXT       *cp;
CS_INT           cmd;
CS_INT           property;
CS_VOID          *bufp;
CS_INT           buflen;
CS_INT           *outlenp;

Parameters

scp

A pointer to a CS_CONTEXT structure previously allocated using cs_ctx_alloc.

cmd

The action to take. Table 3-81 summarizes the legal values for cmd:

Table 3-81: Values for cmd (srv_props)

Value

Meaning

CS_SET

The Open Server application is setting the property. In this case, bufp should contain the value the property is to be set to, and buflen should specify the size, in bytes, of that value.

CS_GET

The Open Server application is retrieving the property. In this case, bufp should point to the buffer where the property value is placed, and buflen should be the size, in bytes, of the buffer.

CS_CLEAR

The Open Server application is resetting the property to its default value. In this case, bufp, buflen, and outlenp are ignored.

property

The property being set, retrieved or cleared. See below for a list of this argument’s legal values.

bufp

A pointer to the Open Server application data buffer where property value information is placed (CS_SET) or property value information is retrieved (CS_GET).

buflen

The length, in bytes, of the buffer.

outlenp

A pointer to a CS_INT variable, which Open Server will set to the size, in bytes, of the property value retrieved. This argument is only used when cmd is CS_GET, and is optional.

Returns

Table 3-82: Return values (srv_props)

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_set_propPROTOTYPE((
CS_CONTEXT *cp,
CS_INT     property,
CS_VOID    *bufp,
CS_INT     buflen
));
/*
** EX_SRV_SET_PROP
**
**    Example routine to set a property using srv_props.
**
** Arguments:
**
**    *cp       Pointer to a CS_CONTEXT structure previously
**              allocated by cs_ctx_alloc.
**    property  The property being set.
**    *bufp     Pointer to the value the property is to be
**              set to.
**    buflen    The length of the value.
** 
** Returns
**
**   CS_SUCCEED   Arguments were valid and srv_props was called.
**   CS_FAIL      An error was detected.
**
*/
CS_RETCODE      ex_srv_set_prop(cp, property, bufp, buflen)
CS_CONTEXT      *cp;
CS_INT          property;
CS_VOID         *bufp;
CS_INT          buflen;
{
      /* Check arguments. */
      if(cp == (CS_CONTEXT *)NULL) 
      {
            return(CS_FAIL);
      }
      if(buflen < 1)
            return(CS_FAIL);                             return(srv_props(cp,(CS_INT)CS_SET,property,bufp,buflen,
  (CS_INT *)0));
}

Usage

See also

srv_init, srv_thread_props, srv_spawn, “Properties”