XBinder  Version 2.6.x
rtxStream.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2003-2018 Objective Systems, Inc.
3  *
4  * This software is furnished under a license and may be used and copied
5  * only in accordance with the terms of such license and with the
6  * inclusion of the above copyright notice. This software or any other
7  * copies thereof may not be provided or otherwise made available to any
8  * other person. No title to and ownership of the software is hereby
9  * transferred.
10  *
11  * The information in this software is subject to change without notice
12  * and should not be construed as a commitment by Objective Systems, Inc.
13  *
14  * PROPRIETARY NOTICE
15  *
16  * This software is an unpublished work subject to a confidentiality agreement
17  * and is protected by copyright and trade secret law. Unauthorized copying,
18  * redistribution or other use of this work is prohibited.
19  *
20  * The above notice of copyright on this source code product does not indicate
21  * any actual or intended publication of such source code.
22  *
23  *****************************************************************************/
28 #ifndef _RTXSTREAM_H_
29 #define _RTXSTREAM_H_
30 
31 #ifndef _NO_STREAM
32 
33 #include "rtxsrc/rtxContext.h"
34 #include "rtxsrc/rtxMemBuf.h"
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
59 struct OSRTSTREAM;
60 
66 typedef long (*OSRTStreamReadProc)
67  (struct OSRTSTREAM* pStream, OSOCTET* pbuffer, size_t bufSize);
68 
74 typedef long (*OSRTStreamBlockingReadProc)
75  (struct OSRTSTREAM* pStream, OSOCTET* pbuffer, size_t toReadBytes);
76 
82 typedef long (*OSRTStreamWriteProc)(struct OSRTSTREAM* pStream,
83  const OSOCTET* data, size_t numocts);
84 
90 typedef int (*OSRTStreamFlushProc)(struct OSRTSTREAM* pStream);
91 
97 typedef int (*OSRTStreamCloseProc)(struct OSRTSTREAM* pStream);
98 
104 typedef int (*OSRTStreamSkipProc)
105  (struct OSRTSTREAM* pStream, size_t skipBytes);
106 
112 typedef int (*OSRTStreamMarkProc)
113  (struct OSRTSTREAM* pStream, size_t readAheadLimit);
114 
120 typedef int (*OSRTStreamResetProc) (struct OSRTSTREAM* pStream);
121 
127 typedef int (*OSRTStreamGetPosProc)
128  (struct OSRTSTREAM* pStream, size_t* ppos);
129 
135 typedef int (*OSRTStreamSetPosProc)
136  (struct OSRTSTREAM* pStream, size_t pos);
137 
138 #define OSRTSTRMF_INPUT 0x0001
139 #define OSRTSTRMF_OUTPUT 0x0002
140 #define OSRTSTRMF_BUFFERED 0x8000 /* direct-buffer stream */
141 #define OSRTSTRMF_UNBUFFERED 0x4000 /* force unbuffered stream */
142 #define OSRTSTRMF_POSMARKED 0x2000 /* stream has marked position */
143 #define OSRTSTRMF_FIXINMEM 0x1000 /* disable flushing */
144 #define OSRTSTRMF_HEXTEXT 0x0800 /* do hex text / binary conversion */
145 
146 #define OSRTSTRMF_BUF_INPUT (OSRTSTRMF_INPUT|OSRTSTRMF_BUFFERED)
147 #define OSRTSTRMF_BUF_OUTPUT (OSRTSTRMF_OUTPUT|OSRTSTRMF_BUFFERED)
148 
149 
150 #define OSRTSTRMID_FILE 1
151 #define OSRTSTRMID_SOCKET 2
152 #define OSRTSTRMID_MEMORY 3
153 #define OSRTSTRMID_BUFFERED 4
154 #define OSRTSTRMID_DIRECTBUF 5
155 #define OSRTSTRMID_CTXTBUF 6
156 #define OSRTSTRMID_ZLIB 7
157 #define OSRTSTRMID_USER 1000
158 
159 #define OSRTSTRM_K_BUFSIZE 1024
160 
161 #define OSRTSTRM_K_INVALIDMARK ((size_t)-1)
162 
163 #define OSRTSTREAM_BYTEINDEX(pctxt) \
164 (((pctxt)->pStream->flags & OSRTSTRMF_BUFFERED) ? \
165  ((pctxt)->pStream->bytesProcessed + (pctxt)->buffer.byteIndex) : \
166  ((pctxt)->pStream->bytesProcessed /* was ioBytes */ ))
167 
168 #define OSRTSTREAM_ID(pctxt) ((pctxt)->pStream->id)
169 #define OSRTSTREAM_FLAGS(pctxt) ((pctxt)->pStream->flags)
170 
176 typedef struct OSRTSTREAM {
189  void* extra;
190  size_t bufsize;
192  size_t readAheadLimit;
194  size_t bytesProcessed;
198  size_t ioBytes;
200  size_t nextMarkOffset;
202  size_t segsize;
203  OSUINT32 id;
209  OSRTMEMBUF* pCaptureBuf;
210 
211  OSUINT16 flags;
212 } OSRTSTREAM;
213 
223 EXTERNRT int rtxStreamClose (OSCTXT* pctxt);
224 
235 EXTERNRT int rtxStreamFlush (OSCTXT* pctxt);
236 
246 EXTERNRT int rtxStreamInit (OSCTXT* pctxt);
247 
257 EXTERNRT int rtxStreamInitCtxtBuf (OSCTXT* pctxt);
258 
270 EXTERNRT int rtxStreamRemoveCtxtBuf (OSCTXT* pctxt);
271 
288 EXTERNRT long rtxStreamRead
289  (OSCTXT* pctxt, OSOCTET* pbuffer, size_t bufSize);
290 
291 EXTERNRT long rtxStreamReadDirect
292 (OSCTXT* pctxt, OSOCTET* pbuffer, OSSIZE bufSize);
293 
310 EXTERNRT long rtxStreamBlockingRead
311  (OSCTXT* pctxt, OSOCTET* pbuffer, size_t readBytes);
312 
324 EXTERNRT int rtxStreamSkip (OSCTXT* pctxt, size_t skipBytes);
325 
338 EXTERNRT long rtxStreamWrite
339  (OSCTXT* pctxt, const OSOCTET* data, size_t numocts);
340 
355 EXTERNRT int rtxStreamGetIOBytes (OSCTXT* pctxt, size_t* pPos);
356 
371 EXTERNRT int rtxStreamMark (OSCTXT* pctxt, size_t readAheadLimit);
372 
382 EXTERNRT int rtxStreamReset (OSCTXT* pctxt);
383 
394 EXTERNRT OSBOOL rtxStreamMarkSupported (OSCTXT* pctxt);
395 
404 EXTERNRT OSBOOL rtxStreamIsOpened (OSCTXT* pctxt);
405 
414 EXTERNRT OSBOOL rtxStreamIsReadable (OSCTXT* pctxt);
415 
424 EXTERNRT OSBOOL rtxStreamIsWritable (OSCTXT* pctxt);
425 
435 EXTERNRT int rtxStreamRelease (OSCTXT* pctxt);
436 
447 EXTERNRT void rtxStreamSetCapture (OSCTXT* pctxt, OSRTMEMBUF* pmembuf);
448 
458 EXTERNRT OSRTMEMBUF* rtxStreamGetCapture (OSCTXT* pctxt);
459 
468 EXTERNRT int rtxStreamGetPos (OSCTXT* pctxt, size_t* ppos);
469 
478 EXTERNRT int rtxStreamSetPos (OSCTXT* pctxt, size_t pos);
479 
482 #ifdef __cplusplus
483 }
484 #endif
485 
486 #endif /* _NO_STREAM */
487 #endif /* _RTXSTREAM_H_ */
488 
EXTERNRT int rtxStreamGetPos(OSCTXT *pctxt, size_t *ppos)
Get the current position in input stream.
OSRTStreamGetPosProc getPos
pointer to getPos function
Definition: rtxStream.h:186
EXTERNRT long rtxStreamWrite(OSCTXT *pctxt, const OSOCTET *data, size_t numocts)
This function writes the specified amount of octets from the specified array to the output stream...
int(* OSRTStreamSkipProc)(struct OSRTSTREAM *pStream, size_t skipBytes)
Stream skip function pointer type.
Definition: rtxStream.h:105
size_t markedBytesProcessed
the marked number of bytes already processed
Definition: rtxStream.h:196
size_t readAheadLimit
read ahead limit (used by rtxStreamMark/rtxStreamReset
Definition: rtxStream.h:192
EXTERNRT int rtxStreamInit(OSCTXT *pctxt)
This function initializes a stream part of the context block.
EXTERNRT void rtxStreamSetCapture(OSCTXT *pctxt, OSRTMEMBUF *pmembuf)
This function sets a capture buffer for the stream.
EXTERNRT OSBOOL rtxStreamMarkSupported(OSCTXT *pctxt)
Tests if this input stream supports the mark and reset methods.
EXTERNRT OSBOOL rtxStreamIsOpened(OSCTXT *pctxt)
Tests if this stream opened (for reading or writing).
OSUINT16 flags
flags (see OSRTSTRMF_* macros
Definition: rtxStream.h:211
int(* OSRTStreamCloseProc)(struct OSRTSTREAM *pStream)
Stream close function pointer type.
Definition: rtxStream.h:97
EXTERNRT int rtxStreamGetIOBytes(OSCTXT *pctxt, size_t *pPos)
This function returns the number of processed octets.
size_t segsize
size of decoded segment
Definition: rtxStream.h:202
OSUINT32 id
id of stream (see OSRTSTRMID_* macros)
Definition: rtxStream.h:203
OSRTStreamWriteProc write
pointer to write function
Definition: rtxStream.h:180
EXTERNRT int rtxStreamSetPos(OSCTXT *pctxt, size_t pos)
Set the current position in input stream.
size_t nextMarkOffset
offset of next appropriate mark position
Definition: rtxStream.h:200
EXTERNRT long rtxStreamBlockingRead(OSCTXT *pctxt, OSOCTET *pbuffer, size_t readBytes)
This function reads up to 'bufsize' bytes of data from the input stream into an array of octets...
OSRTMEMBUF * pCaptureBuf
Buffer into which data read from stream can be captured for debugging purposes.
Definition: rtxStream.h:209
int(* OSRTStreamSetPosProc)(struct OSRTSTREAM *pStream, size_t pos)
Stream set position function pointer type.
Definition: rtxStream.h:136
size_t bytesProcessed
the number of bytes processed by the application program
Definition: rtxStream.h:194
EXTERNRT int rtxStreamInitCtxtBuf(OSCTXT *pctxt)
This function initializes a stream to use the context memory buffer for stream buffering.
OSRTStreamSetPosProc setPos
pointer to setPos function
Definition: rtxStream.h:187
int(* OSRTStreamFlushProc)(struct OSRTSTREAM *pStream)
Stream flush function pointer type.
Definition: rtxStream.h:90
Common run-time context definitions.
EXTERNRT int rtxStreamFlush(OSCTXT *pctxt)
This function flushes the output stream and forces any buffered output octets to be written out...
EXTERNRT OSBOOL rtxStreamIsWritable(OSCTXT *pctxt)
Tests if this stream opened for writing.
long(* OSRTStreamWriteProc)(struct OSRTSTREAM *pStream, const OSOCTET *data, size_t numocts)
Stream write function pointer type.
Definition: rtxStream.h:82
EXTERNRT OSRTMEMBUF * rtxStreamGetCapture(OSCTXT *pctxt)
This function returns the capture buffer currently assigned to the stream.
OSRTStreamSkipProc skip
pointer to skip function
Definition: rtxStream.h:183
EXTERNRT long rtxStreamRead(OSCTXT *pctxt, OSOCTET *pbuffer, size_t bufSize)
This function reads up to 'bufsize' bytes of data from the input stream into an array of octets...
EXTERNRT int rtxStreamClose(OSCTXT *pctxt)
This function closes the input or output stream and releases any system resources associated with the...
int(* OSRTStreamResetProc)(struct OSRTSTREAM *pStream)
Stream reset function pointer type.
Definition: rtxStream.h:120
long(* OSRTStreamReadProc)(struct OSRTSTREAM *pStream, OSOCTET *pbuffer, size_t bufSize)
Stream read function pointer type.
Definition: rtxStream.h:67
int(* OSRTStreamMarkProc)(struct OSRTSTREAM *pStream, size_t readAheadLimit)
Stream mark function pointer type.
Definition: rtxStream.h:113
EXTERNRT int rtxStreamSkip(OSCTXT *pctxt, size_t skipBytes)
This function skips over and discards the specified amount of data octets from this input stream...
size_t bufsize
physical size of pctxt->buffer.data buffer
Definition: rtxStream.h:190
size_t ioBytes
the actual number of bytes read from or written to the stream
Definition: rtxStream.h:198
OSRTStreamMarkProc mark
pointer to mark function
Definition: rtxStream.h:184
EXTERNRT int rtxStreamRelease(OSCTXT *pctxt)
This function releases the stream's resources.
struct OSRTSTREAM OSRTSTREAM
The stream control block.
EXTERNRT OSBOOL rtxStreamIsReadable(OSCTXT *pctxt)
Tests if this stream opened for reading.
OSRTStreamReadProc read
pointer to read function
Definition: rtxStream.h:177
EXTERNRT int rtxStreamReset(OSCTXT *pctxt)
Repositions this stream to the position recorded by the last call to the rtxStreamMark function...
OSRTStreamCloseProc close
pointer to close function
Definition: rtxStream.h:182
OSRTStreamResetProc reset
pointer to reset function
Definition: rtxStream.h:185
Run-time context structure.
Definition: rtxContext.h:185
OSRTStreamFlushProc flush
pointer to flush function
Definition: rtxStream.h:181
The stream control block.
Definition: rtxStream.h:176
int(* OSRTStreamGetPosProc)(struct OSRTSTREAM *pStream, size_t *ppos)
Stream get position function pointer type.
Definition: rtxStream.h:128
long(* OSRTStreamBlockingReadProc)(struct OSRTSTREAM *pStream, OSOCTET *pbuffer, size_t toReadBytes)
Stream blockingRead function pointer type.
Definition: rtxStream.h:75
EXTERNRT int rtxStreamRemoveCtxtBuf(OSCTXT *pctxt)
This function removes the use of a context memory buffer from a stream.
OSRTStreamBlockingReadProc blockingRead
pointer to blockingRead function
Definition: rtxStream.h:179
EXTERNRT int rtxStreamMark(OSCTXT *pctxt, size_t readAheadLimit)
Marks the current position in this input stream.
void * extra
pointer to stream-specific data
Definition: rtxStream.h:189