XBinder  Version 2.6.x
rtxMemBuf.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2003-2018 Objective Systems, Inc.
3  *
4  * This software is furnished under a license and may be used and copied
5  * only in accordance with the terms of such license and with the
6  * inclusion of the above copyright notice. This software or any other
7  * copies thereof may not be provided or otherwise made available to any
8  * other person. No title to and ownership of the software is hereby
9  * transferred.
10  *
11  * The information in this software is subject to change without notice
12  * and should not be construed as a commitment by Objective Systems, Inc.
13  *
14  * PROPRIETARY NOTICE
15  *
16  * This software is an unpublished work subject to a confidentiality agreement
17  * and is protected by copyright and trade secret law. Unauthorized copying,
18  * redistribution or other use of this work is prohibited.
19  *
20  * The above notice of copyright on this source code product does not indicate
21  * any actual or intended publication of such source code.
22  *
23  *****************************************************************************/
24 
41 /* memory buffer */
42 
43 #ifndef _RTXMEMBUF_H_
44 #define _RTXMEMBUF_H_
45 
46 #include "rtxsrc/rtxContext.h"
47 
48 typedef struct OSRTMEMBUF {
49  OSCTXT* pctxt;
50  OSSIZE segsize; /* segment size */
51  OSSIZE startidx; /* start index of useful info */
52  OSSIZE usedcnt; /* used byte count */
53  OSSIZE bufsize; /* buffer size */
54  OSSIZE bitOffset; /* bit offset */
55  OSUINT32 userState; /* user state - any value, 0 is initial */
56  OSOCTET* buffer; /* memory buffer */
57  OSBOOL isDynamic; /* is buffer allocated dynamically? */
58  OSBOOL isExpandable; /* is buffer expandable? */
59  OSBOOL useSysMem; /* use system memory management */
60 } OSRTMEMBUF;
61 
62 #define OSMBDFLTSEGSIZE 1024
63 
64 #define OSMEMBUFPTR(pmb) ((pmb)->buffer + (pmb)->startidx)
65 #define OSMEMBUFENDPTR(pmb) ((pmb)->buffer + (pmb)->startidx + (pmb)->usedcnt)
66 #define OSMEMBUFUSEDSIZE(pmb) ((OSSIZE)(pmb)->usedcnt)
67 
68 #define OSMBAPPENDSTR(pmb,str) if (0 != str) \
69 rtxMemBufAppend(pmb,(OSOCTET*)str,OSCRTLSTRLEN(str))
70 
71 #define OSMBAPPENDSTRL(pmb,str) \
72 rtxMemBufAppend(pmb,(OSOCTET*)str,OSCRTLSTRLEN(str))
73 
74 #define OSMBAPPENDUTF8(pmb,str) if (0 != str) \
75 rtxMemBufAppend(pmb,(OSOCTET*)str,rtxUTF8LenBytes(str))
76 
77 #ifdef __cplusplus
78 extern "C" {
79 #endif
80 
81 /* Memory buffer functions */
82 
97 EXTERNRT int rtxMemBufAppend
98 (OSRTMEMBUF* pMemBuf, const OSOCTET* pdata, OSSIZE nbytes);
99 
114 EXTERNRT int rtxMemBufCut
115 (OSRTMEMBUF* pMemBuf, OSSIZE fromOffset, OSSIZE nbytes);
116 
124 EXTERNRT void rtxMemBufFree (OSRTMEMBUF* pMemBuf);
125 
134 EXTERNRT OSOCTET* rtxMemBufGetData (const OSRTMEMBUF* pMemBuf, int* length);
135 
146 EXTERNRT OSOCTET* rtxMemBufGetDataExt
147 (const OSRTMEMBUF* pMemBuf, OSSIZE* length);
148 
155 EXTERNRT OSSIZE rtxMemBufGetDataLen (const OSRTMEMBUF* pMemBuf);
156 
169 EXTERNRT void rtxMemBufInit
170 (OSCTXT* pCtxt, OSRTMEMBUF* pMemBuf, OSSIZE segsize);
171 
189 EXTERNRT void rtxMemBufInitBuffer (OSCTXT* pCtxt, OSRTMEMBUF* pMemBuf,
190  OSOCTET* buf, OSSIZE bufsize,
191  OSSIZE segsize);
192 
202 EXTERNRT int rtxMemBufPreAllocate (OSRTMEMBUF* pMemBuf, OSSIZE nbytes);
203 
210 EXTERNRT void rtxMemBufReset (OSRTMEMBUF* pMemBuf);
211 
227 EXTERNRT int rtxMemBufSet (OSRTMEMBUF* pMemBuf, OSOCTET value, OSSIZE nbytes);
228 
240 EXTERNRT OSBOOL rtxMemBufSetExpandable
241 (OSRTMEMBUF* pMemBuf, OSBOOL isExpandable);
242 
253 EXTERNRT OSBOOL rtxMemBufSetUseSysMem (OSRTMEMBUF* pMemBuf, OSBOOL value);
254 
261 EXTERNRT OSSIZE rtxMemBufTrimW (OSRTMEMBUF* pMemBuf);
262 
266 #ifdef __cplusplus
267 }
268 #endif
269 
270 #endif
EXTERNRT void rtxMemBufInitBuffer(OSCTXT *pCtxt, OSRTMEMBUF *pMemBuf, OSOCTET *buf, OSSIZE bufsize, OSSIZE segsize)
This function assigns a static buffer to the memory buffer structure.
EXTERNRT OSOCTET * rtxMemBufGetData(const OSRTMEMBUF *pMemBuf, int *length)
This function returns the pointer to the used part of a memory buffer.
EXTERNRT int rtxMemBufPreAllocate(OSRTMEMBUF *pMemBuf, OSSIZE nbytes)
This function allocates a buffer with a predetermined amount of space.
EXTERNRT OSOCTET * rtxMemBufGetDataExt(const OSRTMEMBUF *pMemBuf, OSSIZE *length)
This function returns the pointer to the used part of a memory buffer.
EXTERNRT int rtxMemBufCut(OSRTMEMBUF *pMemBuf, OSSIZE fromOffset, OSSIZE nbytes)
This function cuts off the part of memory buffer.
EXTERNRT OSSIZE rtxMemBufTrimW(OSRTMEMBUF *pMemBuf)
This function trims white space of the memory buffer.
Common run-time context definitions.
EXTERNRT OSSIZE rtxMemBufGetDataLen(const OSRTMEMBUF *pMemBuf)
This function returns the length of the used part of a memory buffer.
EXTERNRT void rtxMemBufInit(OSCTXT *pCtxt, OSRTMEMBUF *pMemBuf, OSSIZE segsize)
This function initializes a memory buffer structure.
EXTERNRT int rtxMemBufAppend(OSRTMEMBUF *pMemBuf, const OSOCTET *pdata, OSSIZE nbytes)
This function appends the data to the end of a memory buffer.
EXTERNRT void rtxMemBufFree(OSRTMEMBUF *pMemBuf)
This function frees the memory buffer.
EXTERNRT int rtxMemBufSet(OSRTMEMBUF *pMemBuf, OSOCTET value, OSSIZE nbytes)
This function sets part of a memory buffer to a specified octet value.
EXTERNRT void rtxMemBufReset(OSRTMEMBUF *pMemBuf)
This function resets the memory buffer structure.
Run-time context structure.
Definition: rtxContext.h:185
EXTERNRT OSBOOL rtxMemBufSetUseSysMem(OSRTMEMBUF *pMemBuf, OSBOOL value)
This function sets a flag to indicate that system memory management should be used instead of the cus...
EXTERNRT OSBOOL rtxMemBufSetExpandable(OSRTMEMBUF *pMemBuf, OSBOOL isExpandable)
This function sets "isExpandable" flag for the memory buffer object.