[Pkg-clamav-commits] [SCM] Debian repository for ClamAV branch, debian/unstable, updated. debian/0.95+dfsg-1-6156-g094ec9b
Tomasz Kojm
tkojm at clamav.net
Sun Apr 4 00:59:26 UTC 2010
The following commit has been merged in the debian/unstable branch:
commit cc447ac82c78343e7026769206920e50775742a5
Author: Tomasz Kojm <tkojm at clamav.net>
Date: Tue Aug 4 23:17:28 2009 +0200
configure, libclamav: fix compile issues on IRIX (bb#1532)
diff --git a/ChangeLog b/ChangeLog
index 6c22fa8..a5d3ae3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Tue Aug 4 23:15:26 CEST 2009 (tk)
+----------------------------------
+ * configure, libclamav: fix compile issues on IRIX (bb#1532)
+
Tue Aug 4 20:24:06 CEST 2009 (tk)
----------------------------------
* libclamav/macho.c: wrap unistd.h, reported by Nigel Horne
diff --git a/configure b/configure
index 6d2500f..914b238 100755
--- a/configure
+++ b/configure
@@ -20945,6 +20945,7 @@ cat >>confdefs.h <<\_ACEOF
_ACEOF
fi
+ LIBS="$LIBS -lgen"
cat >>confdefs.h <<\_ACEOF
#define C_IRIX 1
diff --git a/configure.in b/configure.in
index 7a97f37..7a001cc 100644
--- a/configure.in
+++ b/configure.in
@@ -1084,6 +1084,7 @@ irix*)
AC_DEFINE([CL_THREAD_SAFE],1,[thread safe])
AC_DEFINE([_REENTRANT],1,[thread safe])
fi
+ LIBS="$LIBS -lgen"
AC_DEFINE([C_IRIX],1,[os is irix])
;;
interix*)
diff --git a/contrib/entitynorm/generate_encoding_aliases.c b/contrib/entitynorm/generate_encoding_aliases.c
index f7df968..fa39e1e 100644
--- a/contrib/entitynorm/generate_encoding_aliases.c
+++ b/contrib/entitynorm/generate_encoding_aliases.c
@@ -62,16 +62,16 @@ extern short cli_debug_flag;
int main(int argc, char* argv[])
{
- struct hashtable ht;
+ struct cli_hashtable ht;
size_t i;
cli_debug_flag=1;
- hashtab_init(&ht,aliases_cnt);
+ cli_hashtab_init(&ht,aliases_cnt);
for(i=0;i < aliases_cnt;i++) {
- hashtab_insert(&ht,(const unsigned char*)aliases[i].alias,strlen(aliases[i].alias),aliases[i].encoding);
+ cli_hashtab_insert(&ht,(const unsigned char*)aliases[i].alias,strlen(aliases[i].alias),aliases[i].encoding);
}
- hashtab_generate_c(&ht,"aliases_htable");
+ cli_hashtab_generate_c(&ht,"aliases_htable");
return 0;
}
diff --git a/contrib/entitynorm/generate_entitylist.c b/contrib/entitynorm/generate_entitylist.c
index e720ae3..90b6d30 100644
--- a/contrib/entitynorm/generate_entitylist.c
+++ b/contrib/entitynorm/generate_entitylist.c
@@ -32,7 +32,7 @@
static uint16_t* map_data = NULL;
static size_t map_data_n = 0;
-static void loadEntities(struct hashtable* s)
+static void loadEntities(struct cli_hashtable* s)
{
char line[MAX_LINE];
@@ -40,7 +40,7 @@ static void loadEntities(struct hashtable* s)
const char* name = line;
char* mapto;
size_t val;
- struct element* elem;
+ struct cli_element* elem;
uint16_t converted;
int found=0, i;
@@ -52,27 +52,27 @@ static void loadEntities(struct hashtable* s)
*mapto++ = '\0';
mapto[strlen(mapto)-1] = '\0';
- if(elem = hashtab_find(s,name,strlen(name))) {
+ if(elem = cli_hashtab_find(s,name,strlen(name))) {
if(strlen(elem->key) == strlen(name)) {
fprintf(stderr, "Duplicate entity:%s\n", name);
}
continue;
}
converted = atoi(mapto);
- hashtab_insert(s,name,strlen(name), converted);
+ cli_hashtab_insert(s,name,strlen(name), converted);
}
}
extern short cli_debug_flag;
int main(int argc, char* argv[])
{
- struct hashtable ht;
+ struct cli_hashtable ht;
int i;
cli_debug_flag=1;
- hashtab_init(&ht,2048);
+ cli_hashtab_init(&ht,2048);
loadEntities(&ht);
- hashtab_generate_c(&ht,"entities_htable");
+ cli_hashtab_generate_c(&ht,"entities_htable");
return 0;
}
diff --git a/libclamav/encoding_aliases.h b/libclamav/encoding_aliases.h
index 1702916..bed5a5f 100644
--- a/libclamav/encoding_aliases.h
+++ b/libclamav/encoding_aliases.h
@@ -21,7 +21,7 @@
*/
#include <hashtab.h>
-static struct element aliases_htable_elements[] = {
+static struct cli_element aliases_htable_elements[] = {
{NULL,0,0},
{NULL,0,0},
{NULL,0,0},
@@ -87,6 +87,6 @@ static struct element aliases_htable_elements[] = {
{NULL,0,0},
{NULL,0,0},
};
-const struct hashtable aliases_htable = {
+const struct cli_hashtable aliases_htable = {
aliases_htable_elements, 64, 25, 51
};
diff --git a/libclamav/entconv.c b/libclamav/entconv.c
index 11d5b98..c073ac0 100644
--- a/libclamav/entconv.c
+++ b/libclamav/entconv.c
@@ -113,7 +113,7 @@ unsigned char* u16_normalize_tobuffer(uint16_t u16, unsigned char* dst, size_t d
const char* entity_norm(struct entity_conv* conv,const unsigned char* entity)
{
- struct element* e = hashtab_find(&entities_htable, (const char*)entity, strlen((const char*)entity));
+ struct cli_element* e = cli_hashtab_find(&entities_htable, (const char*)entity, strlen((const char*)entity));
if(e && e->key) {
unsigned char* out = u16_normalize(e->data, conv->entity_buff, sizeof(conv->entity_buff)-1);
if(out) {
@@ -128,7 +128,7 @@ const char* entity_norm(struct entity_conv* conv,const unsigned char* entity)
static size_t encoding_bytes(const char* fromcode, enum encodings* encoding)
{
/* special case for these unusual byteorders */
- struct element * e = hashtab_find(&aliases_htable,fromcode,strlen(fromcode));
+ struct cli_element * e = cli_hashtab_find(&aliases_htable,fromcode,strlen(fromcode));
if(e && e->key) {
*encoding = e->data;
} else {
@@ -534,7 +534,7 @@ struct iconv_cache {
iconv_t* tab;
size_t len;
size_t last;
- struct hashtable hashtab;
+ struct cli_hashtable hashtab;
};
static void iconv_cache_init(struct iconv_cache* cache)
@@ -543,7 +543,7 @@ static void iconv_cache_init(struct iconv_cache* cache)
cache->len = 0;
cache->used = 0; - already done by memset*/
cli_dbgmsg(MODULE_NAME "Initializing iconv pool:%p\n",(void*)cache);
- hashtab_init(&cache->hashtab, 32);
+ cli_hashtab_init(&cache->hashtab, 32);
}
static void iconv_cache_destroy(struct iconv_cache* cache)
@@ -554,7 +554,7 @@ static void iconv_cache_destroy(struct iconv_cache* cache)
cli_dbgmsg(MODULE_NAME "closing iconv:%p\n",cache->tab[i]);
iconv_close(cache->tab[i]);
}
- hashtab_clear(&cache->hashtab);
+ cli_hashtab_clear(&cache->hashtab);
free(cache->hashtab.htable);
free(cache->tab);
free(cache);
@@ -655,7 +655,7 @@ static iconv_t iconv_open_cached(const char* fromcode)
struct iconv_cache * cache;
size_t idx;
const size_t fromcode_len = strlen((const char*)fromcode);
- struct element * e;
+ struct cli_element * e;
iconv_t iconv_struct;
init_iconv_pool_ifneeded();
@@ -666,7 +666,7 @@ static iconv_t iconv_open_cached(const char* fromcode)
return (iconv_t)-1;
}
- e = hashtab_find(&cache->hashtab, fromcode, fromcode_len);
+ e = cli_hashtab_find(&cache->hashtab, fromcode, fromcode_len);
if(e && (e->data < 0 || (size_t)e->data > cache->len)) {
e = NULL;
}
@@ -690,7 +690,7 @@ static iconv_t iconv_open_cached(const char* fromcode)
}
}
- hashtab_insert(&cache->hashtab, fromcode, fromcode_len, idx);
+ cli_hashtab_insert(&cache->hashtab, fromcode, fromcode_len, idx);
cache->tab[idx] = iconv_struct;
cli_dbgmsg(MODULE_NAME "iconv_open(),for:%s -> %p\n",fromcode,(void*)cache->tab[idx]);
return cache->tab[idx];
diff --git a/libclamav/entitylist.h b/libclamav/entitylist.h
index 6eef96d..0d452be 100644
--- a/libclamav/entitylist.h
+++ b/libclamav/entitylist.h
@@ -19,7 +19,7 @@
*/
#include <hashtab.h>
-static struct element entities_htable_elements[] = {
+static struct cli_element entities_htable_elements[] = {
{"rsaquo", 8250, 6},
{NULL,0,0},
{NULL,0,0},
@@ -2069,6 +2069,6 @@ static struct element entities_htable_elements[] = {
{NULL,0,0},
{NULL,0,0},
};
-const struct hashtable entities_htable = {
+const struct cli_hashtable entities_htable = {
entities_htable_elements, 2048, 743, 1638
};
diff --git a/libclamav/hashtab.c b/libclamav/hashtab.c
index 2cb5aef..c5f899e 100644
--- a/libclamav/hashtab.c
+++ b/libclamav/hashtab.c
@@ -52,82 +52,82 @@ static unsigned long nearest_power(unsigned long num)
* and then these functions modify something the compiler assumes is readonly.
* Please, never use PROFILE_HASHTABLE in production code, and in releases. Use it for development only!*/
-static inline void PROFILE_INIT(struct hashtable *s)
+static inline void PROFILE_INIT(struct cli_hashtable *s)
{
memset(&s->PROFILE_STRUCT,0,sizeof(s->PROFILE_STRUCT));
}
-static inline void PROFILE_CALC_HASH(struct hashtable *s)
+static inline void PROFILE_CALC_HASH(struct cli_hashtable *s)
{
s->PROFILE_STRUCT.calc_hash++;
}
-static inline void PROFILE_FIND_ELEMENT(struct hashtable *s)
+static inline void PROFILE_FIND_ELEMENT(struct cli_hashtable *s)
{
s->PROFILE_STRUCT.find_req++;
}
-static inline void PROFILE_FIND_NOTFOUND(struct hashtable *s, size_t tries)
+static inline void PROFILE_FIND_NOTFOUND(struct cli_hashtable *s, size_t tries)
{
s->PROFILE_STRUCT.not_found++;
s->PROFILE_STRUCT.not_found_tries += tries;
}
-static inline void PROFILE_FIND_FOUND(struct hashtable *s, size_t tries)
+static inline void PROFILE_FIND_FOUND(struct cli_hashtable *s, size_t tries)
{
s->PROFILE_STRUCT.found++;
s->PROFILE_STRUCT.found_tries += tries;
}
-static inline void PROFILE_HASH_EXHAUSTED(struct hashtable *s)
+static inline void PROFILE_HASH_EXHAUSTED(struct cli_hashtable *s)
{
s->PROFILE_STRUCT.hash_exhausted++;
}
-static inline void PROFILE_GROW_START(struct hashtable *s)
+static inline void PROFILE_GROW_START(struct cli_hashtable *s)
{
s->PROFILE_STRUCT.grow++;
}
-static inline void PROFILE_GROW_FOUND(struct hashtable *s, size_t tries)
+static inline void PROFILE_GROW_FOUND(struct cli_hashtable *s, size_t tries)
{
s->PROFILE_STRUCT.grow_found++;
s->PROFILE_STRUCT.grow_found_tries += tries;
}
-static inline void PROFILE_GROW_DONE(struct hashtable *s)
+static inline void PROFILE_GROW_DONE(struct cli_hashtable *s)
{
}
-static inline void PROFILE_DELETED_REUSE(struct hashtable *s, size_t tries)
+static inline void PROFILE_DELETED_REUSE(struct cli_hashtable *s, size_t tries)
{
s->PROFILE_STRUCT.deleted_reuse++;
s->PROFILE_STRUCT.deleted_tries += tries;
}
-static inline void PROFILE_INSERT(struct hashtable *s, size_t tries)
+static inline void PROFILE_INSERT(struct cli_hashtable *s, size_t tries)
{
s->PROFILE_STRUCT.inserts++;
s->PROFILE_STRUCT.insert_tries += tries;
}
-static inline void PROFILE_DATA_UPDATE(struct hashtable *s, size_t tries)
+static inline void PROFILE_DATA_UPDATE(struct cli_hashtable *s, size_t tries)
{
s->PROFILE_STRUCT.update++;
s->PROFILE_STRUCT.update_tries += tries;
}
-static inline void PROFILE_HASH_DELETE(struct hashtable *s)
+static inline void PROFILE_HASH_DELETE(struct cli_hashtable *s)
{
s->PROFILE_STRUCT.deletes++;
}
-static inline void PROFILE_HASH_CLEAR(struct hashtable *s)
+static inline void PROFILE_HASH_CLEAR(struct cli_hashtable *s)
{
s->PROFILE_STRUCT.clear++;
}
-static inline void PROFILE_REPORT(const struct hashtable *s)
+static inline void PROFILE_REPORT(const struct cli_hashtable *s)
{
size_t lookups, queries, insert_tries, inserts;
cli_dbgmsg("--------Hashtable usage report for %p--------------\n",(const void*)s);
@@ -168,7 +168,7 @@ static inline void PROFILE_REPORT(const struct hashtable *s)
#define PROFILE_REPORT(s)
#endif
-int hashtab_init(struct hashtable *s,size_t capacity)
+int cli_hashtab_init(struct cli_hashtable *s,size_t capacity)
{
if(!s)
return CL_ENULLARG;
@@ -211,9 +211,9 @@ static inline size_t hash(const unsigned char* k,const size_t len,const size_t S
}
/* if returned element has key==NULL, then key was not found in table */
-struct element* hashtab_find(const struct hashtable *s,const char* key,const size_t len)
+struct cli_element* cli_hashtab_find(const struct cli_hashtable *s,const char* key,const size_t len)
{
- struct element* element;
+ struct cli_element* element;
size_t tries = 1;
size_t idx;
@@ -241,10 +241,10 @@ struct element* hashtab_find(const struct hashtable *s,const char* key,const siz
return NULL; /* not found */
}
-static int hashtab_grow(struct hashtable *s)
+static int cli_hashtab_grow(struct cli_hashtable *s)
{
const size_t new_capacity = nearest_power(s->capacity + 1);
- struct element* htable = cli_calloc(new_capacity, sizeof(*s->htable));
+ struct cli_element* htable = cli_calloc(new_capacity, sizeof(*s->htable));
size_t i,idx, used = 0;
cli_dbgmsg("hashtab.c: new capacity: %lu\n",new_capacity);
if(new_capacity == s->capacity || !htable)
@@ -254,7 +254,7 @@ static int hashtab_grow(struct hashtable *s)
cli_dbgmsg("hashtab.c: Warning: growing open-addressing hashtables is slow. Either allocate more storage when initializing, or use other hashtable types!\n");
for(i=0; i < s->capacity;i++) {
if(s->htable[i].key && s->htable[i].key != DELETED_KEY) {
- struct element* element;
+ struct cli_element* element;
size_t tries = 1;
PROFILE_CALC_HASH(s);
@@ -287,17 +287,17 @@ static int hashtab_grow(struct hashtable *s)
return CL_SUCCESS;
}
-const struct element* hashtab_insert(struct hashtable *s, const char* key, const size_t len, const element_data data)
+const struct cli_element* cli_hashtab_insert(struct cli_hashtable *s, const char* key, const size_t len, const cli_element_data data)
{
- struct element* element;
- struct element* deleted_element = NULL;
+ struct cli_element* element;
+ struct cli_element* deleted_element = NULL;
size_t tries = 1;
size_t idx;
if(!s)
return NULL;
if(s->used > s->maxfill) {
cli_dbgmsg("hashtab.c:Growing hashtable %p, because it has exceeded maxfill, old size:%ld\n",(void*)s,s->capacity);
- hashtab_grow(s);
+ cli_hashtab_grow(s);
}
do {
PROFILE_CALC_HASH(s);
@@ -343,12 +343,12 @@ const struct element* hashtab_insert(struct hashtable *s, const char* key, const
/* no free place found*/
PROFILE_HASH_EXHAUSTED(s);
cli_dbgmsg("hashtab.c: Growing hashtable %p, because its full, old size:%ld.\n",(void*)s,s->capacity);
- } while( hashtab_grow(s) >= 0 );
+ } while( cli_hashtab_grow(s) >= 0 );
cli_warnmsg("hashtab.c: Unable to grow hashtable\n");
return NULL;
}
-void hashtab_clear(struct hashtable *s)
+void cli_hashtab_clear(struct cli_hashtable *s)
{
size_t i;
PROFILE_HASH_CLEAR(s);
@@ -361,19 +361,19 @@ void hashtab_clear(struct hashtable *s)
s->used = 0;
}
-void hashtab_free(struct hashtable *s)
+void cli_hashtab_free(struct cli_hashtable *s)
{
- hashtab_clear(s);
+ cli_hashtab_clear(s);
free(s->htable);
s->htable = NULL;
s->capacity = 0;
}
-int hashtab_store(const struct hashtable *s,FILE* out)
+int cli_hashtab_store(const struct cli_hashtable *s,FILE* out)
{
size_t i;
for(i=0; i < s->capacity; i++) {
- const struct element* e = &s->htable[i];
+ const struct cli_element* e = &s->htable[i];
if(e->key && e->key != DELETED_KEY) {
fprintf(out,"%ld %s\n",e->data,e->key);
}
@@ -381,14 +381,14 @@ int hashtab_store(const struct hashtable *s,FILE* out)
return CL_SUCCESS;
}
-int hashtab_generate_c(const struct hashtable *s,const char* name)
+int cli_hashtab_generate_c(const struct cli_hashtable *s,const char* name)
{
size_t i;
printf("/* TODO: include GPL headers */\n");
printf("#include <hashtab.h>\n");
- printf("static struct element %s_elements[] = {\n",name);
+ printf("static struct cli_element %s_elements[] = {\n",name);
for(i=0; i < s->capacity; i++) {
- const struct element* e = &s->htable[i];
+ const struct cli_element* e = &s->htable[i];
if(!e->key)
printf("\t{NULL,0,0},\n");
else if(e->key == DELETED_KEY)
@@ -397,7 +397,7 @@ int hashtab_generate_c(const struct hashtable *s,const char* name)
printf("\t{\"%s\", %ld, %ld},\n", e->key, e->data, e->len);
}
printf("};\n");
- printf("const struct hashtable %s = {\n",name);
+ printf("const struct cli_hashtable %s = {\n",name);
printf("\t%s_elements, %ld, %ld, %ld", name, s->capacity, s->used, s->maxfill);
printf("\n};\n");
@@ -405,21 +405,21 @@ int hashtab_generate_c(const struct hashtable *s,const char* name)
return 0;
}
-int hashtab_load(FILE* in, struct hashtable *s)
+int cli_hashtab_load(FILE* in, struct cli_hashtable *s)
{
char line[1024];
while (fgets(line, sizeof(line), in)) {
char l[1024];
int val;
sscanf(line,"%d %1023s",&val,l);
- hashtab_insert(s,l,strlen(l),val);
+ cli_hashtab_insert(s,l,strlen(l),val);
}
return CL_SUCCESS;
}
/* Initialize hashset. @initial_capacity is rounded to nearest power of 2.
* Load factor is between 50 and 99. When capacity*load_factor/100 is reached, the hashset is growed */
-int hashset_init(struct hashset* hs, size_t initial_capacity, uint8_t load_factor)
+int cli_hashset_init(struct cli_hashset* hs, size_t initial_capacity, uint8_t load_factor)
{
if(load_factor < 50 || load_factor > 99) {
cli_dbgmsg(MODULE_NAME "Invalid load factor: %u, using default of 80%%\n", load_factor);
@@ -442,7 +442,7 @@ int hashset_init(struct hashset* hs, size_t initial_capacity, uint8_t load_facto
return 0;
}
-void hashset_destroy(struct hashset* hs)
+void cli_hashset_destroy(struct cli_hashset* hs)
{
cli_dbgmsg(MODULE_NAME "Freeing hashset, elements: %u, capacity: %u\n", hs->count, hs->capacity);
free(hs->keys);
@@ -458,7 +458,7 @@ void hashset_destroy(struct hashset* hs)
* searches the hashset for the @key.
* Returns the position the key is at, or a candidate position where it could be inserted.
*/
-static inline size_t hashset_search(const struct hashset* hs, const uint32_t key)
+static inline size_t cli_hashset_search(const struct cli_hashset* hs, const uint32_t key)
{
/* calculate hash value for this key, and map it to our table */
size_t idx = hash32shift(key) & (hs->mask);
@@ -476,9 +476,9 @@ static inline size_t hashset_search(const struct hashset* hs, const uint32_t key
}
-static void hashset_addkey_internal(struct hashset* hs, const uint32_t key)
+static void cli_hashset_addkey_internal(struct cli_hashset* hs, const uint32_t key)
{
- const size_t idx = hashset_search(hs, key);
+ const size_t idx = cli_hashset_search(hs, key);
/* we know hashtable is not full, when this method is called */
if(!BITMAP_CONTAINS(hs->bitmap, idx)) {
@@ -489,9 +489,9 @@ static void hashset_addkey_internal(struct hashset* hs, const uint32_t key)
}
}
-static int hashset_grow(struct hashset *hs)
+static int cli_hashset_grow(struct cli_hashset *hs)
{
- struct hashset new_hs;
+ struct cli_hashset new_hs;
size_t i;
int rc;
@@ -499,43 +499,43 @@ static int hashset_grow(struct hashset *hs)
* will hash to different locations. */
cli_dbgmsg(MODULE_NAME "Growing hashset, used: %u, capacity: %u\n", hs->count, hs->capacity);
/* create a bigger hashset */
- if((rc = hashset_init(&new_hs, hs->capacity << 1, hs->limit*100/hs->capacity)) < 0) {
+ if((rc = cli_hashset_init(&new_hs, hs->capacity << 1, hs->limit*100/hs->capacity)) < 0) {
return rc;
}
/* and copy keys */
for(i=0;i < hs->capacity;i++) {
if(BITMAP_CONTAINS(hs->bitmap, i)) {
const size_t key = hs->keys[i];
- hashset_addkey_internal(&new_hs, key);
+ cli_hashset_addkey_internal(&new_hs, key);
}
}
- hashset_destroy(hs);
+ cli_hashset_destroy(hs);
/* replace old hashset with new one */
*hs = new_hs;
return 0;
}
-int hashset_addkey(struct hashset* hs, const uint32_t key)
+int cli_hashset_addkey(struct cli_hashset* hs, const uint32_t key)
{
/* check that we didn't reach the load factor.
* Even if we don't know yet whether we'd add this key */
if(hs->count + 1 > hs->limit) {
- int rc = hashset_grow(hs);
+ int rc = cli_hashset_grow(hs);
if(rc) {
return rc;
}
}
- hashset_addkey_internal(hs, key);
+ cli_hashset_addkey_internal(hs, key);
return 0;
}
-int hashset_contains(const struct hashset* hs, const uint32_t key)
+int cli_hashset_contains(const struct cli_hashset* hs, const uint32_t key)
{
- const size_t idx = hashset_search(hs, key);
+ const size_t idx = cli_hashset_search(hs, key);
return BITMAP_CONTAINS(hs->bitmap, idx);
}
-ssize_t hashset_toarray(const struct hashset* hs, uint32_t** array)
+ssize_t cli_hashset_toarray(const struct cli_hashset* hs, uint32_t** array)
{
size_t i, j;
uint32_t* arr;
diff --git a/libclamav/hashtab.h b/libclamav/hashtab.h
index 1a0cd32..d06858d 100644
--- a/libclamav/hashtab.h
+++ b/libclamav/hashtab.h
@@ -25,7 +25,7 @@
#include <stdio.h>
#include <stddef.h>
#include "cltypes.h"
-typedef long element_data;
+typedef long cli_element_data;
/* define this for debugging/profiling purposes only, NOT in production/release code */
#ifdef PROFILE_HASHTABLE
@@ -58,15 +58,15 @@ typedef struct {
#define STRUCT_PROFILE
#endif
-struct element
+struct cli_element
{
const char* key;
- element_data data;
+ cli_element_data data;
size_t len;
};
-struct hashtable {
- struct element* htable;
+struct cli_hashtable {
+ struct cli_element* htable;
size_t capacity;
size_t used;
size_t maxfill;/* 80% */
@@ -76,18 +76,18 @@ struct hashtable {
-int hashtab_generate_c(const struct hashtable *s,const char* name);
-struct element* hashtab_find(const struct hashtable *s, const char* key, const size_t len);
-int hashtab_init(struct hashtable *s,size_t capacity);
-const struct element* hashtab_insert(struct hashtable *s, const char* key, const size_t len, const element_data data);
-void hashtab_delete(struct hashtable *s,const char* key,const size_t len);
-void hashtab_clear(struct hashtable *s);
-void hashtab_free(struct hashtable *s);
-int hashtab_load(FILE* in, struct hashtable *s);
-int hashtab_store(const struct hashtable *s,FILE* out);
+int cli_hashtab_generate_c(const struct cli_hashtable *s,const char* name);
+struct cli_element* cli_hashtab_find(const struct cli_hashtable *s, const char* key, const size_t len);
+int cli_hashtab_init(struct cli_hashtable *s,size_t capacity);
+const struct cli_element* cli_hashtab_insert(struct cli_hashtable *s, const char* key, const size_t len, const cli_element_data data);
+void cli_hashtab_delete(struct cli_hashtable *s,const char* key,const size_t len);
+void cli_hashtab_clear(struct cli_hashtable *s);
+void cli_hashtab_free(struct cli_hashtable *s);
+int cli_hashtab_load(FILE* in, struct cli_hashtable *s);
+int cli_hashtab_store(const struct cli_hashtable *s,FILE* out);
/* A set of unique keys. */
-struct hashset {
+struct cli_hashset {
uint32_t* keys;
uint32_t* bitmap;
uint32_t capacity;
@@ -96,12 +96,12 @@ struct hashset {
uint32_t limit;
};
-int hashset_init(struct hashset* hs, size_t initial_capacity, uint8_t load_factor);
-int hashset_addkey(struct hashset* hs, const uint32_t key);
-int hashset_removekey(struct hashset* hs, const uint32_t key);
-int hashset_contains(const struct hashset* hs, const uint32_t key);
-int hashset_clear(struct hashset* hs);
-void hashset_destroy(struct hashset* hs);
-ssize_t hashset_toarray(const struct hashset* hs, uint32_t** array);
+int cli_hashset_init(struct cli_hashset* hs, size_t initial_capacity, uint8_t load_factor);
+int cli_hashset_addkey(struct cli_hashset* hs, const uint32_t key);
+int cli_hashset_removekey(struct cli_hashset* hs, const uint32_t key);
+int cli_hashset_contains(const struct cli_hashset* hs, const uint32_t key);
+int cli_hashset_clear(struct cli_hashset* hs);
+void cli_hashset_destroy(struct cli_hashset* hs);
+ssize_t cli_hashset_toarray(const struct cli_hashset* hs, uint32_t** array);
#endif
diff --git a/libclamav/jsparse/js-norm.c b/libclamav/jsparse/js-norm.c
index d8b5bb1..4264836 100644
--- a/libclamav/jsparse/js-norm.c
+++ b/libclamav/jsparse/js-norm.c
@@ -89,7 +89,7 @@ enum fsm_state {
};
struct scope {
- struct hashtable id_map;
+ struct cli_hashtable id_map;
struct scope *parent;/* hierarchy */
struct scope *nxt;/* all scopes kept in a list so we can easily free all of them */
enum fsm_state fsm_state;
@@ -122,7 +122,7 @@ static struct scope* scope_new(struct parser_state *state)
struct scope *s = cli_calloc(1, sizeof(*s));
if(!s)
return NULL;
- if(hashtab_init(&s->id_map, 10) < 0) {
+ if(cli_hashtab_init(&s->id_map, 10) < 0) {
free(s);
return NULL;
}
@@ -138,7 +138,7 @@ static struct scope* scope_done(struct scope *s)
{
struct scope* parent = s->parent;
/* TODO: have a hashtab_destroy */
- hashtab_clear(&s->id_map);
+ cli_hashtab_clear(&s->id_map);
free(s->id_map.htable);
free(s);
return parent;
@@ -250,15 +250,15 @@ static struct scope* scope_done(struct scope *s)
static const char* scope_declare(struct scope *s, const char *token, const size_t len, struct parser_state *state)
{
- const struct element *el = hashtab_insert(&s->id_map, token, len, state->var_uniq++);
- /* hashtab_insert either finds an already existing entry, or allocates a
+ const struct cli_element *el = cli_hashtab_insert(&s->id_map, token, len, state->var_uniq++);
+ /* cli_hashtab_insert either finds an already existing entry, or allocates a
* new one, we return the allocated string */
return el ? el->key : NULL;
}
static const char* scope_use(struct scope *s, const char *token, const size_t len)
{
- const struct element *el = hashtab_find(&s->id_map, token, len);
+ const struct cli_element *el = cli_hashtab_find(&s->id_map, token, len);
if(el) {
/* identifier already found in current scope,
* return here to avoid overwriting uniq id */
@@ -268,14 +268,14 @@ static const char* scope_use(struct scope *s, const char *token, const size_t le
* Later if we find a declaration it will automatically assign a uniq ID
* to it. If not, we'll know that we have to push ID == -1 tokens to an
* outer scope.*/
- el = hashtab_insert(&s->id_map, token, len, -1);
+ el = cli_hashtab_insert(&s->id_map, token, len, -1);
return el ? el->key : NULL;
}
static long scope_lookup(struct scope *s, const char *token, const size_t len)
{
while(s) {
- const struct element *el = hashtab_find(&s->id_map, token, len);
+ const struct cli_element *el = cli_hashtab_find(&s->id_map, token, len);
if(el && el->data != -1) {
return el->data;
}
diff --git a/libclamav/matcher.h b/libclamav/matcher.h
index 0069cb1..82d030b 100644
--- a/libclamav/matcher.h
+++ b/libclamav/matcher.h
@@ -72,7 +72,7 @@ struct cli_matcher {
/* Extended Boyer-Moore */
uint8_t *bm_shift;
struct cli_bm_patt **bm_suffix;
- struct hashset md5_sizes_hs;
+ struct cli_hashset md5_sizes_hs;
uint32_t *soff, soff_len; /* for PE section sigs */
uint32_t bm_patterns;
diff --git a/libclamav/ole2_extract.c b/libclamav/ole2_extract.c
index f076f77..9766ac8 100644
--- a/libclamav/ole2_extract.c
+++ b/libclamav/ole2_extract.c
@@ -48,8 +48,6 @@
#include "others.h"
#include "ole2_extract.h"
#include "scanners.h"
-#include "hashtab.h"
-
#include "mbox.h"
#define ole2_endian_convert_16(v) le16_to_host((uint16_t)(v))
diff --git a/libclamav/readdb.c b/libclamav/readdb.c
index 293753f..6d2cc19 100644
--- a/libclamav/readdb.c
+++ b/libclamav/readdb.c
@@ -83,7 +83,7 @@ struct cli_ignsig {
};
struct cli_ignored {
- struct hashset hs;
+ struct cli_hashset hs;
struct cli_ignsig *list;
};
@@ -429,7 +429,7 @@ static int cli_chkign(const struct cli_ignored *ignored, const char *dbname, uns
if(!ignored || !dbname || !signame)
return 0;
- if(hashset_contains(&ignored->hs, line)) {
+ if(cli_hashset_contains(&ignored->hs, line)) {
pt = ignored->list;
while(pt) {
if(pt->line == line && !strcmp(pt->dbname, dbname) && !strcmp(pt->signame, signame)) {
@@ -1198,7 +1198,7 @@ static int cli_loadign(FILE *fs, struct cl_engine *engine, unsigned int options,
if(!engine->ignored) {
engine->ignored = (struct cli_ignored *) cli_calloc(sizeof(struct cli_ignored), 1);
- if(!engine->ignored || hashset_init(&engine->ignored->hs, 64, 50))
+ if(!engine->ignored || cli_hashset_init(&engine->ignored->hs, 64, 50))
return CL_EMEM;
}
@@ -1233,7 +1233,7 @@ static int cli_loadign(FILE *fs, struct cl_engine *engine, unsigned int options,
new->line = atoi(tokens[1]);
- if((ret = hashset_addkey(&engine->ignored->hs, new->line)))
+ if((ret = cli_hashset_addkey(&engine->ignored->hs, new->line)))
break;
new->signame = cli_mpool_strdup(engine->mempool, tokens[2]);
@@ -1269,7 +1269,7 @@ static void cli_freeign(struct cl_engine *engine)
mpool_free(engine->mempool, pt->signame);
mpool_free(engine->mempool,pt);
}
- hashset_destroy(&ignored->hs);
+ cli_hashset_destroy(&ignored->hs);
free(engine->ignored);
engine->ignored = NULL;
}
@@ -1404,9 +1404,9 @@ static int cli_loadmd5(FILE *fs, struct cl_engine *engine, unsigned int *signo,
if(mode == MD5_MDB) { /* section MD5 */
if(!db->md5_sizes_hs.capacity) {
- hashset_init(&db->md5_sizes_hs, 65536, 80);
+ cli_hashset_init(&db->md5_sizes_hs, 65536, 80);
}
- hashset_addkey(&db->md5_sizes_hs, size);
+ cli_hashset_addkey(&db->md5_sizes_hs, size);
}
sigs++;
@@ -2112,7 +2112,7 @@ int cl_engine_free(struct cl_engine *engine)
cli_bm_free(root);
mpool_free(engine->mempool, root->soff);
if(root->md5_sizes_hs.capacity) {
- hashset_destroy(&root->md5_sizes_hs);
+ cli_hashset_destroy(&root->md5_sizes_hs);
}
mpool_free(engine->mempool, root);
}
@@ -2173,14 +2173,14 @@ static void cli_md5db_build(struct cli_matcher* root)
uint32_t *mpoolht;
unsigned int mpoolhtsz = root->md5_sizes_hs.count * sizeof(*mpoolht);
root->soff = mpool_malloc(root->mempool, mpoolhtsz);
- root->soff_len = hashset_toarray(&root->md5_sizes_hs, &mpoolht);
+ root->soff_len = cli_hashset_toarray(&root->md5_sizes_hs, &mpoolht);
memcpy(root->soff, mpoolht, mpoolhtsz);
free(mpoolht);
}
#else
- root->soff_len = hashset_toarray(&root->md5_sizes_hs, &root->soff);
+ root->soff_len = cli_hashset_toarray(&root->md5_sizes_hs, &root->soff);
#endif
- hashset_destroy(&root->md5_sizes_hs);
+ cli_hashset_destroy(&root->md5_sizes_hs);
qsort(root->soff, root->soff_len, sizeof(uint32_t), scomp);
}
}
diff --git a/libclamav/regex_list.c b/libclamav/regex_list.c
index 5f46c4a..802829c 100644
--- a/libclamav/regex_list.c
+++ b/libclamav/regex_list.c
@@ -362,7 +362,7 @@ int init_regex_list(struct regex_matcher* matcher)
matcher->list_inited=1;
matcher->list_built=0;
matcher->list_loaded=0;
- hashtab_init(&matcher->suffix_hash, 512);
+ cli_hashtab_init(&matcher->suffix_hash, 512);
#ifdef USE_MPOOL
matcher->mempool = mp;
matcher->suffixes.mempool = mp;
@@ -448,13 +448,13 @@ static int add_hash(struct regex_matcher *matcher, char* pattern, const char fl,
}
if (!matcher->sha256_pfx_set.keys) {
- if((rc = hashset_init(&matcher->sha256_pfx_set, 1048576, 90))) {
+ if((rc = cli_hashset_init(&matcher->sha256_pfx_set, 1048576, 90))) {
return rc;
}
}
if (fl != 'W' && pat->length == 32 &&
- hashset_contains(&matcher->sha256_pfx_set, cli_readint32(pat->pattern)) &&
+ cli_hashset_contains(&matcher->sha256_pfx_set, cli_readint32(pat->pattern)) &&
cli_bm_scanbuff(pat->pattern, 32, &vname, &matcher->sha256_hashes,0,0,-1) == CL_VIRUS) {
if (*vname == 'W') {
/* hash is whitelisted in local.gdb */
@@ -470,7 +470,7 @@ static int add_hash(struct regex_matcher *matcher, char* pattern, const char fl,
return CL_EMEM;
}
*pat->virname = fl;
- hashset_addkey(&matcher->sha256_pfx_set, cli_readint32(pat->pattern));
+ cli_hashset_addkey(&matcher->sha256_pfx_set, cli_readint32(pat->pattern));
if((rc = cli_bm_addpatt(bm, pat))) {
cli_errmsg("add_hash: failed to add BM pattern\n");
free(pat->pattern);
@@ -607,11 +607,11 @@ int cli_build_regex_list(struct regex_matcher* matcher)
return -1;/*TODO: better error code */
}
cli_dbgmsg("Building regex list\n");
- hashtab_free(&matcher->suffix_hash);
+ cli_hashtab_free(&matcher->suffix_hash);
if(( rc = cli_ac_buildtrie(&matcher->suffixes) ))
return rc;
matcher->list_built=1;
- hashset_destroy(&matcher->sha256_pfx_set);
+ cli_hashset_destroy(&matcher->sha256_pfx_set);
return CL_SUCCESS;
}
@@ -645,7 +645,7 @@ void regex_list_done(struct regex_matcher* matcher)
}
mpool_free(matcher->mempool, matcher->all_pregs);
}
- hashtab_free(&matcher->suffix_hash);
+ cli_hashtab_free(&matcher->suffix_hash);
cli_bm_free(&matcher->sha256_hashes);
cli_bm_free(&matcher->hostkey_prefix);
}
@@ -719,7 +719,7 @@ static int add_pattern_suffix(void *cbdata, const char *suffix, size_t suffix_le
{
struct regex_matcher *matcher = cbdata;
struct regex_list *regex = cli_malloc(sizeof(*regex));
- const struct element *el;
+ const struct cli_element *el;
assert(matcher);
if(!regex)
@@ -727,7 +727,7 @@ static int add_pattern_suffix(void *cbdata, const char *suffix, size_t suffix_le
regex->pattern = iregex->pattern ? cli_strdup(iregex->pattern) : NULL;
regex->preg = iregex->preg;
regex->nxt = NULL;
- el = hashtab_find(&matcher->suffix_hash, suffix, suffix_len);
+ el = cli_hashtab_find(&matcher->suffix_hash, suffix, suffix_len);
/* TODO: what if suffixes are prefixes of eachother and only one will
* match? */
if(el) {
@@ -737,7 +737,7 @@ static int add_pattern_suffix(void *cbdata, const char *suffix, size_t suffix_le
} else {
/* new suffix */
size_t n = matcher->suffix_cnt++;
- el = hashtab_insert(&matcher->suffix_hash, suffix, suffix_len, n);
+ el = cli_hashtab_insert(&matcher->suffix_hash, suffix, suffix_len, n);
matcher->suffix_regexes = cli_realloc(matcher->suffix_regexes, (n+1)*sizeof(*matcher->suffix_regexes));
if(!matcher->suffix_regexes)
return CL_EMEM;
diff --git a/libclamav/regex_list.h b/libclamav/regex_list.h
index c1036c0..040a702 100644
--- a/libclamav/regex_list.h
+++ b/libclamav/regex_list.h
@@ -44,7 +44,7 @@ struct regex_list_ht {
};
struct regex_matcher {
- struct hashtable suffix_hash;
+ struct cli_hashtable suffix_hash;
size_t suffix_cnt;
struct regex_list_ht *suffix_regexes;
size_t root_regex_idx;
@@ -52,7 +52,7 @@ struct regex_matcher {
regex_t **all_pregs;
struct cli_matcher suffixes;
struct cli_matcher sha256_hashes;
- struct hashset sha256_pfx_set;
+ struct cli_hashset sha256_pfx_set;
struct cli_matcher hostkey_prefix;
struct filter filter;
#ifdef USE_MPOOL
--
Debian repository for ClamAV
More information about the Pkg-clamav-commits
mailing list