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);
/* 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;
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])
/* 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;
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))) {
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;
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)
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;
/* XXX */
-int silc_idcache_del_by_data(SilcIDCache cache, char *data)
+int silc_idcache_del_by_data(SilcIDCache cache, unsigned char *data)
{
return TRUE;
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.
*/
typedef struct {
- char *data;
+ unsigned char *data;
SilcIdType type;
void *id;
unsigned long expire;
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);
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);