diff options
Diffstat (limited to 'src/ddhardrescue.c')
-rw-r--r-- | src/ddhardrescue.c | 46 |
1 files changed, 36 insertions, 10 deletions
diff --git a/src/ddhardrescue.c b/src/ddhardrescue.c index 9f355b3..de89c26 100644 --- a/src/ddhardrescue.c +++ b/src/ddhardrescue.c @@ -4,7 +4,7 @@ #include <stdint.h> #include <string.h> #include <pthread.h> - + #include "slices_evt.h" #include "recover.h" #include "utils.h" @@ -24,15 +24,17 @@ void sigHookAbrt() { end=1; } -//TODO : remove that when procViewer is done +/*TODO : remove that when procViewer is done void dumper(slices_evt_t *slicesEvt, slice_t *modifiedSlice) { address_t blockSize=0; char *dump; - dump=slicesDump(slicesEvt->data, &blockSize, 1000, 0, 21474836480ULL); + dump=slicesDump(slicesEvt->data, &blockSize, 3000, 0, 21474836480ULL); + system("clear"); puts(dump); free(dump); } +*/ void *procWorker(void *a); void *procViewer(void *a); @@ -40,7 +42,7 @@ void *procViewer(void *a); int main(int argc, char **argv) { // System structures struct sigaction sa; - pthread_t tWorker, tViewer; + pthread_t tWorker; // Main data structures slices_evt_t slices; @@ -74,7 +76,7 @@ int main(int argc, char **argv) { // Data structure initialization memset(&slices, 0, sizeof(slices)); slices.data=slicesNewSingleton(args.beginSector, args.endSector, S_UNKNOWN); - slices.eventListener=dumper; +// slices.eventListener=dumper; res=pthread_mutex_init(&(slices.mutex), NULL); if (res!=0) { return 3; @@ -90,14 +92,11 @@ int main(int argc, char **argv) { return 4; } - res=pthread_create(&tViewer, NULL, procViewer, &tArgs); - if (res!=0) { - return 5; - } + // Ncurses interface run in the main thread + (void) procViewer((void*)&tArgs); // Thread join point (void) pthread_join(tWorker, NULL); - (void) pthread_join(tViewer, NULL); /*Final dump of datas address_t blockSize=0; @@ -138,7 +137,34 @@ void * procWorker(void *a) { return a; } +#define CURSESWIN_COUNT 3 void *procViewer(void *a) { + WINDOW *wins[CURSESWIN_COUNT]; + PANEL *panels[CURSESWIN_COUNT]; + int ch; + //struct threadArgs *tArgs = (struct threadArgs *)a; + + cursesInit(wins, panels, CURSESWIN_COUNT); + + /* Show it on the screen */ + attron(COLOR_PAIR(4)); + mvprintw(LINES - 2, 0, "Use tab to browse through the windows (F2 to Exit)"); + attroff(COLOR_PAIR(4)); + doupdate(); + + while((ch = getch()) != KEY_F(2)) { + switch(ch) { + case 1: + case 2: + case 3: + top_panel(panels[ch]); + break; + } + + update_panels(); + doupdate(); + } + endwin(); return a; } |