1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
/*
* MOST NetServices "Light" V3.2.7.0.1796 MultiInstance Patch
*
* Copyright (C) 2015 Microchip Technology Germany II GmbH & Co. KG
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* You may also obtain this software under a propriety license from Microchip.
* Please contact Microchip for further information.
*
*/
/*!
* \file
* \brief Internal header file of the doubly linked list.
*
* \cond MNS_INTERNAL_DOC
* \addtogroup G_DL
* @{
*/
#ifndef MNS_DL_H
#define MNS_DL_H
/*------------------------------------------------------------------------------------------------*/
/* Includes */
/*------------------------------------------------------------------------------------------------*/
#include "mns_types_cfg.h"
#ifdef __cplusplus
extern "C"
{
#endif
/*------------------------------------------------------------------------------------------------*/
/* Type definitions */
/*------------------------------------------------------------------------------------------------*/
/*! \brief Callback signature used by foreach-function
* \param d_ptr Reference to the data of the current node
* \param up_ptr Reference to the user data
* \return true: Stop the for-each-loop
* \return false: Continue the for-each-loop
*/
typedef bool(*Dl_ForeachFunc_t)(void *d_ptr, void *ud_ptr);
/*------------------------------------------------------------------------------------------------*/
/* Enumerators */
/*------------------------------------------------------------------------------------------------*/
/*! \brief Standard return values of the list module. */
typedef enum Dl_Ret_
{
DL_OK, /*!< \brief No error */
DL_UNKNOWN_NODE, /*!< \brief Unknown node */
DL_STOPPED /*!< \brief Search process stopped */
} Dl_Ret_t;
/*------------------------------------------------------------------------------------------------*/
/* Structures */
/*------------------------------------------------------------------------------------------------*/
/*! \brief Class structure of doubly linked list node. */
typedef struct DlNode_
{
struct DlNode_ *prev; /*!< \brief Reference to previous node in list */
struct DlNode_ *next; /*!< \brief Reference to next node in list */
void *data_ptr; /*!< \brief Reference to optional data */
bool in_use; /*!< \brief Flag which signals that the node is in use */
} CDlNode;
/*! \brief Class structure of the doubly linked list. */
typedef struct CDlList_
{
struct DlNode_ *head; /*!< \brief Reference to head of the list */
struct DlNode_ *tail; /*!< \brief Reference to tail of the list */
uint16_t size; /*!< \brief Number of nodes in the list */
uint8_t mns_inst_id; /*!< \brief MOST NetServices instance ID */
} CDlList;
/*------------------------------------------------------------------------------------------------*/
/* Prototypes of class CDlList */
/*------------------------------------------------------------------------------------------------*/
extern void Dl_Ctor(CDlList *self, uint8_t mns_inst_id);
extern void Dl_InsertAfter(CDlList *self, CDlNode *node, CDlNode *new_node);
extern void Dl_InsertBefore(CDlList *self, CDlNode *node, CDlNode *new_node);
extern void Dl_InsertHead(CDlList *self, CDlNode *new_node);
extern void Dl_InsertTail(CDlList *self, CDlNode *new_node);
extern Dl_Ret_t Dl_Remove(CDlList *self, CDlNode *node);
extern CDlNode * Dl_PopHead(CDlList *self);
extern CDlNode * Dl_PopTail(CDlList *self);
extern CDlNode * Dl_PeekHead(CDlList *self);
extern CDlNode * Dl_PeekTail(CDlList *self);
extern CDlNode * Dl_Foreach(CDlList *self, Dl_ForeachFunc_t func_ptr, void *user_data_ptr);
extern bool Dl_IsNodeInList(CDlList *self, const CDlNode *node);
extern void Dl_AppendList(CDlList *self, CDlList *list_ptr);
extern uint16_t Dl_GetSize(CDlList *self);
/*------------------------------------------------------------------------------------------------*/
/* Prototypes of class CDlNode */
/*------------------------------------------------------------------------------------------------*/
extern void Dln_Ctor(CDlNode *self, void *data_ptr);
extern void Dln_SetData(CDlNode *self, void *data_ptr);
extern void * Dln_GetData(CDlNode *self);
extern bool Dln_IsNodePartOfAList(CDlNode *self);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* #ifndef MNS_DL_H */
/*!
* @}
* \endcond
*/
/*------------------------------------------------------------------------------------------------*/
/* End of file */
/*------------------------------------------------------------------------------------------------*/
|