sync wit master
[platform/framework/web/livebox-viewer.git] / live.viewer / include / dlist.h
1 /*
2  * Copyright 2012  Samsung Electronics Co., Ltd
3  *
4  * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
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 #define dlist_remove_data(list, data) do { \
18         struct dlist *l; \
19         l = dlist_find_data(list, data); \
20         list = dlist_remove(list, l); \
21 } while (0)
22
23 #define dlist_foreach(list, l, data) \
24         for ((l) = (list); (l) && ((data) = dlist_data(l)); (l) = dlist_next(l))
25
26 #define dlist_foreach_safe(list, l, n, data) \
27         for ((l) = (list), (n) = dlist_next(l); \
28                 (l) && ((data) = dlist_data(l)); \
29                 (l) = (n), (n) = dlist_next(l))
30
31 struct dlist;
32
33 extern struct dlist *dlist_append(struct dlist *list, void *data);
34 extern struct dlist *dlist_prepend(struct dlist *list, void *data);
35 extern struct dlist *dlist_remove(struct dlist *list, struct dlist *l);
36 extern struct dlist *dlist_find_data(struct dlist *list, void *data);
37 extern void *dlist_data(struct dlist *l);
38 extern struct dlist *dlist_next(struct dlist *l);
39 extern struct dlist *dlist_prev(struct dlist *l);
40 extern int dlist_count(struct dlist *l);
41 extern struct dlist *dlist_nth(struct dlist *l, int nth);
42
43 /* End of a file */