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 OSBOOL useSysMem;
00060 } OSRTMEMBUF;
00061
00062 #define OSMBDFLTSEGSIZE 1024
00063
00064 #define OSMEMBUFPTR(pmb) ((pmb)->buffer + (pmb)->startidx)
00065 #define OSMEMBUFENDPTR(pmb) ((pmb)->buffer + (pmb)->startidx + (pmb)->usedcnt)
00066 #define OSMEMBUFUSEDSIZE(pmb) ((size_t)(pmb)->usedcnt)
00067
00068 #define OSMBAPPENDSTR(pmb,str) if (0 != str) \
00069 rtxMemBufAppend(pmb,(OSOCTET*)str,OSCRTLSTRLEN(str))
00070
00071 #define OSMBAPPENDSTRL(pmb,str) \
00072 rtxMemBufAppend(pmb,(OSOCTET*)str,OSCRTLSTRLEN(str))
00073
00074 #define OSMBAPPENDUTF8(pmb,str) if (0 != str) \
00075 rtxMemBufAppend(pmb,(OSOCTET*)str,rtxUTF8LenBytes(str))
00076
00077 #ifdef __cplusplus
00078 extern "C" {
00079 #endif
00080
00081
00082
00097 EXTERNRT int rtxMemBufAppend
00098 (OSRTMEMBUF* pMemBuf, const OSOCTET* pdata, size_t nbytes);
00099
00114 EXTERNRT int rtxMemBufCut
00115 (OSRTMEMBUF* pMemBuf, size_t fromOffset, size_t nbytes);
00116
00124 EXTERNRT void rtxMemBufFree (OSRTMEMBUF* pMemBuf);
00125
00134 EXTERNRT OSOCTET* rtxMemBufGetData (OSRTMEMBUF* pMemBuf, int* length);
00135
00142 EXTERNRT int rtxMemBufGetDataLen (OSRTMEMBUF* pMemBuf);
00143
00156 EXTERNRT void rtxMemBufInit
00157 (OSCTXT* pCtxt, OSRTMEMBUF* pMemBuf, size_t segsize);
00158
00176 EXTERNRT void rtxMemBufInitBuffer (OSCTXT* pCtxt, OSRTMEMBUF* pMemBuf,
00177 OSOCTET* buf, size_t bufsize,
00178 size_t segsize);
00179
00189 EXTERNRT int rtxMemBufPreAllocate (OSRTMEMBUF* pMemBuf, size_t nbytes);
00190
00197 EXTERNRT void rtxMemBufReset (OSRTMEMBUF* pMemBuf);
00198
00214 EXTERNRT int rtxMemBufSet (OSRTMEMBUF* pMemBuf, OSOCTET value, size_t nbytes);
00215
00227 EXTERNRT OSBOOL rtxMemBufSetExpandable
00228 (OSRTMEMBUF* pMemBuf, OSBOOL isExpandable);
00229
00240 EXTERNRT OSBOOL rtxMemBufSetUseSysMem (OSRTMEMBUF* pMemBuf, OSBOOL value);
00241
00250 EXTERNRT int rtxMemBufTrimW (OSRTMEMBUF* pMemBuf);
00251
00255 #ifdef __cplusplus
00256 }
00257 #endif
00258
00259 #endif