D-Bus
1.10.12
|
00001 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ 00002 /* dbus-list.h Generic linked list utility (internal to D-Bus implementation) 00003 * 00004 * Copyright (C) 2002, 2003 Red Hat, Inc. 00005 * 00006 * Licensed under the Academic Free License version 2.1 00007 * 00008 * This program is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU General Public License as published by 00010 * the Free Software Foundation; either version 2 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * This program is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License 00019 * along with this program; if not, write to the Free Software 00020 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00021 * 00022 */ 00023 00024 #ifndef DBUS_LIST_H 00025 #define DBUS_LIST_H 00026 00027 #include <dbus/dbus-internals.h> 00028 #include <dbus/dbus-memory.h> 00029 #include <dbus/dbus-types.h> 00030 #include <dbus/dbus-sysdeps.h> 00031 00032 DBUS_BEGIN_DECLS 00033 00034 struct DBusList 00035 { 00036 DBusList *prev; 00037 DBusList *next; 00038 void *data; 00039 }; 00040 DBUS_PRIVATE_EXPORT 00041 dbus_bool_t _dbus_list_append (DBusList **list, 00042 void *data); 00043 DBUS_PRIVATE_EXPORT 00044 dbus_bool_t _dbus_list_prepend (DBusList **list, 00045 void *data); 00046 dbus_bool_t _dbus_list_insert_before (DBusList **list, 00047 DBusList *before_this_link, 00048 void *data); 00049 DBUS_PRIVATE_EXPORT 00050 dbus_bool_t _dbus_list_insert_after (DBusList **list, 00051 DBusList *after_this_link, 00052 void *data); 00053 DBUS_PRIVATE_EXPORT 00054 void _dbus_list_insert_before_link (DBusList **list, 00055 DBusList *before_this_link, 00056 DBusList *link); 00057 DBUS_PRIVATE_EXPORT 00058 void _dbus_list_insert_after_link (DBusList **list, 00059 DBusList *after_this_link, 00060 DBusList *link); 00061 DBUS_PRIVATE_EXPORT 00062 dbus_bool_t _dbus_list_remove (DBusList **list, 00063 void *data); 00064 DBUS_PRIVATE_EXPORT 00065 dbus_bool_t _dbus_list_remove_last (DBusList **list, 00066 void *data); 00067 DBUS_PRIVATE_EXPORT 00068 void _dbus_list_remove_link (DBusList **list, 00069 DBusList *link); 00070 DBUS_PRIVATE_EXPORT 00071 DBusList* _dbus_list_find_last (DBusList **list, 00072 void *data); 00073 DBUS_PRIVATE_EXPORT 00074 void _dbus_list_clear (DBusList **list); 00075 DBUS_PRIVATE_EXPORT 00076 DBusList* _dbus_list_get_first_link (DBusList **list); 00077 DBUS_PRIVATE_EXPORT 00078 DBusList* _dbus_list_get_last_link (DBusList **list); 00079 DBUS_PRIVATE_EXPORT 00080 void* _dbus_list_get_last (DBusList **list); 00081 DBUS_PRIVATE_EXPORT 00082 void* _dbus_list_get_first (DBusList **list); 00083 DBUS_PRIVATE_EXPORT 00084 void* _dbus_list_pop_first (DBusList **list); 00085 DBUS_PRIVATE_EXPORT 00086 void* _dbus_list_pop_last (DBusList **list); 00087 DBUS_PRIVATE_EXPORT 00088 DBusList* _dbus_list_pop_first_link (DBusList **list); 00089 DBUS_PRIVATE_EXPORT 00090 dbus_bool_t _dbus_list_copy (DBusList **list, 00091 DBusList **dest); 00092 DBUS_PRIVATE_EXPORT 00093 int _dbus_list_get_length (DBusList **list); 00094 DBUS_PRIVATE_EXPORT 00095 DBusList* _dbus_list_alloc_link (void *data); 00096 DBUS_PRIVATE_EXPORT 00097 void _dbus_list_free_link (DBusList *link); 00098 DBUS_PRIVATE_EXPORT 00099 void _dbus_list_unlink (DBusList **list, 00100 DBusList *link); 00101 DBUS_PRIVATE_EXPORT 00102 void _dbus_list_append_link (DBusList **list, 00103 DBusList *link); 00104 DBUS_PRIVATE_EXPORT 00105 void _dbus_list_prepend_link (DBusList **list, 00106 DBusList *link); 00107 DBUS_PRIVATE_EXPORT 00108 dbus_bool_t _dbus_list_length_is_one (DBusList **list); 00109 00110 00111 DBUS_PRIVATE_EXPORT 00112 void _dbus_list_foreach (DBusList **list, 00113 DBusForeachFunction function, 00114 void *data); 00115 00116 #define _dbus_list_get_next_link(list, link) ((link)->next == *(list) ? NULL : (link)->next) 00117 #define _dbus_list_get_prev_link(list, link) ((link) == *(list) ? NULL : (link)->prev) 00118 00119 /* if DBUS_ENABLE_STATS */ 00120 DBUS_PRIVATE_EXPORT 00121 void _dbus_list_get_stats (dbus_uint32_t *in_use_p, 00122 dbus_uint32_t *in_free_list_p, 00123 dbus_uint32_t *allocated_p); 00124 00125 DBUS_END_DECLS 00126 00127 #endif /* DBUS_LIST_H */