rtxStream.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00028 #ifndef _RTXSTREAM_H_
00029 #define _RTXSTREAM_H_
00030
00031 #include "rtxsrc/rtxContext.h"
00032
00033 #ifdef __cplusplus
00034 extern "C" {
00035 #endif
00036
00056 struct OSRTSTREAM;
00057
00063 typedef long (*OSRTStreamReadProc)
00064 (struct OSRTSTREAM* pStream, OSOCTET* pbuffer, size_t bufSize);
00065
00071 typedef long (*OSRTStreamBlockingReadProc)
00072 (struct OSRTSTREAM* pStream, OSOCTET* pbuffer, size_t toReadBytes);
00073
00079 typedef long (*OSRTStreamWriteProc)(struct OSRTSTREAM* pStream,
00080 const OSOCTET* data, size_t numocts);
00081
00087 typedef int (*OSRTStreamFlushProc)(struct OSRTSTREAM* pStream);
00088
00094 typedef int (*OSRTStreamCloseProc)(struct OSRTSTREAM* pStream);
00095
00101 typedef int (*OSRTStreamSkipProc)
00102 (struct OSRTSTREAM* pStream, size_t skipBytes);
00103
00109 typedef int (*OSRTStreamMarkProc)
00110 (struct OSRTSTREAM* pStream, size_t readAheadLimit);
00111
00117 typedef int (*OSRTStreamResetProc) (struct OSRTSTREAM* pStream);
00118
00119 #define OSRTSTRMF_INPUT 0x0001
00120 #define OSRTSTRMF_OUTPUT 0x0002
00121 #define OSRTSTRMF_BUFFERED 0x8000
00122 #define OSRTSTRMF_UNBUFFERED 0x4000
00123 #define OSRTSTRMF_POSMARKED 0x2000
00124
00125 #define OSRTSTRMF_BUF_INPUT (OSRTSTRMF_INPUT|OSRTSTRMF_BUFFERED)
00126 #define OSRTSTRMF_BUF_OUTPUT (OSRTSTRMF_OUTPUT|OSRTSTRMF_BUFFERED)
00127
00128
00129 #define OSRTSTRMID_FILE 1
00130 #define OSRTSTRMID_SOCKET 2
00131 #define OSRTSTRMID_MEMORY 3
00132 #define OSRTSTRMID_BUFFERED 4
00133 #define OSRTSTRMID_DIRECTBUF 5
00134 #define OSRTSTRMID_USER 1000
00135
00136 #define OSRTSTRM_K_BUFSIZE 1024
00137
00138 #define OSRTSTRM_K_INVALIDMARK ((size_t)-1)
00139
00140 #define OSRTSTREAM_BYTEINDEX(pctxt) \
00141 (((pctxt)->pStream->id == OSRTSTRMID_DIRECTBUF) ? \
00142 ((pctxt)->pStream->bytesProcessed + (pctxt)->buffer.byteIndex) : \
00143 ((pctxt)->pStream->ioBytes))
00144
00145 #define OSRTSTREAM_ID(pctxt) ((pctxt)->pStream->id)
00146 #define OSRTSTREAM_FLAGS(pctxt) ((pctxt)->pStream->flags)
00147
00153 typedef struct OSRTSTREAM {
00154 OSRTStreamReadProc read;
00155 OSRTStreamBlockingReadProc blockingRead;
00156 OSRTStreamWriteProc write;
00157 OSRTStreamFlushProc flush;
00158 OSRTStreamCloseProc close;
00159 OSRTStreamSkipProc skip;
00160 OSRTStreamMarkProc mark;
00161 OSRTStreamResetProc reset;
00162
00163 void* extra;
00164
00165 size_t bufsize;
00166 size_t readAheadLimit;
00167 size_t bytesProcessed;
00168 size_t markedBytesProcessed;
00169 size_t ioBytes;
00170 size_t nextMarkOffset;
00171
00172 OSUINT32 id;
00173
00174
00175
00176
00177 OSUINT16 flags;
00178 } OSRTSTREAM;
00179
00189 EXTERNRTX int rtxStreamClose (OSCTXT* pctxt);
00190
00201 EXTERNRTX int rtxStreamFlush (OSCTXT* pctxt);
00202
00212 EXTERNRTX int rtxStreamInit (OSCTXT* pctxt);
00213
00230 EXTERNRTX long rtxStreamRead
00231 (OSCTXT* pctxt, OSOCTET* pbuffer, size_t bufSize);
00232
00249 EXTERNRTX long rtxStreamBlockingRead
00250 (OSCTXT* pctxt, OSOCTET* pbuffer, size_t readBytes);
00251
00263 EXTERNRTX int rtxStreamSkip (OSCTXT* pctxt, size_t skipBytes);
00264
00277 EXTERNRTX long rtxStreamWrite
00278 (OSCTXT* pctxt, const OSOCTET* data, size_t numocts);
00279
00294 EXTERNRTX int rtxStreamGetIOBytes (OSCTXT* pctxt, size_t* pPos);
00295
00310 EXTERNRTX int rtxStreamMark (OSCTXT* pctxt, size_t readAheadLimit);
00311
00321 EXTERNRTX int rtxStreamReset (OSCTXT* pctxt);
00322
00333 EXTERNRTX OSBOOL rtxStreamMarkSupported (OSCTXT* pctxt);
00334
00343 EXTERNRTX OSBOOL rtxStreamIsOpened (OSCTXT* pctxt);
00344
00353 EXTERNRTX OSBOOL rtxStreamIsReadable (OSCTXT* pctxt);
00354
00363 EXTERNRTX OSBOOL rtxStreamIsWritable (OSCTXT* pctxt);
00364
00374 EXTERNRTX int rtxStreamRelease (OSCTXT* pctxt);
00375
00378 #ifdef __cplusplus
00379 }
00380 #endif
00381
00382 #endif
00383