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 OSSIZE segsize;
00051 OSSIZE startidx;
00052 OSSIZE usedcnt;
00053 OSSIZE bufsize;
00054 OSSIZE 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) ((OSSIZE)(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, OSSIZE nbytes);
00099
00114 EXTERNRT int rtxMemBufCut
00115 (OSRTMEMBUF* pMemBuf, OSSIZE fromOffset, OSSIZE nbytes);
00116
00124 EXTERNRT void rtxMemBufFree (OSRTMEMBUF* pMemBuf);
00125
00134 EXTERNRT OSOCTET* rtxMemBufGetData (const OSRTMEMBUF* pMemBuf, int* length);
00135
00146 EXTERNRT OSOCTET* rtxMemBufGetDataExt
00147 (const OSRTMEMBUF* pMemBuf, OSSIZE* length);
00148
00155 EXTERNRT OSSIZE rtxMemBufGetDataLen (const OSRTMEMBUF* pMemBuf);
00156
00169 EXTERNRT void rtxMemBufInit
00170 (OSCTXT* pCtxt, OSRTMEMBUF* pMemBuf, OSSIZE segsize);
00171
00189 EXTERNRT void rtxMemBufInitBuffer (OSCTXT* pCtxt, OSRTMEMBUF* pMemBuf,
00190 OSOCTET* buf, OSSIZE bufsize,
00191 OSSIZE segsize);
00192
00202 EXTERNRT int rtxMemBufPreAllocate (OSRTMEMBUF* pMemBuf, OSSIZE nbytes);
00203
00210 EXTERNRT void rtxMemBufReset (OSRTMEMBUF* pMemBuf);
00211
00227 EXTERNRT int rtxMemBufSet (OSRTMEMBUF* pMemBuf, OSOCTET value, OSSIZE nbytes);
00228
00240 EXTERNRT OSBOOL rtxMemBufSetExpandable
00241 (OSRTMEMBUF* pMemBuf, OSBOOL isExpandable);
00242
00253 EXTERNRT OSBOOL rtxMemBufSetUseSysMem (OSRTMEMBUF* pMemBuf, OSBOOL value);
00254
00261 EXTERNRT OSSIZE rtxMemBufTrimW (OSRTMEMBUF* pMemBuf);
00262
00266 #ifdef __cplusplus
00267 }
00268 #endif
00269
00270 #endif