updates.
[silc.git] / lib / silccore / idcache.h
index 84682bb0016938951d0670480eddd0594c716ce0..e1c2b0636780cc981368ef8145a53c7d0c0a6e1e 100644 (file)
@@ -4,7 +4,7 @@
 
   Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
 
-  Copyright (C) 2000 Pekka Riikonen
+  Copyright (C) 2000 - 2001 Pekka Riikonen
 
   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
    filled with ID cache utility functions. The ID cache system does not
    allocate any of these fields nor free them.
 
-   unsigned char *data
-   unsigned int data_len;
-
-      The data that is usually used to find the data from the cache.
-      For example for Client ID's this is nickname.
-
-   SilcIdType type
-
-      Type of the ID.
-
    void *id
 
       The actual ID.
 
-   unsigned long expire
+   char name
+
+      A name associated with the ID.
+
+   uint32 expire
 
       Time when this cache entry expires.  This is normal time() value
       plus the validity.  Cache entry has expired if current time is
 
 */
 typedef struct {
-  unsigned char *data;
-  unsigned int data_len;
-  SilcIdType type;
   void *id;
-  unsigned long expire;
+  char *name;
+  uint32 expire;
   void *context;
 } *SilcIDCacheEntry;
 
@@ -83,34 +75,42 @@ typedef void (*SilcIDCacheDestructor)(SilcIDCache cache,
 #define SILC_ID_CACHE_EXPIRE_DEF (time(NULL) + SILC_ID_CACHE_EXPIRE)
 
 /* Prototypes */
-SilcIDCache silc_idcache_alloc(unsigned int count,
+SilcIDCache silc_idcache_alloc(uint32 count, SilcIdType id_type,
                               SilcIDCacheDestructor destructor);
 void silc_idcache_free(SilcIDCache cache);
-void silc_idcache_sort_by_data(SilcIDCache cache);
-int silc_idcache_find_by_data(SilcIDCache cache, unsigned char *data, 
-                             SilcIDCacheList *ret);
-int silc_idcache_find_by_data_one(SilcIDCache cache, unsigned char *data,
-                                 SilcIDCacheEntry *ret);
-int silc_idcache_find_by_data_loose(SilcIDCache cache, unsigned char *data, 
-                                   SilcIDCacheList *ret);
-int silc_idcache_find_by_id(SilcIDCache cache, void *id, SilcIdType type,
-                           SilcIDCacheList *ret);
-int silc_idcache_find_by_id_one(SilcIDCache cache, void *id, SilcIdType type, 
-                               SilcIDCacheEntry *ret);
-int silc_idcache_find_by_context(SilcIDCache cache, void *context, 
+bool silc_idcache_add(SilcIDCache cache, char *name, void *id, 
+                     void *context, int expire);
+bool silc_idcache_del(SilcIDCache cache, SilcIDCacheEntry old);
+bool silc_idcache_del_by_id(SilcIDCache cache, void *id);
+bool silc_idcache_del_by_id_ext(SilcIDCache cache, void *id,
+                               SilcHashFunction hash, 
+                               void *hash_context,
+                               SilcHashCompare compare, 
+                               void *compare_context);
+bool silc_idcache_del_by_context(SilcIDCache cache, void *context);
+bool silc_idcache_del_all(SilcIDCache cache);
+bool silc_idcache_purge(SilcIDCache cache);
+bool silc_idcache_purge_by_context(SilcIDCache cache, void *context);
+bool silc_idcache_get_all(SilcIDCache cache, SilcIDCacheList *ret);
+bool silc_idcache_find_by_id(SilcIDCache cache, void *id, 
+                            SilcIDCacheList *ret);
+bool silc_idcache_find_by_id_one(SilcIDCache cache, void *id, 
                                 SilcIDCacheEntry *ret);
-int silc_idcache_add(SilcIDCache cache, unsigned char *data, 
-                    unsigned int data_len, SilcIdType id_type, void *id, 
-                    void *context, int sort, int expire);
-int silc_idcache_del(SilcIDCache cache, SilcIDCacheEntry old);
-int silc_idcache_del_by_data(SilcIDCache cache, unsigned char *data);
-int silc_idcache_del_by_id(SilcIDCache cache, SilcIdType type, void *id);
-int silc_idcache_del_all(SilcIDCache cache);
-int silc_idcache_purge(SilcIDCache cache);
-int silc_idcache_purge_by_context(SilcIDCache cache, void *context);
+bool silc_idcache_find_by_id_one_ext(SilcIDCache cache, void *id, 
+                                    SilcHashFunction hash, 
+                                    void *hash_context,
+                                    SilcHashCompare compare, 
+                                    void *compare_context,
+                                    SilcIDCacheEntry *ret);
+bool silc_idcache_find_by_context(SilcIDCache cache, void *context, 
+                                 SilcIDCacheEntry *ret);
+bool silc_idcache_find_by_name(SilcIDCache cache, char *name, 
+                              SilcIDCacheList *ret);
+bool silc_idcache_find_by_name_one(SilcIDCache cache, char *name,
+                                  SilcIDCacheEntry *ret);
 int silc_idcache_list_count(SilcIDCacheList list);
-int silc_idcache_list_first(SilcIDCacheList list, SilcIDCacheEntry *ret);
-int silc_idcache_list_next(SilcIDCacheList list, SilcIDCacheEntry *ret);
+bool silc_idcache_list_first(SilcIDCacheList list, SilcIDCacheEntry *ret);
+bool silc_idcache_list_next(SilcIDCacheList list, SilcIDCacheEntry *ret);
 void silc_idcache_list_free(SilcIDCacheList list);
 
 #endif