00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00041
00042
00043 #ifndef _RTXMEMBUF_H_
00044 #define _RTXMEMBUF_H_
00045
00046 #include "rtxsrc/rtxContext.h"
00047
00048 typedef struct OSRTMEMBUF {
00049 OSCTXT* pctxt;
00050 OSUINT32 segsize;
00051 OSUINT32 startidx;
00052 OSUINT32 usedcnt;
00053 OSUINT32 bufsize;
00054 OSUINT32 bitOffset;
00055 OSUINT32 userState;
00056 OSOCTET* buffer;
00057 OSBOOL isDynamic;
00058 OSBOOL isExpandable;
00059 } OSRTMEMBUF;
00060
00061 #define OSMBDFLTSEGSIZE 1024
00062
00063 #define OSMEMBUFPTR(pmb) ((pmb)->buffer + (pmb)->startidx)
00064 #define OSMEMBUFENDPTR(pmb) ((pmb)->buffer + (pmb)->startidx + (pmb)->usedcnt)
00065 #define OSMEMBUFUSEDSIZE(pmb) ((size_t)(pmb)->usedcnt)
00066
00067 #define OSMBAPPENDSTR(pmb,str) \
00068 rtxMemBufAppend(pmb,(OSOCTET*)str,OSCRTLSTRLEN(str))
00069
00070 #define OSMBAPPENDUTF8(pmb,str) \
00071 rtxMemBufAppend(pmb,(OSOCTET*)str,rtxUTF8LenBytes(str))
00072
00073 #ifdef __cplusplus
00074 extern "C" {
00075 #endif
00076
00077
00078
00093 EXTERNRT int rtxMemBufAppend
00094 (OSRTMEMBUF* pMemBuf, const OSOCTET* pdata, size_t nbytes);
00095
00110 EXTERNRT int rtxMemBufCut (OSRTMEMBUF* pMemBuf, size_t fromOffset, size_t nbytes);
00111
00119 EXTERNRT void rtxMemBufFree (OSRTMEMBUF* pMemBuf);
00120
00129 EXTERNRT OSOCTET* rtxMemBufGetData (OSRTMEMBUF* pMemBuf, int* length);
00130
00137 EXTERNRT int rtxMemBufGetDataLen (OSRTMEMBUF* pMemBuf);
00138
00151 EXTERNRT void rtxMemBufInit (OSCTXT* pCtxt, OSRTMEMBUF* pMemBuf,
00152 size_t segsize);
00153
00171 EXTERNRT void rtxMemBufInitBuffer (OSCTXT* pCtxt, OSRTMEMBUF* pMemBuf,
00172 OSOCTET* buf, size_t bufsize,
00173 size_t segsize);
00174
00184 EXTERNRT int rtxMemBufPreAllocate (OSRTMEMBUF* pMemBuf, size_t nbytes);
00185
00192 EXTERNRT void rtxMemBufReset (OSRTMEMBUF* pMemBuf);
00193
00209 EXTERNRT int rtxMemBufSet (OSRTMEMBUF* pMemBuf, OSOCTET value, size_t nbytes);
00210
00222 EXTERNRT OSBOOL rtxMemBufSetExpandable
00223 (OSRTMEMBUF* pMemBuf, OSBOOL isExpandable);
00224
00233 EXTERNRT int rtxMemBufTrimW (OSRTMEMBUF* pMemBuf);
00234
00238 #ifdef __cplusplus
00239 }
00240 #endif
00241
00242 #endif