blob: 68c1a2a3eca86c27184725cd0b18d64356e9985e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
#ifndef SQUARKDB_H
#define SQUARKDB_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
|