Copy a client’s language request into an application buffer.
CS_INT srv_langcpy(spp, start, nbytes, bp)
SRV_PROC *spp; CS_INT start; CS_INT nbytes; CS_BYTE *bp;
A pointer to an internal thread control structure.
The point at which to start copying characters from the request buffer. The first character in the request buffer is the 0’th character.
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.
A CS_CHAR pointer to the programmer-supplied buffer into which to copy the bytes.
Returns |
To indicate |
---|---|
An integer |
The number of bytes copied. |
-1 |
There is no current language request from this client. |
#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);
}
When a language request is received from the client, srv_langcpy can be used to copy a portion of the request buffer to a Open Server program variable. The copy placed in the destination buffer is null terminated.
srv_langcpy is also used to process language strings in cursor declare or update statements.
WARNING! srv_langcpy assumes that the destination buffer is large enough to handle nbytes + 1 bytes.
To set the total length of the language request buffer call srv_langlen.
The request buffer can contain any string of characters, including Transact-SQL statements. It’s up to the Open Server application to process the string.