device: Merge public api on Tizen 2.3 into tizen branch
[platform/core/api/device.git] / src / list.h
1 /*
2  * deviced
3  *
4  * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18
19 #ifndef __LIST_H__
20 #define __LIST_H__
21
22 #include <stdio.h>
23
24 #define EINA_LIST_APPEND(a, b) \
25         a = eina_list_append(a, b)
26
27 #define EINA_LIST_REMOVE(a, b) \
28         a = eina_list_remove(a, b)
29
30 #define EINA_LIST_REMOVE_LIST(a, b) \
31         a = eina_list_remove_list(a, b)
32
33 #define EINA_LIST_FREE_LIST(a) \
34         a = eina_list_free(a)
35
36 #define EINA_LIST_PROMOTE_LIST(a, b) \
37         a = eina_list_promote_list(a, b)
38
39 #ifdef EINA_LIST
40 #include <Ecore.h>
41 typedef Eina_List dd_list;
42 #define DD_LIST_PREPEND(a, b)   \
43         a = eina_list_prepend(a, b)
44 #define DD_LIST_APPEND(a, b)    \
45         a = eina_list_append(a, b)
46 #define DD_LIST_REMOVE(a, b)    \
47         a = eina_list_remove(a, b)
48 #define DD_LIST_LENGTH(a)               \
49         eina_list_count(a)
50 #define DD_LIST_NTH(a, b)                       \
51         eina_list_nth(a, b)
52 #define DD_LIST_FREE_LIST(a)    \
53         a = eina_list_free(a)
54 #define DD_LIST_FOREACH(head, elem, node)       \
55         EINA_LIST_FOREACH(head, elem, node)
56 #define DD_LIST_FOREACH_SAFE(head, elem, elem_next, node) \
57         EINA_LIST_FOREACH_SAFE(head, elem, elem_next, node)
58
59 #else
60 #include <glib.h>
61 typedef GList dd_list;
62 #define DD_LIST_PREPEND(a, b)           \
63         a = g_list_prepend(a, (gpointer)b)
64 #define DD_LIST_APPEND(a, b)            \
65         a = g_list_append(a, (gpointer)b)
66 #define DD_LIST_REMOVE(a, b)            \
67         a = g_list_remove(a, (gpointer)b)
68 #define DD_LIST_LENGTH(a)                       \
69         g_list_length(a)
70 #define DD_LIST_NTH(a, b)                       \
71         g_list_nth_data(a, b)
72 #define DD_LIST_FREE_LIST(a)        \
73         g_list_free(a)
74 #define DD_LIST_FOREACH(head, elem, node)       \
75         for (elem = head, node = NULL; elem && ((node = elem->data) != NULL); elem = elem->next, node = NULL)
76 #define DD_LIST_FOREACH_SAFE(head, elem, elem_next, node) \
77         for (elem = head, elem_next = g_list_next(elem), node = NULL; \
78                         elem && ((node = elem->data) != NULL); \
79                         elem = elem_next, elem_next = g_list_next(elem), node = NULL)
80
81 #endif
82
83 #endif