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 BSL_LIST_INTERNAL_H 17 #define BSL_LIST_INTERNAL_H 18 19 #include "hitls_build.h" 20 #ifdef HITLS_BSL_LIST 21 22 #include "bsl_list.h" 23 24 #ifdef __cplusplus 25 extern "C" { 26 #endif 27 28 typedef int32_t (*QSORT_COMP_FN_TYPE)(const void *, const void *); 29 30 /* Sort the list in ascending order of content */ 31 int32_t BSL_ListSortInternal(BslList *pList, int32_t((*cmp)(const void *, const void *))); 32 33 /** 34 * @ingroup bsl_list 35 * @brief To return the data of the node at the given index in the list, starting at 0. 36 * 37 * @param[IN] ulIndex The index in the list. 38 * @param[IN] pstListNode The list node. 39 * @param[IN] pstList The list. 40 * 41 * @retval void* The element which was found. [void *] 42 * @retval void* If none found. [NULL] 43 */ 44 void *BSL_LIST_GetIndexNodeEx(uint32_t ulIndex, const BslListNode *pstListNode, const BslList *pstList); 45 46 /** 47 * @ingroup bsl_list 48 * @brief This function searches a list based on the comparator function supplied (3rd param). 49 * The second param is given to the comparator as its second param and each data item on the 50 * list is given as its first param while searching. The comparator must return 0 to indicate a match. 51 * 52 * The Search callback function should return -2(SEC_INT_ERROR) if search should not be continued anymore. 53 * 54 * @param[IN] pList The list. 55 * @param[IN] pSearchFor The element to be searched. 56 * @param[IN] pSearcher The pointer to the comparison function of data. 57 * @param[OUT] pstErr Error codes for internal error. [-2/0] 58 * 59 * @retval Void* The element which was found [Void*] 60 * @retval Void* If none found [NULL] 61 */ 62 void *BSL_LIST_SearchEx(BslList *pList, const void *pSearchFor, BSL_LIST_PFUNC_CMP pSearcher); 63 64 /** 65 * @ingroup bsl_list 66 * @brief This creates a new node before/after/At end /begin of the current node. If the list was already empty, 67 * the node will be added as the only node.The current pointer is changed to point to the newly added node in the list. 68 * If the current pointer is NULL then this operation fails. 69 * 70 * @param[IN] pList The list. 71 * @param[IN] pData The element to be added. 72 * @param[IN] enPosition Whether the element is to be added before/after the list 73 * 74 * @retval uint32_t, The error code 75 * BSL_LIST_INVALID_LIST_CURRENT: If current pointer is NULL 76 * BSL_LIST_DATA_NOT_AVAILABLE: If data pointer is NULL 77 * BSL_MALLOC_FAIL: If failure to allocate memory for new node 78 * BSL_SUCCESS: If successful 79 */ 80 uint32_t BSL_LIST_AddElementInt(BslList *pList, void *pData, BslListPosition enPosition); 81 82 #define CURR_LIST_NODE(al) ((al)->curr) 83 84 #define SET_CURR_LIST_NODE(al, listNode) ((al)->curr = (listNode)) 85 86 #ifdef __cplusplus 87 } 88 #endif /* __cplusplus */ 89 90 #endif /* HITLS_BSL_LIST */ 91 92 #endif // BSL_LIST_INTERNAL_H 93