Changed char *data to unsigned char *data in CacheEntry.
authorPekka Riikonen <priikone@silcnet.org>
Fri, 15 Dec 2000 15:04:25 +0000 (15:04 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Fri, 15 Dec 2000 15:04:25 +0000 (15:04 +0000)
lib/silccore/id.h
lib/silccore/idcache.c
lib/silccore/idcache.h

index 9da7f87376c04510ceccb153cd96ab04f3e3647b..5da1d7ee79859dddbc5a4ec0ac8ef1d084649e0b 100644 (file)
@@ -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);
index 9dc176f3c84401806870adab7decc839a0427924..b35d23bf0d03ec798c5911db681833ec4f4ecd20 100644 (file)
@@ -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;
index 582019ceff79d3405458b68ddd73c75c3a4c4404..9421caf0a1d0d7c692c585de6c8def099de64380 100644 (file)
@@ -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);