ubinos
list.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2009 Sung Ho Park
3  Contact: ubinos.org@gmail.com
4 
5  This file is part of the itf_ubinos component of the Ubinos.
6 
7  GNU General Public License Usage
8  This file may be used under the terms of the GNU
9  General Public License version 3.0 as published by the Free Software
10  Foundation and appearing in the file license_gpl3.txt included in the
11  packaging of this file. Please review the following information to
12  ensure the GNU General Public License version 3.0 requirements will be
13  met: http://www.gnu.org/copyleft/gpl.html.
14 
15  GNU Lesser General Public License Usage
16  Alternatively, this file may be used under the terms of the GNU Lesser
17  General Public License version 2.1 as published by the Free Software
18  Foundation and appearing in the file license_lgpl.txt included in the
19  packaging of this file. Please review the following information to
20  ensure the GNU Lesser General Public License version 2.1 requirements
21  will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
22 
23  Commercial Usage
24  Alternatively, licensees holding valid commercial licenses may
25  use this file in accordance with the commercial license agreement
26  provided with the software or, alternatively, in accordance with the
27  terms contained in a written agreement between you and rightful owner.
28  */
29 
30 #ifndef UBICLIB_LIST_H_
31 #define UBICLIB_LIST_H_
32 
33 #ifdef __cplusplus
34 extern "C"
35 {
36 #endif
37 
46 #include <ubinos_config.h>
47 #include <ubinos/type.h>
48 
50 #define LIST_ERR__NOTEXIST -21
51 
53 typedef struct _list_elmt_t
54 {
55  struct _list_elmt_t * next;
56  void * data;
57 } list_elmt_t;
58 
67 
78 
90 
92 typedef struct _list_t
93 {
94  unsigned int count;
97 } list_t;
98 
106 typedef list_t * list_pt;
107 
113 #define list_init(list) \
114 { \
115  (list)->count = 0; \
116  (list)->head = NULL; \
117  (list)->tail = NULL; \
118 }
119 
130 int list_create(list_pt * list_p);
131 
143 int list_delete(list_pt * list_p);
144 
160 int list_insertnext(list_pt list, list_elmt_pt ref, list_elmt_pt elmt);
161 
174 int list_inserttail(list_pt list, list_elmt_pt elmt);
175 
191 int list_removenext(list_pt list, list_elmt_pt ref, list_elmt_pt * elmt_p);
192 
208 int list_find(list_pt list, list_elmt_pt * elmt_p, void * data);
209 
225 int list_findandremove(list_pt list, list_elmt_pt * elmt_p, void * data);
226 
227 #ifdef __cplusplus
228 }
229 #endif
230 
231 #endif /* UBICLIB_LIST_H_ */
_list_elmt_t
Definition: list.h:53
_list_elmt_t::data
void * data
Definition: list.h:56
list_elmt_delete
int list_elmt_delete(list_elmt_pt elmt)
list_t
struct _list_t list_t
_list_t
Definition: list.h:92
list_create
int list_create(list_pt *list_p)
type.h
ubinos basic data type
_list_elmt_t::next
struct _list_elmt_t * next
Definition: list.h:55
list_elmt_pt
list_elmt_t * list_elmt_pt
Definition: list.h:66
_list_t::count
unsigned int count
Definition: list.h:94
list_delete
int list_delete(list_pt *list_p)
list_pt
list_t * list_pt
Definition: list.h:106
_list_t::tail
list_elmt_pt tail
Definition: list.h:96
list_inserttail
int list_inserttail(list_pt list, list_elmt_pt elmt)
list_insertnext
int list_insertnext(list_pt list, list_elmt_pt ref, list_elmt_pt elmt)
_list_t::head
list_elmt_pt head
Definition: list.h:95
list_findandremove
int list_findandremove(list_pt list, list_elmt_pt *elmt_p, void *data)
list_removenext
int list_removenext(list_pt list, list_elmt_pt ref, list_elmt_pt *elmt_p)
list_elmt_create
list_elmt_pt list_elmt_create(void *data)
list_elmt_t
struct _list_elmt_t list_elmt_t
list_find
int list_find(list_pt list, list_elmt_pt *elmt_p, void *data)