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/rtxCommon.h"
00047
00048 typedef struct OSMemBuf {
00049 OSCTXT* pctxt;
00050 OSUINT32 segsize;
00051 OSUINT32 startidx;
00052 OSUINT32 usedcnt;
00053 OSUINT32 bufsize;
00054 OSUINT32 bitOffset;
00055 OSOCTET* buffer;
00056 OSBOOL isDynamic;
00057 } OSMemBuf;
00058
00059 #define OSMBDFLTSEGSIZE 1024
00060
00061 #define OSMEMBUFPTR(pmb) ((pmb)->buffer + (pmb)->startidx)
00062 #define OSMEMBUFENDPTR(pmb) ((pmb)->buffer + (pmb)->startidx + (pmb)->usedcnt)
00063 #define OSMEMBUFUSEDSIZE(pmb) ((size_t)(pmb)->usedcnt)
00064
00065 #define OSMBAPPENDSTR(pmb,str) \
00066 rtxMemBufAppend(pmb,(OSOCTET*)str,strlen(str))
00067
00068 #define OSMBAPPENDUTF8(pmb,str) \
00069 rtxMemBufAppend(pmb,(OSOCTET*)str,rtxUTF8LenBytes(str))
00070
00071 #ifdef __cplusplus
00072 extern "C" {
00073 #endif
00074
00075
00076
00091 EXTERNRTX int rtxMemBufAppend
00092 (OSMemBuf* pMemBuf, const OSOCTET* pdata, OSUINT32 nbytes);
00093
00108 EXTERNRTX int rtxMemBufCut (OSMemBuf* pMemBuf, OSUINT32 fromOffset, OSUINT32 nbytes);
00109
00117 EXTERNRTX void rtxMemBufFree (OSMemBuf* pMemBuf);
00118
00127 EXTERNRTX OSOCTET* rtxMemBufGetData (OSMemBuf* pMemBuf, int* length);
00128
00135 EXTERNRTX int rtxMemBufGetDataLen (OSMemBuf* pMemBuf);
00136
00149 EXTERNRTX void rtxMemBufInit (OSCTXT* pCtxt, OSMemBuf* pMemBuf,
00150 OSUINT32 segsize);
00151
00169 EXTERNRTX void rtxMemBufInitBuffer (OSCTXT* pCtxt, OSMemBuf* pMemBuf,
00170 OSOCTET* buf, OSUINT32 bufsize,
00171 OSUINT32 segsize);
00172
00182 EXTERNRTX int rtxMemBufPreAllocate (OSMemBuf* pMemBuf, OSUINT32 nbytes);
00183
00190 EXTERNRTX void rtxMemBufReset (OSMemBuf* pMemBuf);
00191
00207 EXTERNRTX int rtxMemBufSet (OSMemBuf* pMemBuf, OSOCTET value, OSUINT32 nbytes);
00208
00217 EXTERNRTX int rtxMemBufTrimW (OSMemBuf* pMemBuf);
00218
00222 #ifdef __cplusplus
00223 }
00224 #endif
00225
00226 #endif