]>
Commit | Line | Data |
---|---|---|
1 | /* Copyright © 2017-2018 Apple Inc. All rights reserved. | |
2 | * | |
3 | * lf_hfs_rangelist.h | |
4 | * livefiles_hfs | |
5 | * | |
6 | * Created by Yakov Ben Zaken on 19/03/2018. | |
7 | */ | |
8 | ||
9 | #ifndef lf_hfs_rangelist_h | |
10 | #define lf_hfs_rangelist_h | |
11 | ||
12 | #include <stdio.h> | |
13 | #include <sys/queue.h> | |
14 | ||
15 | TAILQ_HEAD(rl_head, rl_entry); | |
16 | ||
17 | struct rl_entry { | |
18 | TAILQ_ENTRY(rl_entry) rl_link; | |
19 | off_t rl_start; | |
20 | off_t rl_end; | |
21 | }; | |
22 | ||
23 | enum rl_overlaptype { | |
24 | RL_NOOVERLAP = 0, /* 0 */ | |
25 | RL_MATCHINGOVERLAP, /* 1 */ | |
26 | RL_OVERLAPCONTAINSRANGE, /* 2 */ | |
27 | RL_OVERLAPISCONTAINED, /* 3 */ | |
28 | RL_OVERLAPSTARTSBEFORE, /* 4 */ | |
29 | RL_OVERLAPENDSAFTER /* 5 */ | |
30 | }; | |
31 | ||
32 | #define RL_INFINITY INT64_MAX | |
33 | ||
34 | void rl_init(struct rl_head *rangelist); | |
35 | enum rl_overlaptype rl_overlap(const struct rl_entry *range, off_t start, off_t end); | |
36 | void rl_remove(off_t start, off_t end, struct rl_head *rangelist); | |
37 | off_t rl_len(const struct rl_entry *range); | |
38 | void rl_remove_all(struct rl_head *rangelist); | |
39 | enum rl_overlaptype rl_scan(struct rl_head *rangelist, off_t start, off_t end, struct rl_entry **overlap); | |
40 | void rl_add(off_t start, off_t end, struct rl_head *rangelist); | |
41 | void rl_subtract(struct rl_entry *a, const struct rl_entry *b); | |
42 | struct rl_entry rl_make(off_t start, off_t end); | |
43 | ||
44 | #endif /* lf_hfs_rangelist_h */ |