summaryrefslogtreecommitdiffstats
path: root/squarkdb.h
diff options
context:
space:
mode:
Diffstat (limited to 'squarkdb.h')
-rw-r--r--squarkdb.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/squarkdb.h b/squarkdb.h
new file mode 100644
index 0000000..2f96155
--- /dev/null
+++ b/squarkdb.h
@@ -0,0 +1,50 @@
+#ifndef SQUARKDB_H
+#define SQUARKDB_H
+
+#include <stdint.h>
+
+#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 {
+ u_int32_t offset;
+ u_int32_t length;
+};
+
+struct sqdb_header {
+ char description[116];
+ u_int32_t num_sections;
+ u_int32_t version;
+ u_int32_t magic;
+ struct sqdb_section section[SQDB_SECTION_MAX];
+};
+
+struct sqdb_index_entry {
+ u_int32_t has_subdomains : 1;
+ u_int32_t has_paths : 1;
+ u_int32_t category : 6;
+ u_int32_t parent : 24;
+ u_int32_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, u_int32_t size);
+void *sqdb_section_get(struct sqdb *db, int id, u_int32_t *size);
+
+#endif