summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
Diffstat (limited to 'inc')
-rwxr-xr-xinc/recover.h11
-rwxr-xr-xinc/slices.h44
2 files changed, 55 insertions, 0 deletions
diff --git a/inc/recover.h b/inc/recover.h
new file mode 100755
index 0000000..85f1738
--- /dev/null
+++ b/inc/recover.h
@@ -0,0 +1,11 @@
+#ifndef RECOVER_H
+#define RECOVER_H
+
+#include "slices.h"
+
+extern int end;
+
+slices_t *recover(char *src, char *dst, char*ddOpts, address_t beginSector, address_t endSector/*, int depth*/);
+int tryRecoverUntilError(slice_t *sliceToRead, address_t *firstError, char *src, char *dst, char *ddOpts);
+
+#endif /*RECOVER_H*/
diff --git a/inc/slices.h b/inc/slices.h
new file mode 100755
index 0000000..4b60ebc
--- /dev/null
+++ b/inc/slices.h
@@ -0,0 +1,44 @@
+#ifndef SLICES_H
+#define SLICES_H
+
+#include <stdint.h>
+#include <stdlib.h>
+
+/* IMPORTANT NOTES
+Slice are inclusive intervals. Let say sliceNew(1,2,S_UNKNOWN,NULL) return a [1;2] interval,
+ so interval lenght is end-begin+1. Here, it is 2 sectors lenght slice.
+*/
+
+typedef enum { S_UNKNOWN, S_RECOVERED, S_UNREADABLE } sliceStatus_t;
+typedef unsigned long long int address_t;
+
+typedef struct _slice {
+ address_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);
+
+// Return the numbers of slices after split (3 in the general case, 2 or 1 in particular cases. -1 is memory error)
+int sliceSplit(slices_t *slices, slice_t *initialSlice, address_t splitAt, sliceStatus_t statusBefore, sliceStatus_t statusAt, sliceStatus_t statusAfter);
+
+
+slices_t *slicesNewEmpty();
+
+slices_t *sliceNewSingleton(begin, end, sliceStatus_t status);
+
+void slicesAppend(slices_t *slices, slice_t *slice);
+
+slice_t *slicesFindLargest(slices_t *slices, sliceStatus_t status);
+
+slice_t *slicesFindLargestFast(slices_t *slices, address_t *foundMax, sliceStatus_t status, address_t knownMax, slice_t *firstToTry);
+
+char *slicesDump(slices_t *slices, address_t *blockSize, unsigned int charCount, address_t begin, address_t end);
+
+#endif /*SLICES_H*/