srv_langcpy

Description

Copy a client’s language request into an application buffer.

Syntax

CS_INT srv_langcpy(spp, start, nbytes, bp)
SRV_PROC    *spp;
CS_INT           start;
CS_INT           nbytes;
CS_BYTE      *bp;

Parameters

spp

A pointer to an internal thread control structure.

start

The point at which to start copying characters from the request buffer. The first character in the request buffer is the 0’th character.

nbytes

The number of characters to copy. If nbytes is -1, srv_langcpy copies as many bytes as possible. It is legal to copy 0 bytes. If there are not nbytes characters available to copy, srv_langcpy copies as many as are in the request buffer.

bp

A CS_CHAR pointer to the programmer-supplied buffer into which to copy the bytes.

Returns

Table 3-58: Return values (srv_langcpy)

Returns

To indicate

An integer

The number of bytes copied.

-1

There is no current language request from this client.

Examples

Example 1

#include  <ospublic.h>

/*
** Local Prototype
*/
CS_RETCODE     ex_srv_langcpy PROTOTYPE((
SRV_PROC       *spp,
CS_CHAR        *buf,
CS_INT         size,
CS_INT         *outlen
));

/* 
** EX_SRV_LANGCPY
**
**    Example routine to illustrate the use of srv_langcpy to
 **    copy language commands sent by a client.
**
** Arguments:
**    spp      A pointer to internal thread control structure.
**    buf      A CS_CHAR pointer to buffer for language commands.
**    size     The size of the buffer; A CS_INT.
**    outlen   A pointer to CS_INT; the actual length of
                language query copied to buf is returned here. -1
 **             is returned in case of failure.
**
** Returns:
**
**    CS_SUCCEED   Language request was copied successfully.
**    CS_FAIL      An error was detected.
*/
CS_RETCODE   ex_srv_langcpy(spp, buf, size, outlen)
SRV_PROC     *spp;
CS_CHAR      *buf;
CS_INT       size;
CS_INT       *outlen;
{
   CS_INT        act_len; /* actual length of language request */

    /* Initialization.*/
    *outlen = (CS_INT)-1;

    /* Get the length of language request.*/
    if ((act_len = srv_langlen(spp)) == -1)
        return (CS_FAIL);

    /* Check to see whether we got a buffer of adequate size. */
    if (size < (act_len +1))
        return (CS_FAIL);

    /* Copy language commands.*/
    if (srv_langcpy(spp, (CS_INT)0, act_len, buf) <= 0)
        return (CS_FAIL);

    /* Set the actual length copied. */
    *outlen = act_len;

    return (CS_SUCCEED);
}

Usage

See also

srv_langlen