From: Pekka Riikonen Date: Fri, 15 Dec 2000 15:04:25 +0000 (+0000) Subject: Changed char *data to unsigned char *data in CacheEntry. X-Git-Tag: SILC.0.1~304 X-Git-Url: http://git.silcnet.org/gitweb/?a=commitdiff_plain;h=fa16fabc720e452960142c3e79e3a1820144a2bd;p=silc.git Changed char *data to unsigned char *data in CacheEntry. --- diff --git a/lib/silccore/id.h b/lib/silccore/id.h index 9da7f873..5da1d7ee 100644 --- a/lib/silccore/id.h +++ b/lib/silccore/id.h @@ -105,8 +105,8 @@ typedef struct { SILC_ID_COMPARE(id1, id2, 4) /* Compare nickname hash from Client ID */ -#define SILC_ID_COMPARE_HASH(id, hash) \ - memcmp(id->hash, hash, CLIENTID_HASH_LEN) +#define SILC_ID_COMPARE_HASH(id, _hash) \ + memcmp(id->hash, _hash, CLIENTID_HASH_LEN) /* Prototypes */ unsigned char *silc_id_id2str(void *id, SilcIdType type); diff --git a/lib/silccore/idcache.c b/lib/silccore/idcache.c index 9dc176f3..b35d23bf 100644 --- a/lib/silccore/idcache.c +++ b/lib/silccore/idcache.c @@ -165,7 +165,7 @@ void silc_idcache_sort_by_data(SilcIDCache cache) /* Find ID Cache entry by data. The data maybe anything that must match exactly. Returns list of cache entries. */ -int silc_idcache_find_by_data(SilcIDCache cache, char *data, +int silc_idcache_find_by_data(SilcIDCache cache, unsigned char *data, SilcIDCacheList *ret) { int i; @@ -181,6 +181,9 @@ int silc_idcache_find_by_data(SilcIDCache cache, char *data, else i = 0; + if (i == -1) + i = 0; + for (i = i; i < cache->cache_count; i++) { if (cache->sorted && cache->cache[i].data && cache->cache[i].data[0] != data[0]) @@ -205,7 +208,7 @@ int silc_idcache_find_by_data(SilcIDCache cache, char *data, /* Find ID Cache entry by data. The data maybe anything that must match exactly. Returns one cache entry. */ -int silc_idcache_find_by_data_one(SilcIDCache cache, char *data, +int silc_idcache_find_by_data_one(SilcIDCache cache, unsigned char *data, SilcIDCacheEntry *ret) { int i; @@ -218,6 +221,9 @@ int silc_idcache_find_by_data_one(SilcIDCache cache, char *data, else i = 0; + if (i == -1) + i = 0; + for (i = i; i < cache->cache_count; i++) if (cache->cache[i].data && !memcmp(cache->cache[i].data, data, strlen(cache->cache[i].data))) { @@ -233,7 +239,7 @@ int silc_idcache_find_by_data_one(SilcIDCache cache, char *data, match. This ignores data case-sensitivity when searching with this function. Returns list of cache entries. */ -int silc_idcache_find_by_data_loose(SilcIDCache cache, char *data, +int silc_idcache_find_by_data_loose(SilcIDCache cache, unsigned char *data, SilcIDCacheList *ret) { int i, c; @@ -251,6 +257,9 @@ int silc_idcache_find_by_data_loose(SilcIDCache cache, char *data, else i = 0; + if (i == -1) + i = 0; + for (i = i; i < cache->cache_count; i++) { if (cache->sorted && cache->cache[i].data && cache->cache[i].data[0] != (char)c) @@ -371,7 +380,8 @@ int silc_idcache_find_by_context(SilcIDCache cache, void *context, cache must be sorted in order for the fast access feature to work, however, it is not mandatory. */ -int silc_idcache_add(SilcIDCache cache, char *data, SilcIdType id_type, +int silc_idcache_add(SilcIDCache cache, unsigned char *data, + SilcIdType id_type, void *id, void *context, int sort) { int i; @@ -443,7 +453,7 @@ int silc_idcache_del(SilcIDCache cache, SilcIDCacheEntry old) /* XXX */ -int silc_idcache_del_by_data(SilcIDCache cache, char *data) +int silc_idcache_del_by_data(SilcIDCache cache, unsigned char *data) { return TRUE; diff --git a/lib/silccore/idcache.h b/lib/silccore/idcache.h index 582019ce..9421caf0 100644 --- a/lib/silccore/idcache.h +++ b/lib/silccore/idcache.h @@ -29,7 +29,7 @@ filled with ID cache utility functions. The ID cache system does not allocate any of these fields nor free them. - char *data + unsigned char *data The data that is usually used to find the data from the cache. For example for Client ID's this is nickname. @@ -55,7 +55,7 @@ */ typedef struct { - char *data; + unsigned char *data; SilcIdType type; void *id; unsigned long expire; @@ -76,11 +76,11 @@ typedef struct SilcIDCacheListStruct *SilcIDCacheList; SilcIDCache silc_idcache_alloc(unsigned int count); void silc_idcache_free(SilcIDCache cache); void silc_idcache_sort_by_data(SilcIDCache cache); -int silc_idcache_find_by_data(SilcIDCache cache, char *data, +int silc_idcache_find_by_data(SilcIDCache cache, unsigned char *data, SilcIDCacheList *ret); -int silc_idcache_find_by_data_one(SilcIDCache cache, char *data, +int silc_idcache_find_by_data_one(SilcIDCache cache, unsigned char *data, SilcIDCacheEntry *ret); -int silc_idcache_find_by_data_loose(SilcIDCache cache, char *data, +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); @@ -88,10 +88,11 @@ 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, SilcIDCacheEntry *ret); -int silc_idcache_add(SilcIDCache cache, char *data, SilcIdType id_type, +int silc_idcache_add(SilcIDCache cache, unsigned char *data, + SilcIdType id_type, void *id, void *context, int sort); int silc_idcache_del(SilcIDCache cache, SilcIDCacheEntry old); -int silc_idcache_del_by_data(SilcIDCache cache, char *data); +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);