libmobi
C library for handling MOBI format ebook documents
structure.h
Go to the documentation of this file.
1 
11 #ifndef mobi_structure_h
12 #define mobi_structure_h
13 
14 #include "config.h"
15 #include "mobi.h"
16 
20 typedef struct {
21  uint32_t *data;
22  size_t maxsize;
23  size_t step;
24  size_t size;
25 } MOBIArray;
26 
27 MOBIArray * array_init(const size_t len);
28 MOBI_RET array_insert(MOBIArray *arr, const uint32_t value);
29 void array_sort(MOBIArray *arr, const bool unique);
30 size_t array_size(MOBIArray *arr);
31 void array_free(MOBIArray *arr);
32 
36 typedef struct MOBITrie {
37  char c;
38  void **values;
39  size_t values_count;
40  struct MOBITrie *next;
41  struct MOBITrie *children;
43 
44 MOBI_RET mobi_trie_insert_reversed(MOBITrie **root, char *string, char *value);
45 MOBITrie * mobi_trie_get_next(char ***values, size_t *values_count, const MOBITrie *node, const char c);
46 void mobi_trie_free(MOBITrie *node);
47 
53 typedef struct MOBIFragment {
54  size_t raw_offset;
55  unsigned char *fragment;
56  size_t size;
57  bool is_malloc;
58  struct MOBIFragment *next;
60 
61 MOBIFragment * mobi_list_add(MOBIFragment *curr, size_t raw_offset, unsigned char *fragment, const size_t size, const bool is_malloc);
63 MOBI_RET mobi_list_insert(MOBIFragment **curr, size_t raw_offset, unsigned char *fragment, const size_t size, const bool is_malloc, const size_t offset);
64 void mobi_list_del_all(MOBIFragment *first);
65 
66 #endif
MOBI_RET
Error codes returned by functions.
Definition: mobi.h:59
Libmobi main header file.
Dynamic array of uint32_t values structure.
Definition: structure.h:20
size_t step
Definition: structure.h:23
size_t size
Definition: structure.h:24
size_t maxsize
Definition: structure.h:22
uint32_t * data
Definition: structure.h:21
Structure for links reconstruction.
Definition: structure.h:53
struct MOBIFragment * next
Definition: structure.h:58
unsigned char * fragment
Definition: structure.h:55
bool is_malloc
Definition: structure.h:57
size_t raw_offset
Definition: structure.h:54
size_t size
Definition: structure.h:56
Trie storing arrays of values for character keys.
Definition: structure.h:36
void ** values
Definition: structure.h:38
struct MOBITrie * children
Definition: structure.h:41
struct MOBITrie * next
Definition: structure.h:40
char c
Definition: structure.h:37
size_t values_count
Definition: structure.h:39
MOBI_RET array_insert(MOBIArray *arr, const uint32_t value)
Inserts value into MOBIArray array.
Definition: structure.c:55
void array_sort(MOBIArray *arr, const bool unique)
Sort MOBIArray in ascending order.
Definition: structure.c:100
void mobi_trie_free(MOBITrie *node)
Recursively free MOBITrie trie starting from node.
Definition: structure.c:163
void mobi_list_del_all(MOBIFragment *first)
Delete all fragments from linked list.
Definition: structure.c:562
MOBIFragment * mobi_list_del(MOBIFragment *curr)
Delete fragment from linked list.
Definition: structure.c:546
MOBIArray * array_init(const size_t len)
Initializer for MOBIArray structure.
Definition: structure.c:29
void array_free(MOBIArray *arr)
Free MOBIArray structure and contained data.
Definition: structure.c:136
MOBI_RET mobi_trie_insert_reversed(MOBITrie **root, char *string, char *value)
Insert reversed string into MOBITrie trie.
Definition: structure.c:247
MOBITrie * mobi_trie_get_next(char ***values, size_t *values_count, const MOBITrie *node, const char c)
Fetch values for key c from MOBITrie trie's current level starting at node.
Definition: structure.c:283
size_t array_size(MOBIArray *arr)
Get size of the array.
Definition: structure.c:125
struct MOBIFragment MOBIFragment
Structure for links reconstruction.
MOBI_RET mobi_list_insert(MOBIFragment **curr, size_t raw_offset, unsigned char *fragment, const size_t size, const bool is_malloc, const size_t offset)
Allocate fragment, fill with data, insert into linked list at given offset.
Definition: structure.c:445
struct MOBITrie MOBITrie
Trie storing arrays of values for character keys.
MOBIFragment * mobi_list_add(MOBIFragment *curr, size_t raw_offset, unsigned char *fragment, const size_t size, const bool is_malloc)
Allocate fragment, fill with data, append to linked list.
Definition: structure.c:412