summaryrefslogtreecommitdiffstats
path: root/dbus/dbus-list.h
blob: 77e878ce517aa36e457acb118b55b390dbe2f428 (plain)
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
/* -*- mode: C; c-file-style: "gnu" -*- */
/* dbus-list.h Generic linked list utility (internal to D-Bus implementation)
 * 
 * Copyright (C) 2002, 2003 Red Hat, Inc.
 *
 * Licensed under the Academic Free License version 2.1
 * 
 * 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 2 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, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */

#ifndef DBUS_LIST_H
#define DBUS_LIST_H

#include <dbus/dbus-internals.h>
#include <dbus/dbus-memory.h>
#include <dbus/dbus-types.h>

DBUS_BEGIN_DECLS

typedef struct DBusList DBusList;

struct DBusList
{
  DBusList *prev; /**< Previous list node. */
  DBusList *next; /**< Next list node. */
  void     *data; /**< Data stored at this element. */
};
dbus_bool_t _dbus_list_append             (DBusList **list,
                                           void      *data);
dbus_bool_t _dbus_list_prepend            (DBusList **list,
                                           void      *data);
dbus_bool_t _dbus_list_insert_before      (DBusList **list,
                                           DBusList  *before_this_link,
                                           void      *data);
dbus_bool_t _dbus_list_insert_after       (DBusList **list,
                                           DBusList  *after_this_link,
                                           void      *data);
void        _dbus_list_insert_before_link (DBusList **list,
                                           DBusList  *before_this_link,
                                           DBusList  *link);
void        _dbus_list_insert_after_link  (DBusList **list,
                                           DBusList  *after_this_link,
                                           DBusList  *link);
dbus_bool_t _dbus_list_remove             (DBusList **list,
                                           void      *data);
dbus_bool_t _dbus_list_remove_last        (DBusList **list,
                                           void      *data);
void        _dbus_list_remove_link        (DBusList **list,
                                           DBusList  *link);
DBusList*   _dbus_list_find_last          (DBusList **list,
                                           void      *data);
void        _dbus_list_clear              (DBusList **list);
DBusList*   _dbus_list_get_first_link     (DBusList **list);
DBusList*   _dbus_list_get_last_link      (DBusList **list);
void*       _dbus_list_get_last           (DBusList **list);
void*       _dbus_list_get_first          (DBusList **list);
void*       _dbus_list_pop_first          (DBusList **list);
void*       _dbus_list_pop_last           (DBusList **list);
DBusList*   _dbus_list_pop_first_link     (DBusList **list);
DBusList*   _dbus_list_pop_last_link      (DBusList **list);
dbus_bool_t _dbus_list_copy               (DBusList **list,
                                           DBusList **dest);
int         _dbus_list_get_length         (DBusList **list);
DBusList*   _dbus_list_alloc_link         (void      *data);
void        _dbus_list_free_link          (DBusList  *link);
void        _dbus_list_unlink             (DBusList **list,
                                           DBusList  *link);
void        _dbus_list_append_link        (DBusList **list,
                                           DBusList  *link);
void        _dbus_list_prepend_link       (DBusList **list,
                                           DBusList  *link);
dbus_bool_t _dbus_list_length_is_one      (DBusList **list);




void _dbus_list_foreach (DBusList            **list,
                         DBusForeachFunction   function,
                         void                 *data);

#define _dbus_list_get_next_link(list, link) ((link)->next == *(list) ? NULL : (link)->next)
#define _dbus_list_get_prev_link(list, link) ((link) == *(list) ? NULL : (link)->prev)

DBUS_END_DECLS

#endif /* DBUS_LIST_H */