summaryrefslogtreecommitdiff
path: root/src/slices.h
blob: 062c4f44a3e892607cfeb32faee5df6b2f9ace19 (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
#ifndef SLICES_H
#define SLICES_H

#include <stdint.h>
#include <stdlib.h>

typedef enum { S_UNKNOWN, S_RECOVERED, S_UNREADABLE } sliceStatus_t;
typedef uint32_t address_t;

typedef struct _slice {
	uint32_t begin, end;
	sliceStatus_t status;
	struct _slice *next;
} slice_t;

typedef struct {
	int count;
	slice_t *first, *last;
} slices_t;

slice_t *sliceNew(address_t begin, address_t end, sliceStatus_t status, slice_t *next);
int sliceSplit(slice_t *slice, address_t splitAt, sliceStatus_t statusBefore, sliceStatus_t statusAt, sliceStatus_t statusAfter); 

slices_t *slicesNew();
void slicesAppend(slices_t *slices, slice_t *slice);
slice_t *slicesFindLargest(slices_t *slices, sliceStatus_t status);
char *slicesDump(slices_t *slices, int charCount, address_t begin, address_t end);

#endif /*SLICES_H*/