Main Page | Modules | Data Structures | File List | Data Fields | Related Pages

mntd_volume_hash.h

00001 /***************************************************************************
00002  * CVSID: $Id: mntd_volume_hash.h,v 1.12 2004/08/29 18:43:23 stefanb Exp $
00003  *
00004  * mntd_volume_hash.h : Volume Manager hash functions for MNT daemon
00005  *
00006  * Copyright (C) 2004 Stefan Bambach, <sbambach@gmx.net>
00007  *
00008  * Licensed under the GNU General Public License 2.0
00009  *
00010  * This program is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version.
00014  *
00015  * This program is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License
00021  * along with this program; if not, write to the Free Software
00022  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023  *
00024  **************************************************************************/
00025 
00026 #ifndef __HASHMAP_H__
00027 #define __HASHMAP_H__
00028 
00029 #include "mntd_volume_hash_types.h"
00030 #include "hashmap.h"
00031 #include "linklist.h"
00032 
00033 #if defined(__cplusplus)
00034 extern "C" {
00035 #endif
00036 
00037     
00050 #define DEFAULT_BUCKETS 1021    
00063 PHASHMAP new_HashMap(unsigned int bucket, void (*cb_free_element)(void *obj));
00064 
00065     
00069 struct HASHMAPELEMENT_ {
00070     PHASHMAP phm;                
00071     char *key;                   
00072     void *userdata;              
00079     void    (*destroy)              (PHASHMAPELEMENT phme);
00080     
00086     void    (*cb_free_element)  (void *data);
00087 };
00088 
00089 
00093 struct HASHMAP_ {
00094     CHTbl *hm;                   
00095     unsigned int bucket;         
00103     int (*init)         (PHASHMAP phm);
00104     
00111     int (*hash)         (const void *obj);
00112     
00120     int (*compare)      (const void *obj1, const void *obj2);
00121     
00127     void    (*free)         (void *data);
00128 
00134     void    (*cb_free_element)  (void *data);
00135 
00142     void    (*destroy)      (PHASHMAP phm);
00143     
00153     int (*add)          (PHASHMAP phm, const char *key, void *data);
00154     
00161     int (*remove)       (PHASHMAP phm, const char *key);
00162     
00168     int (*size)         (PHASHMAP phm);
00169     
00176     int (*contains)     (PHASHMAP phm, const char *key);
00177     
00185     int (*get)          (PHASHMAP phm, const char *key, void **userdata);
00186     
00194     int (*update)       (PHASHMAP phm, const char *key, void *userdata);
00195     
00203     int (*foreach)      (PHASHMAP phm, int (*func)(void *data, void *userdata), void *userdata);
00204     
00205 };
00206 
00207 
00211 #if defined(__cplusplus)
00212 }
00213 #endif
00214 
00215 #endif /* __HASHMAP_H__ */

Generated on Wed Mar 30 13:43:27 2005 for Mntd by  doxygen 1.3.9.1