ASN1C C/C++ Common Runtime  ASN1C v7.6.x
rtxStream.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2003-2022 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 
77 typedef long (*OSRTStreamReadProc)
78  (struct OSRTSTREAM* pStream, OSOCTET* pbuffer, size_t nocts);
79 
84 
90 typedef long (*OSRTStreamWriteProc)(struct OSRTSTREAM* pStream,
91  const OSOCTET* data, size_t numocts);
92 
98 typedef int (*OSRTStreamFlushProc)(struct OSRTSTREAM* pStream);
99 
105 typedef int (*OSRTStreamCloseProc)(struct OSRTSTREAM* pStream);
106 
112 typedef int (*OSRTStreamSkipProc)
113  (struct OSRTSTREAM* pStream, size_t skipBytes);
114 
120 typedef int (*OSRTStreamMarkProc)
121  (struct OSRTSTREAM* pStream, size_t readAheadLimit);
122 
128 typedef int (*OSRTStreamResetProc) (struct OSRTSTREAM* pStream);
129 
135 typedef int (*OSRTStreamGetPosProc)
136  (struct OSRTSTREAM* pStream, size_t* ppos);
137 
143 typedef int (*OSRTStreamSetPosProc)
144  (struct OSRTSTREAM* pStream, size_t pos);
145 
146 #define OSRTSTRMF_INPUT 0x0001
147 #define OSRTSTRMF_OUTPUT 0x0002
148 #define OSRTSTRMF_BUFFERED 0x8000 /* direct-buffer stream */
149 #define OSRTSTRMF_UNBUFFERED 0x4000 /* force unbuffered stream */
150 #define OSRTSTRMF_POSMARKED 0x2000 /* stream has marked position */
151 #define OSRTSTRMF_FIXINMEM 0x1000 /* disable flushing */
152 #define OSRTSTRMF_HEXTEXT 0x0800 /* do hex text / binary conversion */
153 
154 #define OSRTSTRMF_BUF_INPUT (OSRTSTRMF_INPUT|OSRTSTRMF_BUFFERED)
155 #define OSRTSTRMF_BUF_OUTPUT (OSRTSTRMF_OUTPUT|OSRTSTRMF_BUFFERED)
156 
157 
158 #define OSRTSTRMID_FILE 1
159 #define OSRTSTRMID_SOCKET 2
160 #define OSRTSTRMID_MEMORY 3
161 #define OSRTSTRMID_BUFFERED 4
162 #define OSRTSTRMID_DIRECTBUF 5
163 #define OSRTSTRMID_CTXTBUF 6
164 #define OSRTSTRMID_ZLIB 7
165 #define OSRTSTRMID_USER 1000
166 
167 #define OSRTSTRM_K_BUFSIZE 1024
168 
169 #define OSRTSTRM_K_INVALIDMARK ((size_t)-1)
170 
171 #define OSRTSTREAM_BYTEINDEX(pctxt) \
172 (((pctxt)->pStream->flags & OSRTSTRMF_BUFFERED) ? \
173  ((pctxt)->pStream->bytesProcessed + (pctxt)->buffer.byteIndex) : \
174  ((pctxt)->pStream->bytesProcessed /* was ioBytes */ ))
175 
176 #define OSRTSTREAM_ID(pctxt) ((pctxt)->pStream->id)
177 #define OSRTSTREAM_FLAGS(pctxt) ((pctxt)->pStream->flags)
178 
184 typedef struct OSRTSTREAM {
195  void* extra;
196  size_t bufsize;
200  size_t readAheadLimit;
202  size_t bytesProcessed;
206  size_t ioBytes;
208  size_t nextMarkOffset;
210  size_t segsize;
211  OSUINT32 id;
218 
219  OSUINT16 flags;
220 } OSRTSTREAM;
221 
231 EXTERNRT int rtxStreamClose (OSCTXT* pctxt);
232 
243 EXTERNRT int rtxStreamFlush (OSCTXT* pctxt);
244 
266 EXTERNRT int rtxStreamLoadInputBuffer(OSCTXT* pctxt, OSSIZE nbytes);
267 
268 
278 EXTERNRT int rtxStreamInit (OSCTXT* pctxt);
279 
289 EXTERNRT int rtxStreamInitCtxtBuf (OSCTXT* pctxt);
290 
302 EXTERNRT int rtxStreamRemoveCtxtBuf (OSCTXT* pctxt);
303 
318 EXTERNRT long rtxStreamRead
319  (OSCTXT* pctxt, OSOCTET* pbuffer, size_t nocts);
320 
322 #define rtxStreamBlockingRead rtxStreamRead
323 
324 EXTERNRT long rtxStreamReadDirect
325 (OSCTXT* pctxt, OSOCTET* pbuffer, OSSIZE bufSize);
326 
327 
342 EXTERNRT int rtxStreamSkip (OSCTXT* pctxt, size_t skipBytes);
343 
356 EXTERNRT long rtxStreamWrite
357  (OSCTXT* pctxt, const OSOCTET* data, size_t numocts);
358 
373 EXTERNRT int rtxStreamGetIOBytes (OSCTXT* pctxt, size_t* pPos);
374 
389 EXTERNRT int rtxStreamMark (OSCTXT* pctxt, size_t readAheadLimit);
390 
400 EXTERNRT int rtxStreamReset (OSCTXT* pctxt);
401 
412 EXTERNRT OSBOOL rtxStreamMarkSupported (OSCTXT* pctxt);
413 
422 EXTERNRT OSBOOL rtxStreamIsOpened (OSCTXT* pctxt);
423 
432 EXTERNRT OSBOOL rtxStreamIsReadable (OSCTXT* pctxt);
433 
442 EXTERNRT OSBOOL rtxStreamIsWritable (OSCTXT* pctxt);
443 
453 EXTERNRT int rtxStreamRelease (OSCTXT* pctxt);
454 
465 EXTERNRT void rtxStreamSetCapture (OSCTXT* pctxt, OSRTMEMBUF* pmembuf);
466 
476 EXTERNRT OSRTMEMBUF* rtxStreamGetCapture (OSCTXT* pctxt);
477 
486 EXTERNRT int rtxStreamGetPos (OSCTXT* pctxt, size_t* ppos);
487 
496 EXTERNRT int rtxStreamSetPos (OSCTXT* pctxt, size_t pos);
497 
500 #ifdef __cplusplus
501 }
502 #endif
503 
504 #endif /* _NO_STREAM */
505 #endif /* _RTXSTREAM_H_ */
506 
OSRTStreamGetPosProc getPos
Definition: rtxStream.h:192
int rtxStreamLoadInputBuffer(OSCTXT *pctxt, OSSIZE nbytes)
int(* OSRTStreamSkipProc)(struct OSRTSTREAM *pStream, size_t skipBytes)
Definition: rtxStream.h:113
size_t markedBytesProcessed
Definition: rtxStream.h:204
int rtxStreamSkip(OSCTXT *pctxt, size_t skipBytes)
size_t readAheadLimit
Definition: rtxStream.h:200
int rtxStreamGetPos(OSCTXT *pctxt, size_t *ppos)
int rtxStreamInit(OSCTXT *pctxt)
OSRTStreamReadProc OSRTStreamBlockingReadProc
Definition: rtxStream.h:83
OSUINT16 flags
Definition: rtxStream.h:219
int(* OSRTStreamCloseProc)(struct OSRTSTREAM *pStream)
Definition: rtxStream.h:105
size_t segsize
Definition: rtxStream.h:210
long(* OSRTStreamReadProc)(struct OSRTSTREAM *pStream, OSOCTET *pbuffer, size_t nocts)
Definition: rtxStream.h:78
OSUINT32 id
Definition: rtxStream.h:211
OSRTStreamWriteProc write
Definition: rtxStream.h:186
size_t nextMarkOffset
Definition: rtxStream.h:208
int rtxStreamReset(OSCTXT *pctxt)
OSRTMEMBUF * pCaptureBuf
Definition: rtxStream.h:217
long rtxStreamWrite(OSCTXT *pctxt, const OSOCTET *data, size_t numocts)
int(* OSRTStreamSetPosProc)(struct OSRTSTREAM *pStream, size_t pos)
Definition: rtxStream.h:144
int rtxStreamSetPos(OSCTXT *pctxt, size_t pos)
size_t bytesProcessed
Definition: rtxStream.h:202
OSRTStreamSetPosProc setPos
Definition: rtxStream.h:193
int(* OSRTStreamFlushProc)(struct OSRTSTREAM *pStream)
Definition: rtxStream.h:98
int rtxStreamFlush(OSCTXT *pctxt)
long rtxStreamRead(OSCTXT *pctxt, OSOCTET *pbuffer, size_t nocts)
long(* OSRTStreamWriteProc)(struct OSRTSTREAM *pStream, const OSOCTET *data, size_t numocts)
Definition: rtxStream.h:90
OSRTStreamSkipProc skip
Definition: rtxStream.h:189
int(* OSRTStreamResetProc)(struct OSRTSTREAM *pStream)
Definition: rtxStream.h:128
int rtxStreamRemoveCtxtBuf(OSCTXT *pctxt)
int(* OSRTStreamMarkProc)(struct OSRTSTREAM *pStream, size_t readAheadLimit)
Definition: rtxStream.h:121
int rtxStreamClose(OSCTXT *pctxt)
size_t bufsize
Definition: rtxStream.h:196
size_t ioBytes
Definition: rtxStream.h:206
OSRTStreamMarkProc mark
Definition: rtxStream.h:190
OSBOOL rtxStreamIsWritable(OSCTXT *pctxt)
OSBOOL rtxStreamIsReadable(OSCTXT *pctxt)
struct OSRTSTREAM OSRTSTREAM
Definition: rtxMemBuf.h:48
OSRTStreamReadProc read
Definition: rtxStream.h:185
OSRTStreamCloseProc close
Definition: rtxStream.h:188
OSRTStreamResetProc reset
Definition: rtxStream.h:191
int rtxStreamMark(OSCTXT *pctxt, size_t readAheadLimit)
Definition: rtxContext.h:198
OSRTStreamFlushProc flush
Definition: rtxStream.h:187
Definition: rtxStream.h:184
int(* OSRTStreamGetPosProc)(struct OSRTSTREAM *pStream, size_t *ppos)
Definition: rtxStream.h:136
OSRTMEMBUF * rtxStreamGetCapture(OSCTXT *pctxt)
int rtxStreamGetIOBytes(OSCTXT *pctxt, size_t *pPos)
OSBOOL rtxStreamMarkSupported(OSCTXT *pctxt)
void rtxStreamSetCapture(OSCTXT *pctxt, OSRTMEMBUF *pmembuf)
int rtxStreamInitCtxtBuf(OSCTXT *pctxt)
int rtxStreamRelease(OSCTXT *pctxt)
void * extra
Definition: rtxStream.h:195
OSBOOL rtxStreamIsOpened(OSCTXT *pctxt)