D-Bus
1.6.8
|
00001 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ 00002 /* dbus-hash.h Generic hash table utility (internal to D-Bus implementation) 00003 * 00004 * Copyright (C) 2002 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_HASH_H 00025 #define DBUS_HASH_H 00026 00027 #ifdef HAVE_STDINT_H 00028 #include <stdint.h> 00029 #endif 00030 00031 #ifdef HAVE_INTTYPES_H 00032 #include <inttypes.h> 00033 #endif 00034 00035 #include <dbus/dbus-memory.h> 00036 #include <dbus/dbus-types.h> 00037 #include <dbus/dbus-sysdeps.h> 00038 00039 DBUS_BEGIN_DECLS 00040 00049 struct DBusHashIter 00050 { 00051 void *dummy1; 00052 void *dummy2; 00053 void *dummy3; 00054 void *dummy4; 00055 int dummy5; 00056 int dummy6; 00057 }; 00058 00059 typedef struct DBusHashTable DBusHashTable; 00060 typedef struct DBusHashIter DBusHashIter; 00061 00062 /* Allowing an arbitrary function as with GLib 00063 * would be nicer for a public API, but for 00064 * an internal API this saves typing, we can add 00065 * more whenever we feel like it. 00066 */ 00067 typedef enum 00068 { 00069 DBUS_HASH_STRING, 00070 DBUS_HASH_INT, 00071 DBUS_HASH_UINTPTR 00072 } DBusHashType; 00073 00074 DBusHashTable* _dbus_hash_table_new (DBusHashType type, 00075 DBusFreeFunction key_free_function, 00076 DBusFreeFunction value_free_function); 00077 DBusHashTable* _dbus_hash_table_ref (DBusHashTable *table); 00078 void _dbus_hash_table_unref (DBusHashTable *table); 00079 void _dbus_hash_table_remove_all (DBusHashTable *table); 00080 void _dbus_hash_iter_init (DBusHashTable *table, 00081 DBusHashIter *iter); 00082 dbus_bool_t _dbus_hash_iter_next (DBusHashIter *iter); 00083 void _dbus_hash_iter_remove_entry (DBusHashIter *iter); 00084 void* _dbus_hash_iter_get_value (DBusHashIter *iter); 00085 void _dbus_hash_iter_set_value (DBusHashIter *iter, 00086 void *value); 00087 int _dbus_hash_iter_get_int_key (DBusHashIter *iter); 00088 const char* _dbus_hash_iter_get_string_key (DBusHashIter *iter); 00089 uintptr_t _dbus_hash_iter_get_uintptr_key (DBusHashIter *iter); 00090 dbus_bool_t _dbus_hash_iter_lookup (DBusHashTable *table, 00091 void *key, 00092 dbus_bool_t create_if_not_found, 00093 DBusHashIter *iter); 00094 void* _dbus_hash_table_lookup_string (DBusHashTable *table, 00095 const char *key); 00096 void* _dbus_hash_table_lookup_int (DBusHashTable *table, 00097 int key); 00098 void* _dbus_hash_table_lookup_uintptr (DBusHashTable *table, 00099 uintptr_t key); 00100 dbus_bool_t _dbus_hash_table_remove_string (DBusHashTable *table, 00101 const char *key); 00102 dbus_bool_t _dbus_hash_table_remove_int (DBusHashTable *table, 00103 int key); 00104 dbus_bool_t _dbus_hash_table_remove_uintptr (DBusHashTable *table, 00105 uintptr_t key); 00106 dbus_bool_t _dbus_hash_table_insert_string (DBusHashTable *table, 00107 char *key, 00108 void *value); 00109 dbus_bool_t _dbus_hash_table_insert_int (DBusHashTable *table, 00110 int key, 00111 void *value); 00112 dbus_bool_t _dbus_hash_table_insert_uintptr (DBusHashTable *table, 00113 uintptr_t key, 00114 void *value); 00115 int _dbus_hash_table_get_n_entries (DBusHashTable *table); 00116 00117 /* Preallocation */ 00118 00120 typedef struct DBusPreallocatedHash DBusPreallocatedHash; 00121 00122 DBusPreallocatedHash *_dbus_hash_table_preallocate_entry (DBusHashTable *table); 00123 void _dbus_hash_table_free_preallocated_entry (DBusHashTable *table, 00124 DBusPreallocatedHash *preallocated); 00125 void _dbus_hash_table_insert_string_preallocated (DBusHashTable *table, 00126 DBusPreallocatedHash *preallocated, 00127 char *key, 00128 void *value); 00129 00132 DBUS_END_DECLS 00133 00134 #endif /* DBUS_HASH_H */