Send a text or image data stream to a client, in chunks.
CS_RETCODE srv_send_text(spp, bp, buflen)
SRV_PROC *spp; CS_BYTE *bp; CS_INT buflen;
A pointer to an internal thread control structure.
A pointer to a buffer containing the data to send to the client. This determines the size of a section.
The size of the *bp buffer.
Returns |
To indicate |
---|---|
CS_SUCCEED |
The routine completed successfully. |
CS_FAIL |
The routine failed. |
#include <ctpublic.h>
#include <ospublic.h>
/*
** Local Prototype.
*/
CS_RETCODE ex_srv_send_text PROTOTYPE((
SRV_PROC *spp,
CS_COMMAND *cmd
));
/*
** EX_SRV_SEND_TEXT
**
** Example routine to demonstrate how to write text to a client
** using srv_send_text. This routine will send all the text
** read from a server back to the client.
**
** Arguments:
** spp A pointer to an internal thread control structure.
** cmd The command handle for the command that is returning
** text data.
**
** Returns:
** CS_SUCCEED Result set sent successfully to client.
** CS_FAIL An error was detected.
*/
CS_RETCODE ex_srv_send_text(spp, cmd)
SRV_PROC *spp;
CS_COMMAND *cmd;
{
CS_BOOL ok; /* Error control flag. */
CS_INT ret; /* ct_fetch return value. */
CS_INT len_read; /* Amount of data read. */
CS_BYTE data[1024]; /* Buffer for text data. */
/* Initialization. */
ok = CS_TRUE;
/* Read the text from the server. */
while ((ret = ct_get_data(cmd, 1, data, CS_SIZEOF(data),
&len_read))
== CS_SUCCEED)
{
/* Write text to client a chunck at a time */
if (srv_send_text(spp, data, len_read) != CS_SUCCEED)
{
ok = CS_FALSE;
break;
}
}
switch(ret)
{
case CS_SUCCEED: /* The routine completed successfully. */
case CS_END_ITEM: /* Reached the end of this item’s value. */
case CS_END_DATA: /* Reached the end of this item’s value. */
break;
case CS_FAIL: /* The routine failed. */
case CS_CANCELED: /* The get data operation was cancelled. */
case CS_PENDING: /* Asynchronous network I/O is in effect. */
case CS_BUSY: /* An asynchronous operation is pending. */
default:
ok = CS_FALSE;
}
return (ok ? CS_SUCCEED : CS_FAIL);
}
srv_send_text is used to send a single column of text or image data to a client.
The Open Server application must always call srv_text_info prior to the first call to srv_send_text for the data stream, to set the total length of the data to be sent. The application then calls srv_send_text to send a chunk. srv_send_text is called as many times as there are chunks.
The item being sent to the client must have previously been described using srv_descfmt.
An Open Server application can also write text and image data to a client using srv_bind and srv_xferdata. srv_send_text allows the application to send the data in chunks, whereas the standard srv_bind/srv_xferdata method requires that all the data in the column be sent at once.
A column sent with srv_send_text must be of type text or image.
Open Server treats text and image data streams identically except for character set conversion, which is only performed on text data.
WARNING! An Open Server application can only use srv_send_text to send a row if that row contains a single column and that column contains text or image data.
srv_bind, srv_descfmt, srv_get_text, srv_text_info, srv_xferdata, “Text and image”