5 Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
7 Copyright (C) 2000 Pekka Riikonen
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
25 Silc ID Cache Entry object.
27 This is one entry in the SILC ID Cache system. Contents of this is
28 allocated outside the ID cache system, however, all the fields are
29 filled with ID cache utility functions. The ID cache system does not
30 allocate any of these fields nor free them.
34 The data that is usually used to find the data from the cache.
35 For example for Client ID's this is nickname.
47 Time when this cache entry expires. This is normal time() value
48 plus the validity. Cache entry has expired if current time is
49 more than value in this field, or if this field has been set to
54 Any caller specified context.
65 /* Forward declaration for SILC ID Cache object. */
66 typedef struct SilcIDCacheStruct *SilcIDCache;
68 /* Forward declaration for ID Cache List */
69 typedef struct SilcIDCacheListStruct *SilcIDCacheList;
71 #define SILC_ID_CACHE_ANY ((void *)1)
73 #define SILC_ID_CACHE_EXPIRE 3600
76 SilcIDCache silc_idcache_alloc(unsigned int count);
77 void silc_idcache_free(SilcIDCache cache);
78 void silc_idcache_sort_by_data(SilcIDCache cache);
79 int silc_idcache_find_by_data(SilcIDCache cache, unsigned char *data,
80 SilcIDCacheList *ret);
81 int silc_idcache_find_by_data_one(SilcIDCache cache, unsigned char *data,
82 SilcIDCacheEntry *ret);
83 int silc_idcache_find_by_data_loose(SilcIDCache cache, unsigned char *data,
84 SilcIDCacheList *ret);
85 int silc_idcache_find_by_id(SilcIDCache cache, void *id, SilcIdType type,
86 SilcIDCacheList *ret);
87 int silc_idcache_find_by_id_one(SilcIDCache cache, void *id, SilcIdType type,
88 SilcIDCacheEntry *ret);
89 int silc_idcache_find_by_context(SilcIDCache cache, void *context,
90 SilcIDCacheEntry *ret);
91 int silc_idcache_add(SilcIDCache cache, unsigned char *data,
93 void *id, void *context, int sort);
94 int silc_idcache_del(SilcIDCache cache, SilcIDCacheEntry old);
95 int silc_idcache_del_by_data(SilcIDCache cache, unsigned char *data);
96 int silc_idcache_del_by_id(SilcIDCache cache, SilcIdType type, void *id);
97 int silc_idcache_del_all(SilcIDCache cache);
98 int silc_idcache_purge(SilcIDCache cache);
99 int silc_idcache_list_count(SilcIDCacheList list);
100 int silc_idcache_list_first(SilcIDCacheList list, SilcIDCacheEntry *ret);
101 int silc_idcache_list_next(SilcIDCacheList list, SilcIDCacheEntry *ret);
102 void silc_idcache_list_free(SilcIDCacheList list);