GNU General Public License for more details.
*/
-/*
- * $Id$
- * $Log$
- * Revision 1.5 2000/07/18 06:51:48 priikone
- * Use length of data found from cache instead of length of searched
- * data in comparison.
- *
- * Revision 1.4 2000/07/17 11:46:36 priikone
- * Added debug logging
- *
- * Revision 1.3 2000/07/12 05:54:01 priikone
- * Major rewrite of whole ID Cache system.
- *
- * Revision 1.2 2000/07/05 06:06:35 priikone
- * Global cosmetic change.
- *
- * Revision 1.1.1.1 2000/06/27 11:36:55 priikone
- * Imported from internal CVS/Added Log headers.
- *
- *
- */
+/* $Id$ */
#include "silcincludes.h"
#include "idcache.h"
return TRUE;
}
-/* Find ID Cache entry by ID. Returns list of cache entries. */
-/* XXX this may be useless, need for list really? */
+/* Find ID Cache entry by ID. Returns list of cache entries. If `id' is
+ SILC_ID_CACHE_ANY this returns all ID's of type `type'. */
int silc_idcache_find_by_id(SilcIDCache cache, void *id, SilcIdType type,
SilcIDCacheList *ret)
list = silc_idcache_list_alloc();
- for (i = 0; i < cache->cache_count; i++)
- if (cache->cache[i].id && !memcmp(cache->cache[i].id, id, id_len))
- silc_idcache_list_add(list, &(cache->cache[i]));
+ if (id != SILC_ID_CACHE_ANY) {
+ for (i = 0; i < cache->cache_count; i++)
+ if (cache->cache[i].id && !memcmp(cache->cache[i].id, id, id_len))
+ silc_idcache_list_add(list, &(cache->cache[i]));
+ } else {
+ for (i = 0; i < cache->cache_count; i++)
+ if (cache->cache[i].id && cache->cache[i].type == type)
+ silc_idcache_list_add(list, &(cache->cache[i]));
+ }
if (!silc_idcache_list_count(list))
return FALSE;
return FALSE;
for (i = 0; i < count; i++) {
- if (c[i].data == NULL) {
+ if (c[i].data == NULL && c[i].id == NULL) {
c[i].data = data;
c[i].type = id_type;
c[i].id = id;