Read a text or image datastream from a client, in chunks.
CS_RETCODE srv_get_text(spp, bp, buflen, outlenp)
SRV_PROC *spp; CS_BYTE *bp; CS_INT buflen; CS_INT *outlenp;
A pointer to an internal thread control structure.
A pointer to a buffer where the data from the client is placed.
The size of the *bp pointer. This indicates how many bytes are transferred in each chunk.
The number of the bytes read into the *bp buffer is returned here.
Returns |
To indicate |
---|---|
CS_SUCCEED |
The call to srv_get_text ran successfully. |
CS_FAIL |
The routine failed. |
CS_END_DATA |
Open Server read in the entire text or image data stream. |
#include <ospublic.h>
#include <stdio.h>
/*
** Local Prototype
*/
CS_RETCODE ex_srv_get_text PROTOTYPE((
SRV_PROC *spp,
CS_INT *outlenp,
CS_BYTE *bbuf
));
/*
** EX_SRV_GET_TEXT
**
** Example routine to read chunks of text or image datastream
** from a client into a buffer and then write it to a disk
** file.
**
** Arguments:
**
** spp Pointer to thread control structure.
** outlenp Number of bytes read and written.
** bbuf Pointer to very large buffer for text.
**
** Returns
**
** CS_SUCCEED The data was successfully read.
** CS_FAIL An error was detected.
**
*/
#define BUFSIZE 256
#define FPUTS(a,b) fputs(a,b)
CS_RETCODE ex_srv_get_text(spp,outlenp,bbuf)
SRV_PROC *spp;
CS_INT *outlenp;
CS_BYTE *bbuf;
{
CS_INT llen; /* Local length. */
CS_INT lout; /* Local read count. */
CS_RETCODE lret; /* Local return code. */
CS_BYTE *lbufp; /* Local pointer into bbuf. */
/* Check arguments. */
if(bbuf == (CS_VOID *)0)
return(CS_FAIL);
if(spp == (SRV_PROC *)0)
return(CS_FAIL);
llen = BUFSIZE;
lbufp = bbuf;
/*
** Loop around getting data and copy it to bbuf.
*/
while(lret != CS_END_DATA)
{
(CS_VOID)srv_bzero(lbufp,BUFSIZE);
lout = 0;
lret = srv_get_text(spp, lbufp, llen, &lout);
if(lret == CS_FAIL)
break;
*outlenp += lout;
lbufp += lout;
}
if(lret == CS_END_DATA)
return(CS_SUCCEED);
else
return(lret);
}
srv_get_text is used to read bulk data from a client. The bulk data can be of type text or image.
srv_get_text must be called until all of the bulk data has been read from a client. It returns CS_END_DATA when the whole data stream has been read in.
srv_get_text can only be called from inside the SRV_BULK event handler.
A column read with srv_get_text must be of type text or image.
An Open Server application must call srv_text_info prior to the first call to srv_get_text for the data stream. The application then calls srv_get_text to retrieve a chunk. srv_get_text is called as many times as are necessary to read in the whole column.
Open Server treats text and image data streams except that it converts only text data before sending it to the Open Server application. The only conversion by Open Server performs is character set translation.
srv_bind, srv_desc&fmt, srv_send_text, srv_text_info, srv_thread_props, srv_xferdata, “International support”, “Text and image”