ASN1C C/C++ Common Runtime  ASN1C v7.5.x
rtxMemBuf.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2003-2021 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 
191 EXTERNRT void rtxMemBufInitBuffer (OSCTXT* pCtxt, OSRTMEMBUF* pMemBuf,
192  OSOCTET* buf, OSSIZE bufsize,
193  OSSIZE segsize);
194 
204 EXTERNRT int rtxMemBufPreAllocate (OSRTMEMBUF* pMemBuf, OSSIZE nbytes);
205 
212 EXTERNRT void rtxMemBufReset (OSRTMEMBUF* pMemBuf);
213 
229 EXTERNRT int rtxMemBufSet (OSRTMEMBUF* pMemBuf, OSOCTET value, OSSIZE nbytes);
230 
242 EXTERNRT OSBOOL rtxMemBufSetExpandable
243 (OSRTMEMBUF* pMemBuf, OSBOOL isExpandable);
244 
255 EXTERNRT OSBOOL rtxMemBufSetUseSysMem (OSRTMEMBUF* pMemBuf, OSBOOL value);
256 
263 EXTERNRT OSSIZE rtxMemBufTrimW (OSRTMEMBUF* pMemBuf);
264 
268 #ifdef __cplusplus
269 }
270 #endif
271 
272 #endif
OSSIZE rtxMemBufTrimW(OSRTMEMBUF *pMemBuf)
int rtxMemBufSet(OSRTMEMBUF *pMemBuf, OSOCTET value, OSSIZE nbytes)
void rtxMemBufInit(OSCTXT *pCtxt, OSRTMEMBUF *pMemBuf, OSSIZE segsize)
OSOCTET * rtxMemBufGetData(const OSRTMEMBUF *pMemBuf, int *length)
void rtxMemBufReset(OSRTMEMBUF *pMemBuf)
int rtxMemBufPreAllocate(OSRTMEMBUF *pMemBuf, OSSIZE nbytes)
Definition: rtxMemBuf.h:48
OSSIZE rtxMemBufGetDataLen(const OSRTMEMBUF *pMemBuf)
OSBOOL rtxMemBufSetUseSysMem(OSRTMEMBUF *pMemBuf, OSBOOL value)
OSOCTET * rtxMemBufGetDataExt(const OSRTMEMBUF *pMemBuf, OSSIZE *length)
Definition: rtxContext.h:197
void rtxMemBufFree(OSRTMEMBUF *pMemBuf)
void rtxMemBufInitBuffer(OSCTXT *pCtxt, OSRTMEMBUF *pMemBuf, OSOCTET *buf, OSSIZE bufsize, OSSIZE segsize)
int rtxMemBufCut(OSRTMEMBUF *pMemBuf, OSSIZE fromOffset, OSSIZE nbytes)
int rtxMemBufAppend(OSRTMEMBUF *pMemBuf, const OSOCTET *pdata, OSSIZE nbytes)
OSBOOL rtxMemBufSetExpandable(OSRTMEMBUF *pMemBuf, OSBOOL isExpandable)