1 /* 2 * Copyright (C) 2017-2018 NXP Semiconductors 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 /*! 18 * 19 * \file phOsal_LinkList.h 20 * \brief OSAL linked list header file. 21 * 22 * Project: NFC OSAL LIB 23 */ 24 25 #ifndef PHOSAL_LINKLIST_ 26 #define PHOSAL_LINKLIST_ 27 28 #include "phOsal_Posix.h" 29 30 #ifdef __cplusplus 31 extern "C" { 32 #endif 33 34 typedef enum _PHOSAL_LIST_POSITION { 35 PHOSAL_LIST_POS_HEAD, 36 PHOSAL_LIST_POS_TAIL, 37 PHOSAL_LIST_POS_CUR, 38 PHOSAL_LIST_POS_NEXT, 39 PHOSAL_LIST_POS_PREV 40 } PHOSAL_LIST_POSITION_T; 41 42 typedef struct phOsal_ListCreateParams { 43 void* memHdl; 44 void* (*MemAllocCb)(void* memHdl, uint32_t Size); 45 int (*MemFreeCb)(void* memHdl, void* ptrToMem); 46 } phOsal_ListCreateParams_t; 47 48 /** 49 * \ingroup grp_osal_lib 50 * \brief creates linked list 51 * 52 * This function creates resources for handling linkedlist 53 * \param[out] phListHandle LinkedList Handle 54 * \param[in] psCreateParams structure contatinng params to create 55 * linkedlist \retval #OSALSTATUS_SUCCESS OSAL LIB Linkedlist created 56 * successfully \retval #OSALSTATUS_FAILED OSAL LIB failed to create 57 * linkedlist 58 * 59 */ 60 OSALSTATUS phOsal_ListCreate(void** phListHandle, 61 phOsal_ListCreateParams_t* psCreateParams); 62 63 /** 64 * \ingroup grp_osal_lib 65 * \brief inserts a new element in linked list 66 * 67 * This function inserts node to linkedlist 68 * \param[in] pvListHandle LinkedList Handle 69 * \param[in] eListPos Position to insert linked list 70 * \param[in] pvData Data to be inserted in the new node 71 * \retval #OSALSTATUS_SUCCESS node inserted in Linkedlist successfully 72 * \retval #OSALSTATUS_FAILED node insertion in Linkedlist failed 73 * 74 */ 75 OSALSTATUS phOsal_ListInsertNode(void* pvListHandle, 76 PHOSAL_LIST_POSITION_T eListPos, void* pvData); 77 78 /** 79 * \ingroup grp_osal_lib 80 * \brief removes the node from linked list and provides data of removed node 81 * 82 * This function remove node from linkedlist 83 * \param[in] pvListHandle LinkedList Handle 84 * \param[in] eListPos Position to remove node from linked list 85 * \param[in] ppvData Pointer to data of removed node 86 * \retval #OSALSTATUS_SUCCESS node removed in Linkedlist successfully 87 * \retval #OSALSTATUS_FAILED node removal in Linkedlist failed 88 * 89 */ 90 OSALSTATUS phOsal_ListRemoveNode(void* pvListHandle, 91 PHOSAL_LIST_POSITION_T eListPos, 92 void** ppvData); 93 94 /** 95 * \ingroup grp_osal_lib 96 * \brief Flush all objects/nodes in the linked list 97 * 98 * This function removes all nodes from linkedlist 99 * \param[in] pvListHandle LinkedList Handle 100 * \retval #OSALSTATUS_SUCCESS node removed in Linkedlist successfully 101 * \retval #OSALSTATUS_FAILED node removal in Linkedlist failed 102 * 103 */ 104 OSALSTATUS phOsal_ListFlush(void* pvListHandle); 105 106 /** 107 * \ingroup grp_osal_lib 108 * \brief Destroys the linked list 109 * 110 * This function deletes the linkedlist 111 * \param[in] pvListHandle LinkedList Handle 112 * \retval #OSALSTATUS_SUCCESS node removed in Linkedlist successfully 113 * \retval #OSALSTATUS_FAILED node removal in Linkedlist failed 114 * 115 */ 116 OSALSTATUS phOsal_ListDestroy(void* pvListHandle); 117 118 #ifdef __cplusplus 119 } /* End of extern "C" { */ 120 #endif /* __cplusplus */ 121 122 #endif 123