• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * This file is part of the openHiTLS project.
3  *
4  * openHiTLS is licensed under the Mulan PSL v2.
5  * You can use this software according to the terms and conditions of the Mulan PSL v2.
6  * You may obtain a copy of Mulan PSL v2 at:
7  *
8  *     http://license.coscl.org.cn/MulanPSL2
9  *
10  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
11  * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
12  * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
13  * See the Mulan PSL v2 for more details.
14  */
15 
16 #ifndef REC_BUF_H
17 #define REC_BUF_H
18 
19 #include <stdint.h>
20 #include "bsl_list.h"
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 
27 typedef struct {
28     uint8_t *buf;
29     uint32_t bufSize;
30 
31     uint32_t start;
32     uint32_t end;
33     uint32_t singleRecStart;
34     uint32_t singleRecEnd;
35     bool isHoldBuffer;
36 } RecBuf;
37 
38 typedef struct BslList RecBufList;
39 /**
40  * @brief   Allocate buffer
41  *
42  * @param   bufSize [IN] buffer size
43  *
44  * @return  RecBuf Buffer handle
45  */
46 RecBuf *RecBufNew(uint32_t bufSize);
47 
48 /**
49  * @brief   Release the buffer
50  *
51  * @param   buf [IN] Buffer handle. The buffer is released by the invoker
52  */
53 void RecBufFree(RecBuf *buf);
54 
55 /**
56  * @brief   Release the data in buffer
57  *
58  * @param   buf [IN] Buffer handle
59  */
60 void RecBufClean(RecBuf *buf);
61 
62 RecBufList *RecBufListNew(void);
63 
64 void RecBufListFree(RecBufList *bufList);
65 
66 int32_t RecBufListDereference(RecBufList *bufList);
67 
68 bool RecBufListEmpty(RecBufList *bufList);
69 
70 int32_t RecBufListGetBuffer(RecBufList *bufList, uint8_t *buf, uint32_t bufLen, uint32_t *getLen, bool isPeek);
71 
72 int32_t RecBufListAddBuffer(RecBufList *bufList, RecBuf *buf);
73 
74 int32_t RecBufResize(RecBuf *recBuf, uint32_t size);
75 
76 #ifdef __cplusplus
77 }
78 #endif
79 
80 #endif