librazor/types.h
changeset 247 63444a10fb8e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/librazor/types.h	Fri Jun 20 14:18:52 2008 -0400
     1.3 @@ -0,0 +1,59 @@
     1.4 +#ifndef _RAZOR_TYPES_H_
     1.5 +#define _RAZOR_TYPES_H_
     1.6 +
     1.7 +#include <stdint.h>
     1.8 +
     1.9 +struct array {
    1.10 +	void *data;
    1.11 +	int size, alloc;
    1.12 +};
    1.13 +
    1.14 +void array_init(struct array *array);
    1.15 +void array_release(struct array *array);
    1.16 +void *array_add(struct array *array, int size);
    1.17 +
    1.18 +
    1.19 +struct list_head {
    1.20 +	uint list_ptr : 24;
    1.21 +	uint flags    : 8;
    1.22 +};
    1.23 +
    1.24 +struct list {
    1.25 +	uint data  : 24;
    1.26 +	uint flags : 8;
    1.27 +};
    1.28 +
    1.29 +void list_set_empty(struct list_head *head);
    1.30 +void list_set_ptr(struct list_head *head, uint32_t ptr);
    1.31 +void list_set_array(struct list_head *head, struct array *pool, struct array *items, int force_indirect);
    1.32 +
    1.33 +struct list *list_first(struct list_head *head, struct array *pool);
    1.34 +struct list *list_next(struct list *list);
    1.35 +
    1.36 +void list_remap_pool(struct array *pool, uint32_t *map);
    1.37 +void list_remap_head(struct list_head *list, uint32_t *map);
    1.38 +
    1.39 +
    1.40 +struct hashtable {
    1.41 +	struct array buckets;
    1.42 +	struct array *pool;
    1.43 +};
    1.44 +
    1.45 +void hashtable_init(struct hashtable *table, struct array *pool);
    1.46 +void hashtable_release(struct hashtable *table);
    1.47 +uint32_t hashtable_insert(struct hashtable *table, const char *key);
    1.48 +uint32_t hashtable_lookup(struct hashtable *table, const char *key);
    1.49 +uint32_t hashtable_tokenize(struct hashtable *table, const char *string);
    1.50 +
    1.51 +
    1.52 +struct bitarray {
    1.53 +	uint32_t *bits;
    1.54 +};
    1.55 +
    1.56 +void bitarray_init(struct bitarray *bitarray, int size, int intial_value);
    1.57 +void bitarray_release(struct bitarray *bitarray);
    1.58 +void bitarray_set(struct bitarray *bitarray, int bit, int value);
    1.59 +int bitarray_get(struct bitarray *bitarray, int bit);
    1.60 +
    1.61 +
    1.62 +#endif /* _RAZOR_TYPES_H_ */