summaryrefslogtreecommitdiffstats
path: root/src/filterdb.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/filterdb.h')
-rw-r--r--src/filterdb.h59
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