00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00027 #ifndef _RTXSTREAM_H_
00028 #define _RTXSTREAM_H_
00029
00030 #include "rtxsrc/rtxCommon.h"
00031 #include "rtxsrc/rtxSocket.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
00124 #define OSRTSTRMF_BUF_INPUT (OSRTSTRMF_INPUT|OSRTSTRMF_BUFFERED)
00125 #define OSRTSTRMF_BUF_OUTPUT (OSRTSTRMF_OUTPUT|OSRTSTRMF_BUFFERED)
00126
00127
00128 #define OSRTSTRMID_FILE 1
00129 #define OSRTSTRMID_SOCKET 2
00130 #define OSRTSTRMID_MEMORY 3
00131 #define OSRTSTRMID_BUFFERED 4
00132 #define OSRTSTRMID_DIRECTBUF 5
00133 #define OSRTSTRMID_USER 1000
00134
00135 #define OSRTSTRM_K_BUFSIZE 1024
00136
00137 #define OSRTSTRM_K_INVALIDMARK ((size_t)-1)
00138
00139 #define OSRTSTREAM_BYTEINDEX(pctxt) \
00140 ((pctxt)->pStream->bytesProcessed + (pctxt)->buffer.byteIndex)
00141
00142 #define OSRTSTREAM_ID(pctxt) ((pctxt)->pStream->id)
00143 #define OSRTSTREAM_FLAGS(pctxt) ((pctxt)->pStream->flags)
00144
00150 typedef struct OSRTStream {
00151 OSRTStreamReadProc read;
00152 OSRTStreamBlockingReadProc blockingRead;
00153 OSRTStreamWriteProc write;
00154 OSRTStreamFlushProc flush;
00155 OSRTStreamCloseProc close;
00156 OSRTStreamSkipProc skip;
00157 OSRTStreamMarkProc mark;
00158 OSRTStreamResetProc reset;
00159
00160 void* extra;
00161
00162 size_t bufsize;
00163 size_t readAheadLimit;
00164 size_t bytesProcessed;
00165 size_t markedBytesProcessed;
00166 size_t ioBytes;
00167
00168 OSUINT32 id;
00169 OSRTSOCKET socket;
00170 OSUINT16 flags;
00171 } OSRTStream;
00172
00182 EXTERNRTX int rtxStreamClose (OSCTXT* pctxt);
00183
00194 EXTERNRTX int rtxStreamFlush (OSCTXT* pctxt);
00195
00205 EXTERNRTX int rtxStreamInit (OSCTXT* pctxt);
00206
00223 EXTERNRTX long rtxStreamRead
00224 (OSCTXT* pctxt, OSOCTET* pbuffer, size_t bufSize);
00225
00242 EXTERNRTX long rtxStreamBlockingRead
00243 (OSCTXT* pctxt, OSOCTET* pbuffer, size_t readBytes);
00244
00256 EXTERNRTX int rtxStreamSkip (OSCTXT* pctxt, size_t skipBytes);
00257
00270 EXTERNRTX long rtxStreamWrite
00271 (OSCTXT* pctxt, const OSOCTET* data, size_t numocts);
00272
00287 EXTERNRTX int rtxStreamGetIOBytes (OSCTXT* pctxt, size_t* pPos);
00288
00303 EXTERNRTX int rtxStreamMark (OSCTXT* pctxt, size_t readAheadLimit);
00304
00314 EXTERNRTX int rtxStreamReset (OSCTXT* pctxt);
00315
00326 EXTERNRTX OSBOOL rtxStreamMarkSupported (OSCTXT* pctxt);
00327
00336 EXTERNRTX OSBOOL rtxStreamIsOpened (OSCTXT* pctxt);
00337
00346 EXTERNRTX OSBOOL rtxStreamIsReadable (OSCTXT* pctxt);
00347
00356 EXTERNRTX OSBOOL rtxStreamIsWritable (OSCTXT* pctxt);
00357
00367 EXTERNRTX int rtxStreamRelease (OSCTXT* pctxt);
00368
00371 #ifdef __cplusplus
00372 }
00373 #endif
00374
00375 #endif
00376