ubinos
dlist.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_DLIST_H_
31 #define UBICLIB_DLIST_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 DLIST_ERR__NOTEXIST -21
51 
53 typedef struct _dlist_elmt_t
54 {
55  struct _dlist_elmt_t * prev;
56  struct _dlist_elmt_t * next;
57  void * list;
58  void * data;
59  void * data2;
60 } dlist_elmt_t;
61 
70 
83 
95 
97 typedef struct _dlist_t
98 {
99  unsigned int count;
103  void * data;
104 } dlist_t;
105 
113 typedef dlist_t * dlist_pt;
114 
120 #define dlist_init(dlist) \
121 { \
122  (dlist)->count = 0; \
123  (dlist)->head = NULL; \
124  (dlist)->tail = NULL; \
125  (dlist)->cur = NULL; \
126  (dlist)->data = NULL; \
127 }
128 
139 int dlist_create(dlist_pt * dlist_p);
140 
152 int dlist_delete(dlist_pt * dlist_p);
153 
170 
187 
198 int dlist_remove(dlist_elmt_pt elmt);
199 
211 
227 int dlist_find(dlist_pt dlist, dlist_elmt_pt * elmt_p, void * data);
228 
244 int dlist_findandremove(dlist_pt dlist, dlist_elmt_pt * elmt_p, void * data);
245 
246 #ifdef __cplusplus
247 }
248 #endif
249 
250 #endif /* UBICLIB_DLIST_H_ */
dlist_remove
int dlist_remove(dlist_elmt_pt elmt)
dlist_delete
int dlist_delete(dlist_pt *dlist_p)
_dlist_t::count
unsigned int count
Definition: dlist.h:99
_dlist_t::tail
dlist_elmt_pt tail
Definition: dlist.h:101
_dlist_elmt_t::data2
void * data2
Definition: dlist.h:59
dlist_elmt_pt
dlist_elmt_t * dlist_elmt_pt
Definition: dlist.h:69
dlist_elmt_create
dlist_elmt_pt dlist_elmt_create(void *data, void *data2)
dlist_insertprev
int dlist_insertprev(dlist_pt dlist, dlist_elmt_pt ref, dlist_elmt_pt elmt)
dlist_insertnext
int dlist_insertnext(dlist_pt dlist, dlist_elmt_pt ref, dlist_elmt_pt elmt)
type.h
ubinos basic data type
_dlist_elmt_t::list
void * list
Definition: dlist.h:57
_dlist_t
Definition: dlist.h:97
dlist_getcurnext
dlist_elmt_pt dlist_getcurnext(dlist_pt dlist)
_dlist_elmt_t::data
void * data
Definition: dlist.h:58
_dlist_t::cur
dlist_elmt_pt cur
Definition: dlist.h:102
_dlist_elmt_t::next
struct _dlist_elmt_t * next
Definition: dlist.h:56
_dlist_t::data
void * data
Definition: dlist.h:103
dlist_elmt_delete
int dlist_elmt_delete(dlist_elmt_pt elmt)
dlist_t
struct _dlist_t dlist_t
dlist_findandremove
int dlist_findandremove(dlist_pt dlist, dlist_elmt_pt *elmt_p, void *data)
dlist_elmt_t
struct _dlist_elmt_t dlist_elmt_t
dlist_find
int dlist_find(dlist_pt dlist, dlist_elmt_pt *elmt_p, void *data)
_dlist_elmt_t::prev
struct _dlist_elmt_t * prev
Definition: dlist.h:55
_dlist_t::head
dlist_elmt_pt head
Definition: dlist.h:100
dlist_pt
dlist_t * dlist_pt
Definition: dlist.h:113
_dlist_elmt_t
Definition: dlist.h:53
dlist_create
int dlist_create(dlist_pt *dlist_p)