... | ... |
@@ -1,3 +1,7 @@ |
1 |
+Tue Aug 4 23:15:26 CEST 2009 (tk) |
|
2 |
+---------------------------------- |
|
3 |
+ * configure, libclamav: fix compile issues on IRIX (bb#1532) |
|
4 |
+ |
|
1 | 5 |
Tue Aug 4 20:24:06 CEST 2009 (tk) |
2 | 6 |
---------------------------------- |
3 | 7 |
* libclamav/macho.c: wrap unistd.h, reported by Nigel Horne |
... | ... |
@@ -62,16 +62,16 @@ extern short cli_debug_flag; |
62 | 62 |
|
63 | 63 |
int main(int argc, char* argv[]) |
64 | 64 |
{ |
65 |
- struct hashtable ht; |
|
65 |
+ struct cli_hashtable ht; |
|
66 | 66 |
size_t i; |
67 | 67 |
|
68 | 68 |
cli_debug_flag=1; |
69 |
- hashtab_init(&ht,aliases_cnt); |
|
69 |
+ cli_hashtab_init(&ht,aliases_cnt); |
|
70 | 70 |
|
71 | 71 |
for(i=0;i < aliases_cnt;i++) { |
72 |
- hashtab_insert(&ht,(const unsigned char*)aliases[i].alias,strlen(aliases[i].alias),aliases[i].encoding); |
|
72 |
+ cli_hashtab_insert(&ht,(const unsigned char*)aliases[i].alias,strlen(aliases[i].alias),aliases[i].encoding); |
|
73 | 73 |
} |
74 | 74 |
|
75 |
- hashtab_generate_c(&ht,"aliases_htable"); |
|
75 |
+ cli_hashtab_generate_c(&ht,"aliases_htable"); |
|
76 | 76 |
return 0; |
77 | 77 |
} |
... | ... |
@@ -32,7 +32,7 @@ |
32 | 32 |
static uint16_t* map_data = NULL; |
33 | 33 |
static size_t map_data_n = 0; |
34 | 34 |
|
35 |
-static void loadEntities(struct hashtable* s) |
|
35 |
+static void loadEntities(struct cli_hashtable* s) |
|
36 | 36 |
{ |
37 | 37 |
char line[MAX_LINE]; |
38 | 38 |
|
... | ... |
@@ -40,7 +40,7 @@ static void loadEntities(struct hashtable* s) |
40 | 40 |
const char* name = line; |
41 | 41 |
char* mapto; |
42 | 42 |
size_t val; |
43 |
- struct element* elem; |
|
43 |
+ struct cli_element* elem; |
|
44 | 44 |
uint16_t converted; |
45 | 45 |
int found=0, i; |
46 | 46 |
|
... | ... |
@@ -52,27 +52,27 @@ static void loadEntities(struct hashtable* s) |
52 | 52 |
*mapto++ = '\0'; |
53 | 53 |
|
54 | 54 |
mapto[strlen(mapto)-1] = '\0'; |
55 |
- if(elem = hashtab_find(s,name,strlen(name))) { |
|
55 |
+ if(elem = cli_hashtab_find(s,name,strlen(name))) { |
|
56 | 56 |
if(strlen(elem->key) == strlen(name)) { |
57 | 57 |
fprintf(stderr, "Duplicate entity:%s\n", name); |
58 | 58 |
} |
59 | 59 |
continue; |
60 | 60 |
} |
61 | 61 |
converted = atoi(mapto); |
62 |
- hashtab_insert(s,name,strlen(name), converted); |
|
62 |
+ cli_hashtab_insert(s,name,strlen(name), converted); |
|
63 | 63 |
} |
64 | 64 |
} |
65 | 65 |
extern short cli_debug_flag; |
66 | 66 |
|
67 | 67 |
int main(int argc, char* argv[]) |
68 | 68 |
{ |
69 |
- struct hashtable ht; |
|
69 |
+ struct cli_hashtable ht; |
|
70 | 70 |
int i; |
71 | 71 |
cli_debug_flag=1; |
72 |
- hashtab_init(&ht,2048); |
|
72 |
+ cli_hashtab_init(&ht,2048); |
|
73 | 73 |
|
74 | 74 |
loadEntities(&ht); |
75 |
- hashtab_generate_c(&ht,"entities_htable"); |
|
75 |
+ cli_hashtab_generate_c(&ht,"entities_htable"); |
|
76 | 76 |
return 0; |
77 | 77 |
} |
78 | 78 |
|
... | ... |
@@ -21,7 +21,7 @@ |
21 | 21 |
*/ |
22 | 22 |
|
23 | 23 |
#include <hashtab.h> |
24 |
-static struct element aliases_htable_elements[] = { |
|
24 |
+static struct cli_element aliases_htable_elements[] = { |
|
25 | 25 |
{NULL,0,0}, |
26 | 26 |
{NULL,0,0}, |
27 | 27 |
{NULL,0,0}, |
... | ... |
@@ -87,6 +87,6 @@ static struct element aliases_htable_elements[] = { |
87 | 87 |
{NULL,0,0}, |
88 | 88 |
{NULL,0,0}, |
89 | 89 |
}; |
90 |
-const struct hashtable aliases_htable = { |
|
90 |
+const struct cli_hashtable aliases_htable = { |
|
91 | 91 |
aliases_htable_elements, 64, 25, 51 |
92 | 92 |
}; |
... | ... |
@@ -113,7 +113,7 @@ unsigned char* u16_normalize_tobuffer(uint16_t u16, unsigned char* dst, size_t d |
113 | 113 |
|
114 | 114 |
const char* entity_norm(struct entity_conv* conv,const unsigned char* entity) |
115 | 115 |
{ |
116 |
- struct element* e = hashtab_find(&entities_htable, (const char*)entity, strlen((const char*)entity)); |
|
116 |
+ struct cli_element* e = cli_hashtab_find(&entities_htable, (const char*)entity, strlen((const char*)entity)); |
|
117 | 117 |
if(e && e->key) { |
118 | 118 |
unsigned char* out = u16_normalize(e->data, conv->entity_buff, sizeof(conv->entity_buff)-1); |
119 | 119 |
if(out) { |
... | ... |
@@ -128,7 +128,7 @@ const char* entity_norm(struct entity_conv* conv,const unsigned char* entity) |
128 | 128 |
static size_t encoding_bytes(const char* fromcode, enum encodings* encoding) |
129 | 129 |
{ |
130 | 130 |
/* special case for these unusual byteorders */ |
131 |
- struct element * e = hashtab_find(&aliases_htable,fromcode,strlen(fromcode)); |
|
131 |
+ struct cli_element * e = cli_hashtab_find(&aliases_htable,fromcode,strlen(fromcode)); |
|
132 | 132 |
if(e && e->key) { |
133 | 133 |
*encoding = e->data; |
134 | 134 |
} else { |
... | ... |
@@ -534,7 +534,7 @@ struct iconv_cache { |
534 | 534 |
iconv_t* tab; |
535 | 535 |
size_t len; |
536 | 536 |
size_t last; |
537 |
- struct hashtable hashtab; |
|
537 |
+ struct cli_hashtable hashtab; |
|
538 | 538 |
}; |
539 | 539 |
|
540 | 540 |
static void iconv_cache_init(struct iconv_cache* cache) |
... | ... |
@@ -543,7 +543,7 @@ static void iconv_cache_init(struct iconv_cache* cache) |
543 | 543 |
cache->len = 0; |
544 | 544 |
cache->used = 0; - already done by memset*/ |
545 | 545 |
cli_dbgmsg(MODULE_NAME "Initializing iconv pool:%p\n",(void*)cache); |
546 |
- hashtab_init(&cache->hashtab, 32); |
|
546 |
+ cli_hashtab_init(&cache->hashtab, 32); |
|
547 | 547 |
} |
548 | 548 |
|
549 | 549 |
static void iconv_cache_destroy(struct iconv_cache* cache) |
... | ... |
@@ -554,7 +554,7 @@ static void iconv_cache_destroy(struct iconv_cache* cache) |
554 | 554 |
cli_dbgmsg(MODULE_NAME "closing iconv:%p\n",cache->tab[i]); |
555 | 555 |
iconv_close(cache->tab[i]); |
556 | 556 |
} |
557 |
- hashtab_clear(&cache->hashtab); |
|
557 |
+ cli_hashtab_clear(&cache->hashtab); |
|
558 | 558 |
free(cache->hashtab.htable); |
559 | 559 |
free(cache->tab); |
560 | 560 |
free(cache); |
... | ... |
@@ -655,7 +655,7 @@ static iconv_t iconv_open_cached(const char* fromcode) |
655 | 655 |
struct iconv_cache * cache; |
656 | 656 |
size_t idx; |
657 | 657 |
const size_t fromcode_len = strlen((const char*)fromcode); |
658 |
- struct element * e; |
|
658 |
+ struct cli_element * e; |
|
659 | 659 |
iconv_t iconv_struct; |
660 | 660 |
|
661 | 661 |
init_iconv_pool_ifneeded(); |
... | ... |
@@ -666,7 +666,7 @@ static iconv_t iconv_open_cached(const char* fromcode) |
666 | 666 |
return (iconv_t)-1; |
667 | 667 |
} |
668 | 668 |
|
669 |
- e = hashtab_find(&cache->hashtab, fromcode, fromcode_len); |
|
669 |
+ e = cli_hashtab_find(&cache->hashtab, fromcode, fromcode_len); |
|
670 | 670 |
if(e && (e->data < 0 || (size_t)e->data > cache->len)) { |
671 | 671 |
e = NULL; |
672 | 672 |
} |
... | ... |
@@ -690,7 +690,7 @@ static iconv_t iconv_open_cached(const char* fromcode) |
690 | 690 |
} |
691 | 691 |
} |
692 | 692 |
|
693 |
- hashtab_insert(&cache->hashtab, fromcode, fromcode_len, idx); |
|
693 |
+ cli_hashtab_insert(&cache->hashtab, fromcode, fromcode_len, idx); |
|
694 | 694 |
cache->tab[idx] = iconv_struct; |
695 | 695 |
cli_dbgmsg(MODULE_NAME "iconv_open(),for:%s -> %p\n",fromcode,(void*)cache->tab[idx]); |
696 | 696 |
return cache->tab[idx]; |
... | ... |
@@ -19,7 +19,7 @@ |
19 | 19 |
*/ |
20 | 20 |
|
21 | 21 |
#include <hashtab.h> |
22 |
-static struct element entities_htable_elements[] = { |
|
22 |
+static struct cli_element entities_htable_elements[] = { |
|
23 | 23 |
{"rsaquo", 8250, 6}, |
24 | 24 |
{NULL,0,0}, |
25 | 25 |
{NULL,0,0}, |
... | ... |
@@ -2069,6 +2069,6 @@ static struct element entities_htable_elements[] = { |
2069 | 2069 |
{NULL,0,0}, |
2070 | 2070 |
{NULL,0,0}, |
2071 | 2071 |
}; |
2072 |
-const struct hashtable entities_htable = { |
|
2072 |
+const struct cli_hashtable entities_htable = { |
|
2073 | 2073 |
entities_htable_elements, 2048, 743, 1638 |
2074 | 2074 |
}; |
... | ... |
@@ -52,82 +52,82 @@ static unsigned long nearest_power(unsigned long num) |
52 | 52 |
* and then these functions modify something the compiler assumes is readonly. |
53 | 53 |
* Please, never use PROFILE_HASHTABLE in production code, and in releases. Use it for development only!*/ |
54 | 54 |
|
55 |
-static inline void PROFILE_INIT(struct hashtable *s) |
|
55 |
+static inline void PROFILE_INIT(struct cli_hashtable *s) |
|
56 | 56 |
{ |
57 | 57 |
memset(&s->PROFILE_STRUCT,0,sizeof(s->PROFILE_STRUCT)); |
58 | 58 |
} |
59 | 59 |
|
60 |
-static inline void PROFILE_CALC_HASH(struct hashtable *s) |
|
60 |
+static inline void PROFILE_CALC_HASH(struct cli_hashtable *s) |
|
61 | 61 |
{ |
62 | 62 |
s->PROFILE_STRUCT.calc_hash++; |
63 | 63 |
} |
64 | 64 |
|
65 |
-static inline void PROFILE_FIND_ELEMENT(struct hashtable *s) |
|
65 |
+static inline void PROFILE_FIND_ELEMENT(struct cli_hashtable *s) |
|
66 | 66 |
{ |
67 | 67 |
s->PROFILE_STRUCT.find_req++; |
68 | 68 |
} |
69 | 69 |
|
70 |
-static inline void PROFILE_FIND_NOTFOUND(struct hashtable *s, size_t tries) |
|
70 |
+static inline void PROFILE_FIND_NOTFOUND(struct cli_hashtable *s, size_t tries) |
|
71 | 71 |
{ |
72 | 72 |
s->PROFILE_STRUCT.not_found++; |
73 | 73 |
s->PROFILE_STRUCT.not_found_tries += tries; |
74 | 74 |
} |
75 | 75 |
|
76 |
-static inline void PROFILE_FIND_FOUND(struct hashtable *s, size_t tries) |
|
76 |
+static inline void PROFILE_FIND_FOUND(struct cli_hashtable *s, size_t tries) |
|
77 | 77 |
{ |
78 | 78 |
s->PROFILE_STRUCT.found++; |
79 | 79 |
s->PROFILE_STRUCT.found_tries += tries; |
80 | 80 |
} |
81 | 81 |
|
82 |
-static inline void PROFILE_HASH_EXHAUSTED(struct hashtable *s) |
|
82 |
+static inline void PROFILE_HASH_EXHAUSTED(struct cli_hashtable *s) |
|
83 | 83 |
{ |
84 | 84 |
s->PROFILE_STRUCT.hash_exhausted++; |
85 | 85 |
} |
86 | 86 |
|
87 |
-static inline void PROFILE_GROW_START(struct hashtable *s) |
|
87 |
+static inline void PROFILE_GROW_START(struct cli_hashtable *s) |
|
88 | 88 |
{ |
89 | 89 |
s->PROFILE_STRUCT.grow++; |
90 | 90 |
} |
91 | 91 |
|
92 |
-static inline void PROFILE_GROW_FOUND(struct hashtable *s, size_t tries) |
|
92 |
+static inline void PROFILE_GROW_FOUND(struct cli_hashtable *s, size_t tries) |
|
93 | 93 |
{ |
94 | 94 |
s->PROFILE_STRUCT.grow_found++; |
95 | 95 |
s->PROFILE_STRUCT.grow_found_tries += tries; |
96 | 96 |
} |
97 | 97 |
|
98 |
-static inline void PROFILE_GROW_DONE(struct hashtable *s) |
|
98 |
+static inline void PROFILE_GROW_DONE(struct cli_hashtable *s) |
|
99 | 99 |
{ |
100 | 100 |
} |
101 | 101 |
|
102 |
-static inline void PROFILE_DELETED_REUSE(struct hashtable *s, size_t tries) |
|
102 |
+static inline void PROFILE_DELETED_REUSE(struct cli_hashtable *s, size_t tries) |
|
103 | 103 |
{ |
104 | 104 |
s->PROFILE_STRUCT.deleted_reuse++; |
105 | 105 |
s->PROFILE_STRUCT.deleted_tries += tries; |
106 | 106 |
} |
107 | 107 |
|
108 |
-static inline void PROFILE_INSERT(struct hashtable *s, size_t tries) |
|
108 |
+static inline void PROFILE_INSERT(struct cli_hashtable *s, size_t tries) |
|
109 | 109 |
{ |
110 | 110 |
s->PROFILE_STRUCT.inserts++; |
111 | 111 |
s->PROFILE_STRUCT.insert_tries += tries; |
112 | 112 |
} |
113 | 113 |
|
114 |
-static inline void PROFILE_DATA_UPDATE(struct hashtable *s, size_t tries) |
|
114 |
+static inline void PROFILE_DATA_UPDATE(struct cli_hashtable *s, size_t tries) |
|
115 | 115 |
{ |
116 | 116 |
s->PROFILE_STRUCT.update++; |
117 | 117 |
s->PROFILE_STRUCT.update_tries += tries; |
118 | 118 |
} |
119 | 119 |
|
120 |
-static inline void PROFILE_HASH_DELETE(struct hashtable *s) |
|
120 |
+static inline void PROFILE_HASH_DELETE(struct cli_hashtable *s) |
|
121 | 121 |
{ |
122 | 122 |
s->PROFILE_STRUCT.deletes++; |
123 | 123 |
} |
124 | 124 |
|
125 |
-static inline void PROFILE_HASH_CLEAR(struct hashtable *s) |
|
125 |
+static inline void PROFILE_HASH_CLEAR(struct cli_hashtable *s) |
|
126 | 126 |
{ |
127 | 127 |
s->PROFILE_STRUCT.clear++; |
128 | 128 |
} |
129 | 129 |
|
130 |
-static inline void PROFILE_REPORT(const struct hashtable *s) |
|
130 |
+static inline void PROFILE_REPORT(const struct cli_hashtable *s) |
|
131 | 131 |
{ |
132 | 132 |
size_t lookups, queries, insert_tries, inserts; |
133 | 133 |
cli_dbgmsg("--------Hashtable usage report for %p--------------\n",(const void*)s); |
... | ... |
@@ -168,7 +168,7 @@ static inline void PROFILE_REPORT(const struct hashtable *s) |
168 | 168 |
#define PROFILE_REPORT(s) |
169 | 169 |
#endif |
170 | 170 |
|
171 |
-int hashtab_init(struct hashtable *s,size_t capacity) |
|
171 |
+int cli_hashtab_init(struct cli_hashtable *s,size_t capacity) |
|
172 | 172 |
{ |
173 | 173 |
if(!s) |
174 | 174 |
return CL_ENULLARG; |
... | ... |
@@ -211,9 +211,9 @@ static inline size_t hash(const unsigned char* k,const size_t len,const size_t S |
211 | 211 |
} |
212 | 212 |
|
213 | 213 |
/* if returned element has key==NULL, then key was not found in table */ |
214 |
-struct element* hashtab_find(const struct hashtable *s,const char* key,const size_t len) |
|
214 |
+struct cli_element* cli_hashtab_find(const struct cli_hashtable *s,const char* key,const size_t len) |
|
215 | 215 |
{ |
216 |
- struct element* element; |
|
216 |
+ struct cli_element* element; |
|
217 | 217 |
size_t tries = 1; |
218 | 218 |
size_t idx; |
219 | 219 |
|
... | ... |
@@ -241,10 +241,10 @@ struct element* hashtab_find(const struct hashtable *s,const char* key,const siz |
241 | 241 |
return NULL; /* not found */ |
242 | 242 |
} |
243 | 243 |
|
244 |
-static int hashtab_grow(struct hashtable *s) |
|
244 |
+static int cli_hashtab_grow(struct cli_hashtable *s) |
|
245 | 245 |
{ |
246 | 246 |
const size_t new_capacity = nearest_power(s->capacity + 1); |
247 |
- struct element* htable = cli_calloc(new_capacity, sizeof(*s->htable)); |
|
247 |
+ struct cli_element* htable = cli_calloc(new_capacity, sizeof(*s->htable)); |
|
248 | 248 |
size_t i,idx, used = 0; |
249 | 249 |
cli_dbgmsg("hashtab.c: new capacity: %lu\n",new_capacity); |
250 | 250 |
if(new_capacity == s->capacity || !htable) |
... | ... |
@@ -254,7 +254,7 @@ static int hashtab_grow(struct hashtable *s) |
254 | 254 |
cli_dbgmsg("hashtab.c: Warning: growing open-addressing hashtables is slow. Either allocate more storage when initializing, or use other hashtable types!\n"); |
255 | 255 |
for(i=0; i < s->capacity;i++) { |
256 | 256 |
if(s->htable[i].key && s->htable[i].key != DELETED_KEY) { |
257 |
- struct element* element; |
|
257 |
+ struct cli_element* element; |
|
258 | 258 |
size_t tries = 1; |
259 | 259 |
|
260 | 260 |
PROFILE_CALC_HASH(s); |
... | ... |
@@ -287,17 +287,17 @@ static int hashtab_grow(struct hashtable *s) |
287 | 287 |
return CL_SUCCESS; |
288 | 288 |
} |
289 | 289 |
|
290 |
-const struct element* hashtab_insert(struct hashtable *s, const char* key, const size_t len, const element_data data) |
|
290 |
+const struct cli_element* cli_hashtab_insert(struct cli_hashtable *s, const char* key, const size_t len, const cli_element_data data) |
|
291 | 291 |
{ |
292 |
- struct element* element; |
|
293 |
- struct element* deleted_element = NULL; |
|
292 |
+ struct cli_element* element; |
|
293 |
+ struct cli_element* deleted_element = NULL; |
|
294 | 294 |
size_t tries = 1; |
295 | 295 |
size_t idx; |
296 | 296 |
if(!s) |
297 | 297 |
return NULL; |
298 | 298 |
if(s->used > s->maxfill) { |
299 | 299 |
cli_dbgmsg("hashtab.c:Growing hashtable %p, because it has exceeded maxfill, old size:%ld\n",(void*)s,s->capacity); |
300 |
- hashtab_grow(s); |
|
300 |
+ cli_hashtab_grow(s); |
|
301 | 301 |
} |
302 | 302 |
do { |
303 | 303 |
PROFILE_CALC_HASH(s); |
... | ... |
@@ -343,12 +343,12 @@ const struct element* hashtab_insert(struct hashtable *s, const char* key, const |
343 | 343 |
/* no free place found*/ |
344 | 344 |
PROFILE_HASH_EXHAUSTED(s); |
345 | 345 |
cli_dbgmsg("hashtab.c: Growing hashtable %p, because its full, old size:%ld.\n",(void*)s,s->capacity); |
346 |
- } while( hashtab_grow(s) >= 0 ); |
|
346 |
+ } while( cli_hashtab_grow(s) >= 0 ); |
|
347 | 347 |
cli_warnmsg("hashtab.c: Unable to grow hashtable\n"); |
348 | 348 |
return NULL; |
349 | 349 |
} |
350 | 350 |
|
351 |
-void hashtab_clear(struct hashtable *s) |
|
351 |
+void cli_hashtab_clear(struct cli_hashtable *s) |
|
352 | 352 |
{ |
353 | 353 |
size_t i; |
354 | 354 |
PROFILE_HASH_CLEAR(s); |
... | ... |
@@ -361,19 +361,19 @@ void hashtab_clear(struct hashtable *s) |
361 | 361 |
s->used = 0; |
362 | 362 |
} |
363 | 363 |
|
364 |
-void hashtab_free(struct hashtable *s) |
|
364 |
+void cli_hashtab_free(struct cli_hashtable *s) |
|
365 | 365 |
{ |
366 |
- hashtab_clear(s); |
|
366 |
+ cli_hashtab_clear(s); |
|
367 | 367 |
free(s->htable); |
368 | 368 |
s->htable = NULL; |
369 | 369 |
s->capacity = 0; |
370 | 370 |
} |
371 | 371 |
|
372 |
-int hashtab_store(const struct hashtable *s,FILE* out) |
|
372 |
+int cli_hashtab_store(const struct cli_hashtable *s,FILE* out) |
|
373 | 373 |
{ |
374 | 374 |
size_t i; |
375 | 375 |
for(i=0; i < s->capacity; i++) { |
376 |
- const struct element* e = &s->htable[i]; |
|
376 |
+ const struct cli_element* e = &s->htable[i]; |
|
377 | 377 |
if(e->key && e->key != DELETED_KEY) { |
378 | 378 |
fprintf(out,"%ld %s\n",e->data,e->key); |
379 | 379 |
} |
... | ... |
@@ -381,14 +381,14 @@ int hashtab_store(const struct hashtable *s,FILE* out) |
381 | 381 |
return CL_SUCCESS; |
382 | 382 |
} |
383 | 383 |
|
384 |
-int hashtab_generate_c(const struct hashtable *s,const char* name) |
|
384 |
+int cli_hashtab_generate_c(const struct cli_hashtable *s,const char* name) |
|
385 | 385 |
{ |
386 | 386 |
size_t i; |
387 | 387 |
printf("/* TODO: include GPL headers */\n"); |
388 | 388 |
printf("#include <hashtab.h>\n"); |
389 |
- printf("static struct element %s_elements[] = {\n",name); |
|
389 |
+ printf("static struct cli_element %s_elements[] = {\n",name); |
|
390 | 390 |
for(i=0; i < s->capacity; i++) { |
391 |
- const struct element* e = &s->htable[i]; |
|
391 |
+ const struct cli_element* e = &s->htable[i]; |
|
392 | 392 |
if(!e->key) |
393 | 393 |
printf("\t{NULL,0,0},\n"); |
394 | 394 |
else if(e->key == DELETED_KEY) |
... | ... |
@@ -397,7 +397,7 @@ int hashtab_generate_c(const struct hashtable *s,const char* name) |
397 | 397 |
printf("\t{\"%s\", %ld, %ld},\n", e->key, e->data, e->len); |
398 | 398 |
} |
399 | 399 |
printf("};\n"); |
400 |
- printf("const struct hashtable %s = {\n",name); |
|
400 |
+ printf("const struct cli_hashtable %s = {\n",name); |
|
401 | 401 |
printf("\t%s_elements, %ld, %ld, %ld", name, s->capacity, s->used, s->maxfill); |
402 | 402 |
printf("\n};\n"); |
403 | 403 |
|
... | ... |
@@ -405,21 +405,21 @@ int hashtab_generate_c(const struct hashtable *s,const char* name) |
405 | 405 |
return 0; |
406 | 406 |
} |
407 | 407 |
|
408 |
-int hashtab_load(FILE* in, struct hashtable *s) |
|
408 |
+int cli_hashtab_load(FILE* in, struct cli_hashtable *s) |
|
409 | 409 |
{ |
410 | 410 |
char line[1024]; |
411 | 411 |
while (fgets(line, sizeof(line), in)) { |
412 | 412 |
char l[1024]; |
413 | 413 |
int val; |
414 | 414 |
sscanf(line,"%d %1023s",&val,l); |
415 |
- hashtab_insert(s,l,strlen(l),val); |
|
415 |
+ cli_hashtab_insert(s,l,strlen(l),val); |
|
416 | 416 |
} |
417 | 417 |
return CL_SUCCESS; |
418 | 418 |
} |
419 | 419 |
|
420 | 420 |
/* Initialize hashset. @initial_capacity is rounded to nearest power of 2. |
421 | 421 |
* Load factor is between 50 and 99. When capacity*load_factor/100 is reached, the hashset is growed */ |
422 |
-int hashset_init(struct hashset* hs, size_t initial_capacity, uint8_t load_factor) |
|
422 |
+int cli_hashset_init(struct cli_hashset* hs, size_t initial_capacity, uint8_t load_factor) |
|
423 | 423 |
{ |
424 | 424 |
if(load_factor < 50 || load_factor > 99) { |
425 | 425 |
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 |
442 | 442 |
return 0; |
443 | 443 |
} |
444 | 444 |
|
445 |
-void hashset_destroy(struct hashset* hs) |
|
445 |
+void cli_hashset_destroy(struct cli_hashset* hs) |
|
446 | 446 |
{ |
447 | 447 |
cli_dbgmsg(MODULE_NAME "Freeing hashset, elements: %u, capacity: %u\n", hs->count, hs->capacity); |
448 | 448 |
free(hs->keys); |
... | ... |
@@ -458,7 +458,7 @@ void hashset_destroy(struct hashset* hs) |
458 | 458 |
* searches the hashset for the @key. |
459 | 459 |
* Returns the position the key is at, or a candidate position where it could be inserted. |
460 | 460 |
*/ |
461 |
-static inline size_t hashset_search(const struct hashset* hs, const uint32_t key) |
|
461 |
+static inline size_t cli_hashset_search(const struct cli_hashset* hs, const uint32_t key) |
|
462 | 462 |
{ |
463 | 463 |
/* calculate hash value for this key, and map it to our table */ |
464 | 464 |
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 |
476 | 476 |
} |
477 | 477 |
|
478 | 478 |
|
479 |
-static void hashset_addkey_internal(struct hashset* hs, const uint32_t key) |
|
479 |
+static void cli_hashset_addkey_internal(struct cli_hashset* hs, const uint32_t key) |
|
480 | 480 |
{ |
481 |
- const size_t idx = hashset_search(hs, key); |
|
481 |
+ const size_t idx = cli_hashset_search(hs, key); |
|
482 | 482 |
/* we know hashtable is not full, when this method is called */ |
483 | 483 |
|
484 | 484 |
if(!BITMAP_CONTAINS(hs->bitmap, idx)) { |
... | ... |
@@ -489,9 +489,9 @@ static void hashset_addkey_internal(struct hashset* hs, const uint32_t key) |
489 | 489 |
} |
490 | 490 |
} |
491 | 491 |
|
492 |
-static int hashset_grow(struct hashset *hs) |
|
492 |
+static int cli_hashset_grow(struct cli_hashset *hs) |
|
493 | 493 |
{ |
494 |
- struct hashset new_hs; |
|
494 |
+ struct cli_hashset new_hs; |
|
495 | 495 |
size_t i; |
496 | 496 |
int rc; |
497 | 497 |
|
... | ... |
@@ -499,43 +499,43 @@ static int hashset_grow(struct hashset *hs) |
499 | 499 |
* will hash to different locations. */ |
500 | 500 |
cli_dbgmsg(MODULE_NAME "Growing hashset, used: %u, capacity: %u\n", hs->count, hs->capacity); |
501 | 501 |
/* create a bigger hashset */ |
502 |
- if((rc = hashset_init(&new_hs, hs->capacity << 1, hs->limit*100/hs->capacity)) < 0) { |
|
502 |
+ if((rc = cli_hashset_init(&new_hs, hs->capacity << 1, hs->limit*100/hs->capacity)) < 0) { |
|
503 | 503 |
return rc; |
504 | 504 |
} |
505 | 505 |
/* and copy keys */ |
506 | 506 |
for(i=0;i < hs->capacity;i++) { |
507 | 507 |
if(BITMAP_CONTAINS(hs->bitmap, i)) { |
508 | 508 |
const size_t key = hs->keys[i]; |
509 |
- hashset_addkey_internal(&new_hs, key); |
|
509 |
+ cli_hashset_addkey_internal(&new_hs, key); |
|
510 | 510 |
} |
511 | 511 |
} |
512 |
- hashset_destroy(hs); |
|
512 |
+ cli_hashset_destroy(hs); |
|
513 | 513 |
/* replace old hashset with new one */ |
514 | 514 |
*hs = new_hs; |
515 | 515 |
return 0; |
516 | 516 |
} |
517 | 517 |
|
518 |
-int hashset_addkey(struct hashset* hs, const uint32_t key) |
|
518 |
+int cli_hashset_addkey(struct cli_hashset* hs, const uint32_t key) |
|
519 | 519 |
{ |
520 | 520 |
/* check that we didn't reach the load factor. |
521 | 521 |
* Even if we don't know yet whether we'd add this key */ |
522 | 522 |
if(hs->count + 1 > hs->limit) { |
523 |
- int rc = hashset_grow(hs); |
|
523 |
+ int rc = cli_hashset_grow(hs); |
|
524 | 524 |
if(rc) { |
525 | 525 |
return rc; |
526 | 526 |
} |
527 | 527 |
} |
528 |
- hashset_addkey_internal(hs, key); |
|
528 |
+ cli_hashset_addkey_internal(hs, key); |
|
529 | 529 |
return 0; |
530 | 530 |
} |
531 | 531 |
|
532 |
-int hashset_contains(const struct hashset* hs, const uint32_t key) |
|
532 |
+int cli_hashset_contains(const struct cli_hashset* hs, const uint32_t key) |
|
533 | 533 |
{ |
534 |
- const size_t idx = hashset_search(hs, key); |
|
534 |
+ const size_t idx = cli_hashset_search(hs, key); |
|
535 | 535 |
return BITMAP_CONTAINS(hs->bitmap, idx); |
536 | 536 |
} |
537 | 537 |
|
538 |
-ssize_t hashset_toarray(const struct hashset* hs, uint32_t** array) |
|
538 |
+ssize_t cli_hashset_toarray(const struct cli_hashset* hs, uint32_t** array) |
|
539 | 539 |
{ |
540 | 540 |
size_t i, j; |
541 | 541 |
uint32_t* arr; |
... | ... |
@@ -25,7 +25,7 @@ |
25 | 25 |
#include <stdio.h> |
26 | 26 |
#include <stddef.h> |
27 | 27 |
#include "cltypes.h" |
28 |
-typedef long element_data; |
|
28 |
+typedef long cli_element_data; |
|
29 | 29 |
|
30 | 30 |
/* define this for debugging/profiling purposes only, NOT in production/release code */ |
31 | 31 |
#ifdef PROFILE_HASHTABLE |
... | ... |
@@ -58,15 +58,15 @@ typedef struct { |
58 | 58 |
#define STRUCT_PROFILE |
59 | 59 |
|
60 | 60 |
#endif |
61 |
-struct element |
|
61 |
+struct cli_element |
|
62 | 62 |
{ |
63 | 63 |
const char* key; |
64 |
- element_data data; |
|
64 |
+ cli_element_data data; |
|
65 | 65 |
size_t len; |
66 | 66 |
}; |
67 | 67 |
|
68 |
-struct hashtable { |
|
69 |
- struct element* htable; |
|
68 |
+struct cli_hashtable { |
|
69 |
+ struct cli_element* htable; |
|
70 | 70 |
size_t capacity; |
71 | 71 |
size_t used; |
72 | 72 |
size_t maxfill;/* 80% */ |
... | ... |
@@ -76,18 +76,18 @@ struct hashtable { |
76 | 76 |
|
77 | 77 |
|
78 | 78 |
|
79 |
-int hashtab_generate_c(const struct hashtable *s,const char* name); |
|
80 |
-struct element* hashtab_find(const struct hashtable *s, const char* key, const size_t len); |
|
81 |
-int hashtab_init(struct hashtable *s,size_t capacity); |
|
82 |
-const struct element* hashtab_insert(struct hashtable *s, const char* key, const size_t len, const element_data data); |
|
83 |
-void hashtab_delete(struct hashtable *s,const char* key,const size_t len); |
|
84 |
-void hashtab_clear(struct hashtable *s); |
|
85 |
-void hashtab_free(struct hashtable *s); |
|
86 |
-int hashtab_load(FILE* in, struct hashtable *s); |
|
87 |
-int hashtab_store(const struct hashtable *s,FILE* out); |
|
79 |
+int cli_hashtab_generate_c(const struct cli_hashtable *s,const char* name); |
|
80 |
+struct cli_element* cli_hashtab_find(const struct cli_hashtable *s, const char* key, const size_t len); |
|
81 |
+int cli_hashtab_init(struct cli_hashtable *s,size_t capacity); |
|
82 |
+const struct cli_element* cli_hashtab_insert(struct cli_hashtable *s, const char* key, const size_t len, const cli_element_data data); |
|
83 |
+void cli_hashtab_delete(struct cli_hashtable *s,const char* key,const size_t len); |
|
84 |
+void cli_hashtab_clear(struct cli_hashtable *s); |
|
85 |
+void cli_hashtab_free(struct cli_hashtable *s); |
|
86 |
+int cli_hashtab_load(FILE* in, struct cli_hashtable *s); |
|
87 |
+int cli_hashtab_store(const struct cli_hashtable *s,FILE* out); |
|
88 | 88 |
|
89 | 89 |
/* A set of unique keys. */ |
90 |
-struct hashset { |
|
90 |
+struct cli_hashset { |
|
91 | 91 |
uint32_t* keys; |
92 | 92 |
uint32_t* bitmap; |
93 | 93 |
uint32_t capacity; |
... | ... |
@@ -96,12 +96,12 @@ struct hashset { |
96 | 96 |
uint32_t limit; |
97 | 97 |
}; |
98 | 98 |
|
99 |
-int hashset_init(struct hashset* hs, size_t initial_capacity, uint8_t load_factor); |
|
100 |
-int hashset_addkey(struct hashset* hs, const uint32_t key); |
|
101 |
-int hashset_removekey(struct hashset* hs, const uint32_t key); |
|
102 |
-int hashset_contains(const struct hashset* hs, const uint32_t key); |
|
103 |
-int hashset_clear(struct hashset* hs); |
|
104 |
-void hashset_destroy(struct hashset* hs); |
|
105 |
-ssize_t hashset_toarray(const struct hashset* hs, uint32_t** array); |
|
99 |
+int cli_hashset_init(struct cli_hashset* hs, size_t initial_capacity, uint8_t load_factor); |
|
100 |
+int cli_hashset_addkey(struct cli_hashset* hs, const uint32_t key); |
|
101 |
+int cli_hashset_removekey(struct cli_hashset* hs, const uint32_t key); |
|
102 |
+int cli_hashset_contains(const struct cli_hashset* hs, const uint32_t key); |
|
103 |
+int cli_hashset_clear(struct cli_hashset* hs); |
|
104 |
+void cli_hashset_destroy(struct cli_hashset* hs); |
|
105 |
+ssize_t cli_hashset_toarray(const struct cli_hashset* hs, uint32_t** array); |
|
106 | 106 |
#endif |
107 | 107 |
|
... | ... |
@@ -89,7 +89,7 @@ enum fsm_state { |
89 | 89 |
}; |
90 | 90 |
|
91 | 91 |
struct scope { |
92 |
- struct hashtable id_map; |
|
92 |
+ struct cli_hashtable id_map; |
|
93 | 93 |
struct scope *parent;/* hierarchy */ |
94 | 94 |
struct scope *nxt;/* all scopes kept in a list so we can easily free all of them */ |
95 | 95 |
enum fsm_state fsm_state; |
... | ... |
@@ -122,7 +122,7 @@ static struct scope* scope_new(struct parser_state *state) |
122 | 122 |
struct scope *s = cli_calloc(1, sizeof(*s)); |
123 | 123 |
if(!s) |
124 | 124 |
return NULL; |
125 |
- if(hashtab_init(&s->id_map, 10) < 0) { |
|
125 |
+ if(cli_hashtab_init(&s->id_map, 10) < 0) { |
|
126 | 126 |
free(s); |
127 | 127 |
return NULL; |
128 | 128 |
} |
... | ... |
@@ -138,7 +138,7 @@ static struct scope* scope_done(struct scope *s) |
138 | 138 |
{ |
139 | 139 |
struct scope* parent = s->parent; |
140 | 140 |
/* TODO: have a hashtab_destroy */ |
141 |
- hashtab_clear(&s->id_map); |
|
141 |
+ cli_hashtab_clear(&s->id_map); |
|
142 | 142 |
free(s->id_map.htable); |
143 | 143 |
free(s); |
144 | 144 |
return parent; |
... | ... |
@@ -250,15 +250,15 @@ static struct scope* scope_done(struct scope *s) |
250 | 250 |
|
251 | 251 |
static const char* scope_declare(struct scope *s, const char *token, const size_t len, struct parser_state *state) |
252 | 252 |
{ |
253 |
- const struct element *el = hashtab_insert(&s->id_map, token, len, state->var_uniq++); |
|
254 |
- /* hashtab_insert either finds an already existing entry, or allocates a |
|
253 |
+ const struct cli_element *el = cli_hashtab_insert(&s->id_map, token, len, state->var_uniq++); |
|
254 |
+ /* cli_hashtab_insert either finds an already existing entry, or allocates a |
|
255 | 255 |
* new one, we return the allocated string */ |
256 | 256 |
return el ? el->key : NULL; |
257 | 257 |
} |
258 | 258 |
|
259 | 259 |
static const char* scope_use(struct scope *s, const char *token, const size_t len) |
260 | 260 |
{ |
261 |
- const struct element *el = hashtab_find(&s->id_map, token, len); |
|
261 |
+ const struct cli_element *el = cli_hashtab_find(&s->id_map, token, len); |
|
262 | 262 |
if(el) { |
263 | 263 |
/* identifier already found in current scope, |
264 | 264 |
* 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 |
268 | 268 |
* Later if we find a declaration it will automatically assign a uniq ID |
269 | 269 |
* to it. If not, we'll know that we have to push ID == -1 tokens to an |
270 | 270 |
* outer scope.*/ |
271 |
- el = hashtab_insert(&s->id_map, token, len, -1); |
|
271 |
+ el = cli_hashtab_insert(&s->id_map, token, len, -1); |
|
272 | 272 |
return el ? el->key : NULL; |
273 | 273 |
} |
274 | 274 |
|
275 | 275 |
static long scope_lookup(struct scope *s, const char *token, const size_t len) |
276 | 276 |
{ |
277 | 277 |
while(s) { |
278 |
- const struct element *el = hashtab_find(&s->id_map, token, len); |
|
278 |
+ const struct cli_element *el = cli_hashtab_find(&s->id_map, token, len); |
|
279 | 279 |
if(el && el->data != -1) { |
280 | 280 |
return el->data; |
281 | 281 |
} |
... | ... |
@@ -72,7 +72,7 @@ struct cli_matcher { |
72 | 72 |
/* Extended Boyer-Moore */ |
73 | 73 |
uint8_t *bm_shift; |
74 | 74 |
struct cli_bm_patt **bm_suffix; |
75 |
- struct hashset md5_sizes_hs; |
|
75 |
+ struct cli_hashset md5_sizes_hs; |
|
76 | 76 |
uint32_t *soff, soff_len; /* for PE section sigs */ |
77 | 77 |
uint32_t bm_patterns; |
78 | 78 |
|
... | ... |
@@ -83,7 +83,7 @@ struct cli_ignsig { |
83 | 83 |
}; |
84 | 84 |
|
85 | 85 |
struct cli_ignored { |
86 |
- struct hashset hs; |
|
86 |
+ struct cli_hashset hs; |
|
87 | 87 |
struct cli_ignsig *list; |
88 | 88 |
}; |
89 | 89 |
|
... | ... |
@@ -429,7 +429,7 @@ static int cli_chkign(const struct cli_ignored *ignored, const char *dbname, uns |
429 | 429 |
if(!ignored || !dbname || !signame) |
430 | 430 |
return 0; |
431 | 431 |
|
432 |
- if(hashset_contains(&ignored->hs, line)) { |
|
432 |
+ if(cli_hashset_contains(&ignored->hs, line)) { |
|
433 | 433 |
pt = ignored->list; |
434 | 434 |
while(pt) { |
435 | 435 |
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, |
1198 | 1198 |
|
1199 | 1199 |
if(!engine->ignored) { |
1200 | 1200 |
engine->ignored = (struct cli_ignored *) cli_calloc(sizeof(struct cli_ignored), 1); |
1201 |
- if(!engine->ignored || hashset_init(&engine->ignored->hs, 64, 50)) |
|
1201 |
+ if(!engine->ignored || cli_hashset_init(&engine->ignored->hs, 64, 50)) |
|
1202 | 1202 |
return CL_EMEM; |
1203 | 1203 |
} |
1204 | 1204 |
|
... | ... |
@@ -1233,7 +1233,7 @@ static int cli_loadign(FILE *fs, struct cl_engine *engine, unsigned int options, |
1233 | 1233 |
|
1234 | 1234 |
new->line = atoi(tokens[1]); |
1235 | 1235 |
|
1236 |
- if((ret = hashset_addkey(&engine->ignored->hs, new->line))) |
|
1236 |
+ if((ret = cli_hashset_addkey(&engine->ignored->hs, new->line))) |
|
1237 | 1237 |
break; |
1238 | 1238 |
|
1239 | 1239 |
new->signame = cli_mpool_strdup(engine->mempool, tokens[2]); |
... | ... |
@@ -1269,7 +1269,7 @@ static void cli_freeign(struct cl_engine *engine) |
1269 | 1269 |
mpool_free(engine->mempool, pt->signame); |
1270 | 1270 |
mpool_free(engine->mempool,pt); |
1271 | 1271 |
} |
1272 |
- hashset_destroy(&ignored->hs); |
|
1272 |
+ cli_hashset_destroy(&ignored->hs); |
|
1273 | 1273 |
free(engine->ignored); |
1274 | 1274 |
engine->ignored = NULL; |
1275 | 1275 |
} |
... | ... |
@@ -1404,9 +1404,9 @@ static int cli_loadmd5(FILE *fs, struct cl_engine *engine, unsigned int *signo, |
1404 | 1404 |
|
1405 | 1405 |
if(mode == MD5_MDB) { /* section MD5 */ |
1406 | 1406 |
if(!db->md5_sizes_hs.capacity) { |
1407 |
- hashset_init(&db->md5_sizes_hs, 65536, 80); |
|
1407 |
+ cli_hashset_init(&db->md5_sizes_hs, 65536, 80); |
|
1408 | 1408 |
} |
1409 |
- hashset_addkey(&db->md5_sizes_hs, size); |
|
1409 |
+ cli_hashset_addkey(&db->md5_sizes_hs, size); |
|
1410 | 1410 |
} |
1411 | 1411 |
|
1412 | 1412 |
sigs++; |
... | ... |
@@ -2112,7 +2112,7 @@ int cl_engine_free(struct cl_engine *engine) |
2112 | 2112 |
cli_bm_free(root); |
2113 | 2113 |
mpool_free(engine->mempool, root->soff); |
2114 | 2114 |
if(root->md5_sizes_hs.capacity) { |
2115 |
- hashset_destroy(&root->md5_sizes_hs); |
|
2115 |
+ cli_hashset_destroy(&root->md5_sizes_hs); |
|
2116 | 2116 |
} |
2117 | 2117 |
mpool_free(engine->mempool, root); |
2118 | 2118 |
} |
... | ... |
@@ -2173,14 +2173,14 @@ static void cli_md5db_build(struct cli_matcher* root) |
2173 | 2173 |
uint32_t *mpoolht; |
2174 | 2174 |
unsigned int mpoolhtsz = root->md5_sizes_hs.count * sizeof(*mpoolht); |
2175 | 2175 |
root->soff = mpool_malloc(root->mempool, mpoolhtsz); |
2176 |
- root->soff_len = hashset_toarray(&root->md5_sizes_hs, &mpoolht); |
|
2176 |
+ root->soff_len = cli_hashset_toarray(&root->md5_sizes_hs, &mpoolht); |
|
2177 | 2177 |
memcpy(root->soff, mpoolht, mpoolhtsz); |
2178 | 2178 |
free(mpoolht); |
2179 | 2179 |
} |
2180 | 2180 |
#else |
2181 |
- root->soff_len = hashset_toarray(&root->md5_sizes_hs, &root->soff); |
|
2181 |
+ root->soff_len = cli_hashset_toarray(&root->md5_sizes_hs, &root->soff); |
|
2182 | 2182 |
#endif |
2183 |
- hashset_destroy(&root->md5_sizes_hs); |
|
2183 |
+ cli_hashset_destroy(&root->md5_sizes_hs); |
|
2184 | 2184 |
qsort(root->soff, root->soff_len, sizeof(uint32_t), scomp); |
2185 | 2185 |
} |
2186 | 2186 |
} |
... | ... |
@@ -362,7 +362,7 @@ int init_regex_list(struct regex_matcher* matcher) |
362 | 362 |
matcher->list_inited=1; |
363 | 363 |
matcher->list_built=0; |
364 | 364 |
matcher->list_loaded=0; |
365 |
- hashtab_init(&matcher->suffix_hash, 512); |
|
365 |
+ cli_hashtab_init(&matcher->suffix_hash, 512); |
|
366 | 366 |
#ifdef USE_MPOOL |
367 | 367 |
matcher->mempool = mp; |
368 | 368 |
matcher->suffixes.mempool = mp; |
... | ... |
@@ -448,13 +448,13 @@ static int add_hash(struct regex_matcher *matcher, char* pattern, const char fl, |
448 | 448 |
} |
449 | 449 |
|
450 | 450 |
if (!matcher->sha256_pfx_set.keys) { |
451 |
- if((rc = hashset_init(&matcher->sha256_pfx_set, 1048576, 90))) { |
|
451 |
+ if((rc = cli_hashset_init(&matcher->sha256_pfx_set, 1048576, 90))) { |
|
452 | 452 |
return rc; |
453 | 453 |
} |
454 | 454 |
} |
455 | 455 |
|
456 | 456 |
if (fl != 'W' && pat->length == 32 && |
457 |
- hashset_contains(&matcher->sha256_pfx_set, cli_readint32(pat->pattern)) && |
|
457 |
+ cli_hashset_contains(&matcher->sha256_pfx_set, cli_readint32(pat->pattern)) && |
|
458 | 458 |
cli_bm_scanbuff(pat->pattern, 32, &vname, &matcher->sha256_hashes,0,0,-1) == CL_VIRUS) { |
459 | 459 |
if (*vname == 'W') { |
460 | 460 |
/* hash is whitelisted in local.gdb */ |
... | ... |
@@ -470,7 +470,7 @@ static int add_hash(struct regex_matcher *matcher, char* pattern, const char fl, |
470 | 470 |
return CL_EMEM; |
471 | 471 |
} |
472 | 472 |
*pat->virname = fl; |
473 |
- hashset_addkey(&matcher->sha256_pfx_set, cli_readint32(pat->pattern)); |
|
473 |
+ cli_hashset_addkey(&matcher->sha256_pfx_set, cli_readint32(pat->pattern)); |
|
474 | 474 |
if((rc = cli_bm_addpatt(bm, pat))) { |
475 | 475 |
cli_errmsg("add_hash: failed to add BM pattern\n"); |
476 | 476 |
free(pat->pattern); |
... | ... |
@@ -607,11 +607,11 @@ int cli_build_regex_list(struct regex_matcher* matcher) |
607 | 607 |
return -1;/*TODO: better error code */ |
608 | 608 |
} |
609 | 609 |
cli_dbgmsg("Building regex list\n"); |
610 |
- hashtab_free(&matcher->suffix_hash); |
|
610 |
+ cli_hashtab_free(&matcher->suffix_hash); |
|
611 | 611 |
if(( rc = cli_ac_buildtrie(&matcher->suffixes) )) |
612 | 612 |
return rc; |
613 | 613 |
matcher->list_built=1; |
614 |
- hashset_destroy(&matcher->sha256_pfx_set); |
|
614 |
+ cli_hashset_destroy(&matcher->sha256_pfx_set); |
|
615 | 615 |
|
616 | 616 |
return CL_SUCCESS; |
617 | 617 |
} |
... | ... |
@@ -645,7 +645,7 @@ void regex_list_done(struct regex_matcher* matcher) |
645 | 645 |
} |
646 | 646 |
mpool_free(matcher->mempool, matcher->all_pregs); |
647 | 647 |
} |
648 |
- hashtab_free(&matcher->suffix_hash); |
|
648 |
+ cli_hashtab_free(&matcher->suffix_hash); |
|
649 | 649 |
cli_bm_free(&matcher->sha256_hashes); |
650 | 650 |
cli_bm_free(&matcher->hostkey_prefix); |
651 | 651 |
} |
... | ... |
@@ -719,7 +719,7 @@ static int add_pattern_suffix(void *cbdata, const char *suffix, size_t suffix_le |
719 | 719 |
{ |
720 | 720 |
struct regex_matcher *matcher = cbdata; |
721 | 721 |
struct regex_list *regex = cli_malloc(sizeof(*regex)); |
722 |
- const struct element *el; |
|
722 |
+ const struct cli_element *el; |
|
723 | 723 |
|
724 | 724 |
assert(matcher); |
725 | 725 |
if(!regex) |
... | ... |
@@ -727,7 +727,7 @@ static int add_pattern_suffix(void *cbdata, const char *suffix, size_t suffix_le |
727 | 727 |
regex->pattern = iregex->pattern ? cli_strdup(iregex->pattern) : NULL; |
728 | 728 |
regex->preg = iregex->preg; |
729 | 729 |
regex->nxt = NULL; |
730 |
- el = hashtab_find(&matcher->suffix_hash, suffix, suffix_len); |
|
730 |
+ el = cli_hashtab_find(&matcher->suffix_hash, suffix, suffix_len); |
|
731 | 731 |
/* TODO: what if suffixes are prefixes of eachother and only one will |
732 | 732 |
* match? */ |
733 | 733 |
if(el) { |
... | ... |
@@ -737,7 +737,7 @@ static int add_pattern_suffix(void *cbdata, const char *suffix, size_t suffix_le |
737 | 737 |
} else { |
738 | 738 |
/* new suffix */ |
739 | 739 |
size_t n = matcher->suffix_cnt++; |
740 |
- el = hashtab_insert(&matcher->suffix_hash, suffix, suffix_len, n); |
|
740 |
+ el = cli_hashtab_insert(&matcher->suffix_hash, suffix, suffix_len, n); |
|
741 | 741 |
matcher->suffix_regexes = cli_realloc(matcher->suffix_regexes, (n+1)*sizeof(*matcher->suffix_regexes)); |
742 | 742 |
if(!matcher->suffix_regexes) |
743 | 743 |
return CL_EMEM; |
... | ... |
@@ -44,7 +44,7 @@ struct regex_list_ht { |
44 | 44 |
}; |
45 | 45 |
|
46 | 46 |
struct regex_matcher { |
47 |
- struct hashtable suffix_hash; |
|
47 |
+ struct cli_hashtable suffix_hash; |
|
48 | 48 |
size_t suffix_cnt; |
49 | 49 |
struct regex_list_ht *suffix_regexes; |
50 | 50 |
size_t root_regex_idx; |
... | ... |
@@ -52,7 +52,7 @@ struct regex_matcher { |
52 | 52 |
regex_t **all_pregs; |
53 | 53 |
struct cli_matcher suffixes; |
54 | 54 |
struct cli_matcher sha256_hashes; |
55 |
- struct hashset sha256_pfx_set; |
|
55 |
+ struct cli_hashset sha256_pfx_set; |
|
56 | 56 |
struct cli_matcher hostkey_prefix; |
57 | 57 |
struct filter filter; |
58 | 58 |
#ifdef USE_MPOOL |