diff options
author | Timo Teräs <timo.teras@iki.fi> | 2010-11-07 00:47:39 +0200 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2010-11-07 00:47:39 +0200 |
commit | 25593b5e6fea76ed7c08db586924032c0810c27e (patch) | |
tree | b632534eb96978ad620fee1e5a9a5d280e0b191e /src/filterdb.h | |
parent | e0450bd60a30ca944c16f84ee195463fd4aab653 (diff) | |
download | squark-25593b5e6fea76ed7c08db586924032c0810c27e.tar.bz2 squark-25593b5e6fea76ed7c08db586924032c0810c27e.tar.xz |
squark: reorganize sources to src directory
Diffstat (limited to 'src/filterdb.h')
-rw-r--r-- | src/filterdb.h | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/filterdb.h b/src/filterdb.h new file mode 100644 index 0000000..2d16572 --- /dev/null +++ b/src/filterdb.h @@ -0,0 +1,59 @@ +#ifndef FILTERDB_H +#define FILTERDB_H + +#include <stddef.h> +#include <stdint.h> +#include "blob.h" + +#define SQDB_LENGTH_BITS 5 + +#define SQDB_SECTION_STRINGS 0 +#define SQDB_SECTION_CATEGORIES 1 +#define SQDB_SECTION_INDEX 2 +#define SQDB_SECTION_INDEX_MPH 3 +#define SQDB_SECTION_KEYWORD 4 +#define SQDB_SECTION_KEYWORD_MPH 5 +#define SQDB_SECTION_MAX 8 + +struct sqdb { + int fd; + void * mmap_base; + size_t file_length; +}; + +struct sqdb_section { + uint32_t offset; + uint32_t length; +}; + +struct sqdb_header { + char description[116]; + uint32_t num_sections; + uint32_t version; + uint32_t magic; + struct sqdb_section section[SQDB_SECTION_MAX]; +}; + +#define SQDB_PARENT_ROOT 0xffffff +#define SQDB_PARENT_IPV4 0xfffffe + +struct sqdb_index_entry { + uint32_t has_subdomains : 1; + uint32_t has_paths : 1; + uint32_t category : 6; + uint32_t parent : 24; + uint32_t component; +}; + + +const char *sqdb_section_names[SQDB_SECTION_MAX]; + +int sqdb_create(struct sqdb *db, const char *fn); +int sqdb_open(struct sqdb *db, const char *fn); +void sqdb_close(struct sqdb *db); + +void *sqdb_section_create(struct sqdb *db, int id, uint32_t size); +void *sqdb_section_get(struct sqdb *db, int id, uint32_t *size); +blob_t sqdb_get_string_literal(struct sqdb *db, uint32_t encoded_ptr); + +#endif |