~ubuntu-branches/ubuntu/intrepid/clamav/intrepid-backports

« back to all changes in this revision

Viewing changes to libclamav/hashtab.h

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2009-11-05 23:14:14 UTC
  • mfrom: (0.3.4 jaunty-proposed)
  • Revision ID: james.westby@ubuntu.com-20091105231414-qm9ppy5rowfqhseq
Tags: 0.95.3+dfsg-1ubuntu0.09.04~intrepid1
* Source backport for Intrepid from jaunty-proposed (LP: #473707)
  - Drop build-dep on libtommath-dev and use internal copy

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
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
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
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